2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <muse_camera_msg.h>
24 #include <camera_private.h>
25 #include <muse_client.h>
32 #define LOG_TAG "TIZEN_N_CAMERA"
33 #define MODULE_NAME "camera"
35 /* for device changed callback */
36 static GMutex g_cam_dev_state_changed_cb_lock;
37 static GList *g_cam_dev_state_changed_cb_list;
38 static int g_cam_dev_state_changed_cb_id;
39 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
40 static guint g_cam_dev_state_changed_cb_subscribe_id;
41 static GMutex g_cam_idle_event_lock;
44 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
46 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
47 static void __camera_release_imported_bo(tbm_bo *bo);
49 static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
50 camera_media_packet_data *mp_data, media_packet_h *packet);
51 static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
52 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
53 static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
55 static gboolean __camera_allocate_preview_buffer(camera_h camera);
56 static void __camera_release_preview_buffer(camera_h camera);
59 static gboolean __camera_allocate_preview_buffer(camera_h camera)
62 int ret = CAMERA_ERROR_NONE;
63 int format = CAMERA_PIXEL_FORMAT_INVALID;
67 camera_cli_s *pc = (camera_cli_s *)camera;
68 camera_cb_info_s *cb_info = NULL;
70 if (!pc || !pc->cb_info) {
71 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
75 cb_info = pc->cb_info;
77 CAM_LOG_INFO("Enter");
79 /* get preview info and calculate size */
80 ret = camera_get_preview_format(camera, &format);
81 if (ret != CAMERA_ERROR_NONE) {
82 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
86 ret = camera_get_preview_resolution(camera, &width, &height);
87 if (ret != CAMERA_ERROR_NONE) {
88 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
92 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
95 case CAMERA_PIXEL_FORMAT_INVZ:
96 buffer_size = width * height;
98 case CAMERA_PIXEL_FORMAT_NV12:
99 case CAMERA_PIXEL_FORMAT_I420:
100 buffer_size = (width * height * 3) >> 1;
102 case CAMERA_PIXEL_FORMAT_YUYV:
103 case CAMERA_PIXEL_FORMAT_UYVY:
104 buffer_size = width * height * 2;
107 CAM_LOG_ERROR("unhandled format %d", format);
108 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
111 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
113 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
114 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
115 if (!cb_info->bos[i]) {
116 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
117 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
120 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
121 if (cb_info->fds[i] < 0) {
122 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
123 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
126 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
129 CAM_LOG_INFO("Done");
133 _ALLOCATE_PREVIEW_BUFFER_FAILED:
134 __camera_release_preview_buffer(camera);
139 static void __camera_release_preview_buffer(camera_h camera)
142 camera_cli_s *pc = (camera_cli_s *)camera;
143 camera_cb_info_s *cb_info = NULL;
145 if (!pc || !pc->cb_info) {
146 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
150 CAM_LOG_INFO("Enter");
152 cb_info = pc->cb_info;
154 /* close exported fd and bos */
155 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
156 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
158 if (cb_info->bos[i]) {
159 tbm_bo_unref(cb_info->bos[i]);
160 cb_info->bos[i] = NULL;
165 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
166 close(cb_info->fds[i]);
167 cb_info->fds[i] = CAMERA_FD_INIT;
171 CAM_LOG_INFO("Done");
175 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
178 api < 0 || api >= MUSE_CAMERA_API_MAX) {
179 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
183 g_mutex_lock(&(cb_info->api_mutex[api]));
184 cb_info->api_waiting[api] += value;
185 g_mutex_unlock(&(cb_info->api_mutex[api]));
187 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
188 api, value, cb_info->api_waiting[api]);
192 static void __camera_device_state_changed_cb(GDBusConnection *connection,
193 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
194 const gchar *signal_name, GVariant *param, gpointer user_data)
197 camera_device_e device = CAMERA_DEVICE_CAMERA0;
198 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
199 GList *tmp_list = NULL;
200 camera_cb_info *info = NULL;
202 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
204 if (!g_cam_dev_state_changed_cb_list || !param) {
205 CAM_LOG_WARNING("no callback or NULL param %p", param);
209 /* get device and state */
210 g_variant_get(param, "(i)", &value);
212 device = value >> 16;
213 state = 0x0000ffff & value;
215 CAM_LOG_INFO("device %d, state %d", device, state);
217 tmp_list = g_cam_dev_state_changed_cb_list;
220 info = (camera_cb_info *)tmp_list->data;
223 if (info->callback) {
224 CAM_LOG_INFO("start id[%d] callback", info->id);
225 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
226 CAM_LOG_INFO("returned id[%d] callback", info->id);
228 CAM_LOG_WARNING("NULL callback for id %d", info->id);
232 tmp_list = tmp_list->next;
236 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
240 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
244 int ret_fd = CAMERA_FD_INIT;
245 int preview_fd = CAMERA_FD_INIT;
246 int num_buffer_fd = 0;
247 unsigned char *buf_pos = NULL;
250 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
251 tbm_bo_handle bo_handle = {.ptr = NULL};
252 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
253 tbm_bo data_bo = NULL;
254 tbm_bo_handle data_bo_handle = {.ptr = NULL};
256 camera_msg_param param;
257 camera_preview_data_s frame;
258 camera_stream_data_s *stream = NULL;
259 camera_media_packet_data *mp_data = NULL;
260 media_packet_h pkt = NULL;
262 /* tfd[0]: MMCamcorderVideoStreamDataType
263 tfd[1]: data_bo or zero copy bo[0]
264 tfd[2]: zero copy bo[1]
265 tfd[3]: zero copy bo[2] */
267 if (!cb_info || !recv_msg || !tfd) {
268 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
272 muse_camera_msg_get(preview_fd, recv_msg);
273 muse_camera_msg_get(num_buffer_fd, recv_msg);
275 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
277 memset(&frame, 0x0, sizeof(camera_preview_data_s));
280 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
285 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
287 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
288 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
289 goto _PREVIEW_CB_HANDLER_DONE;
292 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
293 /* import tbm data_bo and get virtual address */
294 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
295 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
296 goto _PREVIEW_CB_HANDLER_DONE;
300 /* import tbm bo and get virtual address */
301 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
302 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
303 goto _PREVIEW_CB_HANDLER_DONE;
306 buf_pos = (unsigned char *)bo_handle.ptr;
308 /* get stream info */
309 stream = (camera_stream_data_s *)buf_pos;
311 for (i = 0 ; i < num_buffer_fd ; i++) {
312 /* import buffer bo and get virtual address */
313 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
314 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
315 goto _PREVIEW_CB_HANDLER_DONE;
319 /* preview callback */
320 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
321 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
323 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
324 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
327 /* make media packet with below cases.
328 * 1. media_packet_preview_cb is set
329 * 2. EVAS display rendering
331 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
332 CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
333 ret = __camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
334 if (ret != CAMERA_ERROR_NONE) {
335 CAM_LOG_ERROR("__camera_media_packet_data_create failed[0x%x]", ret);
336 goto _PREVIEW_CB_HANDLER_DONE;
339 ret = __camera_media_packet_create(cb_info, stream, mp_data, &pkt);
340 if (ret != CAMERA_ERROR_NONE) {
341 CAM_LOG_ERROR("__camera_media_packet_create failed[0x%x]", ret);
342 __camera_media_packet_data_release(mp_data, cb_info);
344 goto _PREVIEW_CB_HANDLER_DONE;
348 /* 1. media packet preview callback */
349 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
350 media_packet_ref(pkt);
351 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
352 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
355 /* 2. call evas renderer */
356 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
357 if (cb_info->run_evas_render) {
358 media_packet_ref(pkt);
359 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
360 if (ret != MM_ERROR_NONE) {
361 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
362 media_packet_unref(pkt);
365 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
369 _PREVIEW_CB_HANDLER_DONE:
370 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
371 and preview callback(normal or media packet) is set. */
372 if (num_buffer_fd > 0 &&
373 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
374 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
375 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
378 media_packet_unref(pkt);
383 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
385 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
387 /* release imported bo and fd */
388 __camera_release_imported_bo(&data_bo);
389 __camera_release_imported_bo(&bo);
391 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
392 __camera_release_imported_bo(&buffer_bo[i]);
394 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
395 if (CAMERA_IS_FD_VALID(tfd[i])) {
397 tfd[i] = CAMERA_FD_INIT;
405 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
409 int capture_fd_main = 0;
410 int capture_fd_post = 0;
411 int capture_fd_thumb = 0;
412 unsigned char *buf_pos = NULL;
414 camera_image_data_s *rImage = NULL;
415 camera_image_data_s *rPostview = NULL;
416 camera_image_data_s *rThumbnail = NULL;
418 tbm_bo bo_main = NULL;
419 tbm_bo bo_post = NULL;
420 tbm_bo bo_thumb = NULL;
421 tbm_bo_handle bo_main_handle = {.ptr = NULL};
422 tbm_bo_handle bo_post_handle = {.ptr = NULL};
423 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
425 if (!cb_info || !recv_msg || !tfd) {
426 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
430 muse_camera_msg_get(capture_fd_main, recv_msg);
431 muse_camera_msg_get(capture_fd_post, recv_msg);
432 muse_camera_msg_get(capture_fd_thumb, recv_msg);
434 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
435 capture_fd_main, capture_fd_post, capture_fd_thumb,
436 tfd[0], tfd[1], tfd[2]);
438 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
439 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
440 goto _CAPTURE_CB_HANDLER_DONE;
443 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
444 CAM_LOG_WARNING("NULL callback");
445 goto _CAPTURE_CB_HANDLER_DONE;
448 /* import tbm bo and get virtual address */
449 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
450 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
451 goto _CAPTURE_CB_HANDLER_DONE;
454 buf_pos = (unsigned char *)bo_main_handle.ptr;
455 rImage = (camera_image_data_s *)buf_pos;
456 rImage->data = buf_pos + sizeof(camera_image_data_s);
457 if (rImage->exif && rImage->exif_size > 0) {
458 rImage->exif = rImage->data + rImage->size;
461 rImage->exif_size = 0;
464 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
465 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
467 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
468 /* import tbm bo and get virtual address */
470 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
471 buf_pos = (unsigned char *)bo_post_handle.ptr;
472 rPostview = (camera_image_data_s *)buf_pos;
473 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
474 rPostview->data = buf_pos + sizeof(camera_image_data_s);
476 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
480 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
481 /* import tbm bo and get virtual address */
483 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
484 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
485 rThumbnail = (camera_image_data_s *)buf_pos;
486 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
487 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
489 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
493 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
494 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
496 _CAPTURE_CB_HANDLER_DONE:
498 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
499 __camera_release_imported_bo(&bo_main);
500 _camera_msg_return_buffer(capture_fd_main, cb_info);
503 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
504 __camera_release_imported_bo(&bo_post);
505 _camera_msg_return_buffer(capture_fd_post, cb_info);
508 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
509 __camera_release_imported_bo(&bo_thumb);
510 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
513 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
514 if (CAMERA_IS_FD_VALID(tfd[i])) {
515 CAM_LOG_INFO("close tfd[%d] %d", i, tfd[i]);
517 tfd[i] = CAMERA_FD_INIT;
523 CAM_LOG_INFO("return buffer done");
527 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
530 int face_fd = CAMERA_FD_INIT;
531 camera_detected_face_s *faces = NULL;
534 tbm_bo_handle bo_handle = {.ptr = NULL};
536 if (!cb_info || !recv_msg || !tfd) {
537 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
541 muse_camera_msg_get(count, recv_msg);
542 muse_camera_msg_get(face_fd, recv_msg);
544 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
545 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
547 if (CAMERA_IS_FD_VALID(tfd[0])) {
548 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
550 faces = bo_handle.ptr;
554 tfd[0] = CAMERA_FD_INIT;
557 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
558 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
561 __camera_release_imported_bo(&bo);
563 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
564 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
568 _camera_msg_return_buffer(face_fd, cb_info);
572 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
574 tbm_bo tmp_bo = NULL;
575 tbm_bo_handle tmp_bo_handle = {NULL, };
577 if (!bufmgr || !bo || !bo_handle || fd < 0) {
578 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
579 bufmgr, bo, bo_handle, fd);
583 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
584 if (tmp_bo == NULL) {
585 CAM_LOG_ERROR("import failed - fd %d", fd);
589 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
590 if (tmp_bo_handle.ptr == NULL) {
591 CAM_LOG_ERROR("map failed %p", tmp_bo);
592 tbm_bo_unref(tmp_bo);
597 tbm_bo_unmap(tmp_bo);
599 /* set bo and bo_handle */
601 *bo_handle = tmp_bo_handle;
603 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
608 static void __camera_release_imported_bo(tbm_bo *bo)
611 CAM_LOG_DEBUG("NULL bo");
619 static int __camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
621 int ret = CAMERA_ERROR_NONE;
624 if (!cb_info->is_server_connected) {
625 CAM_LOG_ERROR("server is disconnected");
626 return CAMERA_ERROR_SERVICE_DISCONNECTED;
629 g_mutex_lock(&(cb_info->api_mutex[api]));
631 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
633 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
635 while (!cb_info->api_activating[api]) {
636 if (time_out == CAMERA_CB_NO_TIMEOUT) {
637 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
638 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
639 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
640 CAM_LOG_ERROR("api %d TIMED OUT!", api);
641 ret = CAMERA_ERROR_INVALID_OPERATION;
645 if (!cb_info->api_activating[api])
646 CAM_LOG_WARNING("invalid signal received, wait again...");
649 ret = cb_info->api_ret[api];
650 cb_info->api_activating[api] = FALSE;
653 g_mutex_unlock(&(cb_info->api_mutex[api]));
655 if (ret != CAMERA_ERROR_NONE)
656 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
662 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
663 int *ret, int timeout)
669 CAM_LOG_ERROR("NULL info - api %d", api);
672 *ret = CAMERA_ERROR_INVALID_PARAMETER;
677 msg = muse_core_msg_new(api, NULL);
679 CAM_LOG_ERROR("msg failed: api %d", api);
682 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
687 CAM_LOG_DEBUG("send msg[%s]", msg);
689 if (cb_info->is_server_connected) {
690 __camera_update_api_waiting(cb_info, api, 1);
692 g_mutex_lock(&cb_info->fd_lock);
693 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
694 g_mutex_unlock(&cb_info->fd_lock);
698 CAM_LOG_ERROR("msg send failed");
700 *ret = CAMERA_ERROR_INVALID_OPERATION;
703 *ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
706 __camera_update_api_waiting(cb_info, api, -1);
708 muse_core_msg_free(msg);
712 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
713 int *ret, camera_msg_param *param, int timeout)
719 if (!cb_info || !param) {
720 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
723 *ret = CAMERA_ERROR_INVALID_PARAMETER;
728 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
730 switch (param->type) {
732 msg = muse_core_msg_new(api,
733 param->type, param->name, param->value.value_INT,
736 case MUSE_TYPE_STRING:
737 msg = muse_core_msg_new(api,
738 param->type, param->name, param->value.value_STRING,
741 case MUSE_TYPE_ARRAY:
742 array_length = param->value_size / sizeof(int) + \
743 (param->value_size % sizeof(int) ? 1 : 0);
745 msg = muse_core_msg_new(api,
746 param->type, param->name, array_length, param->value.value_ARRAY,
750 CAM_LOG_ERROR("unknown type %d", param->type);
755 CAM_LOG_ERROR("msg failed: api %d", api);
758 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
763 CAM_LOG_DEBUG("send msg[%s]", msg);
765 if (cb_info->is_server_connected) {
766 __camera_update_api_waiting(cb_info, api, 1);
768 g_mutex_lock(&cb_info->fd_lock);
769 send_ret = muse_core_msg_send(cb_info->fd, msg);
770 g_mutex_unlock(&cb_info->fd_lock);
774 CAM_LOG_ERROR("msg send failed");
777 *ret = CAMERA_ERROR_INVALID_OPERATION;
780 *ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
783 __camera_update_api_waiting(cb_info, api, -1);
785 muse_core_msg_free(msg);
789 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
790 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
792 int func_ret = CAMERA_ERROR_NONE;
796 if (!cb_info || !param0 || !param1) {
797 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
798 cb_info, param0, param1, api);
799 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
800 goto _SEND_PARAM2_INT_DONE;
803 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
805 param0->name, param0->value.value_INT,
806 param1->name, param1->value.value_INT);
808 msg = muse_core_msg_new(api,
809 param0->type, param0->name, param0->value.value_INT,
810 param1->type, param1->name, param1->value.value_INT,
813 CAM_LOG_ERROR("msg failed: api %d", api);
814 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
815 goto _SEND_PARAM2_INT_DONE;
818 CAM_LOG_DEBUG("send msg[%s]", msg);
820 if (cb_info->is_server_connected) {
821 __camera_update_api_waiting(cb_info, api, 1);
823 g_mutex_lock(&cb_info->fd_lock);
824 send_ret = muse_core_msg_send(cb_info->fd, msg);
825 g_mutex_unlock(&cb_info->fd_lock);
829 CAM_LOG_ERROR("msg send failed");
831 func_ret = CAMERA_ERROR_INVALID_OPERATION;
833 func_ret = __camera_client_wait_for_cb_return(api, cb_info, timeout);
836 __camera_update_api_waiting(cb_info, api, -1);
838 muse_core_msg_free(msg);
840 _SEND_PARAM2_INT_DONE:
846 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
848 camera_msg_param param;
851 CAM_LOG_WARNING("invalid fd %d", ret_fd);
855 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
857 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
861 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
863 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
864 in_format >= MM_PIXEL_FORMAT_NUM ||
865 out_format == NULL) {
866 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
867 return CAMERA_ERROR_INVALID_PARAMETER;
871 case MM_PIXEL_FORMAT_NV12:
872 case MM_PIXEL_FORMAT_NV12T:
873 *out_format = TBM_FORMAT_NV12;
876 case MM_PIXEL_FORMAT_NV16:
877 *out_format = TBM_FORMAT_NV16;
879 case MM_PIXEL_FORMAT_NV21:
880 *out_format = TBM_FORMAT_NV21;
882 case MM_PIXEL_FORMAT_YUYV:
883 *out_format = TBM_FORMAT_YUYV;
885 case MM_PIXEL_FORMAT_UYVY:
886 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
887 *out_format = TBM_FORMAT_UYVY;
889 case MM_PIXEL_FORMAT_422P:
890 *out_format = TBM_FORMAT_YUV422;
892 case MM_PIXEL_FORMAT_I420:
893 *out_format = TBM_FORMAT_YUV420;
895 case MM_PIXEL_FORMAT_YV12:
896 *out_format = TBM_FORMAT_YVU420;
898 case MM_PIXEL_FORMAT_RGB565:
899 *out_format = TBM_FORMAT_RGB565;
901 case MM_PIXEL_FORMAT_RGB888:
902 *out_format = TBM_FORMAT_RGB888;
904 case MM_PIXEL_FORMAT_RGBA:
905 *out_format = TBM_FORMAT_RGBA8888;
907 case MM_PIXEL_FORMAT_ARGB:
908 *out_format = TBM_FORMAT_ARGB8888;
911 CAM_LOG_ERROR("invalid in_format %d", in_format);
912 return CAMERA_ERROR_INVALID_PARAMETER;
916 return CAMERA_ERROR_NONE;
920 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
922 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
923 in_format >= MM_PIXEL_FORMAT_NUM ||
925 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
926 return CAMERA_ERROR_INVALID_PARAMETER;
930 case MM_PIXEL_FORMAT_NV12:
931 case MM_PIXEL_FORMAT_NV12T:
932 *mimetype = MEDIA_FORMAT_NV12;
935 case MM_PIXEL_FORMAT_NV16:
936 *mimetype = MEDIA_FORMAT_NV16;
938 case MM_PIXEL_FORMAT_NV21:
939 *mimetype = MEDIA_FORMAT_NV21;
941 case MM_PIXEL_FORMAT_YUYV:
942 *mimetype = MEDIA_FORMAT_YUYV;
944 case MM_PIXEL_FORMAT_UYVY:
945 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
946 *mimetype = MEDIA_FORMAT_UYVY;
948 case MM_PIXEL_FORMAT_422P:
949 *mimetype = MEDIA_FORMAT_422P;
951 case MM_PIXEL_FORMAT_I420:
952 *mimetype = MEDIA_FORMAT_I420;
954 case MM_PIXEL_FORMAT_YV12:
955 *mimetype = MEDIA_FORMAT_YV12;
957 case MM_PIXEL_FORMAT_RGB565:
958 *mimetype = MEDIA_FORMAT_RGB565;
960 case MM_PIXEL_FORMAT_RGB888:
961 *mimetype = MEDIA_FORMAT_RGB888;
963 case MM_PIXEL_FORMAT_RGBA:
964 *mimetype = MEDIA_FORMAT_RGBA;
966 case MM_PIXEL_FORMAT_ARGB:
967 *mimetype = MEDIA_FORMAT_ARGB;
970 CAM_LOG_ERROR("invalid in_format %d", in_format);
971 return CAMERA_ERROR_INVALID_PARAMETER;
975 return CAMERA_ERROR_NONE;
979 static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
980 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
983 int ret = CAMERA_ERROR_NONE;
984 camera_media_packet_data *new_mp_data = NULL;
986 if (!tfd || !mp_data) {
987 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
988 return CAMERA_ERROR_INVALID_PARAMETER;
991 new_mp_data = g_new0(camera_media_packet_data, 1);
993 new_mp_data->ret_fd = ret_fd;
994 new_mp_data->fd = tfd[0];
995 new_mp_data->num_buffer_fd = num_buffer_fd;
996 new_mp_data->bo = bo;
998 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1002 new_mp_data->data_bo = data_bo;
1003 new_mp_data->data_fd = tfd[1];
1005 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1006 new_mp_data->data_bo, new_mp_data->data_fd);
1009 for (i = 0 ; i < num_buffer_fd ; i++) {
1010 new_mp_data->buffer_bo[i] = buffer_bo[i];
1011 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1013 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1014 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1017 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1018 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1020 new_mp_data->data_fd = CAMERA_FD_INIT;
1023 *mp_data = new_mp_data;
1025 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1030 static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1034 if (!mp_data || !cb_info) {
1035 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1039 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1041 /* release imported bo and close fd */
1042 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1043 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1044 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1046 tbm_bo_unref(mp_data->buffer_bo[i]);
1048 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1049 close(mp_data->buffer_fd[i]);
1051 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1054 if (mp_data->data_bo) {
1055 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1056 mp_data->data_fd, mp_data->data_bo);
1058 tbm_bo_unref(mp_data->data_bo);
1060 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1061 close(mp_data->data_fd);
1063 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1066 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1068 tbm_bo_unref(mp_data->bo);
1070 if (CAMERA_IS_FD_VALID(mp_data->fd))
1073 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1076 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1081 static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1082 camera_media_packet_data *mp_data, media_packet_h *packet)
1084 media_packet_h pkt = NULL;
1085 bool make_pkt_fmt = false;
1086 tbm_surface_h tsurf = NULL;
1087 tbm_surface_info_s tsurf_info;
1088 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1089 uint32_t bo_format = 0;
1092 int num_buffer_fd = 0;
1093 int pkt_fmt_width = 0;
1094 int pkt_fmt_height = 0;
1095 tbm_bo *buffer_bo = NULL;
1096 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1098 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1099 CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1100 cb_info, stream, mp_data, packet);
1101 return CAMERA_ERROR_INVALID_PARAMETER;
1104 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1106 buffer_bo = mp_data->buffer_bo;
1107 num_buffer_fd = mp_data->num_buffer_fd;
1109 /* create tbm surface */
1110 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1111 tsurf_info.planes[i].stride = stream->stride[i];
1113 /* get tbm surface format */
1114 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1115 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1116 if (ret != CAMERA_ERROR_NONE)
1119 tsurf_info.width = stream->width;
1120 tsurf_info.height = stream->height;
1121 tsurf_info.format = bo_format;
1122 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1123 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1125 if (num_buffer_fd > 0) {
1126 switch (bo_format) {
1127 case TBM_FORMAT_NV12:
1128 case TBM_FORMAT_NV21:
1129 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1130 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1131 tsurf_info.planes[0].offset = 0;
1132 if (num_buffer_fd == 1)
1133 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1134 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1137 case TBM_FORMAT_YUV420:
1138 case TBM_FORMAT_YVU420:
1139 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1140 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1141 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1142 tsurf_info.planes[0].offset = 0;
1143 if (num_buffer_fd == 1) {
1144 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1145 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1147 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1149 case TBM_FORMAT_UYVY:
1150 case TBM_FORMAT_YUYV:
1151 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1152 tsurf_info.planes[0].offset = 0;
1153 tsurf_info.size = tsurf_info.planes[0].size;
1160 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1161 } else if (mp_data->data_bo) {
1163 switch (bo_format) {
1164 case TBM_FORMAT_NV12:
1165 case TBM_FORMAT_NV21:
1166 tsurf_info.planes[0].size = stream->width * stream->height;
1167 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1168 tsurf_info.planes[0].offset = 0;
1169 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1170 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1172 case TBM_FORMAT_YUV420:
1173 case TBM_FORMAT_YVU420:
1174 tsurf_info.planes[0].size = stream->width * stream->height;
1175 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1176 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1177 tsurf_info.planes[0].offset = 0;
1178 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1179 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1180 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1182 case TBM_FORMAT_UYVY:
1183 case TBM_FORMAT_YUYV:
1184 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1185 tsurf_info.planes[0].offset = 0;
1186 tsurf_info.size = tsurf_info.planes[0].size;
1192 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1197 CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1198 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1199 return CAMERA_ERROR_INVALID_OPERATION;
1202 /* check media packet format */
1203 if (cb_info->pkt_fmt) {
1204 media_format_get_video_info(cb_info->pkt_fmt,
1205 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1207 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1208 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1210 if (pkt_fmt_mimetype != mimetype ||
1211 pkt_fmt_width != stream->width ||
1212 pkt_fmt_height != stream->height) {
1213 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1214 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1216 media_format_unref(cb_info->pkt_fmt);
1217 cb_info->pkt_fmt = NULL;
1218 make_pkt_fmt = true;
1221 make_pkt_fmt = true;
1224 /* create packet format */
1226 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1227 mimetype, stream->width, stream->height);
1229 ret = media_format_create(&cb_info->pkt_fmt);
1230 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1231 CAM_LOG_WARNING("media_format_create failed 0x%x", ret);
1232 goto _PACKET_CREATE_FAILED;
1235 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1236 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1237 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1238 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1239 CAM_LOG_WARNING("media format set failed 0x%x", ret);
1240 goto _PACKET_CREATE_FAILED;
1244 /* create media packet */
1245 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1246 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1247 (void *)cb_info, &pkt);
1248 if (ret != MEDIA_PACKET_ERROR_NONE) {
1249 CAM_LOG_ERROR("media_packet_new failed 0x%x", ret);
1250 goto _PACKET_CREATE_FAILED;
1253 /* set media packet data */
1254 ret = media_packet_set_extra(pkt, (void *)mp_data);
1255 if (ret != MEDIA_PACKET_ERROR_NONE) {
1256 CAM_LOG_ERROR("media_packet_set_extra failed");
1257 goto _PACKET_CREATE_FAILED;
1260 /* set timestamp : msec -> nsec */
1261 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1262 CAM_LOG_WARNING("media_packet_set_pts failed");
1264 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1268 return CAMERA_ERROR_NONE;
1270 _PACKET_CREATE_FAILED:
1272 tbm_surface_destroy(tsurf);
1274 media_packet_unref(pkt);
1276 return CAMERA_ERROR_INVALID_OPERATION;
1279 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1282 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1283 camera_media_packet_data *mp_data = NULL;
1284 tbm_surface_h tsurf = NULL;
1286 if (!pkt || !cb_info) {
1287 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1291 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1292 if (ret != MEDIA_PACKET_ERROR_NONE) {
1293 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1297 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1298 if (ret != MEDIA_PACKET_ERROR_NONE)
1299 CAM_LOG_ERROR("get tbm_surface failed 0x%x", ret);
1301 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1302 pkt, mp_data, tsurf);
1304 g_mutex_lock(&cb_info->mp_data_mutex);
1305 __camera_media_packet_data_release(mp_data, cb_info);
1306 g_mutex_unlock(&cb_info->mp_data_mutex);
1309 tbm_surface_destroy(tsurf);
1312 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1317 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1318 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1322 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1324 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1326 if (cb_info->user_cb[event] == NULL) {
1327 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1328 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1329 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1330 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1331 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1332 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1336 /* return buffer message should be sent for some events.
1337 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1338 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1339 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1340 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1345 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1351 muse_camera_msg_get(previous, recv_msg);
1352 muse_camera_msg_get(current, recv_msg);
1353 muse_camera_msg_get(by_policy, recv_msg);
1355 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1356 previous, current, by_policy);
1358 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1359 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1362 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1366 muse_camera_msg_get(state, recv_msg);
1368 CAM_LOG_INFO("FOCUS state - %d", state);
1370 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1373 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1374 CAM_LOG_INFO("CAPTURE_COMPLETED");
1375 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1377 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1378 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1379 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1382 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1386 muse_camera_msg_get(percent, recv_msg);
1388 CAM_LOG_INFO("HDR progress - %d %%", percent);
1390 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1393 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1399 muse_camera_msg_get(policy, recv_msg);
1400 muse_camera_msg_get(previous, recv_msg);
1401 muse_camera_msg_get(current, recv_msg);
1403 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1405 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1406 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1409 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1414 muse_camera_msg_get(policy, recv_msg);
1415 muse_camera_msg_get(state, recv_msg);
1417 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1419 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1420 (camera_state_e)state, cb_info->user_data[event]);
1423 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1424 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1426 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1429 int current_state = 0;
1431 muse_camera_msg_get(error, recv_msg);
1432 muse_camera_msg_get(current_state, recv_msg);
1434 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1436 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1437 (camera_state_e)current_state, cb_info->user_data[event]);
1441 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1443 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1444 muse_camera_msg_get(param1, recv_msg);
1445 muse_camera_msg_get(param2, recv_msg);
1447 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1449 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1450 cb_info->user_cb[event] = NULL;
1451 cb_info->user_data[event] = NULL;
1452 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1455 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1457 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1459 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1461 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1463 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1465 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1467 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1469 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1471 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1473 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1475 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1477 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1479 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1482 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1484 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1485 muse_camera_msg_get(param1, recv_msg);
1487 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1489 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1490 cb_info->user_cb[event] = NULL;
1491 cb_info->user_data[event] = NULL;
1492 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1496 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1497 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1500 CAM_LOG_WARNING("unhandled event %d", event);
1504 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1507 static gboolean __camera_idle_event_callback(gpointer data)
1509 camera_cb_info_s *cb_info = NULL;
1510 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1512 if (cam_idle_event == NULL) {
1513 CAM_LOG_ERROR("cam_idle_event is NULL");
1518 g_mutex_lock(&g_cam_idle_event_lock);
1520 cb_info = cam_idle_event->cb_info;
1521 if (cb_info == NULL) {
1522 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1523 g_mutex_unlock(&g_cam_idle_event_lock);
1524 goto IDLE_EVENT_CALLBACK_DONE;
1527 /* remove event from list */
1528 if (cb_info->idle_event_list)
1529 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1531 g_mutex_unlock(&g_cam_idle_event_lock);
1534 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1536 IDLE_EVENT_CALLBACK_DONE:
1538 g_free(cam_idle_event);
1539 cam_idle_event = NULL;
1544 static gpointer __camera_msg_handler_func(gpointer data)
1548 camera_message_s *cam_msg = NULL;
1549 camera_idle_event_s *cam_idle_event = NULL;
1550 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1551 camera_cb_info_s *cb_info = NULL;
1553 if (!handler_info || !handler_info->cb_info) {
1554 CAM_LOG_ERROR("NULL handler %p", handler_info);
1558 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1559 type = handler_info->type;
1561 CAM_LOG_INFO("t:%d start", type);
1563 g_mutex_lock(&handler_info->mutex);
1565 while (g_atomic_int_get(&handler_info->running)) {
1566 if (g_queue_is_empty(handler_info->queue)) {
1567 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1568 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1569 CAM_LOG_VERBOSE("t[%d] signal received", type);
1571 if (g_atomic_int_get(&handler_info->running) == 0) {
1572 CAM_LOG_INFO("t:%d stop event thread", type);
1577 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1579 g_mutex_unlock(&handler_info->mutex);
1581 if (cam_msg == NULL) {
1582 CAM_LOG_ERROR("t:%d NULL message", type);
1583 g_mutex_lock(&handler_info->mutex);
1589 if (api < MUSE_CAMERA_API_MAX) {
1592 g_mutex_lock(&cb_info->api_mutex[api]);
1594 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1595 if (cb_info->api_waiting[api] > 0) {
1596 cb_info->api_ret[api] = ret;
1597 cb_info->api_activating[api] = TRUE;
1599 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1601 g_cond_signal(&cb_info->api_cond[api]);
1603 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1606 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1609 g_mutex_unlock(&cb_info->api_mutex[api]);
1610 } else if (api == MUSE_CAMERA_CB_EVENT) {
1611 switch (cam_msg->event_class) {
1612 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1613 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1615 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1616 cam_idle_event = g_new0(camera_idle_event_s, 1);
1617 if (cam_idle_event == NULL) {
1618 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1622 cam_idle_event->event = cam_msg->event;
1623 cam_idle_event->cb_info = cb_info;
1625 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1626 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1628 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1629 type, cam_msg->event, cam_idle_event);
1631 g_mutex_lock(&g_cam_idle_event_lock);
1632 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1633 g_mutex_unlock(&g_cam_idle_event_lock);
1635 g_idle_add_full(G_PRIORITY_DEFAULT,
1636 (GSourceFunc)__camera_idle_event_callback,
1637 (gpointer)cam_idle_event,
1641 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1645 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1651 g_mutex_lock(&handler_info->mutex);
1654 /* remove remained event */
1655 while (!g_queue_is_empty(handler_info->queue)) {
1656 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1658 CAM_LOG_INFO("t:%d remove camera message %p", type, cam_msg);
1662 CAM_LOG_WARNING("t:%d NULL camera message", type);
1666 g_mutex_unlock(&handler_info->mutex);
1668 CAM_LOG_INFO("t:%d return", type);
1674 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1676 camera_idle_event_s *cam_idle_event = NULL;
1679 if (cb_info == NULL) {
1680 CAM_LOG_ERROR("cb_info is NULL");
1684 g_mutex_lock(&g_cam_idle_event_lock);
1686 if (cb_info->idle_event_list == NULL) {
1687 CAM_LOG_INFO("No remained idle event");
1688 g_mutex_unlock(&g_cam_idle_event_lock);
1692 list = cb_info->idle_event_list;
1695 cam_idle_event = list->data;
1696 list = g_list_next(list);
1698 if (!cam_idle_event) {
1699 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1703 if (g_idle_remove_by_data(cam_idle_event)) {
1704 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1706 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1708 g_free(cam_idle_event);
1709 cam_idle_event = NULL;
1714 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1715 cam_idle_event, cam_idle_event->event);
1717 cam_idle_event->cb_info = NULL;
1719 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1722 g_list_free(cb_info->idle_event_list);
1723 cb_info->idle_event_list = NULL;
1725 g_mutex_unlock(&g_cam_idle_event_lock);
1729 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1731 camera_message_s *cam_msg = NULL;
1733 if (!cb_info || !msg) {
1734 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1738 cam_msg = g_new0(camera_message_s, 1);
1740 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1745 cam_msg->event = event;
1746 cam_msg->event_class = event_class;
1748 if (tfd && CAMERA_IS_FD_VALID(tfd[0]))
1749 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1751 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1753 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1754 api, event, event_class);
1756 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1757 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1758 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1759 g_cond_signal(&cb_info->preview_cb_info.cond);
1760 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1761 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1762 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1763 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1764 g_cond_signal(&cb_info->capture_cb_info.cond);
1765 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1767 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1768 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1769 g_cond_signal(&cb_info->msg_handler_info.cond);
1770 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1777 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1779 int ret = CAMERA_ERROR_NONE;
1783 int event_class = -1;
1787 if (!cb_info || !msg) {
1788 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1792 CAM_LOG_DEBUG("msg[%s]", msg);
1794 if (!muse_camera_msg_get(api, msg)) {
1795 CAM_LOG_ERROR("failed to get camera api");
1799 if (api == MUSE_CAMERA_CB_EVENT) {
1800 if (!muse_camera_msg_get(event, msg) ||
1801 !muse_camera_msg_get(event_class, msg)) {
1802 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1806 if (!muse_camera_msg_get(api_class, msg)) {
1807 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1812 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1813 if (api >= MUSE_CAMERA_API_MAX) {
1814 CAM_LOG_ERROR("invalid api %d", api);
1818 if (!muse_camera_msg_get(ret, msg)) {
1819 CAM_LOG_ERROR("failed to get camera ret");
1823 g_mutex_lock(&cb_info->api_mutex[api]);
1826 case MUSE_CAMERA_API_CREATE:
1827 if (ret != CAMERA_ERROR_NONE) {
1828 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1829 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1832 case MUSE_CAMERA_API_DESTROY:
1833 if (ret == CAMERA_ERROR_NONE) {
1834 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1835 CAM_LOG_INFO("camera destroy done. close client cb handler");
1839 muse_camera_msg_get(get_type, msg);
1840 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1841 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1842 muse_camera_msg_get(get_index, msg);
1845 case MUSE_CAMERA_GET_TYPE_INT:
1846 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1848 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1849 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1850 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1852 case MUSE_CAMERA_GET_TYPE_ARRAY:
1853 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1854 muse_core_msg_deserialize("get_value",
1855 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1856 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1857 cb_info->get_display_roi_area[0],
1858 cb_info->get_display_roi_area[1],
1859 cb_info->get_display_roi_area[2],
1860 cb_info->get_display_roi_area[3]);
1862 muse_core_msg_deserialize("get_value",
1863 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1864 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
1865 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1868 case MUSE_CAMERA_GET_TYPE_STRING:
1869 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1872 CAM_LOG_WARNING("unknown type %d", get_type);
1879 if (cb_info->api_waiting[api] > 0) {
1880 cb_info->api_ret[api] = ret;
1881 cb_info->api_activating[api] = TRUE;
1883 g_cond_signal(&cb_info->api_cond[api]);
1885 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1888 g_mutex_unlock(&cb_info->api_mutex[api]);
1889 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1890 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
1892 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
1897 static gpointer __camera_msg_recv_func(gpointer data)
1900 int recv_length = 0;
1901 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
1902 char *recv_msg = NULL;
1903 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1906 CAM_LOG_ERROR("cb_info NULL");
1910 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
1912 recv_msg = cb_info->recv_msg;
1914 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1915 for (i = 0 ; i < MUSE_NUM_FD ; i++)
1916 tfd[i] = CAMERA_FD_INIT;
1918 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
1919 if (recv_length <= 0) {
1920 cb_info->is_server_connected = FALSE;
1921 CAM_LOG_ERROR("receive msg failed - server disconnected");
1925 if (CAMERA_IS_FD_VALID(tfd[0]))
1926 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
1928 recv_msg[recv_length] = '\0';
1930 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
1932 __camera_process_msg(cb_info, recv_msg, tfd);
1935 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
1937 if (!cb_info->is_server_connected) {
1938 char *error_msg = NULL;
1940 if (cb_info->bufmgr == NULL) {
1941 CAM_LOG_ERROR("No need to send error(handle is not created)");
1945 if (cb_info->fd < 0) {
1946 CAM_LOG_ERROR("fd is closed in client side");
1950 /* send error msg for server disconnection */
1951 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1952 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1953 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1957 CAM_LOG_ERROR("error_msg failed");
1961 __camera_add_msg_to_queue(cb_info,
1962 MUSE_CAMERA_CB_EVENT,
1963 MUSE_CAMERA_EVENT_TYPE_ERROR,
1964 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1968 muse_core_msg_free(error_msg);
1971 CAM_LOG_ERROR("add error msg for service disconnection done");
1978 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1979 int type, const char *thread_name, camera_cb_info_s *cb_info)
1981 if (!handler_info || !thread_name || !cb_info) {
1982 CAM_LOG_ERROR("t:%d NULL %p %p %p",
1983 type, handler_info, thread_name, cb_info);
1987 CAM_LOG_INFO("t:%d", type);
1989 handler_info->type = type;
1990 handler_info->queue = g_queue_new();
1991 if (handler_info->queue == NULL) {
1992 CAM_LOG_ERROR("t:%d queue failed", type);
1996 g_mutex_init(&handler_info->mutex);
1997 g_cond_init(&handler_info->cond);
1999 handler_info->cb_info = (void *)cb_info;
2000 g_atomic_int_set(&handler_info->running, 1);
2002 handler_info->thread = g_thread_try_new(thread_name,
2003 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2004 if (handler_info->thread == NULL) {
2005 CAM_LOG_ERROR("t:%d thread failed", type);
2007 g_mutex_clear(&handler_info->mutex);
2008 g_cond_clear(&handler_info->cond);
2009 g_queue_free(handler_info->queue);
2010 handler_info->queue = NULL;
2015 CAM_LOG_INFO("t:%d done", type);
2021 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2025 if (!handler_info) {
2026 CAM_LOG_ERROR("NULL handler");
2030 if (!handler_info->thread) {
2031 CAM_LOG_WARNING("thread is not created");
2035 type = handler_info->type;
2037 CAM_LOG_INFO("t:%d thread %p", type, handler_info->thread);
2039 g_mutex_lock(&handler_info->mutex);
2040 g_atomic_int_set(&handler_info->running, 0);
2041 g_cond_signal(&handler_info->cond);
2042 g_mutex_unlock(&handler_info->mutex);
2044 g_thread_join(handler_info->thread);
2045 handler_info->thread = NULL;
2047 g_mutex_clear(&handler_info->mutex);
2048 g_cond_clear(&handler_info->cond);
2049 g_queue_free(handler_info->queue);
2050 handler_info->queue = NULL;
2052 CAM_LOG_INFO("t:%d done", type);
2056 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2058 camera_cb_info_s *cb_info = NULL;
2061 g_return_val_if_fail(sockfd > 0, NULL);
2063 cb_info = g_new0(camera_cb_info_s, 1);
2064 if (cb_info == NULL) {
2065 CAM_LOG_ERROR("cb_info failed");
2069 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2071 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2072 g_mutex_init(&cb_info->api_mutex[i]);
2073 g_cond_init(&cb_info->api_cond[i]);
2076 g_mutex_init(&cb_info->fd_lock);
2077 g_mutex_init(&cb_info->mp_data_mutex);
2079 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2080 g_mutex_init(&cb_info->user_cb_mutex[i]);
2082 /* message handler thread */
2083 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2084 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2085 CAM_LOG_ERROR("msg_handler_info failed");
2089 /* message handler thread for preview callback */
2090 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2091 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2092 CAM_LOG_ERROR("preview_cb_info failed");
2096 /* message handler thread for capture callback */
2097 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2098 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2099 CAM_LOG_ERROR("capture_cb_info failed");
2103 cb_info->fd = sockfd;
2104 cb_info->preview_cb_flag = 0;
2106 /* message receive thread */
2107 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2108 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2109 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2110 if (cb_info->msg_recv_thread == NULL) {
2111 CAM_LOG_ERROR("message receive thread creation failed");
2116 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2117 cb_info->fds[i] = CAMERA_FD_INIT;
2119 cb_info->is_server_connected = TRUE;
2125 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2126 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2127 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2129 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2130 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2132 g_mutex_clear(&cb_info->fd_lock);
2133 g_mutex_clear(&cb_info->mp_data_mutex);
2135 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2136 g_mutex_clear(&cb_info->api_mutex[i]);
2137 g_cond_clear(&cb_info->api_cond[i]);
2148 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2152 g_return_if_fail(cb_info != NULL);
2154 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2156 g_thread_join(cb_info->msg_recv_thread);
2157 cb_info->msg_recv_thread = NULL;
2159 CAM_LOG_INFO("msg_recv thread removed");
2161 /* destroy msg handler threads */
2162 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2163 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2164 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2166 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2167 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2169 g_mutex_clear(&cb_info->fd_lock);
2170 g_mutex_clear(&cb_info->mp_data_mutex);
2172 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2173 g_mutex_clear(&cb_info->api_mutex[i]);
2174 g_cond_clear(&cb_info->api_cond[i]);
2177 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2178 muse_client_close(cb_info->fd);
2179 cb_info->fd = CAMERA_FD_INIT;
2182 if (cb_info->bufmgr) {
2183 tbm_bufmgr_deinit(cb_info->bufmgr);
2184 cb_info->bufmgr = NULL;
2186 if (cb_info->pkt_fmt) {
2187 media_format_unref(cb_info->pkt_fmt);
2188 cb_info->pkt_fmt = NULL;
2191 if (cb_info->dp_interface) {
2192 mm_display_interface_deinit(cb_info->dp_interface);
2193 cb_info->dp_interface = NULL;
2196 cb_info->preview_cb_flag = 0;
2202 int _camera_start_evas_rendering(camera_h camera)
2204 camera_cli_s *pc = (camera_cli_s *)camera;
2206 if (!pc || !pc->cb_info) {
2207 CAM_LOG_ERROR("NULL handle");
2208 return CAMERA_ERROR_INVALID_PARAMETER;
2211 CAM_LOG_INFO("start");
2213 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2214 CAM_LOG_ERROR("EVAS surface is not set");
2215 return CAMERA_ERROR_NONE;
2218 /* set evas render flag as RUN */
2219 pc->cb_info->run_evas_render = true;
2221 return CAMERA_ERROR_NONE;
2225 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2227 int ret = CAMERA_ERROR_NONE;
2228 camera_cli_s *pc = (camera_cli_s *)camera;
2230 if (!pc || !pc->cb_info) {
2231 CAM_LOG_ERROR("NULL handle");
2232 return CAMERA_ERROR_INVALID_PARAMETER;
2235 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2237 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2238 CAM_LOG_ERROR("EVAS surface is not set");
2239 return CAMERA_ERROR_NONE;
2242 /* set evas render flag as STOP and release buffers */
2243 pc->cb_info->run_evas_render = false;
2245 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2246 if (ret == MM_ERROR_NONE) {
2247 ret = CAMERA_ERROR_NONE;
2249 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2250 ret = CAMERA_ERROR_INVALID_OPERATION;
2257 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2259 int ret = CAMERA_ERROR_NONE;
2260 int sock_fd = CAMERA_FD_INIT;
2261 int module_index = -1;
2263 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2265 /* create muse connection */
2266 if (!key || !value) {
2267 CAM_LOG_ERROR("NULL pointer");
2268 return CAMERA_ERROR_INVALID_PARAMETER;
2271 sock_fd = muse_client_new();
2273 CAM_LOG_ERROR("muse_client_new failed");
2274 return CAMERA_ERROR_INVALID_OPERATION;
2277 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2278 CAM_LOG_ERROR("muse client get module index failed");
2279 ret = CAMERA_ERROR_INVALID_OPERATION;
2283 msg = muse_core_msg_new(api,
2284 MUSE_TYPE_INT, "module", module_index,
2285 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2288 CAM_LOG_ERROR("msg failed");
2289 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2293 ret = muse_core_msg_send(sock_fd, msg);
2295 muse_core_msg_free(msg);
2299 CAM_LOG_ERROR("send msg failed");
2300 ret = CAMERA_ERROR_INVALID_OPERATION;
2304 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2306 CAM_LOG_ERROR("recv msg failed %d", errno);
2307 ret = CAMERA_ERROR_INVALID_OPERATION;
2311 if (!muse_camera_msg_get(ret, recv_msg)) {
2312 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2313 ret = CAMERA_ERROR_INVALID_OPERATION;
2317 if (ret == CAMERA_ERROR_NONE)
2318 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2320 CAM_LOG_INFO("api %d - value %d", api, *value);
2323 if (CAMERA_IS_FD_VALID(sock_fd)) {
2324 muse_client_close(sock_fd);
2325 sock_fd = CAMERA_FD_INIT;
2332 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2334 int sock_fd = CAMERA_FD_INIT;
2335 char *send_msg = NULL;
2337 int ret = CAMERA_ERROR_NONE;
2338 camera_cli_s *pc = NULL;
2339 tbm_bufmgr bufmgr = NULL;
2341 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2342 int module_index = -1;
2343 int device_type = (int)device;
2346 CAM_LOG_ERROR("NULL pointer");
2347 return CAMERA_ERROR_INVALID_PARAMETER;
2350 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2352 sock_fd = muse_client_new();
2354 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2355 ret = CAMERA_ERROR_INVALID_OPERATION;
2359 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2360 CAM_LOG_ERROR("muse client get module index failed");
2361 ret = CAMERA_ERROR_INVALID_OPERATION;
2365 send_msg = muse_core_msg_new(api,
2366 MUSE_TYPE_INT, "module", module_index,
2367 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2368 MUSE_TYPE_INT, "is_network", (int)is_network,
2372 CAM_LOG_ERROR("NULL msg");
2373 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2377 send_ret = muse_core_msg_send(sock_fd, send_msg);
2379 muse_core_msg_free(send_msg);
2383 CAM_LOG_ERROR("send msg failed %d", errno);
2384 ret = CAMERA_ERROR_INVALID_OPERATION;
2388 pc = g_new0(camera_cli_s, 1);
2390 CAM_LOG_ERROR("camera_cli_s alloc failed");
2391 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2395 bufmgr = tbm_bufmgr_init(-1);
2396 if (bufmgr == NULL) {
2397 CAM_LOG_ERROR("get tbm bufmgr failed");
2398 ret = CAMERA_ERROR_INVALID_OPERATION;
2402 pc->cb_info = __camera_client_callback_new(sock_fd);
2403 if (pc->cb_info == NULL) {
2404 CAM_LOG_ERROR("cb_info alloc failed");
2405 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2409 sock_fd = CAMERA_FD_INIT;
2411 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2413 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2415 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2417 if (ret == CAMERA_ERROR_NONE) {
2418 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2419 int user_buffer_supported = 0;
2420 int log_level = CAMERA_LOG_LEVEL_INFO;
2421 intptr_t handle = 0;
2423 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2425 CAM_LOG_ERROR("Receiving Handle Failed!!");
2426 ret = CAMERA_ERROR_INVALID_OPERATION;
2430 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2431 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2432 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2434 pc->remote_handle = handle;
2435 pc->cb_info->bufmgr = bufmgr;
2436 pc->cb_info->preview_format = preview_format;
2437 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2438 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2439 g_camera_log_level = log_level;
2441 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2442 preview_format, user_buffer_supported, g_camera_log_level);
2444 *camera = (camera_h)pc;
2446 /* get display interface handle */
2447 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2448 CAM_LOG_WARNING("display interface init failed");
2457 tbm_bufmgr_deinit(bufmgr);
2461 if (CAMERA_IS_FD_VALID(sock_fd)) {
2462 muse_client_close(sock_fd);
2463 sock_fd = CAMERA_FD_INIT;
2468 int temp_fd = pc->cb_info->fd;
2470 /* pc->cb_info->fd should be closed,
2471 because g_thread_join for msg_recv_thread is not returned
2472 in __camera_client_callback_destroy. */
2473 if (CAMERA_IS_FD_VALID(temp_fd)) {
2474 pc->cb_info->fd = CAMERA_FD_INIT;
2475 muse_client_close(temp_fd);
2478 __camera_client_callback_destroy(pc->cb_info);
2485 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2492 int camera_create(camera_device_e device, camera_h *camera)
2494 return _camera_create_private(device, false, camera);
2498 int camera_change_device(camera_h camera, camera_device_e device)
2501 int ret = CAMERA_ERROR_NONE;
2502 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2503 camera_cli_s *pc = (camera_cli_s *)camera;
2504 camera_msg_param param;
2506 if (!pc || !pc->cb_info) {
2507 CAM_LOG_ERROR("NULL handle");
2508 return CAMERA_ERROR_INVALID_PARAMETER;
2511 CAMERA_MSG_PARAM_SET(param, INT, device);
2513 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2515 if (ret == CAMERA_ERROR_NONE) {
2516 /* reset callback and user data */
2517 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2518 pc->cb_info->user_cb[i] = NULL;
2519 pc->cb_info->user_data[i] = NULL;
2521 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2528 int camera_destroy(camera_h camera)
2530 int ret = CAMERA_ERROR_NONE;
2531 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2532 camera_cli_s *pc = (camera_cli_s *)camera;
2534 if (!pc || !pc->cb_info) {
2535 CAM_LOG_ERROR("NULL handle");
2536 return CAMERA_ERROR_INVALID_PARAMETER;
2539 CAM_LOG_INFO("Enter");
2541 if (pc->cb_info->is_server_connected)
2542 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2544 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2546 if (ret == CAMERA_ERROR_NONE) {
2547 __camera_deactivate_idle_event_all(pc->cb_info);
2548 __camera_client_callback_destroy(pc->cb_info);
2555 CAM_LOG_INFO("ret : 0x%x", ret);
2560 int camera_start_preview(camera_h camera)
2562 int ret = CAMERA_ERROR_NONE;
2563 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2564 camera_cli_s *pc = (camera_cli_s *)camera;
2565 camera_state_e current_state = CAMERA_STATE_NONE;
2567 if (!pc || !pc->cb_info) {
2568 CAM_LOG_ERROR("NULL handle");
2569 return CAMERA_ERROR_INVALID_PARAMETER;
2572 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2573 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2575 ret = camera_get_state(camera, ¤t_state);
2576 if (ret != CAMERA_ERROR_NONE) {
2577 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2581 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2582 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2583 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2584 pc->cb_info->dp_info.type);
2585 return CAMERA_ERROR_INVALID_OPERATION;
2588 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2589 if (!__camera_allocate_preview_buffer(camera))
2590 return CAMERA_ERROR_INVALID_OPERATION;
2592 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2594 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2597 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2598 ret = _camera_start_evas_rendering(camera);
2599 if (ret != CAMERA_ERROR_NONE) {
2600 CAM_LOG_ERROR("stop preview because of error");
2601 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2605 CAM_LOG_INFO("ret : 0x%x", ret);
2611 int camera_stop_preview(camera_h camera)
2613 int ret = CAMERA_ERROR_NONE;
2614 camera_cli_s *pc = (camera_cli_s *)camera;
2615 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2616 camera_state_e current_state = CAMERA_STATE_NONE;
2618 if (!pc || !pc->cb_info) {
2619 CAM_LOG_ERROR("NULL handle");
2620 return CAMERA_ERROR_INVALID_PARAMETER;
2623 CAM_LOG_INFO("Enter");
2626 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2627 ret = camera_get_state(camera, ¤t_state);
2628 if (ret != CAMERA_ERROR_NONE) {
2629 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2633 if (current_state == CAMERA_STATE_PREVIEW) {
2634 ret = _camera_stop_evas_rendering(camera, false);
2635 if (ret != CAMERA_ERROR_NONE)
2640 /* send stop preview message */
2641 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2643 if (ret == CAMERA_ERROR_NONE) {
2644 if (pc->cb_info->user_buffer_supported)
2645 __camera_release_preview_buffer(camera);
2646 } else if (current_state == CAMERA_STATE_PREVIEW) {
2647 CAM_LOG_WARNING("restart evas rendering");
2648 _camera_start_evas_rendering(camera);
2651 CAM_LOG_INFO("ret : 0x%x", ret);
2657 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2659 int ret = CAMERA_ERROR_NONE;
2660 camera_cli_s *pc = (camera_cli_s *)camera;
2661 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2663 if (!pc || !pc->cb_info) {
2664 CAM_LOG_ERROR("NULL handle");
2665 return CAMERA_ERROR_INVALID_PARAMETER;
2668 CAM_LOG_INFO("Enter");
2670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2673 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2674 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2676 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2678 CAM_LOG_INFO("ret : 0x%x", ret);
2684 bool camera_is_supported_continuous_capture(camera_h camera)
2686 int ret = CAMERA_ERROR_NONE;
2687 camera_cli_s *pc = (camera_cli_s *)camera;
2688 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2690 if (!pc || !pc->cb_info) {
2691 CAM_LOG_ERROR("NULL handle");
2692 return CAMERA_ERROR_INVALID_PARAMETER;
2695 CAM_LOG_INFO("Enter");
2697 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2700 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2704 CAM_LOG_INFO("ret : %d", ret);
2710 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)
2712 int ret = CAMERA_ERROR_NONE;
2713 camera_cli_s *pc = (camera_cli_s *)camera;
2714 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2715 camera_msg_param param;
2718 if (!pc || !pc->cb_info) {
2719 CAM_LOG_ERROR("NULL handle");
2720 return CAMERA_ERROR_INVALID_PARAMETER;
2723 CAM_LOG_INFO("Enter");
2725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2728 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2729 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2731 value = (count << 16) | interval;
2732 CAMERA_MSG_PARAM_SET(param, INT, value);
2734 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2736 CAM_LOG_INFO("ret : 0x%x", ret);
2742 int camera_stop_continuous_capture(camera_h camera)
2744 int ret = CAMERA_ERROR_NONE;
2745 camera_cli_s *pc = (camera_cli_s *)camera;
2746 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2748 if (!pc || !pc->cb_info) {
2749 CAM_LOG_ERROR("NULL handle");
2750 return CAMERA_ERROR_INVALID_PARAMETER;
2753 CAM_LOG_INFO("Enter");
2755 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2757 CAM_LOG_INFO("ret : 0x%x", ret);
2763 bool camera_is_supported_face_detection(camera_h camera)
2765 int ret = CAMERA_ERROR_NONE;
2766 camera_cli_s *pc = (camera_cli_s *)camera;
2767 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2769 if (!pc || !pc->cb_info) {
2770 CAM_LOG_ERROR("NULL handle");
2771 return CAMERA_ERROR_INVALID_PARAMETER;
2774 CAM_LOG_INFO("Enter");
2776 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2779 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2783 CAM_LOG_INFO("ret : %d", ret);
2789 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2791 int ret = CAMERA_ERROR_NONE;
2792 camera_cli_s *pc = (camera_cli_s *)camera;
2793 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2795 if (!pc || !pc->cb_info) {
2796 CAM_LOG_ERROR("NULL handle");
2797 return CAMERA_ERROR_INVALID_PARAMETER;
2800 CAM_LOG_INFO("Enter");
2802 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2805 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2809 CAM_LOG_INFO("ret : %d", ret);
2815 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2817 int ret = CAMERA_ERROR_NONE;
2818 camera_cli_s *pc = (camera_cli_s *)camera;
2819 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2821 if (!pc || !pc->cb_info) {
2822 CAM_LOG_ERROR("NULL handle");
2823 return CAMERA_ERROR_INVALID_PARAMETER;
2826 CAM_LOG_INFO("Enter");
2828 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2831 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2835 CAM_LOG_INFO("ret : %d", ret);
2840 int camera_get_device_count(camera_h camera, int *device_count)
2842 int ret = CAMERA_ERROR_NONE;
2843 camera_cli_s *pc = (camera_cli_s *)camera;
2844 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2846 if (!pc || !pc->cb_info) {
2847 CAM_LOG_ERROR("NULL handle");
2848 return CAMERA_ERROR_INVALID_PARAMETER;
2851 CAM_LOG_INFO("Enter");
2853 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2855 if (ret == CAMERA_ERROR_NONE)
2856 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2858 CAM_LOG_INFO("ret : 0x%x", ret);
2863 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2865 int ret = CAMERA_ERROR_NONE;
2866 camera_cli_s *pc = (camera_cli_s *)camera;
2867 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2869 if (!pc || !pc->cb_info) {
2870 CAM_LOG_ERROR("NULL handle");
2871 return CAMERA_ERROR_INVALID_PARAMETER;
2874 CAM_LOG_INFO("Enter");
2876 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2878 if (ret == CAMERA_ERROR_NONE) {
2879 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2884 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2887 CAM_LOG_INFO("ret : 0x%x", ret);
2892 int camera_stop_face_detection(camera_h camera)
2894 int ret = CAMERA_ERROR_NONE;
2895 camera_cli_s *pc = (camera_cli_s *)camera;
2896 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2898 if (!pc || !pc->cb_info) {
2899 CAM_LOG_ERROR("NULL handle");
2900 return CAMERA_ERROR_INVALID_PARAMETER;
2903 CAM_LOG_INFO("Enter");
2905 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2907 if (ret == CAMERA_ERROR_NONE) {
2908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2916 CAM_LOG_INFO("ret : 0x%x", ret);
2921 int camera_get_state(camera_h camera, camera_state_e *state)
2923 int ret = CAMERA_ERROR_NONE;
2924 camera_cli_s *pc = (camera_cli_s *)camera;
2925 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2927 if (!pc || !pc->cb_info || !state) {
2928 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
2929 return CAMERA_ERROR_INVALID_PARAMETER;
2932 CAM_LOG_INFO("Enter");
2934 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2936 if (ret == CAMERA_ERROR_NONE)
2937 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2939 CAM_LOG_INFO("ret : 0x%x", ret);
2944 int camera_start_focusing(camera_h camera, bool continuous)
2946 int ret = CAMERA_ERROR_NONE;
2947 camera_cli_s *pc = (camera_cli_s *)camera;
2948 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2949 camera_msg_param param;
2950 int is_continuous = (int)continuous;
2952 if (!pc || !pc->cb_info) {
2953 CAM_LOG_ERROR("NULL handle");
2954 return CAMERA_ERROR_INVALID_PARAMETER;
2957 CAM_LOG_INFO("Enter");
2959 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2961 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2963 CAM_LOG_INFO("ret : 0x%x", ret);
2968 int camera_cancel_focusing(camera_h camera)
2970 int ret = CAMERA_ERROR_NONE;
2971 camera_cli_s *pc = (camera_cli_s *)camera;
2972 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2974 if (!pc || !pc->cb_info) {
2975 CAM_LOG_ERROR("NULL handle");
2976 return CAMERA_ERROR_INVALID_PARAMETER;
2979 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
2981 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2983 CAM_LOG_INFO("ret : 0x%x", ret);
2989 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
2991 int mm_ret = MM_ERROR_NONE;
2992 int ret = CAMERA_ERROR_NONE;
2993 camera_cli_s *pc = (camera_cli_s *)camera;
2994 camera_cb_info_s *cb_info = NULL;
2995 camera_state_e current_state = CAMERA_STATE_NONE;
2996 camera_msg_param param;
2997 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2998 muse_camera_display_info_s *dp_info = NULL;
3000 if (!pc || !pc->cb_info) {
3001 CAM_LOG_ERROR("NULL handle");
3002 return CAMERA_ERROR_INVALID_PARAMETER;
3005 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3006 CAM_LOG_ERROR("invalid type %d", type);
3007 return CAMERA_ERROR_INVALID_PARAMETER;
3010 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3011 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3012 return CAMERA_ERROR_INVALID_PARAMETER;
3015 cb_info = (camera_cb_info_s *)pc->cb_info;
3016 dp_info = &cb_info->dp_info;
3018 ret = camera_get_state(camera, ¤t_state);
3019 if (ret != CAMERA_ERROR_NONE) {
3020 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3024 if (current_state != CAMERA_STATE_CREATED) {
3025 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3026 return CAMERA_ERROR_INVALID_STATE;
3029 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3031 if (type != MM_DISPLAY_TYPE_NONE) {
3032 /* check display interface handle */
3033 if (!cb_info->dp_interface) {
3034 CAM_LOG_ERROR("display interface not supported");
3035 return CAMERA_ERROR_NOT_SUPPORTED;
3038 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3039 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3040 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3041 return CAMERA_ERROR_NOT_SUPPORTED;
3042 } else if (mm_ret != MM_ERROR_NONE) {
3043 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3044 return CAMERA_ERROR_INVALID_OPERATION;
3047 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3048 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3050 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3051 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3052 dp_info->window_rect.width, dp_info->window_rect.height);
3053 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3055 camera_flip_e flip = CAMERA_FLIP_NONE;
3056 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3057 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3064 camera_get_display_flip(camera, &flip);
3065 camera_get_display_mode(camera, &mode);
3066 camera_get_display_rotation(camera, &rotation);
3067 camera_is_display_visible(camera, &visible);
3069 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3070 flip, mode, rotation, visible);
3072 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3073 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3074 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3075 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3077 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3078 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3079 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3080 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3086 if (mm_ret != MM_ERROR_NONE) {
3087 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3088 return CAMERA_ERROR_INVALID_OPERATION;
3091 dp_info->type = type;
3093 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3095 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3097 if (ret == CAMERA_ERROR_NONE) {
3098 if (type == MM_DISPLAY_TYPE_EVAS)
3099 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3106 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3108 CAM_LOG_INFO("type %d, display %p", type, display);
3109 return _camera_set_display(camera, (mm_display_type_e)type, display);
3113 int camera_set_preview_resolution(camera_h camera, int width, int height)
3115 int ret = CAMERA_ERROR_NONE;
3116 camera_state_e current_state = CAMERA_STATE_NONE;
3117 camera_cli_s *pc = (camera_cli_s *)camera;
3118 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3119 camera_msg_param param;
3122 if (!pc || !pc->cb_info) {
3123 CAM_LOG_ERROR("NULL handle");
3124 return CAMERA_ERROR_INVALID_PARAMETER;
3127 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3128 ret = camera_get_state(camera, ¤t_state);
3129 if (ret != CAMERA_ERROR_NONE) {
3130 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3134 if (current_state == CAMERA_STATE_PREVIEW) {
3135 ret = _camera_stop_evas_rendering(camera, true);
3136 if (ret != CAMERA_ERROR_NONE)
3141 value = (width << 16) | height;
3142 CAMERA_MSG_PARAM_SET(param, INT, value);
3144 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3146 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3148 CAM_LOG_INFO("ret : 0x%x", ret);
3150 if (current_state == CAMERA_STATE_PREVIEW) {
3151 CAM_LOG_WARNING("restart evas rendering");
3152 _camera_start_evas_rendering(camera);
3159 int camera_set_capture_resolution(camera_h camera, int width, int height)
3161 int ret = CAMERA_ERROR_NONE;
3162 camera_cli_s *pc = (camera_cli_s *)camera;
3163 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3164 camera_msg_param param;
3167 if (!pc || !pc->cb_info) {
3168 CAM_LOG_ERROR("NULL handle");
3169 return CAMERA_ERROR_INVALID_PARAMETER;
3172 CAM_LOG_INFO("Enter");
3174 value = (width << 16) | height;
3175 CAMERA_MSG_PARAM_SET(param, INT, value);
3177 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3179 CAM_LOG_INFO("ret : 0x%x", ret);
3185 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3187 int ret = CAMERA_ERROR_NONE;
3188 int set_format = (int)format;
3189 camera_cli_s *pc = (camera_cli_s *)camera;
3190 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3191 camera_msg_param param;
3193 if (!pc || !pc->cb_info) {
3194 CAM_LOG_ERROR("NULL handle");
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3198 CAM_LOG_INFO("Enter - format %d", set_format);
3200 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3202 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3204 CAM_LOG_INFO("ret : 0x%x", ret);
3210 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3212 int ret = CAMERA_ERROR_NONE;
3213 int set_format = (int)format;
3214 camera_msg_param param;
3215 camera_cli_s *pc = (camera_cli_s *)camera;
3216 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3218 if (!pc || !pc->cb_info) {
3219 CAM_LOG_ERROR("NULL handle");
3220 return CAMERA_ERROR_INVALID_PARAMETER;
3223 CAM_LOG_INFO("Enter - format %d", set_format);
3225 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3227 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3229 if (ret == CAMERA_ERROR_NONE)
3230 pc->cb_info->preview_format = set_format;
3232 CAM_LOG_INFO("ret : 0x%x", ret);
3238 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3240 int ret = CAMERA_ERROR_NONE;
3241 camera_cli_s *pc = (camera_cli_s *)camera;
3242 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3244 if (!pc || !pc->cb_info || !width || !height) {
3245 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3246 return CAMERA_ERROR_INVALID_PARAMETER;
3249 CAM_LOG_INFO("Enter");
3251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3253 if (ret == CAMERA_ERROR_NONE) {
3254 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3255 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3258 CAM_LOG_INFO("ret : 0x%x", ret);
3264 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3266 int ret = CAMERA_ERROR_NONE;
3267 int set_rotation = (int)rotation;
3268 camera_cli_s *pc = (camera_cli_s *)camera;
3269 camera_msg_param param;
3271 if (!pc || !pc->cb_info) {
3272 CAM_LOG_ERROR("NULL handle");
3273 return CAMERA_ERROR_INVALID_PARAMETER;
3276 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3277 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3278 if (ret != MM_ERROR_NONE) {
3279 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3280 return CAMERA_ERROR_INVALID_OPERATION;
3284 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3286 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3292 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3294 int ret = CAMERA_ERROR_NONE;
3295 camera_cli_s *pc = (camera_cli_s *)camera;
3297 if (!pc || !pc->cb_info || !rotation) {
3298 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3299 return CAMERA_ERROR_INVALID_PARAMETER;
3302 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3304 if (ret == CAMERA_ERROR_NONE)
3305 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3311 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3313 int ret = CAMERA_ERROR_NONE;
3314 int set_flip = (int)flip;
3315 camera_cli_s *pc = (camera_cli_s *)camera;
3316 camera_msg_param param;
3318 if (!pc || !pc->cb_info) {
3319 CAM_LOG_ERROR("NULL handle");
3320 return CAMERA_ERROR_INVALID_PARAMETER;
3323 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3324 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3325 if (ret != MM_ERROR_NONE) {
3326 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3327 return CAMERA_ERROR_INVALID_OPERATION;
3331 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3333 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3339 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3341 int ret = CAMERA_ERROR_NONE;
3342 camera_cli_s *pc = (camera_cli_s *)camera;
3344 if (!pc || !pc->cb_info || !flip) {
3345 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3346 return CAMERA_ERROR_INVALID_PARAMETER;
3349 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3351 if (ret == CAMERA_ERROR_NONE)
3352 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3358 int camera_set_display_visible(camera_h camera, bool visible)
3360 int ret = CAMERA_ERROR_NONE;
3361 int set_visible = (int)visible;
3362 camera_cli_s *pc = (camera_cli_s *)camera;
3363 camera_msg_param param;
3365 if (!pc || !pc->cb_info) {
3366 CAM_LOG_ERROR("NULL handle");
3367 return CAMERA_ERROR_INVALID_PARAMETER;
3370 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3371 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3372 if (ret != MM_ERROR_NONE) {
3373 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3374 return CAMERA_ERROR_INVALID_OPERATION;
3378 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3380 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3386 int camera_is_display_visible(camera_h camera, bool *visible)
3388 int ret = CAMERA_ERROR_NONE;
3389 camera_cli_s *pc = (camera_cli_s *)camera;
3391 if (!pc || !pc->cb_info || !visible) {
3392 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3393 return CAMERA_ERROR_INVALID_PARAMETER;
3396 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3398 if (ret == CAMERA_ERROR_NONE)
3399 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3405 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3407 int ret = CAMERA_ERROR_NONE;
3408 int set_mode = (int)mode;
3409 camera_cli_s *pc = (camera_cli_s *)camera;
3410 camera_msg_param param;
3412 if (!pc || !pc->cb_info) {
3413 CAM_LOG_ERROR("NULL handle");
3414 return CAMERA_ERROR_INVALID_PARAMETER;
3417 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3418 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3419 if (ret != MM_ERROR_NONE) {
3420 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3421 return CAMERA_ERROR_INVALID_OPERATION;
3425 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3427 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3433 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3435 int ret = CAMERA_ERROR_NONE;
3436 camera_cli_s *pc = (camera_cli_s *)camera;
3438 if (!pc || !pc->cb_info || !mode) {
3439 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3443 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3445 if (ret == CAMERA_ERROR_NONE)
3446 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3452 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3454 int ret = CAMERA_ERROR_NONE;
3455 int set_hint = (int)hint;
3456 camera_cli_s *pc = (camera_cli_s *)camera;
3457 camera_msg_param param;
3459 if (!pc || !pc->cb_info) {
3460 CAM_LOG_ERROR("NULL handle");
3461 return CAMERA_ERROR_INVALID_PARAMETER;
3464 CAM_LOG_INFO("Enter - hint %d", set_hint);
3466 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3468 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3474 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3476 int ret = CAMERA_ERROR_NONE;
3477 camera_cli_s *pc = (camera_cli_s *)camera;
3478 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3480 if (!pc || !pc->cb_info || !hint) {
3481 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3482 return CAMERA_ERROR_INVALID_PARAMETER;
3485 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3487 if (ret == CAMERA_ERROR_NONE) {
3488 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3489 CAM_LOG_INFO("display reuse hint %d", *hint);
3496 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3498 int ret = CAMERA_ERROR_NONE;
3499 camera_cli_s *pc = (camera_cli_s *)camera;
3500 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3502 if (!pc || !pc->cb_info || !width || !height) {
3503 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3504 return CAMERA_ERROR_INVALID_PARAMETER;
3507 CAM_LOG_INFO("Enter");
3509 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3511 if (ret == CAMERA_ERROR_NONE) {
3512 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3513 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3516 CAM_LOG_INFO("ret : 0x%x", ret);
3522 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3524 int ret = CAMERA_ERROR_NONE;
3525 camera_cli_s *pc = (camera_cli_s *)camera;
3526 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3528 if (!pc || !pc->cb_info || !format) {
3529 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3530 return CAMERA_ERROR_INVALID_PARAMETER;
3533 CAM_LOG_INFO("Enter");
3535 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3537 if (ret == CAMERA_ERROR_NONE)
3538 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3540 CAM_LOG_INFO("ret : 0x%x", ret);
3546 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3548 int ret = CAMERA_ERROR_NONE;
3549 camera_cli_s *pc = (camera_cli_s *)camera;
3550 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3552 if (!pc || !pc->cb_info || !format) {
3553 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3554 return CAMERA_ERROR_INVALID_PARAMETER;
3557 CAM_LOG_INFO("Enter");
3559 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3561 if (ret == CAMERA_ERROR_NONE)
3562 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3564 CAM_LOG_INFO("ret : 0x%x", ret);
3570 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3572 int ret = CAMERA_ERROR_NONE;
3573 camera_cli_s *pc = (camera_cli_s *)camera;
3574 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3576 if (!pc || !pc->cb_info || !facing_direction) {
3577 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3578 return CAMERA_ERROR_INVALID_PARAMETER;
3581 CAM_LOG_INFO("Enter");
3583 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3585 if (ret == CAMERA_ERROR_NONE)
3586 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3588 CAM_LOG_INFO("ret : 0x%x", ret);
3594 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3596 int ret = CAMERA_ERROR_NONE;
3597 camera_cli_s *pc = (camera_cli_s *)camera;
3598 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3600 if (!pc || !pc->cb_info || !callback) {
3601 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3602 return CAMERA_ERROR_INVALID_PARAMETER;
3605 CAM_LOG_INFO("Enter");
3607 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3609 if (ret == CAMERA_ERROR_NONE) {
3610 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3612 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3613 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3615 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3617 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3620 CAM_LOG_INFO("ret : 0x%x", ret);
3626 int camera_unset_preview_cb(camera_h camera)
3628 int ret = CAMERA_ERROR_NONE;
3629 camera_cli_s *pc = (camera_cli_s *)camera;
3630 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3632 if (!pc || !pc->cb_info) {
3633 CAM_LOG_ERROR("NULL handle");
3634 return CAMERA_ERROR_INVALID_PARAMETER;
3637 CAM_LOG_INFO("Enter");
3639 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3641 if (ret == CAMERA_ERROR_NONE) {
3642 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3644 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3645 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3647 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3649 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3652 CAM_LOG_INFO("ret : 0x%x", ret);
3658 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3660 int ret = CAMERA_ERROR_NONE;
3661 camera_cli_s *pc = (camera_cli_s *)camera;
3662 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3664 if (!pc || !pc->cb_info) {
3665 CAM_LOG_ERROR("NULL handle");
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3669 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3670 CAM_LOG_ERROR("NOT SUPPORTED");
3671 return CAMERA_ERROR_NOT_SUPPORTED;
3674 if (callback == NULL) {
3675 CAM_LOG_ERROR("NULL callback");
3676 return CAMERA_ERROR_INVALID_PARAMETER;
3679 CAM_LOG_INFO("Enter");
3681 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3683 if (ret == CAMERA_ERROR_NONE) {
3684 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3686 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3687 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3689 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3692 CAM_LOG_INFO("ret : 0x%x", ret);
3698 int camera_unset_media_packet_preview_cb(camera_h camera)
3700 int ret = CAMERA_ERROR_NONE;
3701 camera_cli_s *pc = (camera_cli_s *)camera;
3702 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3704 if (!pc || !pc->cb_info) {
3705 CAM_LOG_ERROR("NULL handle");
3706 return CAMERA_ERROR_INVALID_PARAMETER;
3709 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3710 CAM_LOG_ERROR("NOT SUPPORTED");
3711 return CAMERA_ERROR_NOT_SUPPORTED;
3714 CAM_LOG_INFO("Enter");
3716 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3718 if (ret == CAMERA_ERROR_NONE) {
3719 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3721 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3722 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3724 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3727 CAM_LOG_INFO("ret : 0x%x", ret);
3733 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3735 int ret = CAMERA_ERROR_NONE;
3736 camera_cli_s *pc = (camera_cli_s *)camera;
3737 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3739 if (!pc || !pc->cb_info || !callback) {
3740 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3741 return CAMERA_ERROR_INVALID_PARAMETER;
3744 CAM_LOG_INFO("Enter");
3746 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3748 if (ret == CAMERA_ERROR_NONE) {
3749 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3751 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3752 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3754 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3757 CAM_LOG_INFO("ret : 0x%x", ret);
3763 int camera_unset_state_changed_cb(camera_h camera)
3765 int ret = CAMERA_ERROR_NONE;
3766 camera_cli_s *pc = (camera_cli_s *)camera;
3767 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3769 if (!pc || !pc->cb_info) {
3770 CAM_LOG_ERROR("NULL handle");
3771 return CAMERA_ERROR_INVALID_PARAMETER;
3774 CAM_LOG_INFO("Enter");
3776 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3778 if (ret == CAMERA_ERROR_NONE) {
3779 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3781 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3782 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3784 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3787 CAM_LOG_INFO("ret : 0x%x", ret);
3793 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3795 int ret = CAMERA_ERROR_NONE;
3796 camera_cli_s *pc = (camera_cli_s *)camera;
3797 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3799 if (!pc || !pc->cb_info || !callback) {
3800 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3801 return CAMERA_ERROR_INVALID_PARAMETER;
3804 CAM_LOG_INFO("Enter");
3806 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3808 if (ret == CAMERA_ERROR_NONE) {
3809 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3811 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3812 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3814 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3817 CAM_LOG_INFO("ret : 0x%x", ret);
3823 int camera_unset_interrupted_cb(camera_h camera)
3825 int ret = CAMERA_ERROR_NONE;
3826 camera_cli_s *pc = (camera_cli_s *)camera;
3827 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3829 if (!pc || !pc->cb_info) {
3830 CAM_LOG_ERROR("NULL handle");
3831 return CAMERA_ERROR_INVALID_PARAMETER;
3834 CAM_LOG_INFO("Enter");
3836 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3838 if (ret == CAMERA_ERROR_NONE) {
3839 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3841 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3842 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3844 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3847 CAM_LOG_INFO("ret : 0x%x", ret);
3853 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3855 int ret = CAMERA_ERROR_NONE;
3856 camera_cli_s *pc = (camera_cli_s *)camera;
3857 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3859 if (!pc || !pc->cb_info || !callback) {
3860 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3861 return CAMERA_ERROR_INVALID_PARAMETER;
3864 CAM_LOG_INFO("Enter");
3866 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3868 if (ret == CAMERA_ERROR_NONE) {
3869 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3871 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3872 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3874 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3877 CAM_LOG_INFO("ret : 0x%x", ret);
3883 int camera_unset_interrupt_started_cb(camera_h camera)
3885 int ret = CAMERA_ERROR_NONE;
3886 camera_cli_s *pc = (camera_cli_s *)camera;
3887 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3889 if (!pc || !pc->cb_info) {
3890 CAM_LOG_ERROR("NULL handle");
3891 return CAMERA_ERROR_INVALID_PARAMETER;
3894 CAM_LOG_INFO("Enter");
3896 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3898 if (ret == CAMERA_ERROR_NONE) {
3899 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3901 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3902 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3904 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3907 CAM_LOG_INFO("ret : 0x%x", ret);
3913 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3915 int ret = CAMERA_ERROR_NONE;
3916 camera_cli_s *pc = (camera_cli_s *)camera;
3917 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3919 if (!pc || !pc->cb_info || !callback) {
3920 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3921 return CAMERA_ERROR_INVALID_PARAMETER;
3924 CAM_LOG_INFO("Enter");
3926 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3928 if (ret == CAMERA_ERROR_NONE) {
3929 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3931 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3932 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3934 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3937 CAM_LOG_INFO("ret : 0x%x", ret);
3943 int camera_unset_focus_changed_cb(camera_h camera)
3945 int ret = CAMERA_ERROR_NONE;
3946 camera_cli_s *pc = (camera_cli_s *)camera;
3947 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3949 if (!pc || !pc->cb_info) {
3950 CAM_LOG_ERROR("NULL handle");
3951 return CAMERA_ERROR_INVALID_PARAMETER;
3954 CAM_LOG_INFO("Enter");
3956 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3958 if (ret == CAMERA_ERROR_NONE) {
3959 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3961 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3962 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3964 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3967 CAM_LOG_INFO("ret : 0x%x", ret);
3973 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3975 int ret = CAMERA_ERROR_NONE;
3976 camera_cli_s *pc = (camera_cli_s *)camera;
3977 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3979 if (!pc || !pc->cb_info || !callback) {
3980 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3981 return CAMERA_ERROR_INVALID_PARAMETER;
3984 CAM_LOG_INFO("Enter");
3986 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3988 if (ret == CAMERA_ERROR_NONE) {
3989 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3991 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3992 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3994 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3997 CAM_LOG_INFO("ret : 0x%x", ret);
4003 int camera_unset_error_cb(camera_h camera)
4005 int ret = CAMERA_ERROR_NONE;
4006 camera_cli_s *pc = (camera_cli_s *)camera;
4007 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4009 if (!pc || !pc->cb_info) {
4010 CAM_LOG_ERROR("NULL handle");
4011 return CAMERA_ERROR_INVALID_PARAMETER;
4014 CAM_LOG_INFO("Enter");
4016 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4018 if (ret == CAMERA_ERROR_NONE) {
4019 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4021 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4022 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4024 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4027 CAM_LOG_INFO("ret : 0x%x", ret);
4033 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4035 int ret = CAMERA_ERROR_NONE;
4036 camera_cli_s *pc = (camera_cli_s *)camera;
4037 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4039 if (!pc || !pc->cb_info || !foreach_cb) {
4040 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4041 return CAMERA_ERROR_INVALID_PARAMETER;
4044 CAM_LOG_INFO("Enter");
4046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4049 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4051 CAM_LOG_INFO("ret : 0x%x", ret);
4057 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4059 int ret = CAMERA_ERROR_NONE;
4060 camera_cli_s *pc = (camera_cli_s *)camera;
4061 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4063 if (!pc || !pc->cb_info || !foreach_cb) {
4064 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4065 return CAMERA_ERROR_INVALID_PARAMETER;
4068 CAM_LOG_INFO("Enter");
4070 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4071 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4073 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4075 CAM_LOG_INFO("ret : 0x%x", ret);
4081 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4083 int ret = CAMERA_ERROR_NONE;
4084 camera_cli_s *pc = (camera_cli_s *)camera;
4085 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4087 if (!pc || !pc->cb_info || !foreach_cb) {
4088 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4089 return CAMERA_ERROR_INVALID_PARAMETER;
4092 CAM_LOG_INFO("Enter");
4094 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4095 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4099 CAM_LOG_INFO("ret : 0x%x", ret);
4105 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4107 int ret = CAMERA_ERROR_NONE;
4108 camera_cli_s *pc = (camera_cli_s *)camera;
4109 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4111 if (!pc || !pc->cb_info || !foreach_cb) {
4112 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4113 return CAMERA_ERROR_INVALID_PARAMETER;
4116 CAM_LOG_INFO("Enter");
4118 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4119 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4121 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4123 CAM_LOG_INFO("ret : 0x%x", ret);
4129 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4131 int ret = CAMERA_ERROR_NONE;
4132 camera_cli_s *pc = (camera_cli_s *)camera;
4133 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4135 if (!pc || !pc->cb_info || !width || !height) {
4136 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4137 return CAMERA_ERROR_INVALID_PARAMETER;
4140 CAM_LOG_INFO("Enter");
4141 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4143 if (ret == CAMERA_ERROR_NONE) {
4144 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4145 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4148 CAM_LOG_INFO("ret : 0x%x", ret);
4154 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4156 int ret = CAMERA_ERROR_NONE;
4157 camera_cli_s *pc = (camera_cli_s *)camera;
4158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4160 if (!pc || !pc->cb_info || !angle) {
4161 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4162 return CAMERA_ERROR_INVALID_PARAMETER;
4165 CAM_LOG_INFO("Enter");
4167 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4169 if (ret == CAMERA_ERROR_NONE)
4170 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4172 CAM_LOG_INFO("ret : 0x%x", ret);
4178 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4180 int ret = CAMERA_ERROR_NONE;
4181 camera_cli_s *pc = (camera_cli_s *)camera;
4182 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4183 camera_msg_param param;
4184 int set_mode = (int)mode;
4186 if (!pc || !pc->cb_info) {
4187 CAM_LOG_ERROR("NULL handle");
4188 return CAMERA_ERROR_INVALID_PARAMETER;
4191 CAM_LOG_INFO("Enter");
4193 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4195 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4197 CAM_LOG_INFO("ret : 0x%x", ret);
4203 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4205 int ret = CAMERA_ERROR_NONE;
4206 camera_cli_s *pc = (camera_cli_s *)camera;
4207 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4209 if (!pc || !pc->cb_info || !mode) {
4210 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4211 return CAMERA_ERROR_INVALID_PARAMETER;
4214 CAM_LOG_INFO("Enter");
4216 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4218 if (ret == CAMERA_ERROR_NONE)
4219 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4221 CAM_LOG_INFO("ret : 0x%x", ret);
4227 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4229 int ret = CAMERA_ERROR_NONE;
4230 camera_cli_s *pc = (camera_cli_s *)camera;
4231 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4233 if (!pc || !pc->cb_info || !foreach_cb) {
4234 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4235 return CAMERA_ERROR_INVALID_PARAMETER;
4238 CAM_LOG_INFO("Enter");
4240 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4241 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4243 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4245 CAM_LOG_INFO("Finish, return :%x", ret);
4251 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4253 int ret = CAMERA_ERROR_NONE;
4254 camera_cli_s *pc = (camera_cli_s *)camera;
4255 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4256 camera_msg_param param;
4257 int set_fps = (int)fps;
4259 if (!pc || !pc->cb_info) {
4260 CAM_LOG_ERROR("NULL handle");
4261 return CAMERA_ERROR_INVALID_PARAMETER;
4264 CAM_LOG_INFO("Enter");
4266 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4268 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4270 CAM_LOG_INFO("ret : 0x%x", ret);
4276 int camera_attr_set_image_quality(camera_h camera, int quality)
4278 int ret = CAMERA_ERROR_NONE;
4279 camera_cli_s *pc = (camera_cli_s *)camera;
4280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4281 camera_msg_param param;
4283 if (!pc || !pc->cb_info) {
4284 CAM_LOG_ERROR("NULL handle");
4285 return CAMERA_ERROR_INVALID_PARAMETER;
4288 CAM_LOG_INFO("Enter");
4290 CAMERA_MSG_PARAM_SET(param, INT, quality);
4292 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4294 CAM_LOG_INFO("ret : 0x%x", ret);
4300 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4302 int ret = CAMERA_ERROR_NONE;
4303 camera_cli_s *pc = (camera_cli_s *)camera;
4304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4306 if (!pc || !pc->cb_info || !fps) {
4307 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4308 return CAMERA_ERROR_INVALID_PARAMETER;
4311 CAM_LOG_INFO("Enter");
4313 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4315 if (ret == CAMERA_ERROR_NONE)
4316 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4318 CAM_LOG_INFO("ret : 0x%x", ret);
4324 int camera_attr_get_image_quality(camera_h camera, int *quality)
4326 int ret = CAMERA_ERROR_NONE;
4327 camera_cli_s *pc = (camera_cli_s *)camera;
4328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4330 if (!pc || !pc->cb_info || !quality) {
4331 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4332 return CAMERA_ERROR_INVALID_PARAMETER;
4335 CAM_LOG_INFO("Enter");
4337 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4339 if (ret == CAMERA_ERROR_NONE)
4340 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4342 CAM_LOG_INFO("ret : 0x%x", ret);
4348 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4350 int ret = CAMERA_ERROR_NONE;
4351 camera_cli_s *pc = (camera_cli_s *)camera;
4352 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4354 if (!pc || !pc->cb_info || !bitrate) {
4355 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4356 return CAMERA_ERROR_INVALID_PARAMETER;
4359 CAM_LOG_INFO("Enter");
4361 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4363 if (ret == CAMERA_ERROR_NONE)
4364 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4366 CAM_LOG_INFO("ret : 0x%x", ret);
4372 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4374 int ret = CAMERA_ERROR_NONE;
4375 camera_cli_s *pc = (camera_cli_s *)camera;
4376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4377 camera_msg_param param;
4378 int set_bitrate = bitrate;
4380 if (!pc || !pc->cb_info) {
4381 CAM_LOG_ERROR("NULL handle");
4382 return CAMERA_ERROR_INVALID_PARAMETER;
4385 CAM_LOG_INFO("Enter");
4387 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4389 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4391 CAM_LOG_INFO("ret : 0x%x", ret);
4397 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4399 int ret = CAMERA_ERROR_NONE;
4400 camera_cli_s *pc = (camera_cli_s *)camera;
4401 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4403 if (!pc || !pc->cb_info || !interval) {
4404 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4405 return CAMERA_ERROR_INVALID_PARAMETER;
4408 CAM_LOG_INFO("Enter");
4410 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4412 if (ret == CAMERA_ERROR_NONE)
4413 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4415 CAM_LOG_INFO("ret : 0x%x", ret);
4421 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4423 int ret = CAMERA_ERROR_NONE;
4424 camera_cli_s *pc = (camera_cli_s *)camera;
4425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4426 camera_msg_param param;
4427 int set_gop_interval = interval;
4429 if (!pc || !pc->cb_info) {
4430 CAM_LOG_ERROR("NULL handle");
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 CAM_LOG_INFO("Enter");
4436 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4438 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4440 CAM_LOG_INFO("ret : 0x%x", ret);
4446 int camera_attr_set_zoom(camera_h camera, int zoom)
4448 int ret = CAMERA_ERROR_NONE;
4449 camera_cli_s *pc = (camera_cli_s *)camera;
4450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4451 camera_msg_param param;
4453 if (!pc || !pc->cb_info) {
4454 CAM_LOG_ERROR("NULL handle");
4455 return CAMERA_ERROR_INVALID_PARAMETER;
4458 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4460 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4462 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4464 CAM_LOG_INFO("ret : 0x%x", ret);
4470 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4472 int ret = CAMERA_ERROR_NONE;
4473 camera_cli_s *pc = (camera_cli_s *)camera;
4474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4475 camera_msg_param param;
4476 int set_mode = (int)mode;
4478 if (!pc || !pc->cb_info) {
4479 CAM_LOG_ERROR("NULL handle");
4480 return CAMERA_ERROR_INVALID_PARAMETER;
4483 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4485 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4487 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4493 int camera_attr_set_af_area(camera_h camera, int x, int y)
4495 int ret = CAMERA_ERROR_NONE;
4496 camera_cli_s *pc = (camera_cli_s *)camera;
4497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4498 camera_msg_param param;
4501 if (!pc || !pc->cb_info) {
4502 CAM_LOG_ERROR("NULL handle");
4503 return CAMERA_ERROR_INVALID_PARAMETER;
4506 CAM_LOG_INFO("Enter - %d,%d", x, y);
4508 value = (x << 16) | y;
4509 CAMERA_MSG_PARAM_SET(param, INT, value);
4511 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4513 CAM_LOG_INFO("ret : 0x%x", ret);
4519 int camera_attr_clear_af_area(camera_h camera)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4525 if (!pc || !pc->cb_info) {
4526 CAM_LOG_ERROR("NULL handle");
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4530 CAM_LOG_INFO("Enter");
4532 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4534 CAM_LOG_INFO("ret : 0x%x", ret);
4540 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4542 int ret = CAMERA_ERROR_NONE;
4543 camera_cli_s *pc = (camera_cli_s *)camera;
4544 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4545 camera_msg_param param;
4546 int set_mode = (int)mode;
4548 if (!pc || !pc->cb_info) {
4549 CAM_LOG_ERROR("NULL handle");
4550 return CAMERA_ERROR_INVALID_PARAMETER;
4553 CAM_LOG_INFO("Enter");
4555 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4557 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4559 CAM_LOG_INFO("ret : 0x%x", ret);
4565 int camera_attr_set_exposure(camera_h camera, int value)
4567 int ret = CAMERA_ERROR_NONE;
4568 camera_cli_s *pc = (camera_cli_s *)camera;
4569 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4570 camera_msg_param param;
4572 if (!pc || !pc->cb_info) {
4573 CAM_LOG_ERROR("NULL handle");
4574 return CAMERA_ERROR_INVALID_PARAMETER;
4577 CAM_LOG_INFO("Enter");
4579 CAMERA_MSG_PARAM_SET(param, INT, value);
4581 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4583 CAM_LOG_INFO("ret : 0x%x", ret);
4589 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4591 int ret = CAMERA_ERROR_NONE;
4592 camera_cli_s *pc = (camera_cli_s *)camera;
4593 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4594 camera_msg_param param;
4595 int set_iso = (int)iso;
4597 if (!pc || !pc->cb_info) {
4598 CAM_LOG_ERROR("NULL handle");
4599 return CAMERA_ERROR_INVALID_PARAMETER;
4602 CAM_LOG_INFO("Enter");
4604 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4606 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4608 CAM_LOG_INFO("ret : 0x%x", ret);
4614 int camera_attr_set_brightness(camera_h camera, int level)
4616 int ret = CAMERA_ERROR_NONE;
4617 camera_cli_s *pc = (camera_cli_s *)camera;
4618 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4619 camera_msg_param param;
4621 if (!pc || !pc->cb_info) {
4622 CAM_LOG_ERROR("NULL handle");
4623 return CAMERA_ERROR_INVALID_PARAMETER;
4626 CAM_LOG_INFO("Enter");
4628 CAMERA_MSG_PARAM_SET(param, INT, level);
4630 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4632 CAM_LOG_INFO("ret : 0x%x", ret);
4638 int camera_attr_set_contrast(camera_h camera, int level)
4640 int ret = CAMERA_ERROR_NONE;
4641 camera_cli_s *pc = (camera_cli_s *)camera;
4642 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4643 camera_msg_param param;
4645 if (!pc || !pc->cb_info) {
4646 CAM_LOG_ERROR("NULL handle");
4647 return CAMERA_ERROR_INVALID_PARAMETER;
4650 CAM_LOG_INFO("Enter");
4652 CAMERA_MSG_PARAM_SET(param, INT, level);
4654 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4656 CAM_LOG_INFO("ret : 0x%x", ret);
4662 int camera_attr_set_hue(camera_h camera, int level)
4664 int ret = CAMERA_ERROR_NONE;
4665 camera_cli_s *pc = (camera_cli_s *)camera;
4666 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4667 camera_msg_param param;
4669 if (!pc || !pc->cb_info) {
4670 CAM_LOG_ERROR("NULL handle");
4671 return CAMERA_ERROR_INVALID_PARAMETER;
4674 CAM_LOG_INFO("Enter");
4676 CAMERA_MSG_PARAM_SET(param, INT, level);
4678 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4680 CAM_LOG_INFO("ret : 0x%x", ret);
4686 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4688 int ret = CAMERA_ERROR_NONE;
4689 camera_cli_s *pc = (camera_cli_s *)camera;
4690 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4691 camera_msg_param param;
4692 int set_whitebalance = (int)wb;
4694 if (!pc || !pc->cb_info) {
4695 CAM_LOG_ERROR("NULL handle");
4696 return CAMERA_ERROR_INVALID_PARAMETER;
4699 CAM_LOG_INFO("Enter");
4701 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4703 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4705 CAM_LOG_INFO("ret : 0x%x", ret);
4711 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4713 int ret = CAMERA_ERROR_NONE;
4714 camera_cli_s *pc = (camera_cli_s *)camera;
4715 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4716 camera_msg_param param;
4717 int set_effect = (int)effect;
4719 if (!pc || !pc->cb_info) {
4720 CAM_LOG_ERROR("NULL handle");
4721 return CAMERA_ERROR_INVALID_PARAMETER;
4724 CAM_LOG_INFO("Enter");
4726 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4728 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4730 CAM_LOG_INFO("ret : 0x%x", ret);
4736 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4738 int ret = CAMERA_ERROR_NONE;
4739 camera_cli_s *pc = (camera_cli_s *)camera;
4740 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4741 camera_msg_param param;
4742 int set_mode = (int)mode;
4744 if (!pc || !pc->cb_info) {
4745 CAM_LOG_ERROR("NULL handle");
4746 return CAMERA_ERROR_INVALID_PARAMETER;
4749 CAM_LOG_INFO("Enter");
4751 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4753 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4755 CAM_LOG_INFO("ret : 0x%x", ret);
4761 int camera_attr_enable_tag(camera_h camera, bool enable)
4763 int ret = CAMERA_ERROR_NONE;
4764 camera_cli_s *pc = (camera_cli_s *)camera;
4765 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4766 camera_msg_param param;
4767 int set_enable = (int)enable;
4769 if (!pc || !pc->cb_info) {
4770 CAM_LOG_ERROR("NULL handle");
4771 return CAMERA_ERROR_INVALID_PARAMETER;
4774 CAM_LOG_INFO("Enter");
4776 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4778 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4780 CAM_LOG_INFO("ret : 0x%x", ret);
4786 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4788 int ret = CAMERA_ERROR_NONE;
4789 camera_cli_s *pc = (camera_cli_s *)camera;
4790 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4791 camera_msg_param param;
4793 if (!pc || !pc->cb_info || !description) {
4794 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4795 return CAMERA_ERROR_INVALID_PARAMETER;
4798 CAM_LOG_INFO("Enter");
4800 CAMERA_MSG_PARAM_SET(param, STRING, description);
4802 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4804 CAM_LOG_INFO("ret : 0x%x", ret);
4810 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4812 int ret = CAMERA_ERROR_NONE;
4813 camera_cli_s *pc = (camera_cli_s *)camera;
4814 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4815 camera_msg_param param;
4816 int set_orientation = (int)orientation;
4818 if (!pc || !pc->cb_info) {
4819 CAM_LOG_ERROR("NULL handle");
4820 return CAMERA_ERROR_INVALID_PARAMETER;
4823 CAM_LOG_INFO("Enter");
4825 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4827 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4829 CAM_LOG_INFO("ret : 0x%x", ret);
4835 int camera_attr_set_tag_software(camera_h camera, const char *software)
4837 int ret = CAMERA_ERROR_NONE;
4838 camera_cli_s *pc = (camera_cli_s *)camera;
4839 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4840 camera_msg_param param;
4842 if (!pc || !pc->cb_info || !software) {
4843 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4844 return CAMERA_ERROR_INVALID_PARAMETER;
4847 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4849 CAMERA_MSG_PARAM_SET(param, STRING, software);
4851 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4853 CAM_LOG_INFO("ret : 0x%x", ret);
4859 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4861 int ret = CAMERA_ERROR_NONE;
4862 camera_cli_s *pc = (camera_cli_s *)camera;
4863 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4864 double set_geotag[3] = {latitude, longitude, altitude};
4869 if (!pc || !pc->cb_info) {
4870 CAM_LOG_ERROR("NULL handle");
4871 return CAMERA_ERROR_INVALID_PARAMETER;
4874 CAM_LOG_INFO("Enter");
4876 length = sizeof(set_geotag) / sizeof(int) + \
4877 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4879 msg = muse_core_msg_new(api,
4880 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4883 CAM_LOG_ERROR("msg creation failed: api %d", api);
4884 return CAMERA_ERROR_OUT_OF_MEMORY;
4887 if (pc->cb_info->is_server_connected) {
4888 __camera_update_api_waiting(pc->cb_info, api, 1);
4890 g_mutex_lock(&pc->cb_info->fd_lock);
4891 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4892 g_mutex_unlock(&pc->cb_info->fd_lock);
4896 CAM_LOG_ERROR("message send failed");
4897 ret = CAMERA_ERROR_INVALID_OPERATION;
4899 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4902 __camera_update_api_waiting(pc->cb_info, api, -1);
4904 muse_core_msg_free(msg);
4906 CAM_LOG_INFO("ret : 0x%x", ret);
4912 int camera_attr_remove_geotag(camera_h camera)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4918 if (!pc || !pc->cb_info) {
4919 CAM_LOG_ERROR("NULL handle");
4920 return CAMERA_ERROR_INVALID_PARAMETER;
4923 CAM_LOG_INFO("Enter");
4925 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4927 CAM_LOG_INFO("ret : 0x%x", ret);
4933 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4935 int ret = CAMERA_ERROR_NONE;
4936 camera_cli_s *pc = (camera_cli_s *)camera;
4937 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4938 camera_msg_param param;
4939 int set_mode = (int)mode;
4941 if (!pc || !pc->cb_info) {
4942 CAM_LOG_ERROR("NULL handle");
4943 return CAMERA_ERROR_INVALID_PARAMETER;
4946 CAM_LOG_INFO("Enter");
4948 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4950 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4952 CAM_LOG_INFO("ret : 0x%x", ret);
4958 int camera_attr_get_zoom(camera_h camera, int *zoom)
4960 int ret = CAMERA_ERROR_NONE;
4961 camera_cli_s *pc = (camera_cli_s *)camera;
4962 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4964 if (!pc || !pc->cb_info || !zoom) {
4965 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4966 return CAMERA_ERROR_INVALID_PARAMETER;
4969 CAM_LOG_INFO("Enter");
4971 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4973 if (ret == CAMERA_ERROR_NONE)
4974 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4976 CAM_LOG_INFO("ret : 0x%x", ret);
4982 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4984 int ret = CAMERA_ERROR_NONE;
4985 camera_cli_s *pc = (camera_cli_s *)camera;
4986 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4988 if (!pc || !pc->cb_info || !min || !max) {
4989 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4990 return CAMERA_ERROR_INVALID_PARAMETER;
4993 CAM_LOG_INFO("Enter");
4995 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4997 if (ret == CAMERA_ERROR_NONE) {
4998 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4999 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5002 CAM_LOG_INFO("ret : 0x%x", ret);
5008 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5010 int ret = CAMERA_ERROR_NONE;
5011 camera_cli_s *pc = (camera_cli_s *)camera;
5012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5014 if (!pc || !pc->cb_info || !mode) {
5015 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5016 return CAMERA_ERROR_INVALID_PARAMETER;
5019 CAM_LOG_INFO("Enter");
5021 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5023 if (ret == CAMERA_ERROR_NONE)
5024 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5026 CAM_LOG_INFO("ret : 0x%x", ret);
5032 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5034 int ret = CAMERA_ERROR_NONE;
5035 camera_cli_s *pc = (camera_cli_s *)camera;
5036 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5038 if (!pc || !pc->cb_info || !mode) {
5039 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5040 return CAMERA_ERROR_INVALID_PARAMETER;
5043 CAM_LOG_INFO("Enter");
5045 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5047 if (ret == CAMERA_ERROR_NONE)
5048 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5050 CAM_LOG_INFO("ret : 0x%x", ret);
5056 int camera_attr_get_exposure(camera_h camera, int *value)
5058 int ret = CAMERA_ERROR_NONE;
5059 camera_cli_s *pc = (camera_cli_s *)camera;
5060 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5062 if (!pc || !pc->cb_info || !value) {
5063 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5064 return CAMERA_ERROR_INVALID_PARAMETER;
5067 CAM_LOG_INFO("Enter");
5069 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5071 if (ret == CAMERA_ERROR_NONE)
5072 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5074 CAM_LOG_INFO("ret : 0x%x", ret);
5080 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5082 int ret = CAMERA_ERROR_NONE;
5083 camera_cli_s *pc = (camera_cli_s *)camera;
5084 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5086 if (!pc || !pc->cb_info || !min || !max) {
5087 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5088 return CAMERA_ERROR_INVALID_PARAMETER;
5091 CAM_LOG_INFO("Enter");
5093 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5095 if (ret == CAMERA_ERROR_NONE) {
5096 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5097 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5100 CAM_LOG_INFO("ret : 0x%x", ret);
5106 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5108 int ret = CAMERA_ERROR_NONE;
5109 camera_cli_s *pc = (camera_cli_s *)camera;
5110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5112 if (!pc || !pc->cb_info || !iso) {
5113 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5114 return CAMERA_ERROR_INVALID_PARAMETER;
5117 CAM_LOG_INFO("Enter");
5119 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5121 if (ret == CAMERA_ERROR_NONE)
5122 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5124 CAM_LOG_INFO("ret : 0x%x", ret);
5130 int camera_attr_get_brightness(camera_h camera, int *level)
5132 int ret = CAMERA_ERROR_NONE;
5133 camera_cli_s *pc = (camera_cli_s *)camera;
5134 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5136 if (!pc || !pc->cb_info || !level) {
5137 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5138 return CAMERA_ERROR_INVALID_PARAMETER;
5141 CAM_LOG_INFO("Enter");
5143 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5145 if (ret == CAMERA_ERROR_NONE)
5146 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5148 CAM_LOG_INFO("ret : 0x%x", ret);
5154 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5156 int ret = CAMERA_ERROR_NONE;
5157 camera_cli_s *pc = (camera_cli_s *)camera;
5158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5160 if (!pc || !pc->cb_info || !min || !max) {
5161 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5162 return CAMERA_ERROR_INVALID_PARAMETER;
5165 CAM_LOG_INFO("Enter");
5167 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5169 if (ret == CAMERA_ERROR_NONE) {
5170 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5171 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5174 CAM_LOG_INFO("ret : 0x%x", ret);
5180 int camera_attr_get_contrast(camera_h camera, int *level)
5182 int ret = CAMERA_ERROR_NONE;
5183 camera_cli_s *pc = (camera_cli_s *)camera;
5184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5186 if (!pc || !pc->cb_info || !level) {
5187 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5188 return CAMERA_ERROR_INVALID_PARAMETER;
5191 CAM_LOG_INFO("Enter");
5193 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5195 if (ret == CAMERA_ERROR_NONE)
5196 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5198 CAM_LOG_INFO("ret : 0x%x", ret);
5204 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5206 int ret = CAMERA_ERROR_NONE;
5207 camera_cli_s *pc = (camera_cli_s *)camera;
5208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5210 if (!pc || !pc->cb_info || !min || !max) {
5211 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5212 return CAMERA_ERROR_INVALID_PARAMETER;
5215 CAM_LOG_INFO("Enter");
5217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5219 if (ret == CAMERA_ERROR_NONE) {
5220 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5221 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5222 CAM_LOG_INFO("min %d, max %d", *min, *max);
5225 CAM_LOG_INFO("ret : 0x%x", ret);
5231 int camera_attr_get_hue(camera_h camera, int *level)
5233 int ret = CAMERA_ERROR_NONE;
5234 camera_cli_s *pc = (camera_cli_s *)camera;
5235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5237 if (!pc || !pc->cb_info || !level) {
5238 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5239 return CAMERA_ERROR_INVALID_PARAMETER;
5242 CAM_LOG_INFO("Enter");
5244 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5246 if (ret == CAMERA_ERROR_NONE)
5247 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5249 CAM_LOG_INFO("ret : 0x%x", ret);
5255 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5257 int ret = CAMERA_ERROR_NONE;
5258 camera_cli_s *pc = (camera_cli_s *)camera;
5259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5261 if (!pc || !pc->cb_info || !min || !max) {
5262 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5263 return CAMERA_ERROR_INVALID_PARAMETER;
5266 CAM_LOG_INFO("Enter");
5268 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5270 if (ret == CAMERA_ERROR_NONE) {
5271 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5272 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5273 CAM_LOG_INFO("min %d, max %d", *min, *max);
5276 CAM_LOG_INFO("ret : 0x%x", ret);
5282 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5284 int ret = CAMERA_ERROR_NONE;
5285 camera_cli_s *pc = (camera_cli_s *)camera;
5286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5288 if (!pc || !pc->cb_info || !wb) {
5289 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5290 return CAMERA_ERROR_INVALID_PARAMETER;
5293 CAM_LOG_INFO("Enter");
5295 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5297 if (ret == CAMERA_ERROR_NONE)
5298 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5300 CAM_LOG_INFO("ret : 0x%x", ret);
5306 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5308 int ret = CAMERA_ERROR_NONE;
5309 camera_cli_s *pc = (camera_cli_s *)camera;
5310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5312 if (!pc || !pc->cb_info || !effect) {
5313 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5314 return CAMERA_ERROR_INVALID_PARAMETER;
5317 CAM_LOG_INFO("Enter");
5319 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5321 if (ret == CAMERA_ERROR_NONE)
5322 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5324 CAM_LOG_INFO("ret : 0x%x", ret);
5330 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5332 int ret = CAMERA_ERROR_NONE;
5333 camera_cli_s *pc = (camera_cli_s *)camera;
5334 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5336 if (!pc || !pc->cb_info || !mode) {
5337 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5338 return CAMERA_ERROR_INVALID_PARAMETER;
5341 CAM_LOG_INFO("Enter");
5343 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5345 if (ret == CAMERA_ERROR_NONE)
5346 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5348 CAM_LOG_INFO("ret : 0x%x", ret);
5354 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5356 int ret = CAMERA_ERROR_NONE;
5357 camera_cli_s *pc = (camera_cli_s *)camera;
5358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5360 if (!pc || !pc->cb_info || !enable) {
5361 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5362 return CAMERA_ERROR_INVALID_PARAMETER;
5365 CAM_LOG_INFO("Enter");
5367 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5369 if (ret == CAMERA_ERROR_NONE)
5370 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5372 CAM_LOG_INFO("ret : 0x%x", ret);
5378 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5380 int ret = CAMERA_ERROR_NONE;
5381 camera_cli_s *pc = (camera_cli_s *)camera;
5382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5384 if (!pc || !pc->cb_info || !description) {
5385 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5386 return CAMERA_ERROR_INVALID_PARAMETER;
5389 CAM_LOG_INFO("Enter");
5391 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5393 if (ret == CAMERA_ERROR_NONE)
5394 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5396 CAM_LOG_INFO("ret : 0x%x", ret);
5402 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5404 int ret = CAMERA_ERROR_NONE;
5405 camera_cli_s *pc = (camera_cli_s *)camera;
5406 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5408 if (!pc || !pc->cb_info || !orientation) {
5409 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5410 return CAMERA_ERROR_INVALID_PARAMETER;
5413 CAM_LOG_INFO("Enter");
5415 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5417 if (ret == CAMERA_ERROR_NONE)
5418 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5420 CAM_LOG_INFO("ret : 0x%x", ret);
5426 int camera_attr_get_tag_software(camera_h camera, char **software)
5428 int ret = CAMERA_ERROR_NONE;
5429 camera_cli_s *pc = (camera_cli_s *)camera;
5430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5432 if (!pc || !pc->cb_info || !software) {
5433 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5434 return CAMERA_ERROR_INVALID_PARAMETER;
5437 CAM_LOG_INFO("Enter");
5439 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5441 if (ret == CAMERA_ERROR_NONE)
5442 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5444 CAM_LOG_INFO("ret : 0x%x", ret);
5450 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5452 int ret = CAMERA_ERROR_NONE;
5453 camera_cli_s *pc = (camera_cli_s *)camera;
5454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5456 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5457 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5458 return CAMERA_ERROR_INVALID_PARAMETER;
5461 CAM_LOG_INFO("Enter");
5463 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5465 if (ret == CAMERA_ERROR_NONE) {
5466 *latitude = pc->cb_info->get_geotag[0];
5467 *longitude = pc->cb_info->get_geotag[1];
5468 *altitude = pc->cb_info->get_geotag[2];
5471 CAM_LOG_INFO("ret : 0x%x", ret);
5477 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5479 int ret = CAMERA_ERROR_NONE;
5480 camera_cli_s *pc = (camera_cli_s *)camera;
5481 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5483 if (!pc || !pc->cb_info || !mode) {
5484 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5485 return CAMERA_ERROR_INVALID_PARAMETER;
5488 CAM_LOG_INFO("Enter");
5490 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5492 if (ret == CAMERA_ERROR_NONE)
5493 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5495 CAM_LOG_INFO("ret : 0x%x", ret);
5501 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5503 int ret = CAMERA_ERROR_NONE;
5504 int get_flash_state = 0;
5507 CAM_LOG_ERROR("NULL pointer");
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5511 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5512 (int)device, "get_flash_state", &get_flash_state);
5514 if (ret == CAMERA_ERROR_NONE) {
5515 *state = (camera_flash_state_e)get_flash_state;
5516 CAM_LOG_INFO("flash state %d", *state);
5518 CAM_LOG_ERROR("failed 0x%x", ret);
5525 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5527 int ret = CAMERA_ERROR_NONE;
5528 camera_cli_s *pc = (camera_cli_s *)camera;
5529 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5531 if (!pc || !pc->cb_info || !foreach_cb) {
5532 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5533 return CAMERA_ERROR_INVALID_PARAMETER;
5536 CAM_LOG_INFO("Enter");
5538 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5539 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5541 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5543 CAM_LOG_INFO("ret : 0x%x", ret);
5549 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5551 int ret = CAMERA_ERROR_NONE;
5552 camera_cli_s *pc = (camera_cli_s *)camera;
5553 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5555 if (!pc || !pc->cb_info || !foreach_cb) {
5556 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5557 return CAMERA_ERROR_INVALID_PARAMETER;
5560 CAM_LOG_INFO("Enter");
5562 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5563 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5565 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5567 CAM_LOG_INFO("ret : 0x%x", ret);
5573 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5575 int ret = CAMERA_ERROR_NONE;
5576 camera_cli_s *pc = (camera_cli_s *)camera;
5577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5579 if (!pc || !pc->cb_info || !foreach_cb) {
5580 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5581 return CAMERA_ERROR_INVALID_PARAMETER;
5584 CAM_LOG_INFO("Enter");
5586 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5587 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5589 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5591 CAM_LOG_INFO("ret : 0x%x", ret);
5597 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5599 int ret = CAMERA_ERROR_NONE;
5600 camera_cli_s *pc = (camera_cli_s *)camera;
5601 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5603 if (!pc || !pc->cb_info || !foreach_cb) {
5604 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5605 return CAMERA_ERROR_INVALID_PARAMETER;
5608 CAM_LOG_INFO("Enter");
5610 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5611 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5613 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5615 CAM_LOG_INFO("ret : 0x%x", ret);
5621 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5623 int ret = CAMERA_ERROR_NONE;
5624 camera_cli_s *pc = (camera_cli_s *)camera;
5625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5627 if (!pc || !pc->cb_info || !foreach_cb) {
5628 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5629 return CAMERA_ERROR_INVALID_PARAMETER;
5632 CAM_LOG_INFO("Enter");
5634 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5635 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5637 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5639 CAM_LOG_INFO("ret : 0x%x", ret);
5645 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5647 int ret = CAMERA_ERROR_NONE;
5648 camera_cli_s *pc = (camera_cli_s *)camera;
5649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5651 if (!pc || !pc->cb_info || !foreach_cb) {
5652 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5653 return CAMERA_ERROR_INVALID_PARAMETER;
5656 CAM_LOG_INFO("Enter");
5658 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5659 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5661 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5663 CAM_LOG_INFO("ret : 0x%x", ret);
5669 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5671 int ret = CAMERA_ERROR_NONE;
5672 camera_cli_s *pc = (camera_cli_s *)camera;
5673 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5675 if (!pc || !pc->cb_info || !foreach_cb) {
5676 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5677 return CAMERA_ERROR_INVALID_PARAMETER;
5680 CAM_LOG_INFO("Enter");
5682 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5683 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5685 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5687 CAM_LOG_INFO("ret : 0x%x", ret);
5693 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5695 int ret = CAMERA_ERROR_NONE;
5696 camera_cli_s *pc = (camera_cli_s *)camera;
5697 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5699 if (!pc || !pc->cb_info || !foreach_cb) {
5700 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5701 return CAMERA_ERROR_INVALID_PARAMETER;
5704 CAM_LOG_INFO("Enter");
5706 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5707 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5709 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5711 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5717 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)
5719 int ret = CAMERA_ERROR_NONE;
5720 camera_cli_s *pc = (camera_cli_s *)camera;
5721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5722 camera_msg_param param;
5725 if (!pc || !pc->cb_info || !foreach_cb) {
5726 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5727 return CAMERA_ERROR_INVALID_PARAMETER;
5730 CAM_LOG_INFO("Enter");
5732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5735 value = (width << 16) | height;
5736 CAMERA_MSG_PARAM_SET(param, INT, value);
5738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5740 CAM_LOG_INFO("ret : 0x%x", ret);
5746 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5748 int ret = CAMERA_ERROR_NONE;
5749 camera_cli_s *pc = (camera_cli_s *)camera;
5750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5752 if (!pc || !pc->cb_info || !foreach_cb) {
5753 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5754 return CAMERA_ERROR_INVALID_PARAMETER;
5757 CAM_LOG_INFO("Enter");
5759 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5760 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5762 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5764 CAM_LOG_INFO("ret : 0x%x", ret);
5770 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5772 int ret = CAMERA_ERROR_NONE;
5773 camera_cli_s *pc = (camera_cli_s *)camera;
5774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5776 if (!pc || !pc->cb_info || !foreach_cb) {
5777 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5778 return CAMERA_ERROR_INVALID_PARAMETER;
5781 CAM_LOG_INFO("Enter");
5783 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5784 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5786 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5788 CAM_LOG_INFO("ret : 0x%x", ret);
5794 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5796 int ret = CAMERA_ERROR_NONE;
5797 camera_cli_s *pc = (camera_cli_s *)camera;
5798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5799 camera_msg_param param;
5800 int set_rotation = (int)rotation;
5802 if (!pc || !pc->cb_info) {
5803 CAM_LOG_ERROR("NULL handle");
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5807 CAM_LOG_INFO("Enter");
5809 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5813 CAM_LOG_INFO("ret : 0x%x", ret);
5819 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5825 if (!pc || !pc->cb_info || !rotation) {
5826 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5830 CAM_LOG_INFO("Enter");
5832 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5834 if (ret == CAMERA_ERROR_NONE)
5835 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5837 CAM_LOG_INFO("ret : 0x%x", ret);
5843 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5845 int ret = CAMERA_ERROR_NONE;
5846 camera_cli_s *pc = (camera_cli_s *)camera;
5847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5848 camera_msg_param param;
5849 int set_flip = (int)flip;
5851 if (!pc || !pc->cb_info) {
5852 CAM_LOG_ERROR("NULL handle");
5853 return CAMERA_ERROR_INVALID_PARAMETER;
5856 CAM_LOG_INFO("Enter");
5858 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5860 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5862 CAM_LOG_INFO("ret : 0x%x", ret);
5868 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5870 int ret = CAMERA_ERROR_NONE;
5871 camera_cli_s *pc = (camera_cli_s *)camera;
5872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5874 if (!pc || !pc->cb_info || !flip) {
5875 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5876 return CAMERA_ERROR_INVALID_PARAMETER;
5879 CAM_LOG_INFO("Enter");
5881 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5883 if (ret == CAMERA_ERROR_NONE)
5884 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5886 CAM_LOG_INFO("ret : 0x%x", ret);
5891 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5893 int ret = CAMERA_ERROR_NONE;
5894 camera_cli_s *pc = (camera_cli_s *)camera;
5895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5896 camera_msg_param param;
5897 int set_mode = (int)mode;
5899 if (!pc || !pc->cb_info) {
5900 CAM_LOG_ERROR("NULL handle");
5901 return CAMERA_ERROR_INVALID_PARAMETER;
5904 CAM_LOG_INFO("Enter");
5906 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5908 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5910 CAM_LOG_INFO("ret : 0x%x", ret);
5916 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5922 if (!pc || !pc->cb_info || !mode) {
5923 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5924 return CAMERA_ERROR_INVALID_PARAMETER;
5927 CAM_LOG_INFO("Enter");
5929 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5931 if (ret == CAMERA_ERROR_NONE)
5932 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5934 CAM_LOG_INFO("ret : 0x%x", ret);
5940 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5942 int ret = CAMERA_ERROR_NONE;
5943 camera_cli_s *pc = (camera_cli_s *)camera;
5944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5946 if (!pc || !pc->cb_info) {
5947 CAM_LOG_ERROR("NULL handle");
5948 return CAMERA_ERROR_INVALID_PARAMETER;
5951 CAM_LOG_INFO("Enter");
5953 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5956 CAM_LOG_ERROR("error is occurred 0x%x", ret);
5960 CAM_LOG_INFO("ret : %d", ret);
5966 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5968 int ret = CAMERA_ERROR_NONE;
5969 camera_cli_s *pc = (camera_cli_s *)camera;
5970 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5972 if (!pc || !pc->cb_info) {
5973 CAM_LOG_ERROR("NULL handle");
5974 return CAMERA_ERROR_INVALID_PARAMETER;
5977 CAM_LOG_INFO("Enter");
5979 if (!camera_attr_is_supported_hdr_capture(camera)) {
5980 CAM_LOG_ERROR("HDR not supported");
5981 return CAMERA_ERROR_NOT_SUPPORTED;
5985 CAM_LOG_ERROR("NULL callback");
5986 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5991 if (ret == CAMERA_ERROR_NONE) {
5992 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5994 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5995 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5997 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6000 CAM_LOG_INFO("ret : 0x%x", ret);
6006 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6008 int ret = CAMERA_ERROR_NONE;
6009 camera_cli_s *pc = (camera_cli_s *)camera;
6010 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6012 if (!pc || !pc->cb_info) {
6013 CAM_LOG_ERROR("NULL handle");
6014 return CAMERA_ERROR_INVALID_PARAMETER;
6017 CAM_LOG_INFO("Enter");
6019 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6021 if (ret == CAMERA_ERROR_NONE) {
6022 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6027 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6030 CAM_LOG_INFO("ret : 0x%x", ret);
6036 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6038 int ret = CAMERA_ERROR_NONE;
6039 camera_cli_s *pc = (camera_cli_s *)camera;
6040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6041 camera_msg_param param;
6042 int set_enable = (int)enable;
6044 if (!pc || !pc->cb_info) {
6045 CAM_LOG_ERROR("NULL handle");
6046 return CAMERA_ERROR_INVALID_PARAMETER;
6049 CAM_LOG_INFO("Enter");
6051 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6053 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6055 CAM_LOG_INFO("ret : 0x%x", ret);
6061 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6063 int ret = CAMERA_ERROR_NONE;
6064 camera_cli_s *pc = (camera_cli_s *)camera;
6065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6067 if (!pc || !pc->cb_info || !enabled) {
6068 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6069 return CAMERA_ERROR_INVALID_PARAMETER;
6072 CAM_LOG_INFO("Enter");
6074 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6076 if (ret == CAMERA_ERROR_NONE)
6077 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6079 CAM_LOG_INFO("ret : 0x%x", ret);
6085 bool camera_attr_is_supported_anti_shake(camera_h camera)
6087 int ret = CAMERA_ERROR_NONE;
6088 camera_cli_s *pc = (camera_cli_s *)camera;
6089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6091 if (!pc || !pc->cb_info) {
6092 CAM_LOG_ERROR("NULL handle");
6093 return CAMERA_ERROR_INVALID_PARAMETER;
6096 CAM_LOG_INFO("Enter");
6098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6101 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6105 CAM_LOG_INFO("ret : %d", ret);
6111 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6113 int ret = CAMERA_ERROR_NONE;
6114 camera_cli_s *pc = (camera_cli_s *)camera;
6115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6116 camera_msg_param param;
6117 int set_enable = (int)enable;
6119 if (!pc || !pc->cb_info) {
6120 CAM_LOG_ERROR("NULL handle");
6121 return CAMERA_ERROR_INVALID_PARAMETER;
6124 CAM_LOG_INFO("Enter");
6126 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6128 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6130 CAM_LOG_INFO("ret : 0x%x", ret);
6136 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6138 int ret = CAMERA_ERROR_NONE;
6139 camera_cli_s *pc = (camera_cli_s *)camera;
6140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6142 if (!pc || !pc->cb_info || !enabled) {
6143 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6144 return CAMERA_ERROR_INVALID_PARAMETER;
6147 CAM_LOG_INFO("Enter");
6149 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6151 if (ret == CAMERA_ERROR_NONE)
6152 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6154 CAM_LOG_INFO("ret : 0x%x", ret);
6160 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6162 int ret = CAMERA_ERROR_NONE;
6163 camera_cli_s *pc = (camera_cli_s *)camera;
6164 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6166 if (!pc || !pc->cb_info) {
6167 CAM_LOG_ERROR("NULL handle");
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6171 CAM_LOG_INFO("Enter");
6173 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6176 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6180 CAM_LOG_INFO("ret : %d", ret);
6186 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6188 int ret = CAMERA_ERROR_NONE;
6189 camera_cli_s *pc = (camera_cli_s *)camera;
6190 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6191 camera_msg_param param;
6192 int set_enable = (int)enable;
6194 if (!pc || !pc->cb_info) {
6195 CAM_LOG_ERROR("NULL handle");
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6199 CAM_LOG_INFO("Enter");
6201 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6203 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6205 CAM_LOG_INFO("ret : 0x%x", ret);
6211 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6213 int ret = CAMERA_ERROR_NONE;
6214 camera_cli_s *pc = (camera_cli_s *)camera;
6215 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6217 if (!pc || !pc->cb_info || !enabled) {
6218 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6222 CAM_LOG_INFO("Enter");
6224 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6226 if (ret == CAMERA_ERROR_NONE)
6227 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6229 CAM_LOG_INFO("ret : 0x%x", ret);
6235 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6237 int ret = CAMERA_ERROR_NONE;
6238 camera_cli_s *pc = (camera_cli_s *)camera;
6239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6241 if (!pc || !pc->cb_info) {
6242 CAM_LOG_ERROR("NULL handle");
6243 return CAMERA_ERROR_INVALID_PARAMETER;
6246 CAM_LOG_INFO("Enter");
6248 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6251 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6255 CAM_LOG_INFO("ret : %d", ret);
6261 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6263 int ret = CAMERA_ERROR_NONE;
6264 camera_cli_s *pc = (camera_cli_s *)camera;
6265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6266 camera_msg_param param;
6267 int set_disable = (int)disable;
6269 if (!pc || !pc->cb_info) {
6270 CAM_LOG_ERROR("NULL handle");
6271 return CAMERA_ERROR_INVALID_PARAMETER;
6274 CAM_LOG_INFO("Enter");
6276 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6278 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6280 CAM_LOG_INFO("ret : 0x%x", ret);
6286 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6288 int ret = CAMERA_ERROR_NONE;
6289 camera_cli_s *pc = (camera_cli_s *)camera;
6290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6291 camera_msg_param param0;
6292 camera_msg_param param1;
6294 if (!pc || !pc->cb_info) {
6295 CAM_LOG_ERROR("NULL handle");
6296 return CAMERA_ERROR_INVALID_PARAMETER;
6299 CAM_LOG_INFO("Enter");
6301 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6302 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6304 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6305 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6307 CAM_LOG_INFO("ret : 0x%x", ret);
6313 int camera_attr_get_pan(camera_h camera, int *pan_step)
6315 int ret = CAMERA_ERROR_NONE;
6316 camera_cli_s *pc = (camera_cli_s *)camera;
6317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6319 if (!pc || !pc->cb_info || !pan_step) {
6320 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6321 return CAMERA_ERROR_INVALID_PARAMETER;
6324 CAM_LOG_INFO("Enter");
6326 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6328 if (ret == CAMERA_ERROR_NONE)
6329 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6331 CAM_LOG_INFO("ret : 0x%x", ret);
6337 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6339 int ret = CAMERA_ERROR_NONE;
6340 camera_cli_s *pc = (camera_cli_s *)camera;
6341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6343 if (!pc || !pc->cb_info || !min || !max) {
6344 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6345 return CAMERA_ERROR_INVALID_PARAMETER;
6348 CAM_LOG_INFO("Enter");
6350 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6352 if (ret == CAMERA_ERROR_NONE) {
6353 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6354 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6357 CAM_LOG_INFO("ret : 0x%x", ret);
6363 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6365 int ret = CAMERA_ERROR_NONE;
6366 camera_cli_s *pc = (camera_cli_s *)camera;
6367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6368 camera_msg_param param0;
6369 camera_msg_param param1;
6371 if (!pc || !pc->cb_info) {
6372 CAM_LOG_ERROR("NULL handle");
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6376 CAM_LOG_INFO("Enter");
6378 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6379 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6381 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6382 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6384 CAM_LOG_INFO("ret : 0x%x", ret);
6390 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6392 int ret = CAMERA_ERROR_NONE;
6393 camera_cli_s *pc = (camera_cli_s *)camera;
6394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6396 if (!pc || !pc->cb_info || !tilt_step) {
6397 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6398 return CAMERA_ERROR_INVALID_PARAMETER;
6401 CAM_LOG_INFO("Enter");
6403 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6405 if (ret == CAMERA_ERROR_NONE)
6406 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6408 CAM_LOG_INFO("ret : 0x%x", ret);
6414 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_cli_s *pc = (camera_cli_s *)camera;
6418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6420 if (!pc || !pc->cb_info || !min || !max) {
6421 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6425 CAM_LOG_INFO("Enter");
6427 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6429 if (ret == CAMERA_ERROR_NONE) {
6430 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6431 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6434 CAM_LOG_INFO("ret : 0x%x", ret);
6440 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6442 int ret = CAMERA_ERROR_NONE;
6443 camera_cli_s *pc = (camera_cli_s *)camera;
6444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6445 camera_msg_param param;
6446 int set_ptz_type = (int)ptz_type;
6448 if (!pc || !pc->cb_info) {
6449 CAM_LOG_ERROR("NULL handle");
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6453 CAM_LOG_INFO("Enter");
6455 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6457 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6459 CAM_LOG_INFO("ret : 0x%x", ret);
6465 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6467 int ret = CAMERA_ERROR_NONE;
6468 camera_cli_s *pc = (camera_cli_s *)camera;
6469 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6471 if (!pc || !pc->cb_info || !foreach_cb) {
6472 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6473 return CAMERA_ERROR_INVALID_PARAMETER;
6476 CAM_LOG_INFO("Enter");
6478 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6479 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6481 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6483 CAM_LOG_INFO("ret : 0x%x", ret);
6489 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6491 int ret = CAMERA_ERROR_NONE;
6492 camera_cli_s *pc = (camera_cli_s *)camera;
6493 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6494 int set_display_roi_area[4] = {x, y, width, height};
6499 if (!pc || !pc->cb_info) {
6500 CAM_LOG_ERROR("NULL handle");
6501 return CAMERA_ERROR_INVALID_PARAMETER;
6504 CAM_LOG_INFO("Enter");
6506 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6507 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6508 if (ret != MM_ERROR_NONE) {
6509 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6510 return CAMERA_ERROR_INVALID_OPERATION;
6514 length = sizeof(set_display_roi_area) / sizeof(int) + \
6515 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6517 msg = muse_core_msg_new(api,
6518 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6521 CAM_LOG_ERROR("msg creation failed: api %d", api);
6522 return CAMERA_ERROR_OUT_OF_MEMORY;
6525 if (pc->cb_info->is_server_connected) {
6526 __camera_update_api_waiting(pc->cb_info, api, 1);
6528 g_mutex_lock(&pc->cb_info->fd_lock);
6529 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6530 g_mutex_unlock(&pc->cb_info->fd_lock);
6534 CAM_LOG_ERROR("message send failed");
6535 ret = CAMERA_ERROR_INVALID_OPERATION;
6537 ret = __camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6540 __camera_update_api_waiting(pc->cb_info, api, -1);
6542 muse_core_msg_free(msg);
6544 CAM_LOG_INFO("ret : 0x%x", ret);
6550 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6552 camera_cli_s *pc = (camera_cli_s *)camera;
6553 int ret = CAMERA_ERROR_NONE;
6554 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6556 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6557 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6558 return CAMERA_ERROR_INVALID_PARAMETER;
6561 CAM_LOG_INFO("Enter");
6563 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6565 if (ret == CAMERA_ERROR_NONE) {
6566 *x = pc->cb_info->get_display_roi_area[0];
6567 *y = pc->cb_info->get_display_roi_area[1];
6568 *width = pc->cb_info->get_display_roi_area[2];
6569 *height = pc->cb_info->get_display_roi_area[3];
6572 CAM_LOG_INFO("ret : 0x%x", ret);
6578 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6580 int ret = CAMERA_ERROR_NONE;
6581 int get_device_state = 0;
6584 CAM_LOG_ERROR("NULL pointer");
6585 return CAMERA_ERROR_INVALID_PARAMETER;
6588 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6589 (int)device, "get_device_state", &get_device_state);
6591 if (ret == CAMERA_ERROR_NONE) {
6592 *state = (camera_device_state_e)get_device_state;
6593 CAM_LOG_INFO("device state %d", *state);
6595 CAM_LOG_ERROR("failed 0x%x", ret);
6602 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6604 int ret = CAMERA_ERROR_NONE;
6605 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6606 camera_cb_info *info = NULL;
6608 if (!callback || !cb_id) {
6609 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6610 return CAMERA_ERROR_INVALID_PARAMETER;
6613 /* check camera support */
6614 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6615 if (ret != CAMERA_ERROR_NONE) {
6616 CAM_LOG_ERROR("get device state failed");
6620 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6622 info = g_new0(camera_cb_info, 1);
6624 CAM_LOG_ERROR("info failed");
6625 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6629 info->id = ++g_cam_dev_state_changed_cb_id;
6630 info->callback = (void *)callback;
6631 info->user_data = user_data;
6635 /* subscribe dbus signal for camera state change */
6636 if (!g_cam_dev_state_changed_cb_conn) {
6637 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6638 if (!g_cam_dev_state_changed_cb_conn) {
6639 CAM_LOG_ERROR("failed to get gdbus connection");
6640 ret = CAMERA_ERROR_INVALID_OPERATION;
6644 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6645 MM_CAMCORDER_DBUS_OBJECT,
6646 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6647 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6649 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6650 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6651 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6652 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6653 CAM_LOG_ERROR("failed to get gdbus connection");
6654 ret = CAMERA_ERROR_INVALID_OPERATION;
6658 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6661 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6663 CAM_LOG_INFO("callback id %d", info->id);
6666 if (ret != CAMERA_ERROR_NONE) {
6672 if (g_cam_dev_state_changed_cb_conn) {
6673 g_object_unref(g_cam_dev_state_changed_cb_conn);
6674 g_cam_dev_state_changed_cb_conn = NULL;
6678 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6684 int camera_remove_device_state_changed_cb(int cb_id)
6686 int ret = CAMERA_ERROR_NONE;
6687 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6688 GList *tmp_list = NULL;
6689 camera_cb_info *info = NULL;
6691 /* check camera support */
6692 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6693 if (ret != CAMERA_ERROR_NONE) {
6694 CAM_LOG_ERROR("get device state failed");
6698 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6700 if (!g_cam_dev_state_changed_cb_list) {
6701 CAM_LOG_ERROR("there is no callback info");
6702 ret = CAMERA_ERROR_INVALID_OPERATION;
6706 tmp_list = g_cam_dev_state_changed_cb_list;
6709 info = tmp_list->data;
6710 tmp_list = tmp_list->next;
6713 CAM_LOG_WARNING("NULL info");
6717 if (info->id == cb_id) {
6718 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6723 if (!g_cam_dev_state_changed_cb_list) {
6724 /* no remained callback */
6725 if (g_cam_dev_state_changed_cb_conn) {
6726 /* unsubscribe signal */
6727 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6728 g_cam_dev_state_changed_cb_subscribe_id = 0;
6730 /* unref connection */
6731 g_object_unref(g_cam_dev_state_changed_cb_conn);
6732 g_cam_dev_state_changed_cb_conn = NULL;
6736 CAM_LOG_INFO("id %d callback removed", cb_id);
6737 ret = CAMERA_ERROR_NONE;
6743 CAM_LOG_ERROR("id %d callback not found", cb_id);
6744 ret = CAMERA_ERROR_INVALID_PARAMETER;
6747 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6753 int _camera_get_log_level(void)
6755 return g_camera_log_level;