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(camera_device_e device, 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", device);
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,
2397 CAM_LOG_ERROR("NULL msg");
2398 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2402 send_ret = muse_core_msg_send(sock_fd, send_msg);
2404 muse_core_msg_free(send_msg);
2408 CAM_LOG_ERROR("send msg failed %d", errno);
2409 ret = CAMERA_ERROR_INVALID_OPERATION;
2413 pc = g_new0(camera_cli_s, 1);
2415 CAM_LOG_ERROR("camera_cli_s alloc failed");
2416 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2420 bufmgr = tbm_bufmgr_init(-1);
2421 if (bufmgr == NULL) {
2422 CAM_LOG_ERROR("get tbm bufmgr failed");
2423 ret = CAMERA_ERROR_INVALID_OPERATION;
2427 pc->cb_info = _camera_client_callback_new(sock_fd);
2428 if (pc->cb_info == NULL) {
2429 CAM_LOG_ERROR("cb_info alloc failed");
2430 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2436 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2438 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2440 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2442 if (ret == CAMERA_ERROR_NONE) {
2443 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2444 int user_buffer_supported = 0;
2445 int log_level = CAMERA_LOG_LEVEL_INFO;
2446 intptr_t handle = 0;
2448 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2450 CAM_LOG_ERROR("Receiving Handle Failed!!");
2451 ret = CAMERA_ERROR_INVALID_OPERATION;
2455 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2456 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2457 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2459 pc->remote_handle = handle;
2460 pc->cb_info->bufmgr = bufmgr;
2461 pc->cb_info->preview_format = preview_format;
2462 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2463 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2464 g_mmcam_log_level = log_level;
2466 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2467 preview_format, user_buffer_supported, g_mmcam_log_level);
2469 *camera = (camera_h)pc;
2471 /* get display interface handle */
2472 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2473 CAM_LOG_WARNING("display interface init failed");
2482 tbm_bufmgr_deinit(bufmgr);
2487 muse_client_close(sock_fd);
2493 int temp_fd = pc->cb_info->fd;
2495 /* pc->cb_info->fd should be closed,
2496 because g_thread_join for msg_recv_thread is not returned
2497 in _camera_client_callback_destroy. */
2499 pc->cb_info->fd = -1;
2500 muse_client_close(temp_fd);
2503 _camera_client_callback_destroy(pc->cb_info);
2510 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2517 int camera_change_device(camera_h camera, camera_device_e device)
2520 int ret = CAMERA_ERROR_NONE;
2521 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2522 camera_cli_s *pc = (camera_cli_s *)camera;
2523 camera_msg_param param;
2525 if (!pc || !pc->cb_info) {
2526 CAM_LOG_ERROR("NULL handle");
2527 return CAMERA_ERROR_INVALID_PARAMETER;
2530 CAMERA_MSG_PARAM_SET(param, INT, device);
2532 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2534 if (ret == CAMERA_ERROR_NONE) {
2535 /* reset callback and user data */
2536 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2537 pc->cb_info->user_cb[i] = NULL;
2538 pc->cb_info->user_data[i] = NULL;
2540 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2547 int camera_destroy(camera_h camera)
2549 int ret = CAMERA_ERROR_NONE;
2550 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2551 camera_cli_s *pc = (camera_cli_s *)camera;
2553 if (!pc || !pc->cb_info) {
2554 CAM_LOG_ERROR("NULL handle");
2555 return CAMERA_ERROR_INVALID_PARAMETER;
2558 CAM_LOG_INFO("Enter");
2560 if (pc->cb_info->is_server_connected)
2561 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2563 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2565 if (ret == CAMERA_ERROR_NONE) {
2566 _camera_deactivate_idle_event_all(pc->cb_info);
2567 _camera_client_callback_destroy(pc->cb_info);
2574 CAM_LOG_INFO("ret : 0x%x", ret);
2579 int camera_start_preview(camera_h camera)
2581 int ret = CAMERA_ERROR_NONE;
2582 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2583 camera_cli_s *pc = (camera_cli_s *)camera;
2584 camera_state_e current_state = CAMERA_STATE_NONE;
2586 if (!pc || !pc->cb_info) {
2587 CAM_LOG_ERROR("NULL handle");
2588 return CAMERA_ERROR_INVALID_PARAMETER;
2591 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2592 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2594 ret = camera_get_state(camera, ¤t_state);
2595 if (ret != CAMERA_ERROR_NONE) {
2596 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2600 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2601 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2602 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2603 pc->cb_info->dp_info.type);
2604 return CAMERA_ERROR_INVALID_OPERATION;
2607 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2608 if (!_camera_allocate_preview_buffer(camera))
2609 return CAMERA_ERROR_INVALID_OPERATION;
2611 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2613 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2616 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2617 ret = _camera_start_evas_rendering(camera);
2618 if (ret != CAMERA_ERROR_NONE) {
2619 CAM_LOG_ERROR("stop preview because of error");
2620 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2624 CAM_LOG_INFO("ret : 0x%x", ret);
2630 int camera_stop_preview(camera_h camera)
2632 int ret = CAMERA_ERROR_NONE;
2633 camera_cli_s *pc = (camera_cli_s *)camera;
2634 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2635 camera_state_e current_state = CAMERA_STATE_NONE;
2637 if (!pc || !pc->cb_info) {
2638 CAM_LOG_ERROR("NULL handle");
2639 return CAMERA_ERROR_INVALID_PARAMETER;
2642 CAM_LOG_INFO("Enter");
2645 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2646 ret = camera_get_state(camera, ¤t_state);
2647 if (ret != CAMERA_ERROR_NONE) {
2648 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2652 if (current_state == CAMERA_STATE_PREVIEW) {
2653 ret = _camera_stop_evas_rendering(camera, false);
2654 if (ret != CAMERA_ERROR_NONE)
2659 /* send stop preview message */
2660 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2662 if (ret == CAMERA_ERROR_NONE) {
2663 if (pc->cb_info->user_buffer_supported)
2664 _camera_release_preview_buffer(camera);
2665 } else if (current_state == CAMERA_STATE_PREVIEW) {
2666 CAM_LOG_WARNING("restart evas rendering");
2667 _camera_start_evas_rendering(camera);
2670 CAM_LOG_INFO("ret : 0x%x", ret);
2676 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2678 int ret = CAMERA_ERROR_NONE;
2679 camera_cli_s *pc = (camera_cli_s *)camera;
2680 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2682 if (!pc || !pc->cb_info) {
2683 CAM_LOG_ERROR("NULL handle");
2684 return CAMERA_ERROR_INVALID_PARAMETER;
2687 CAM_LOG_INFO("Enter");
2689 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2690 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2692 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2693 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2697 CAM_LOG_INFO("ret : 0x%x", ret);
2703 bool camera_is_supported_continuous_capture(camera_h camera)
2705 int ret = CAMERA_ERROR_NONE;
2706 camera_cli_s *pc = (camera_cli_s *)camera;
2707 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2709 if (!pc || !pc->cb_info) {
2710 CAM_LOG_ERROR("NULL handle");
2711 return CAMERA_ERROR_INVALID_PARAMETER;
2714 CAM_LOG_INFO("Enter");
2716 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2719 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2723 CAM_LOG_INFO("ret : %d", ret);
2729 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)
2731 int ret = CAMERA_ERROR_NONE;
2732 camera_cli_s *pc = (camera_cli_s *)camera;
2733 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2734 camera_msg_param param;
2737 if (!pc || !pc->cb_info) {
2738 CAM_LOG_ERROR("NULL handle");
2739 return CAMERA_ERROR_INVALID_PARAMETER;
2742 CAM_LOG_INFO("Enter");
2744 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2745 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2747 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2748 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2750 value = (count << 16) | interval;
2751 CAMERA_MSG_PARAM_SET(param, INT, value);
2753 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2755 CAM_LOG_INFO("ret : 0x%x", ret);
2761 int camera_stop_continuous_capture(camera_h camera)
2763 int ret = CAMERA_ERROR_NONE;
2764 camera_cli_s *pc = (camera_cli_s *)camera;
2765 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2767 if (!pc || !pc->cb_info) {
2768 CAM_LOG_ERROR("NULL handle");
2769 return CAMERA_ERROR_INVALID_PARAMETER;
2772 CAM_LOG_INFO("Enter");
2774 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2776 CAM_LOG_INFO("ret : 0x%x", ret);
2782 bool camera_is_supported_face_detection(camera_h camera)
2784 int ret = CAMERA_ERROR_NONE;
2785 camera_cli_s *pc = (camera_cli_s *)camera;
2786 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2788 if (!pc || !pc->cb_info) {
2789 CAM_LOG_ERROR("NULL handle");
2790 return CAMERA_ERROR_INVALID_PARAMETER;
2793 CAM_LOG_INFO("Enter");
2795 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2798 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2802 CAM_LOG_INFO("ret : %d", ret);
2808 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2810 int ret = CAMERA_ERROR_NONE;
2811 camera_cli_s *pc = (camera_cli_s *)camera;
2812 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2814 if (!pc || !pc->cb_info) {
2815 CAM_LOG_ERROR("NULL handle");
2816 return CAMERA_ERROR_INVALID_PARAMETER;
2819 CAM_LOG_INFO("Enter");
2821 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2824 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2828 CAM_LOG_INFO("ret : %d", ret);
2834 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2836 int ret = CAMERA_ERROR_NONE;
2837 camera_cli_s *pc = (camera_cli_s *)camera;
2838 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2840 if (!pc || !pc->cb_info) {
2841 CAM_LOG_ERROR("NULL handle");
2842 return CAMERA_ERROR_INVALID_PARAMETER;
2845 CAM_LOG_INFO("Enter");
2847 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2850 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2854 CAM_LOG_INFO("ret : %d", ret);
2859 int camera_get_device_count(camera_h camera, int *device_count)
2861 int ret = CAMERA_ERROR_NONE;
2862 camera_cli_s *pc = (camera_cli_s *)camera;
2863 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2865 if (!pc || !pc->cb_info) {
2866 CAM_LOG_ERROR("NULL handle");
2867 return CAMERA_ERROR_INVALID_PARAMETER;
2870 CAM_LOG_INFO("Enter");
2872 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2874 if (ret == CAMERA_ERROR_NONE)
2875 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2877 CAM_LOG_INFO("ret : 0x%x", ret);
2882 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2884 int ret = CAMERA_ERROR_NONE;
2885 camera_cli_s *pc = (camera_cli_s *)camera;
2886 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2888 if (!pc || !pc->cb_info) {
2889 CAM_LOG_ERROR("NULL handle");
2890 return CAMERA_ERROR_INVALID_PARAMETER;
2893 CAM_LOG_INFO("Enter");
2895 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2897 if (ret == CAMERA_ERROR_NONE) {
2898 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2900 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2901 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2903 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2906 CAM_LOG_INFO("ret : 0x%x", ret);
2911 int camera_stop_face_detection(camera_h camera)
2913 int ret = CAMERA_ERROR_NONE;
2914 camera_cli_s *pc = (camera_cli_s *)camera;
2915 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2917 if (!pc || !pc->cb_info) {
2918 CAM_LOG_ERROR("NULL handle");
2919 return CAMERA_ERROR_INVALID_PARAMETER;
2922 CAM_LOG_INFO("Enter");
2924 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2926 if (ret == CAMERA_ERROR_NONE) {
2927 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2929 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2930 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2932 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2935 CAM_LOG_INFO("ret : 0x%x", ret);
2940 int camera_get_state(camera_h camera, camera_state_e *state)
2942 int ret = CAMERA_ERROR_NONE;
2943 camera_cli_s *pc = (camera_cli_s *)camera;
2944 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2946 if (!pc || !pc->cb_info || !state) {
2947 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
2948 return CAMERA_ERROR_INVALID_PARAMETER;
2951 CAM_LOG_INFO("Enter");
2953 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2955 if (ret == CAMERA_ERROR_NONE)
2956 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2958 CAM_LOG_INFO("ret : 0x%x", ret);
2963 int camera_start_focusing(camera_h camera, bool continuous)
2965 int ret = CAMERA_ERROR_NONE;
2966 camera_cli_s *pc = (camera_cli_s *)camera;
2967 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2968 camera_msg_param param;
2969 int is_continuous = (int)continuous;
2971 if (!pc || !pc->cb_info) {
2972 CAM_LOG_ERROR("NULL handle");
2973 return CAMERA_ERROR_INVALID_PARAMETER;
2976 CAM_LOG_INFO("Enter");
2978 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2980 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2982 CAM_LOG_INFO("ret : 0x%x", ret);
2987 int camera_cancel_focusing(camera_h camera)
2989 int ret = CAMERA_ERROR_NONE;
2990 camera_cli_s *pc = (camera_cli_s *)camera;
2991 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2993 if (!pc || !pc->cb_info) {
2994 CAM_LOG_ERROR("NULL handle");
2995 return CAMERA_ERROR_INVALID_PARAMETER;
2998 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3000 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3002 CAM_LOG_INFO("ret : 0x%x", ret);
3008 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3010 int mm_ret = MM_ERROR_NONE;
3011 int ret = CAMERA_ERROR_NONE;
3012 camera_cli_s *pc = (camera_cli_s *)camera;
3013 camera_cb_info_s *cb_info = NULL;
3014 camera_state_e current_state = CAMERA_STATE_NONE;
3015 camera_msg_param param;
3016 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3017 muse_camera_display_info_s *dp_info = NULL;
3019 if (!pc || !pc->cb_info) {
3020 CAM_LOG_ERROR("NULL handle");
3021 return CAMERA_ERROR_INVALID_PARAMETER;
3024 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3025 CAM_LOG_ERROR("invalid type %d", type);
3026 return CAMERA_ERROR_INVALID_PARAMETER;
3029 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3030 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3031 return CAMERA_ERROR_INVALID_PARAMETER;
3034 cb_info = (camera_cb_info_s *)pc->cb_info;
3035 dp_info = &cb_info->dp_info;
3037 ret = camera_get_state(camera, ¤t_state);
3038 if (ret != CAMERA_ERROR_NONE) {
3039 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3043 if (current_state != CAMERA_STATE_CREATED) {
3044 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3045 return CAMERA_ERROR_INVALID_STATE;
3048 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3050 if (type != MM_DISPLAY_TYPE_NONE) {
3051 /* check display interface handle */
3052 if (!cb_info->dp_interface) {
3053 CAM_LOG_ERROR("display interface not supported");
3054 return CAMERA_ERROR_NOT_SUPPORTED;
3057 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3058 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3059 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3060 return CAMERA_ERROR_NOT_SUPPORTED;
3061 } else if (mm_ret != MM_ERROR_NONE) {
3062 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3063 return CAMERA_ERROR_INVALID_OPERATION;
3066 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3067 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3069 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3070 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3071 dp_info->window_rect.width, dp_info->window_rect.height);
3072 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3074 camera_flip_e flip = CAMERA_FLIP_NONE;
3075 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3076 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3083 camera_get_display_flip(camera, &flip);
3084 camera_get_display_mode(camera, &mode);
3085 camera_get_display_rotation(camera, &rotation);
3086 camera_is_display_visible(camera, &visible);
3088 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3089 flip, mode, rotation, visible);
3091 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3092 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3093 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3094 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3096 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3097 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3098 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3099 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3105 if (mm_ret != MM_ERROR_NONE) {
3106 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3107 return CAMERA_ERROR_INVALID_OPERATION;
3110 dp_info->type = type;
3112 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3114 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3116 if (ret == CAMERA_ERROR_NONE) {
3117 if (type == MM_DISPLAY_TYPE_EVAS)
3118 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3125 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3127 CAM_LOG_INFO("type %d, display %p", type, display);
3128 return _camera_set_display(camera, (mm_display_type_e)type, display);
3132 int camera_set_preview_resolution(camera_h camera, int width, int height)
3134 int ret = CAMERA_ERROR_NONE;
3135 camera_state_e current_state = CAMERA_STATE_NONE;
3136 camera_cli_s *pc = (camera_cli_s *)camera;
3137 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3138 camera_msg_param param;
3141 if (!pc || !pc->cb_info) {
3142 CAM_LOG_ERROR("NULL handle");
3143 return CAMERA_ERROR_INVALID_PARAMETER;
3146 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3147 ret = camera_get_state(camera, ¤t_state);
3148 if (ret != CAMERA_ERROR_NONE) {
3149 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3153 if (current_state == CAMERA_STATE_PREVIEW) {
3154 ret = _camera_stop_evas_rendering(camera, true);
3155 if (ret != CAMERA_ERROR_NONE)
3160 value = (width << 16) | height;
3161 CAMERA_MSG_PARAM_SET(param, INT, value);
3163 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3165 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3167 CAM_LOG_INFO("ret : 0x%x", ret);
3169 if (current_state == CAMERA_STATE_PREVIEW) {
3170 CAM_LOG_WARNING("restart evas rendering");
3171 _camera_start_evas_rendering(camera);
3178 int camera_set_capture_resolution(camera_h camera, int width, int height)
3180 int ret = CAMERA_ERROR_NONE;
3181 camera_cli_s *pc = (camera_cli_s *)camera;
3182 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3183 camera_msg_param param;
3186 if (!pc || !pc->cb_info) {
3187 CAM_LOG_ERROR("NULL handle");
3188 return CAMERA_ERROR_INVALID_PARAMETER;
3191 CAM_LOG_INFO("Enter");
3193 value = (width << 16) | height;
3194 CAMERA_MSG_PARAM_SET(param, INT, value);
3196 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3198 CAM_LOG_INFO("ret : 0x%x", ret);
3204 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3206 int ret = CAMERA_ERROR_NONE;
3207 int set_format = (int)format;
3208 camera_cli_s *pc = (camera_cli_s *)camera;
3209 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3210 camera_msg_param param;
3212 if (!pc || !pc->cb_info) {
3213 CAM_LOG_ERROR("NULL handle");
3214 return CAMERA_ERROR_INVALID_PARAMETER;
3217 CAM_LOG_INFO("Enter - format %d", set_format);
3219 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3221 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3223 CAM_LOG_INFO("ret : 0x%x", ret);
3229 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3231 int ret = CAMERA_ERROR_NONE;
3232 int set_format = (int)format;
3233 camera_msg_param param;
3234 camera_cli_s *pc = (camera_cli_s *)camera;
3235 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3237 if (!pc || !pc->cb_info) {
3238 CAM_LOG_ERROR("NULL handle");
3239 return CAMERA_ERROR_INVALID_PARAMETER;
3242 CAM_LOG_INFO("Enter - format %d", set_format);
3244 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3246 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3248 if (ret == CAMERA_ERROR_NONE)
3249 pc->cb_info->preview_format = set_format;
3251 CAM_LOG_INFO("ret : 0x%x", ret);
3257 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3259 int ret = CAMERA_ERROR_NONE;
3260 camera_cli_s *pc = (camera_cli_s *)camera;
3261 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3263 if (!pc || !pc->cb_info || !width || !height) {
3264 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3265 return CAMERA_ERROR_INVALID_PARAMETER;
3268 CAM_LOG_INFO("Enter");
3270 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3272 if (ret == CAMERA_ERROR_NONE) {
3273 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3274 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3277 CAM_LOG_INFO("ret : 0x%x", ret);
3283 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3285 int ret = CAMERA_ERROR_NONE;
3286 int set_rotation = (int)rotation;
3287 camera_cli_s *pc = (camera_cli_s *)camera;
3288 camera_msg_param param;
3290 if (!pc || !pc->cb_info) {
3291 CAM_LOG_ERROR("NULL handle");
3292 return CAMERA_ERROR_INVALID_PARAMETER;
3295 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3296 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3297 if (ret != MM_ERROR_NONE) {
3298 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3299 return CAMERA_ERROR_INVALID_OPERATION;
3303 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3305 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3311 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3313 int ret = CAMERA_ERROR_NONE;
3314 camera_cli_s *pc = (camera_cli_s *)camera;
3316 if (!pc || !pc->cb_info || !rotation) {
3317 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3318 return CAMERA_ERROR_INVALID_PARAMETER;
3321 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3323 if (ret == CAMERA_ERROR_NONE)
3324 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3330 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3332 int ret = CAMERA_ERROR_NONE;
3333 int set_flip = (int)flip;
3334 camera_cli_s *pc = (camera_cli_s *)camera;
3335 camera_msg_param param;
3337 if (!pc || !pc->cb_info) {
3338 CAM_LOG_ERROR("NULL handle");
3339 return CAMERA_ERROR_INVALID_PARAMETER;
3342 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3343 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3344 if (ret != MM_ERROR_NONE) {
3345 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3346 return CAMERA_ERROR_INVALID_OPERATION;
3350 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3352 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3358 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3360 int ret = CAMERA_ERROR_NONE;
3361 camera_cli_s *pc = (camera_cli_s *)camera;
3363 if (!pc || !pc->cb_info || !flip) {
3364 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3365 return CAMERA_ERROR_INVALID_PARAMETER;
3368 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3370 if (ret == CAMERA_ERROR_NONE)
3371 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3377 int camera_set_display_visible(camera_h camera, bool visible)
3379 int ret = CAMERA_ERROR_NONE;
3380 int set_visible = (int)visible;
3381 camera_cli_s *pc = (camera_cli_s *)camera;
3382 camera_msg_param param;
3384 if (!pc || !pc->cb_info) {
3385 CAM_LOG_ERROR("NULL handle");
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3389 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3390 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3391 if (ret != MM_ERROR_NONE) {
3392 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3393 return CAMERA_ERROR_INVALID_OPERATION;
3397 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3399 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3405 int camera_is_display_visible(camera_h camera, bool *visible)
3407 int ret = CAMERA_ERROR_NONE;
3408 camera_cli_s *pc = (camera_cli_s *)camera;
3410 if (!pc || !pc->cb_info || !visible) {
3411 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3412 return CAMERA_ERROR_INVALID_PARAMETER;
3415 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3417 if (ret == CAMERA_ERROR_NONE)
3418 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3424 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3426 int ret = CAMERA_ERROR_NONE;
3427 int set_mode = (int)mode;
3428 camera_cli_s *pc = (camera_cli_s *)camera;
3429 camera_msg_param param;
3431 if (!pc || !pc->cb_info) {
3432 CAM_LOG_ERROR("NULL handle");
3433 return CAMERA_ERROR_INVALID_PARAMETER;
3436 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3437 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3438 if (ret != MM_ERROR_NONE) {
3439 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3440 return CAMERA_ERROR_INVALID_OPERATION;
3444 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3446 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3452 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3454 int ret = CAMERA_ERROR_NONE;
3455 camera_cli_s *pc = (camera_cli_s *)camera;
3457 if (!pc || !pc->cb_info || !mode) {
3458 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3464 if (ret == CAMERA_ERROR_NONE)
3465 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3471 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3473 int ret = CAMERA_ERROR_NONE;
3474 int set_hint = (int)hint;
3475 camera_cli_s *pc = (camera_cli_s *)camera;
3476 camera_msg_param param;
3478 if (!pc || !pc->cb_info) {
3479 CAM_LOG_ERROR("NULL handle");
3480 return CAMERA_ERROR_INVALID_PARAMETER;
3483 CAM_LOG_INFO("Enter - hint %d", set_hint);
3485 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3487 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3493 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3495 int ret = CAMERA_ERROR_NONE;
3496 camera_cli_s *pc = (camera_cli_s *)camera;
3497 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3499 if (!pc || !pc->cb_info || !hint) {
3500 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3501 return CAMERA_ERROR_INVALID_PARAMETER;
3504 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3506 if (ret == CAMERA_ERROR_NONE) {
3507 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3508 CAM_LOG_INFO("display reuse hint %d", *hint);
3515 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3517 int ret = CAMERA_ERROR_NONE;
3518 camera_cli_s *pc = (camera_cli_s *)camera;
3519 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3521 if (!pc || !pc->cb_info || !width || !height) {
3522 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3523 return CAMERA_ERROR_INVALID_PARAMETER;
3526 CAM_LOG_INFO("Enter");
3528 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3530 if (ret == CAMERA_ERROR_NONE) {
3531 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3532 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3535 CAM_LOG_INFO("ret : 0x%x", ret);
3541 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3543 int ret = CAMERA_ERROR_NONE;
3544 camera_cli_s *pc = (camera_cli_s *)camera;
3545 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3547 if (!pc || !pc->cb_info || !format) {
3548 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3549 return CAMERA_ERROR_INVALID_PARAMETER;
3552 CAM_LOG_INFO("Enter");
3554 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3556 if (ret == CAMERA_ERROR_NONE)
3557 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3559 CAM_LOG_INFO("ret : 0x%x", ret);
3565 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3567 int ret = CAMERA_ERROR_NONE;
3568 camera_cli_s *pc = (camera_cli_s *)camera;
3569 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3571 if (!pc || !pc->cb_info || !format) {
3572 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3573 return CAMERA_ERROR_INVALID_PARAMETER;
3576 CAM_LOG_INFO("Enter");
3578 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3580 if (ret == CAMERA_ERROR_NONE)
3581 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3583 CAM_LOG_INFO("ret : 0x%x", ret);
3589 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3591 int ret = CAMERA_ERROR_NONE;
3592 camera_cli_s *pc = (camera_cli_s *)camera;
3593 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3595 if (!pc || !pc->cb_info || !facing_direction) {
3596 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3597 return CAMERA_ERROR_INVALID_PARAMETER;
3600 CAM_LOG_INFO("Enter");
3602 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3604 if (ret == CAMERA_ERROR_NONE)
3605 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3607 CAM_LOG_INFO("ret : 0x%x", ret);
3613 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3615 int ret = CAMERA_ERROR_NONE;
3616 camera_cli_s *pc = (camera_cli_s *)camera;
3617 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3619 if (!pc || !pc->cb_info || !callback) {
3620 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3621 return CAMERA_ERROR_INVALID_PARAMETER;
3624 CAM_LOG_INFO("Enter");
3626 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3628 if (ret == CAMERA_ERROR_NONE) {
3629 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3631 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3632 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3634 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3636 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3639 CAM_LOG_INFO("ret : 0x%x", ret);
3645 int camera_unset_preview_cb(camera_h camera)
3647 int ret = CAMERA_ERROR_NONE;
3648 camera_cli_s *pc = (camera_cli_s *)camera;
3649 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3651 if (!pc || !pc->cb_info) {
3652 CAM_LOG_ERROR("NULL handle");
3653 return CAMERA_ERROR_INVALID_PARAMETER;
3656 CAM_LOG_INFO("Enter");
3658 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3660 if (ret == CAMERA_ERROR_NONE) {
3661 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3663 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3664 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3666 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3668 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3671 CAM_LOG_INFO("ret : 0x%x", ret);
3677 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3679 int ret = CAMERA_ERROR_NONE;
3680 camera_cli_s *pc = (camera_cli_s *)camera;
3681 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3683 if (!pc || !pc->cb_info) {
3684 CAM_LOG_ERROR("NULL handle");
3685 return CAMERA_ERROR_INVALID_PARAMETER;
3688 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3689 CAM_LOG_ERROR("NOT SUPPORTED");
3690 return CAMERA_ERROR_NOT_SUPPORTED;
3693 if (callback == NULL) {
3694 CAM_LOG_ERROR("NULL callback");
3695 return CAMERA_ERROR_INVALID_PARAMETER;
3698 CAM_LOG_INFO("Enter");
3700 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3702 if (ret == CAMERA_ERROR_NONE) {
3703 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3705 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3706 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3708 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3711 CAM_LOG_INFO("ret : 0x%x", ret);
3717 int camera_unset_media_packet_preview_cb(camera_h camera)
3719 int ret = CAMERA_ERROR_NONE;
3720 camera_cli_s *pc = (camera_cli_s *)camera;
3721 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3723 if (!pc || !pc->cb_info) {
3724 CAM_LOG_ERROR("NULL handle");
3725 return CAMERA_ERROR_INVALID_PARAMETER;
3728 CAM_LOG_INFO("Enter");
3730 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3732 if (ret == CAMERA_ERROR_NONE) {
3733 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3735 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3736 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3738 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3741 CAM_LOG_INFO("ret : 0x%x", ret);
3747 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3749 int ret = CAMERA_ERROR_NONE;
3750 camera_cli_s *pc = (camera_cli_s *)camera;
3751 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3753 if (!pc || !pc->cb_info || !callback) {
3754 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3755 return CAMERA_ERROR_INVALID_PARAMETER;
3758 CAM_LOG_INFO("Enter");
3760 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3762 if (ret == CAMERA_ERROR_NONE) {
3763 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3768 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3771 CAM_LOG_INFO("ret : 0x%x", ret);
3777 int camera_unset_state_changed_cb(camera_h camera)
3779 int ret = CAMERA_ERROR_NONE;
3780 camera_cli_s *pc = (camera_cli_s *)camera;
3781 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3783 if (!pc || !pc->cb_info) {
3784 CAM_LOG_ERROR("NULL handle");
3785 return CAMERA_ERROR_INVALID_PARAMETER;
3788 CAM_LOG_INFO("Enter");
3790 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3792 if (ret == CAMERA_ERROR_NONE) {
3793 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3795 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3796 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3798 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3801 CAM_LOG_INFO("ret : 0x%x", ret);
3807 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3809 int ret = CAMERA_ERROR_NONE;
3810 camera_cli_s *pc = (camera_cli_s *)camera;
3811 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3813 if (!pc || !pc->cb_info || !callback) {
3814 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3815 return CAMERA_ERROR_INVALID_PARAMETER;
3818 CAM_LOG_INFO("Enter");
3820 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3822 if (ret == CAMERA_ERROR_NONE) {
3823 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3825 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3826 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3828 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3831 CAM_LOG_INFO("ret : 0x%x", ret);
3837 int camera_unset_interrupted_cb(camera_h camera)
3839 int ret = CAMERA_ERROR_NONE;
3840 camera_cli_s *pc = (camera_cli_s *)camera;
3841 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3843 if (!pc || !pc->cb_info) {
3844 CAM_LOG_ERROR("NULL handle");
3845 return CAMERA_ERROR_INVALID_PARAMETER;
3848 CAM_LOG_INFO("Enter");
3850 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3852 if (ret == CAMERA_ERROR_NONE) {
3853 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3855 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3856 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3858 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3861 CAM_LOG_INFO("ret : 0x%x", ret);
3867 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3869 int ret = CAMERA_ERROR_NONE;
3870 camera_cli_s *pc = (camera_cli_s *)camera;
3871 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3873 if (!pc || !pc->cb_info || !callback) {
3874 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3875 return CAMERA_ERROR_INVALID_PARAMETER;
3878 CAM_LOG_INFO("Enter");
3880 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3882 if (ret == CAMERA_ERROR_NONE) {
3883 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3885 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3886 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3888 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3891 CAM_LOG_INFO("ret : 0x%x", ret);
3897 int camera_unset_interrupt_started_cb(camera_h camera)
3899 int ret = CAMERA_ERROR_NONE;
3900 camera_cli_s *pc = (camera_cli_s *)camera;
3901 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3903 if (!pc || !pc->cb_info) {
3904 CAM_LOG_ERROR("NULL handle");
3905 return CAMERA_ERROR_INVALID_PARAMETER;
3908 CAM_LOG_INFO("Enter");
3910 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3912 if (ret == CAMERA_ERROR_NONE) {
3913 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3915 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3916 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3918 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3921 CAM_LOG_INFO("ret : 0x%x", ret);
3927 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3929 int ret = CAMERA_ERROR_NONE;
3930 camera_cli_s *pc = (camera_cli_s *)camera;
3931 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3933 if (!pc || !pc->cb_info || !callback) {
3934 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3935 return CAMERA_ERROR_INVALID_PARAMETER;
3938 CAM_LOG_INFO("Enter");
3940 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3942 if (ret == CAMERA_ERROR_NONE) {
3943 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3945 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3946 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3948 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3951 CAM_LOG_INFO("ret : 0x%x", ret);
3957 int camera_unset_focus_changed_cb(camera_h camera)
3959 int ret = CAMERA_ERROR_NONE;
3960 camera_cli_s *pc = (camera_cli_s *)camera;
3961 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3963 if (!pc || !pc->cb_info) {
3964 CAM_LOG_ERROR("NULL handle");
3965 return CAMERA_ERROR_INVALID_PARAMETER;
3968 CAM_LOG_INFO("Enter");
3970 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3972 if (ret == CAMERA_ERROR_NONE) {
3973 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3978 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3981 CAM_LOG_INFO("ret : 0x%x", ret);
3987 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3989 int ret = CAMERA_ERROR_NONE;
3990 camera_cli_s *pc = (camera_cli_s *)camera;
3991 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3993 if (!pc || !pc->cb_info || !callback) {
3994 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3995 return CAMERA_ERROR_INVALID_PARAMETER;
3998 CAM_LOG_INFO("Enter");
4000 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4002 if (ret == CAMERA_ERROR_NONE) {
4003 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4005 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4006 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4008 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4011 CAM_LOG_INFO("ret : 0x%x", ret);
4017 int camera_unset_error_cb(camera_h camera)
4019 int ret = CAMERA_ERROR_NONE;
4020 camera_cli_s *pc = (camera_cli_s *)camera;
4021 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4023 if (!pc || !pc->cb_info) {
4024 CAM_LOG_ERROR("NULL handle");
4025 return CAMERA_ERROR_INVALID_PARAMETER;
4028 CAM_LOG_INFO("Enter");
4030 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4032 if (ret == CAMERA_ERROR_NONE) {
4033 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4035 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4036 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4038 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4041 CAM_LOG_INFO("ret : 0x%x", ret);
4047 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4049 int ret = CAMERA_ERROR_NONE;
4050 camera_cli_s *pc = (camera_cli_s *)camera;
4051 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4053 if (!pc || !pc->cb_info || !foreach_cb) {
4054 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4055 return CAMERA_ERROR_INVALID_PARAMETER;
4058 CAM_LOG_INFO("Enter");
4060 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4061 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4063 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4065 CAM_LOG_INFO("ret : 0x%x", ret);
4071 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4073 int ret = CAMERA_ERROR_NONE;
4074 camera_cli_s *pc = (camera_cli_s *)camera;
4075 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4077 if (!pc || !pc->cb_info || !foreach_cb) {
4078 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4079 return CAMERA_ERROR_INVALID_PARAMETER;
4082 CAM_LOG_INFO("Enter");
4084 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4085 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4087 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4089 CAM_LOG_INFO("ret : 0x%x", ret);
4095 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4097 int ret = CAMERA_ERROR_NONE;
4098 camera_cli_s *pc = (camera_cli_s *)camera;
4099 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4101 if (!pc || !pc->cb_info || !foreach_cb) {
4102 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4103 return CAMERA_ERROR_INVALID_PARAMETER;
4106 CAM_LOG_INFO("Enter");
4108 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4109 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4111 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4113 CAM_LOG_INFO("ret : 0x%x", ret);
4119 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4121 int ret = CAMERA_ERROR_NONE;
4122 camera_cli_s *pc = (camera_cli_s *)camera;
4123 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4125 if (!pc || !pc->cb_info || !foreach_cb) {
4126 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4127 return CAMERA_ERROR_INVALID_PARAMETER;
4130 CAM_LOG_INFO("Enter");
4132 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4133 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4135 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4137 CAM_LOG_INFO("ret : 0x%x", ret);
4143 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4145 int ret = CAMERA_ERROR_NONE;
4146 camera_cli_s *pc = (camera_cli_s *)camera;
4147 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4149 if (!pc || !pc->cb_info || !width || !height) {
4150 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4151 return CAMERA_ERROR_INVALID_PARAMETER;
4154 CAM_LOG_INFO("Enter");
4155 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4157 if (ret == CAMERA_ERROR_NONE) {
4158 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4159 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4162 CAM_LOG_INFO("ret : 0x%x", ret);
4168 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4170 int ret = CAMERA_ERROR_NONE;
4171 camera_cli_s *pc = (camera_cli_s *)camera;
4172 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4174 if (!pc || !pc->cb_info || !angle) {
4175 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4176 return CAMERA_ERROR_INVALID_PARAMETER;
4179 CAM_LOG_INFO("Enter");
4181 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4183 if (ret == CAMERA_ERROR_NONE)
4184 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4186 CAM_LOG_INFO("ret : 0x%x", ret);
4192 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4194 int ret = CAMERA_ERROR_NONE;
4195 camera_cli_s *pc = (camera_cli_s *)camera;
4196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4197 camera_msg_param param;
4198 int set_mode = (int)mode;
4200 if (!pc || !pc->cb_info) {
4201 CAM_LOG_ERROR("NULL handle");
4202 return CAMERA_ERROR_INVALID_PARAMETER;
4205 CAM_LOG_INFO("Enter");
4207 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4209 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4211 CAM_LOG_INFO("ret : 0x%x", ret);
4217 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4219 int ret = CAMERA_ERROR_NONE;
4220 camera_cli_s *pc = (camera_cli_s *)camera;
4221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4223 if (!pc || !pc->cb_info || !mode) {
4224 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4225 return CAMERA_ERROR_INVALID_PARAMETER;
4228 CAM_LOG_INFO("Enter");
4230 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4232 if (ret == CAMERA_ERROR_NONE)
4233 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4235 CAM_LOG_INFO("ret : 0x%x", ret);
4241 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4243 int ret = CAMERA_ERROR_NONE;
4244 camera_cli_s *pc = (camera_cli_s *)camera;
4245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4247 if (!pc || !pc->cb_info || !foreach_cb) {
4248 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4249 return CAMERA_ERROR_INVALID_PARAMETER;
4252 CAM_LOG_INFO("Enter");
4254 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4255 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4257 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4259 CAM_LOG_INFO("Finish, return :%x", ret);
4265 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4267 int ret = CAMERA_ERROR_NONE;
4268 camera_cli_s *pc = (camera_cli_s *)camera;
4269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4270 camera_msg_param param;
4271 int set_fps = (int)fps;
4273 if (!pc || !pc->cb_info) {
4274 CAM_LOG_ERROR("NULL handle");
4275 return CAMERA_ERROR_INVALID_PARAMETER;
4278 CAM_LOG_INFO("Enter");
4280 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4282 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4284 CAM_LOG_INFO("ret : 0x%x", ret);
4290 int camera_attr_set_image_quality(camera_h camera, int quality)
4292 int ret = CAMERA_ERROR_NONE;
4293 camera_cli_s *pc = (camera_cli_s *)camera;
4294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4295 camera_msg_param param;
4297 if (!pc || !pc->cb_info) {
4298 CAM_LOG_ERROR("NULL handle");
4299 return CAMERA_ERROR_INVALID_PARAMETER;
4302 CAM_LOG_INFO("Enter");
4304 CAMERA_MSG_PARAM_SET(param, INT, quality);
4306 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4308 CAM_LOG_INFO("ret : 0x%x", ret);
4314 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4316 int ret = CAMERA_ERROR_NONE;
4317 camera_cli_s *pc = (camera_cli_s *)camera;
4318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4320 if (!pc || !pc->cb_info || !fps) {
4321 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4322 return CAMERA_ERROR_INVALID_PARAMETER;
4325 CAM_LOG_INFO("Enter");
4327 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4329 if (ret == CAMERA_ERROR_NONE)
4330 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4332 CAM_LOG_INFO("ret : 0x%x", ret);
4338 int camera_attr_get_image_quality(camera_h camera, int *quality)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4344 if (!pc || !pc->cb_info || !quality) {
4345 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4346 return CAMERA_ERROR_INVALID_PARAMETER;
4349 CAM_LOG_INFO("Enter");
4351 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4353 if (ret == CAMERA_ERROR_NONE)
4354 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4356 CAM_LOG_INFO("ret : 0x%x", ret);
4362 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4364 int ret = CAMERA_ERROR_NONE;
4365 camera_cli_s *pc = (camera_cli_s *)camera;
4366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4368 if (!pc || !pc->cb_info || !bitrate) {
4369 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4370 return CAMERA_ERROR_INVALID_PARAMETER;
4373 CAM_LOG_INFO("Enter");
4375 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4377 if (ret == CAMERA_ERROR_NONE)
4378 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4380 CAM_LOG_INFO("ret : 0x%x", ret);
4386 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4388 int ret = CAMERA_ERROR_NONE;
4389 camera_cli_s *pc = (camera_cli_s *)camera;
4390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4391 camera_msg_param param;
4392 int set_bitrate = bitrate;
4394 if (!pc || !pc->cb_info) {
4395 CAM_LOG_ERROR("NULL handle");
4396 return CAMERA_ERROR_INVALID_PARAMETER;
4399 CAM_LOG_INFO("Enter");
4401 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4403 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4405 CAM_LOG_INFO("ret : 0x%x", ret);
4411 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4417 if (!pc || !pc->cb_info || !interval) {
4418 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4419 return CAMERA_ERROR_INVALID_PARAMETER;
4422 CAM_LOG_INFO("Enter");
4424 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4426 if (ret == CAMERA_ERROR_NONE)
4427 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4429 CAM_LOG_INFO("ret : 0x%x", ret);
4435 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4437 int ret = CAMERA_ERROR_NONE;
4438 camera_cli_s *pc = (camera_cli_s *)camera;
4439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4440 camera_msg_param param;
4441 int set_gop_interval = interval;
4443 if (!pc || !pc->cb_info) {
4444 CAM_LOG_ERROR("NULL handle");
4445 return CAMERA_ERROR_INVALID_PARAMETER;
4448 CAM_LOG_INFO("Enter");
4450 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4454 CAM_LOG_INFO("ret : 0x%x", ret);
4460 int camera_attr_set_zoom(camera_h camera, int zoom)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4465 camera_msg_param param;
4467 if (!pc || !pc->cb_info) {
4468 CAM_LOG_ERROR("NULL handle");
4469 return CAMERA_ERROR_INVALID_PARAMETER;
4472 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4474 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4476 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4478 CAM_LOG_INFO("ret : 0x%x", ret);
4484 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4486 int ret = CAMERA_ERROR_NONE;
4487 camera_cli_s *pc = (camera_cli_s *)camera;
4488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4489 camera_msg_param param;
4490 int set_mode = (int)mode;
4492 if (!pc || !pc->cb_info) {
4493 CAM_LOG_ERROR("NULL handle");
4494 return CAMERA_ERROR_INVALID_PARAMETER;
4497 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4499 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4501 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4507 int camera_attr_set_af_area(camera_h camera, int x, int y)
4509 int ret = CAMERA_ERROR_NONE;
4510 camera_cli_s *pc = (camera_cli_s *)camera;
4511 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4512 camera_msg_param param;
4515 if (!pc || !pc->cb_info) {
4516 CAM_LOG_ERROR("NULL handle");
4517 return CAMERA_ERROR_INVALID_PARAMETER;
4520 CAM_LOG_INFO("Enter - %d,%d", x, y);
4522 value = (x << 16) | y;
4523 CAMERA_MSG_PARAM_SET(param, INT, value);
4525 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4527 CAM_LOG_INFO("ret : 0x%x", ret);
4533 int camera_attr_clear_af_area(camera_h camera)
4535 int ret = CAMERA_ERROR_NONE;
4536 camera_cli_s *pc = (camera_cli_s *)camera;
4537 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4539 if (!pc || !pc->cb_info) {
4540 CAM_LOG_ERROR("NULL handle");
4541 return CAMERA_ERROR_INVALID_PARAMETER;
4544 CAM_LOG_INFO("Enter");
4546 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4548 CAM_LOG_INFO("ret : 0x%x", ret);
4554 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4556 int ret = CAMERA_ERROR_NONE;
4557 camera_cli_s *pc = (camera_cli_s *)camera;
4558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4559 camera_msg_param param;
4560 int set_mode = (int)mode;
4562 if (!pc || !pc->cb_info) {
4563 CAM_LOG_ERROR("NULL handle");
4564 return CAMERA_ERROR_INVALID_PARAMETER;
4567 CAM_LOG_INFO("Enter");
4569 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4571 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4573 CAM_LOG_INFO("ret : 0x%x", ret);
4579 int camera_attr_set_exposure(camera_h camera, int value)
4581 int ret = CAMERA_ERROR_NONE;
4582 camera_cli_s *pc = (camera_cli_s *)camera;
4583 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4584 camera_msg_param param;
4586 if (!pc || !pc->cb_info) {
4587 CAM_LOG_ERROR("NULL handle");
4588 return CAMERA_ERROR_INVALID_PARAMETER;
4591 CAM_LOG_INFO("Enter");
4593 CAMERA_MSG_PARAM_SET(param, INT, value);
4595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4597 CAM_LOG_INFO("ret : 0x%x", ret);
4603 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4605 int ret = CAMERA_ERROR_NONE;
4606 camera_cli_s *pc = (camera_cli_s *)camera;
4607 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4608 camera_msg_param param;
4609 int set_iso = (int)iso;
4611 if (!pc || !pc->cb_info) {
4612 CAM_LOG_ERROR("NULL handle");
4613 return CAMERA_ERROR_INVALID_PARAMETER;
4616 CAM_LOG_INFO("Enter");
4618 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4620 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4622 CAM_LOG_INFO("ret : 0x%x", ret);
4628 int camera_attr_set_brightness(camera_h camera, int level)
4630 int ret = CAMERA_ERROR_NONE;
4631 camera_cli_s *pc = (camera_cli_s *)camera;
4632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4633 camera_msg_param param;
4635 if (!pc || !pc->cb_info) {
4636 CAM_LOG_ERROR("NULL handle");
4637 return CAMERA_ERROR_INVALID_PARAMETER;
4640 CAM_LOG_INFO("Enter");
4642 CAMERA_MSG_PARAM_SET(param, INT, level);
4644 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4646 CAM_LOG_INFO("ret : 0x%x", ret);
4652 int camera_attr_set_contrast(camera_h camera, int level)
4654 int ret = CAMERA_ERROR_NONE;
4655 camera_cli_s *pc = (camera_cli_s *)camera;
4656 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4657 camera_msg_param param;
4659 if (!pc || !pc->cb_info) {
4660 CAM_LOG_ERROR("NULL handle");
4661 return CAMERA_ERROR_INVALID_PARAMETER;
4664 CAM_LOG_INFO("Enter");
4666 CAMERA_MSG_PARAM_SET(param, INT, level);
4668 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4670 CAM_LOG_INFO("ret : 0x%x", ret);
4676 int camera_attr_set_hue(camera_h camera, int level)
4678 int ret = CAMERA_ERROR_NONE;
4679 camera_cli_s *pc = (camera_cli_s *)camera;
4680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4681 camera_msg_param param;
4683 if (!pc || !pc->cb_info) {
4684 CAM_LOG_ERROR("NULL handle");
4685 return CAMERA_ERROR_INVALID_PARAMETER;
4688 CAM_LOG_INFO("Enter");
4690 CAMERA_MSG_PARAM_SET(param, INT, level);
4692 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4694 CAM_LOG_INFO("ret : 0x%x", ret);
4700 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4702 int ret = CAMERA_ERROR_NONE;
4703 camera_cli_s *pc = (camera_cli_s *)camera;
4704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4705 camera_msg_param param;
4706 int set_whitebalance = (int)wb;
4708 if (!pc || !pc->cb_info) {
4709 CAM_LOG_ERROR("NULL handle");
4710 return CAMERA_ERROR_INVALID_PARAMETER;
4713 CAM_LOG_INFO("Enter");
4715 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4719 CAM_LOG_INFO("ret : 0x%x", ret);
4725 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4727 int ret = CAMERA_ERROR_NONE;
4728 camera_cli_s *pc = (camera_cli_s *)camera;
4729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4730 camera_msg_param param;
4731 int set_effect = (int)effect;
4733 if (!pc || !pc->cb_info) {
4734 CAM_LOG_ERROR("NULL handle");
4735 return CAMERA_ERROR_INVALID_PARAMETER;
4738 CAM_LOG_INFO("Enter");
4740 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4742 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4744 CAM_LOG_INFO("ret : 0x%x", ret);
4750 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4752 int ret = CAMERA_ERROR_NONE;
4753 camera_cli_s *pc = (camera_cli_s *)camera;
4754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4755 camera_msg_param param;
4756 int set_mode = (int)mode;
4758 if (!pc || !pc->cb_info) {
4759 CAM_LOG_ERROR("NULL handle");
4760 return CAMERA_ERROR_INVALID_PARAMETER;
4763 CAM_LOG_INFO("Enter");
4765 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4767 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4769 CAM_LOG_INFO("ret : 0x%x", ret);
4775 int camera_attr_enable_tag(camera_h camera, bool enable)
4777 int ret = CAMERA_ERROR_NONE;
4778 camera_cli_s *pc = (camera_cli_s *)camera;
4779 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4780 camera_msg_param param;
4781 int set_enable = (int)enable;
4783 if (!pc || !pc->cb_info) {
4784 CAM_LOG_ERROR("NULL handle");
4785 return CAMERA_ERROR_INVALID_PARAMETER;
4788 CAM_LOG_INFO("Enter");
4790 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4792 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4794 CAM_LOG_INFO("ret : 0x%x", ret);
4800 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4802 int ret = CAMERA_ERROR_NONE;
4803 camera_cli_s *pc = (camera_cli_s *)camera;
4804 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4805 camera_msg_param param;
4807 if (!pc || !pc->cb_info || !description) {
4808 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4809 return CAMERA_ERROR_INVALID_PARAMETER;
4812 CAM_LOG_INFO("Enter");
4814 CAMERA_MSG_PARAM_SET(param, STRING, description);
4816 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4818 CAM_LOG_INFO("ret : 0x%x", ret);
4824 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4826 int ret = CAMERA_ERROR_NONE;
4827 camera_cli_s *pc = (camera_cli_s *)camera;
4828 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4829 camera_msg_param param;
4830 int set_orientation = (int)orientation;
4832 if (!pc || !pc->cb_info) {
4833 CAM_LOG_ERROR("NULL handle");
4834 return CAMERA_ERROR_INVALID_PARAMETER;
4837 CAM_LOG_INFO("Enter");
4839 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4841 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4843 CAM_LOG_INFO("ret : 0x%x", ret);
4849 int camera_attr_set_tag_software(camera_h camera, const char *software)
4851 int ret = CAMERA_ERROR_NONE;
4852 camera_cli_s *pc = (camera_cli_s *)camera;
4853 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4854 camera_msg_param param;
4856 if (!pc || !pc->cb_info || !software) {
4857 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4858 return CAMERA_ERROR_INVALID_PARAMETER;
4861 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4863 CAMERA_MSG_PARAM_SET(param, STRING, software);
4865 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4867 CAM_LOG_INFO("ret : 0x%x", ret);
4873 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4875 int ret = CAMERA_ERROR_NONE;
4876 camera_cli_s *pc = (camera_cli_s *)camera;
4877 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4878 double set_geotag[3] = {latitude, longitude, altitude};
4883 if (!pc || !pc->cb_info) {
4884 CAM_LOG_ERROR("NULL handle");
4885 return CAMERA_ERROR_INVALID_PARAMETER;
4888 CAM_LOG_INFO("Enter");
4890 length = sizeof(set_geotag) / sizeof(int) + \
4891 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4893 msg = muse_core_msg_new(api,
4894 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4897 CAM_LOG_ERROR("msg creation failed: api %d", api);
4898 return CAMERA_ERROR_OUT_OF_MEMORY;
4901 if (pc->cb_info->is_server_connected) {
4902 __camera_update_api_waiting(pc->cb_info, api, 1);
4904 g_mutex_lock(&pc->cb_info->fd_lock);
4905 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4906 g_mutex_unlock(&pc->cb_info->fd_lock);
4910 CAM_LOG_ERROR("message send failed");
4911 ret = CAMERA_ERROR_INVALID_OPERATION;
4913 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4916 __camera_update_api_waiting(pc->cb_info, api, -1);
4918 muse_core_msg_free(msg);
4920 CAM_LOG_INFO("ret : 0x%x", ret);
4926 int camera_attr_remove_geotag(camera_h camera)
4928 int ret = CAMERA_ERROR_NONE;
4929 camera_cli_s *pc = (camera_cli_s *)camera;
4930 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4932 if (!pc || !pc->cb_info) {
4933 CAM_LOG_ERROR("NULL handle");
4934 return CAMERA_ERROR_INVALID_PARAMETER;
4937 CAM_LOG_INFO("Enter");
4939 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4941 CAM_LOG_INFO("ret : 0x%x", ret);
4947 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4949 int ret = CAMERA_ERROR_NONE;
4950 camera_cli_s *pc = (camera_cli_s *)camera;
4951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4952 camera_msg_param param;
4953 int set_mode = (int)mode;
4955 if (!pc || !pc->cb_info) {
4956 CAM_LOG_ERROR("NULL handle");
4957 return CAMERA_ERROR_INVALID_PARAMETER;
4960 CAM_LOG_INFO("Enter");
4962 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4964 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4966 CAM_LOG_INFO("ret : 0x%x", ret);
4972 int camera_attr_get_zoom(camera_h camera, int *zoom)
4974 int ret = CAMERA_ERROR_NONE;
4975 camera_cli_s *pc = (camera_cli_s *)camera;
4976 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4978 if (!pc || !pc->cb_info || !zoom) {
4979 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4980 return CAMERA_ERROR_INVALID_PARAMETER;
4983 CAM_LOG_INFO("Enter");
4985 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4987 if (ret == CAMERA_ERROR_NONE)
4988 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4990 CAM_LOG_INFO("ret : 0x%x", ret);
4996 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4998 int ret = CAMERA_ERROR_NONE;
4999 camera_cli_s *pc = (camera_cli_s *)camera;
5000 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5002 if (!pc || !pc->cb_info || !min || !max) {
5003 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5004 return CAMERA_ERROR_INVALID_PARAMETER;
5007 CAM_LOG_INFO("Enter");
5009 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5011 if (ret == CAMERA_ERROR_NONE) {
5012 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5013 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5016 CAM_LOG_INFO("ret : 0x%x", ret);
5022 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5024 int ret = CAMERA_ERROR_NONE;
5025 camera_cli_s *pc = (camera_cli_s *)camera;
5026 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5028 if (!pc || !pc->cb_info || !mode) {
5029 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5030 return CAMERA_ERROR_INVALID_PARAMETER;
5033 CAM_LOG_INFO("Enter");
5035 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5037 if (ret == CAMERA_ERROR_NONE)
5038 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5040 CAM_LOG_INFO("ret : 0x%x", ret);
5046 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5048 int ret = CAMERA_ERROR_NONE;
5049 camera_cli_s *pc = (camera_cli_s *)camera;
5050 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5052 if (!pc || !pc->cb_info || !mode) {
5053 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5054 return CAMERA_ERROR_INVALID_PARAMETER;
5057 CAM_LOG_INFO("Enter");
5059 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5061 if (ret == CAMERA_ERROR_NONE)
5062 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5064 CAM_LOG_INFO("ret : 0x%x", ret);
5070 int camera_attr_get_exposure(camera_h camera, int *value)
5072 int ret = CAMERA_ERROR_NONE;
5073 camera_cli_s *pc = (camera_cli_s *)camera;
5074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5076 if (!pc || !pc->cb_info || !value) {
5077 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5078 return CAMERA_ERROR_INVALID_PARAMETER;
5081 CAM_LOG_INFO("Enter");
5083 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5085 if (ret == CAMERA_ERROR_NONE)
5086 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5088 CAM_LOG_INFO("ret : 0x%x", ret);
5094 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5096 int ret = CAMERA_ERROR_NONE;
5097 camera_cli_s *pc = (camera_cli_s *)camera;
5098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5100 if (!pc || !pc->cb_info || !min || !max) {
5101 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5105 CAM_LOG_INFO("Enter");
5107 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE) {
5110 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5111 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5114 CAM_LOG_INFO("ret : 0x%x", ret);
5120 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5122 int ret = CAMERA_ERROR_NONE;
5123 camera_cli_s *pc = (camera_cli_s *)camera;
5124 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5126 if (!pc || !pc->cb_info || !iso) {
5127 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5128 return CAMERA_ERROR_INVALID_PARAMETER;
5131 CAM_LOG_INFO("Enter");
5133 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5135 if (ret == CAMERA_ERROR_NONE)
5136 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5138 CAM_LOG_INFO("ret : 0x%x", ret);
5144 int camera_attr_get_brightness(camera_h camera, int *level)
5146 int ret = CAMERA_ERROR_NONE;
5147 camera_cli_s *pc = (camera_cli_s *)camera;
5148 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5150 if (!pc || !pc->cb_info || !level) {
5151 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5152 return CAMERA_ERROR_INVALID_PARAMETER;
5155 CAM_LOG_INFO("Enter");
5157 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5159 if (ret == CAMERA_ERROR_NONE)
5160 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5162 CAM_LOG_INFO("ret : 0x%x", ret);
5168 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5170 int ret = CAMERA_ERROR_NONE;
5171 camera_cli_s *pc = (camera_cli_s *)camera;
5172 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5174 if (!pc || !pc->cb_info || !min || !max) {
5175 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5176 return CAMERA_ERROR_INVALID_PARAMETER;
5179 CAM_LOG_INFO("Enter");
5181 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5183 if (ret == CAMERA_ERROR_NONE) {
5184 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5185 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5188 CAM_LOG_INFO("ret : 0x%x", ret);
5194 int camera_attr_get_contrast(camera_h camera, int *level)
5196 int ret = CAMERA_ERROR_NONE;
5197 camera_cli_s *pc = (camera_cli_s *)camera;
5198 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5200 if (!pc || !pc->cb_info || !level) {
5201 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5202 return CAMERA_ERROR_INVALID_PARAMETER;
5205 CAM_LOG_INFO("Enter");
5207 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5209 if (ret == CAMERA_ERROR_NONE)
5210 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5212 CAM_LOG_INFO("ret : 0x%x", ret);
5218 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5220 int ret = CAMERA_ERROR_NONE;
5221 camera_cli_s *pc = (camera_cli_s *)camera;
5222 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5224 if (!pc || !pc->cb_info || !min || !max) {
5225 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5226 return CAMERA_ERROR_INVALID_PARAMETER;
5229 CAM_LOG_INFO("Enter");
5231 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5233 if (ret == CAMERA_ERROR_NONE) {
5234 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5235 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5236 CAM_LOG_INFO("min %d, max %d", *min, *max);
5239 CAM_LOG_INFO("ret : 0x%x", ret);
5245 int camera_attr_get_hue(camera_h camera, int *level)
5247 int ret = CAMERA_ERROR_NONE;
5248 camera_cli_s *pc = (camera_cli_s *)camera;
5249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5251 if (!pc || !pc->cb_info || !level) {
5252 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5253 return CAMERA_ERROR_INVALID_PARAMETER;
5256 CAM_LOG_INFO("Enter");
5258 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5260 if (ret == CAMERA_ERROR_NONE)
5261 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5263 CAM_LOG_INFO("ret : 0x%x", ret);
5269 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5271 int ret = CAMERA_ERROR_NONE;
5272 camera_cli_s *pc = (camera_cli_s *)camera;
5273 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5275 if (!pc || !pc->cb_info || !min || !max) {
5276 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5277 return CAMERA_ERROR_INVALID_PARAMETER;
5280 CAM_LOG_INFO("Enter");
5282 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5284 if (ret == CAMERA_ERROR_NONE) {
5285 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5286 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5287 CAM_LOG_INFO("min %d, max %d", *min, *max);
5290 CAM_LOG_INFO("ret : 0x%x", ret);
5296 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5298 int ret = CAMERA_ERROR_NONE;
5299 camera_cli_s *pc = (camera_cli_s *)camera;
5300 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5302 if (!pc || !pc->cb_info || !wb) {
5303 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5304 return CAMERA_ERROR_INVALID_PARAMETER;
5307 CAM_LOG_INFO("Enter");
5309 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5311 if (ret == CAMERA_ERROR_NONE)
5312 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5314 CAM_LOG_INFO("ret : 0x%x", ret);
5320 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5322 int ret = CAMERA_ERROR_NONE;
5323 camera_cli_s *pc = (camera_cli_s *)camera;
5324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5326 if (!pc || !pc->cb_info || !effect) {
5327 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5328 return CAMERA_ERROR_INVALID_PARAMETER;
5331 CAM_LOG_INFO("Enter");
5333 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5335 if (ret == CAMERA_ERROR_NONE)
5336 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5338 CAM_LOG_INFO("ret : 0x%x", ret);
5344 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5346 int ret = CAMERA_ERROR_NONE;
5347 camera_cli_s *pc = (camera_cli_s *)camera;
5348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5350 if (!pc || !pc->cb_info || !mode) {
5351 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5352 return CAMERA_ERROR_INVALID_PARAMETER;
5355 CAM_LOG_INFO("Enter");
5357 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5359 if (ret == CAMERA_ERROR_NONE)
5360 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5362 CAM_LOG_INFO("ret : 0x%x", ret);
5368 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5370 int ret = CAMERA_ERROR_NONE;
5371 camera_cli_s *pc = (camera_cli_s *)camera;
5372 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5374 if (!pc || !pc->cb_info || !enable) {
5375 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5376 return CAMERA_ERROR_INVALID_PARAMETER;
5379 CAM_LOG_INFO("Enter");
5381 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5383 if (ret == CAMERA_ERROR_NONE)
5384 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5386 CAM_LOG_INFO("ret : 0x%x", ret);
5392 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5394 int ret = CAMERA_ERROR_NONE;
5395 camera_cli_s *pc = (camera_cli_s *)camera;
5396 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5398 if (!pc || !pc->cb_info || !description) {
5399 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5400 return CAMERA_ERROR_INVALID_PARAMETER;
5403 CAM_LOG_INFO("Enter");
5405 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5407 if (ret == CAMERA_ERROR_NONE)
5408 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5410 CAM_LOG_INFO("ret : 0x%x", ret);
5416 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5418 int ret = CAMERA_ERROR_NONE;
5419 camera_cli_s *pc = (camera_cli_s *)camera;
5420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5422 if (!pc || !pc->cb_info || !orientation) {
5423 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5424 return CAMERA_ERROR_INVALID_PARAMETER;
5427 CAM_LOG_INFO("Enter");
5429 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5431 if (ret == CAMERA_ERROR_NONE)
5432 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5434 CAM_LOG_INFO("ret : 0x%x", ret);
5440 int camera_attr_get_tag_software(camera_h camera, char **software)
5442 int ret = CAMERA_ERROR_NONE;
5443 camera_cli_s *pc = (camera_cli_s *)camera;
5444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5446 if (!pc || !pc->cb_info || !software) {
5447 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5448 return CAMERA_ERROR_INVALID_PARAMETER;
5451 CAM_LOG_INFO("Enter");
5453 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5455 if (ret == CAMERA_ERROR_NONE)
5456 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5458 CAM_LOG_INFO("ret : 0x%x", ret);
5464 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5466 int ret = CAMERA_ERROR_NONE;
5467 camera_cli_s *pc = (camera_cli_s *)camera;
5468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5470 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5471 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5475 CAM_LOG_INFO("Enter");
5477 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5479 if (ret == CAMERA_ERROR_NONE) {
5480 *latitude = pc->cb_info->get_geotag[0];
5481 *longitude = pc->cb_info->get_geotag[1];
5482 *altitude = pc->cb_info->get_geotag[2];
5485 CAM_LOG_INFO("ret : 0x%x", ret);
5491 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5493 int ret = CAMERA_ERROR_NONE;
5494 camera_cli_s *pc = (camera_cli_s *)camera;
5495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5497 if (!pc || !pc->cb_info || !mode) {
5498 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5499 return CAMERA_ERROR_INVALID_PARAMETER;
5502 CAM_LOG_INFO("Enter");
5504 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5506 if (ret == CAMERA_ERROR_NONE)
5507 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5509 CAM_LOG_INFO("ret : 0x%x", ret);
5515 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5517 int ret = CAMERA_ERROR_NONE;
5518 int get_flash_state = 0;
5521 CAM_LOG_ERROR("NULL pointer");
5522 return CAMERA_ERROR_INVALID_PARAMETER;
5525 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5526 (int)device, "get_flash_state", &get_flash_state);
5528 if (ret == CAMERA_ERROR_NONE) {
5529 *state = (camera_flash_state_e)get_flash_state;
5530 CAM_LOG_INFO("flash state %d", *state);
5532 CAM_LOG_ERROR("failed 0x%x", ret);
5539 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5541 int ret = CAMERA_ERROR_NONE;
5542 camera_cli_s *pc = (camera_cli_s *)camera;
5543 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5545 if (!pc || !pc->cb_info || !foreach_cb) {
5546 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5547 return CAMERA_ERROR_INVALID_PARAMETER;
5550 CAM_LOG_INFO("Enter");
5552 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5553 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5555 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5557 CAM_LOG_INFO("ret : 0x%x", ret);
5563 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5565 int ret = CAMERA_ERROR_NONE;
5566 camera_cli_s *pc = (camera_cli_s *)camera;
5567 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5569 if (!pc || !pc->cb_info || !foreach_cb) {
5570 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5571 return CAMERA_ERROR_INVALID_PARAMETER;
5574 CAM_LOG_INFO("Enter");
5576 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5577 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5579 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5581 CAM_LOG_INFO("ret : 0x%x", ret);
5587 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5589 int ret = CAMERA_ERROR_NONE;
5590 camera_cli_s *pc = (camera_cli_s *)camera;
5591 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5593 if (!pc || !pc->cb_info || !foreach_cb) {
5594 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5595 return CAMERA_ERROR_INVALID_PARAMETER;
5598 CAM_LOG_INFO("Enter");
5600 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5601 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5603 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5605 CAM_LOG_INFO("ret : 0x%x", ret);
5611 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5613 int ret = CAMERA_ERROR_NONE;
5614 camera_cli_s *pc = (camera_cli_s *)camera;
5615 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5617 if (!pc || !pc->cb_info || !foreach_cb) {
5618 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5619 return CAMERA_ERROR_INVALID_PARAMETER;
5622 CAM_LOG_INFO("Enter");
5624 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5625 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5627 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5629 CAM_LOG_INFO("ret : 0x%x", ret);
5635 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5637 int ret = CAMERA_ERROR_NONE;
5638 camera_cli_s *pc = (camera_cli_s *)camera;
5639 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5641 if (!pc || !pc->cb_info || !foreach_cb) {
5642 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5643 return CAMERA_ERROR_INVALID_PARAMETER;
5646 CAM_LOG_INFO("Enter");
5648 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5649 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5651 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5653 CAM_LOG_INFO("ret : 0x%x", ret);
5659 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5661 int ret = CAMERA_ERROR_NONE;
5662 camera_cli_s *pc = (camera_cli_s *)camera;
5663 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5665 if (!pc || !pc->cb_info || !foreach_cb) {
5666 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5667 return CAMERA_ERROR_INVALID_PARAMETER;
5670 CAM_LOG_INFO("Enter");
5672 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5673 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5675 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5677 CAM_LOG_INFO("ret : 0x%x", ret);
5683 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5685 int ret = CAMERA_ERROR_NONE;
5686 camera_cli_s *pc = (camera_cli_s *)camera;
5687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5689 if (!pc || !pc->cb_info || !foreach_cb) {
5690 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5691 return CAMERA_ERROR_INVALID_PARAMETER;
5694 CAM_LOG_INFO("Enter");
5696 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5697 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5699 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5701 CAM_LOG_INFO("ret : 0x%x", ret);
5707 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5709 int ret = CAMERA_ERROR_NONE;
5710 camera_cli_s *pc = (camera_cli_s *)camera;
5711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5713 if (!pc || !pc->cb_info || !foreach_cb) {
5714 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5715 return CAMERA_ERROR_INVALID_PARAMETER;
5718 CAM_LOG_INFO("Enter");
5720 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5721 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5723 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5725 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5731 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)
5733 int ret = CAMERA_ERROR_NONE;
5734 camera_cli_s *pc = (camera_cli_s *)camera;
5735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5736 camera_msg_param param;
5739 if (!pc || !pc->cb_info || !foreach_cb) {
5740 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5741 return CAMERA_ERROR_INVALID_PARAMETER;
5744 CAM_LOG_INFO("Enter");
5746 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5747 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5749 value = (width << 16) | height;
5750 CAMERA_MSG_PARAM_SET(param, INT, value);
5752 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5754 CAM_LOG_INFO("ret : 0x%x", ret);
5760 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5762 int ret = CAMERA_ERROR_NONE;
5763 camera_cli_s *pc = (camera_cli_s *)camera;
5764 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5766 if (!pc || !pc->cb_info || !foreach_cb) {
5767 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5768 return CAMERA_ERROR_INVALID_PARAMETER;
5771 CAM_LOG_INFO("Enter");
5773 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5774 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5776 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5778 CAM_LOG_INFO("ret : 0x%x", ret);
5784 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5786 int ret = CAMERA_ERROR_NONE;
5787 camera_cli_s *pc = (camera_cli_s *)camera;
5788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5790 if (!pc || !pc->cb_info || !foreach_cb) {
5791 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5792 return CAMERA_ERROR_INVALID_PARAMETER;
5795 CAM_LOG_INFO("Enter");
5797 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5798 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5800 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5802 CAM_LOG_INFO("ret : 0x%x", ret);
5808 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5810 int ret = CAMERA_ERROR_NONE;
5811 camera_cli_s *pc = (camera_cli_s *)camera;
5812 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5813 camera_msg_param param;
5814 int set_rotation = (int)rotation;
5816 if (!pc || !pc->cb_info) {
5817 CAM_LOG_ERROR("NULL handle");
5818 return CAMERA_ERROR_INVALID_PARAMETER;
5821 CAM_LOG_INFO("Enter");
5823 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5825 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5827 CAM_LOG_INFO("ret : 0x%x", ret);
5833 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5835 int ret = CAMERA_ERROR_NONE;
5836 camera_cli_s *pc = (camera_cli_s *)camera;
5837 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5839 if (!pc || !pc->cb_info || !rotation) {
5840 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5841 return CAMERA_ERROR_INVALID_PARAMETER;
5844 CAM_LOG_INFO("Enter");
5846 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5848 if (ret == CAMERA_ERROR_NONE)
5849 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5851 CAM_LOG_INFO("ret : 0x%x", ret);
5857 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5859 int ret = CAMERA_ERROR_NONE;
5860 camera_cli_s *pc = (camera_cli_s *)camera;
5861 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5862 camera_msg_param param;
5863 int set_flip = (int)flip;
5865 if (!pc || !pc->cb_info) {
5866 CAM_LOG_ERROR("NULL handle");
5867 return CAMERA_ERROR_INVALID_PARAMETER;
5870 CAM_LOG_INFO("Enter");
5872 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5874 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5876 CAM_LOG_INFO("ret : 0x%x", ret);
5882 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5884 int ret = CAMERA_ERROR_NONE;
5885 camera_cli_s *pc = (camera_cli_s *)camera;
5886 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5888 if (!pc || !pc->cb_info || !flip) {
5889 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5890 return CAMERA_ERROR_INVALID_PARAMETER;
5893 CAM_LOG_INFO("Enter");
5895 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5897 if (ret == CAMERA_ERROR_NONE)
5898 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5900 CAM_LOG_INFO("ret : 0x%x", ret);
5905 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5907 int ret = CAMERA_ERROR_NONE;
5908 camera_cli_s *pc = (camera_cli_s *)camera;
5909 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5910 camera_msg_param param;
5911 int set_mode = (int)mode;
5913 if (!pc || !pc->cb_info) {
5914 CAM_LOG_ERROR("NULL handle");
5915 return CAMERA_ERROR_INVALID_PARAMETER;
5918 CAM_LOG_INFO("Enter");
5920 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5922 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5924 CAM_LOG_INFO("ret : 0x%x", ret);
5930 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5932 int ret = CAMERA_ERROR_NONE;
5933 camera_cli_s *pc = (camera_cli_s *)camera;
5934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5936 if (!pc || !pc->cb_info || !mode) {
5937 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5941 CAM_LOG_INFO("Enter");
5943 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5945 if (ret == CAMERA_ERROR_NONE)
5946 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5948 CAM_LOG_INFO("ret : 0x%x", ret);
5954 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5956 int ret = CAMERA_ERROR_NONE;
5957 camera_cli_s *pc = (camera_cli_s *)camera;
5958 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5960 if (!pc || !pc->cb_info) {
5961 CAM_LOG_ERROR("NULL handle");
5962 return CAMERA_ERROR_INVALID_PARAMETER;
5965 CAM_LOG_INFO("Enter");
5967 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5970 CAM_LOG_ERROR("error is occurred 0x%x", ret);
5974 CAM_LOG_INFO("ret : %d", ret);
5980 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5982 int ret = CAMERA_ERROR_NONE;
5983 camera_cli_s *pc = (camera_cli_s *)camera;
5984 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5986 if (!pc || !pc->cb_info) {
5987 CAM_LOG_ERROR("NULL handle");
5988 return CAMERA_ERROR_INVALID_PARAMETER;
5991 CAM_LOG_INFO("Enter");
5993 if (!camera_attr_is_supported_hdr_capture(camera)) {
5994 CAM_LOG_ERROR("HDR not supported");
5995 return CAMERA_ERROR_NOT_SUPPORTED;
5999 CAM_LOG_ERROR("NULL callback");
6000 return CAMERA_ERROR_INVALID_PARAMETER;
6003 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6005 if (ret == CAMERA_ERROR_NONE) {
6006 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6008 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6009 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6011 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6014 CAM_LOG_INFO("ret : 0x%x", ret);
6020 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6022 int ret = CAMERA_ERROR_NONE;
6023 camera_cli_s *pc = (camera_cli_s *)camera;
6024 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6026 if (!pc || !pc->cb_info) {
6027 CAM_LOG_ERROR("NULL handle");
6028 return CAMERA_ERROR_INVALID_PARAMETER;
6031 CAM_LOG_INFO("Enter");
6033 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6035 if (ret == CAMERA_ERROR_NONE) {
6036 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6041 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6044 CAM_LOG_INFO("ret : 0x%x", ret);
6050 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6052 int ret = CAMERA_ERROR_NONE;
6053 camera_cli_s *pc = (camera_cli_s *)camera;
6054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6055 camera_msg_param param;
6056 int set_enable = (int)enable;
6058 if (!pc || !pc->cb_info) {
6059 CAM_LOG_ERROR("NULL handle");
6060 return CAMERA_ERROR_INVALID_PARAMETER;
6063 CAM_LOG_INFO("Enter");
6065 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6067 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6069 CAM_LOG_INFO("ret : 0x%x", ret);
6075 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6077 int ret = CAMERA_ERROR_NONE;
6078 camera_cli_s *pc = (camera_cli_s *)camera;
6079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6081 if (!pc || !pc->cb_info || !enabled) {
6082 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6083 return CAMERA_ERROR_INVALID_PARAMETER;
6086 CAM_LOG_INFO("Enter");
6088 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6090 if (ret == CAMERA_ERROR_NONE)
6091 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6093 CAM_LOG_INFO("ret : 0x%x", ret);
6099 bool camera_attr_is_supported_anti_shake(camera_h camera)
6101 int ret = CAMERA_ERROR_NONE;
6102 camera_cli_s *pc = (camera_cli_s *)camera;
6103 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6105 if (!pc || !pc->cb_info) {
6106 CAM_LOG_ERROR("NULL handle");
6107 return CAMERA_ERROR_INVALID_PARAMETER;
6110 CAM_LOG_INFO("Enter");
6112 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6119 CAM_LOG_INFO("ret : %d", ret);
6125 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6127 int ret = CAMERA_ERROR_NONE;
6128 camera_cli_s *pc = (camera_cli_s *)camera;
6129 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6130 camera_msg_param param;
6131 int set_enable = (int)enable;
6133 if (!pc || !pc->cb_info) {
6134 CAM_LOG_ERROR("NULL handle");
6135 return CAMERA_ERROR_INVALID_PARAMETER;
6138 CAM_LOG_INFO("Enter");
6140 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6142 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6144 CAM_LOG_INFO("ret : 0x%x", ret);
6150 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6152 int ret = CAMERA_ERROR_NONE;
6153 camera_cli_s *pc = (camera_cli_s *)camera;
6154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6156 if (!pc || !pc->cb_info || !enabled) {
6157 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6158 return CAMERA_ERROR_INVALID_PARAMETER;
6161 CAM_LOG_INFO("Enter");
6163 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6165 if (ret == CAMERA_ERROR_NONE)
6166 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6168 CAM_LOG_INFO("ret : 0x%x", ret);
6174 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6176 int ret = CAMERA_ERROR_NONE;
6177 camera_cli_s *pc = (camera_cli_s *)camera;
6178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6180 if (!pc || !pc->cb_info) {
6181 CAM_LOG_ERROR("NULL handle");
6182 return CAMERA_ERROR_INVALID_PARAMETER;
6185 CAM_LOG_INFO("Enter");
6187 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6190 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6194 CAM_LOG_INFO("ret : %d", ret);
6200 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6202 int ret = CAMERA_ERROR_NONE;
6203 camera_cli_s *pc = (camera_cli_s *)camera;
6204 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6205 camera_msg_param param;
6206 int set_enable = (int)enable;
6208 if (!pc || !pc->cb_info) {
6209 CAM_LOG_ERROR("NULL handle");
6210 return CAMERA_ERROR_INVALID_PARAMETER;
6213 CAM_LOG_INFO("Enter");
6215 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6217 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6219 CAM_LOG_INFO("ret : 0x%x", ret);
6225 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6227 int ret = CAMERA_ERROR_NONE;
6228 camera_cli_s *pc = (camera_cli_s *)camera;
6229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6231 if (!pc || !pc->cb_info || !enabled) {
6232 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6233 return CAMERA_ERROR_INVALID_PARAMETER;
6236 CAM_LOG_INFO("Enter");
6238 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6240 if (ret == CAMERA_ERROR_NONE)
6241 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6243 CAM_LOG_INFO("ret : 0x%x", ret);
6249 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6251 int ret = CAMERA_ERROR_NONE;
6252 camera_cli_s *pc = (camera_cli_s *)camera;
6253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6255 if (!pc || !pc->cb_info) {
6256 CAM_LOG_ERROR("NULL handle");
6257 return CAMERA_ERROR_INVALID_PARAMETER;
6260 CAM_LOG_INFO("Enter");
6262 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6265 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6269 CAM_LOG_INFO("ret : %d", ret);
6275 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6277 int ret = CAMERA_ERROR_NONE;
6278 camera_cli_s *pc = (camera_cli_s *)camera;
6279 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6280 camera_msg_param param;
6281 int set_disable = (int)disable;
6283 if (!pc || !pc->cb_info) {
6284 CAM_LOG_ERROR("NULL handle");
6285 return CAMERA_ERROR_INVALID_PARAMETER;
6288 CAM_LOG_INFO("Enter");
6290 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6292 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6294 CAM_LOG_INFO("ret : 0x%x", ret);
6300 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6302 int ret = CAMERA_ERROR_NONE;
6303 camera_cli_s *pc = (camera_cli_s *)camera;
6304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6305 camera_msg_param param0;
6306 camera_msg_param param1;
6308 if (!pc || !pc->cb_info) {
6309 CAM_LOG_ERROR("NULL handle");
6310 return CAMERA_ERROR_INVALID_PARAMETER;
6313 CAM_LOG_INFO("Enter");
6315 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6316 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6318 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6319 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6321 CAM_LOG_INFO("ret : 0x%x", ret);
6327 int camera_attr_get_pan(camera_h camera, int *pan_step)
6329 int ret = CAMERA_ERROR_NONE;
6330 camera_cli_s *pc = (camera_cli_s *)camera;
6331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6333 if (!pc || !pc->cb_info || !pan_step) {
6334 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6335 return CAMERA_ERROR_INVALID_PARAMETER;
6338 CAM_LOG_INFO("Enter");
6340 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6342 if (ret == CAMERA_ERROR_NONE)
6343 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6345 CAM_LOG_INFO("ret : 0x%x", ret);
6351 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6353 int ret = CAMERA_ERROR_NONE;
6354 camera_cli_s *pc = (camera_cli_s *)camera;
6355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6357 if (!pc || !pc->cb_info || !min || !max) {
6358 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6359 return CAMERA_ERROR_INVALID_PARAMETER;
6362 CAM_LOG_INFO("Enter");
6364 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6366 if (ret == CAMERA_ERROR_NONE) {
6367 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6368 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6371 CAM_LOG_INFO("ret : 0x%x", ret);
6377 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6379 int ret = CAMERA_ERROR_NONE;
6380 camera_cli_s *pc = (camera_cli_s *)camera;
6381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6382 camera_msg_param param0;
6383 camera_msg_param param1;
6385 if (!pc || !pc->cb_info) {
6386 CAM_LOG_ERROR("NULL handle");
6387 return CAMERA_ERROR_INVALID_PARAMETER;
6390 CAM_LOG_INFO("Enter");
6392 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6393 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6395 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6396 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6398 CAM_LOG_INFO("ret : 0x%x", ret);
6404 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6406 int ret = CAMERA_ERROR_NONE;
6407 camera_cli_s *pc = (camera_cli_s *)camera;
6408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6410 if (!pc || !pc->cb_info || !tilt_step) {
6411 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6412 return CAMERA_ERROR_INVALID_PARAMETER;
6415 CAM_LOG_INFO("Enter");
6417 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6419 if (ret == CAMERA_ERROR_NONE)
6420 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6422 CAM_LOG_INFO("ret : 0x%x", ret);
6428 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6430 int ret = CAMERA_ERROR_NONE;
6431 camera_cli_s *pc = (camera_cli_s *)camera;
6432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6434 if (!pc || !pc->cb_info || !min || !max) {
6435 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6436 return CAMERA_ERROR_INVALID_PARAMETER;
6439 CAM_LOG_INFO("Enter");
6441 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6443 if (ret == CAMERA_ERROR_NONE) {
6444 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6445 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6448 CAM_LOG_INFO("ret : 0x%x", ret);
6454 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6456 int ret = CAMERA_ERROR_NONE;
6457 camera_cli_s *pc = (camera_cli_s *)camera;
6458 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6459 camera_msg_param param;
6460 int set_ptz_type = (int)ptz_type;
6462 if (!pc || !pc->cb_info) {
6463 CAM_LOG_ERROR("NULL handle");
6464 return CAMERA_ERROR_INVALID_PARAMETER;
6467 CAM_LOG_INFO("Enter");
6469 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6471 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6473 CAM_LOG_INFO("ret : 0x%x", ret);
6479 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6481 int ret = CAMERA_ERROR_NONE;
6482 camera_cli_s *pc = (camera_cli_s *)camera;
6483 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6485 if (!pc || !pc->cb_info || !foreach_cb) {
6486 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6487 return CAMERA_ERROR_INVALID_PARAMETER;
6490 CAM_LOG_INFO("Enter");
6492 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6493 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6495 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6497 CAM_LOG_INFO("ret : 0x%x", ret);
6503 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6505 int ret = CAMERA_ERROR_NONE;
6506 camera_cli_s *pc = (camera_cli_s *)camera;
6507 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6508 int set_display_roi_area[4] = {x, y, width, height};
6513 if (!pc || !pc->cb_info) {
6514 CAM_LOG_ERROR("NULL handle");
6515 return CAMERA_ERROR_INVALID_PARAMETER;
6518 CAM_LOG_INFO("Enter");
6520 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6521 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6522 if (ret != MM_ERROR_NONE) {
6523 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6524 return CAMERA_ERROR_INVALID_OPERATION;
6528 length = sizeof(set_display_roi_area) / sizeof(int) + \
6529 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6531 msg = muse_core_msg_new(api,
6532 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6535 CAM_LOG_ERROR("msg creation failed: api %d", api);
6536 return CAMERA_ERROR_OUT_OF_MEMORY;
6539 if (pc->cb_info->is_server_connected) {
6540 __camera_update_api_waiting(pc->cb_info, api, 1);
6542 g_mutex_lock(&pc->cb_info->fd_lock);
6543 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6544 g_mutex_unlock(&pc->cb_info->fd_lock);
6548 CAM_LOG_ERROR("message send failed");
6549 ret = CAMERA_ERROR_INVALID_OPERATION;
6551 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6554 __camera_update_api_waiting(pc->cb_info, api, -1);
6556 muse_core_msg_free(msg);
6558 CAM_LOG_INFO("ret : 0x%x", ret);
6564 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6566 camera_cli_s *pc = (camera_cli_s *)camera;
6567 int ret = CAMERA_ERROR_NONE;
6568 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6570 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6571 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6572 return CAMERA_ERROR_INVALID_PARAMETER;
6575 CAM_LOG_INFO("Enter");
6577 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6579 if (ret == CAMERA_ERROR_NONE) {
6580 *x = pc->cb_info->get_display_roi_area[0];
6581 *y = pc->cb_info->get_display_roi_area[1];
6582 *width = pc->cb_info->get_display_roi_area[2];
6583 *height = pc->cb_info->get_display_roi_area[3];
6586 CAM_LOG_INFO("ret : 0x%x", ret);
6592 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6594 int ret = CAMERA_ERROR_NONE;
6595 int get_device_state = 0;
6598 CAM_LOG_ERROR("NULL pointer");
6599 return CAMERA_ERROR_INVALID_PARAMETER;
6602 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6603 (int)device, "get_device_state", &get_device_state);
6605 if (ret == CAMERA_ERROR_NONE) {
6606 *state = (camera_device_state_e)get_device_state;
6607 CAM_LOG_INFO("device state %d", *state);
6609 CAM_LOG_ERROR("failed 0x%x", ret);
6616 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6618 int ret = CAMERA_ERROR_NONE;
6619 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6620 camera_cb_info *info = NULL;
6622 if (!callback || !cb_id) {
6623 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6624 return CAMERA_ERROR_INVALID_PARAMETER;
6627 /* check camera support */
6628 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6629 if (ret != CAMERA_ERROR_NONE) {
6630 CAM_LOG_ERROR("get device state failed");
6634 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6636 info = g_new0(camera_cb_info, 1);
6638 CAM_LOG_ERROR("info failed");
6639 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6643 info->id = ++g_cam_dev_state_changed_cb_id;
6644 info->callback = (void *)callback;
6645 info->user_data = user_data;
6649 /* subscribe dbus signal for camera state change */
6650 if (!g_cam_dev_state_changed_cb_conn) {
6651 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6652 if (!g_cam_dev_state_changed_cb_conn) {
6653 CAM_LOG_ERROR("failed to get gdbus connection");
6654 ret = CAMERA_ERROR_INVALID_OPERATION;
6658 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6659 MM_CAMCORDER_DBUS_OBJECT,
6660 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6661 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6663 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6664 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6665 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6666 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6667 CAM_LOG_ERROR("failed to get gdbus connection");
6668 ret = CAMERA_ERROR_INVALID_OPERATION;
6672 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6675 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6677 CAM_LOG_INFO("callback id %d", info->id);
6680 if (ret != CAMERA_ERROR_NONE) {
6686 if (g_cam_dev_state_changed_cb_conn) {
6687 g_object_unref(g_cam_dev_state_changed_cb_conn);
6688 g_cam_dev_state_changed_cb_conn = NULL;
6692 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6698 int camera_remove_device_state_changed_cb(int cb_id)
6700 int ret = CAMERA_ERROR_NONE;
6701 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6702 GList *tmp_list = NULL;
6703 camera_cb_info *info = NULL;
6705 /* check camera support */
6706 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6707 if (ret != CAMERA_ERROR_NONE) {
6708 CAM_LOG_ERROR("get device state failed");
6712 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6714 if (!g_cam_dev_state_changed_cb_list) {
6715 CAM_LOG_ERROR("there is no callback info");
6716 ret = CAMERA_ERROR_INVALID_OPERATION;
6720 tmp_list = g_cam_dev_state_changed_cb_list;
6723 info = tmp_list->data;
6724 tmp_list = tmp_list->next;
6727 CAM_LOG_WARNING("NULL info");
6731 if (info->id == cb_id) {
6732 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6737 if (!g_cam_dev_state_changed_cb_list) {
6738 /* no remained callback */
6739 if (g_cam_dev_state_changed_cb_conn) {
6740 /* unsubscribe signal */
6741 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6742 g_cam_dev_state_changed_cb_subscribe_id = 0;
6744 /* unref connection */
6745 g_object_unref(g_cam_dev_state_changed_cb_conn);
6746 g_cam_dev_state_changed_cb_conn = NULL;
6750 CAM_LOG_INFO("id %d callback removed", cb_id);
6751 ret = CAMERA_ERROR_NONE;
6757 CAM_LOG_ERROR("id %d callback not found", cb_id);
6758 ret = CAMERA_ERROR_INVALID_PARAMETER;
6761 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);