2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <mm_camcorder.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_client.h>
35 #define LOG_TAG "TIZEN_N_CAMERA"
36 #define MODULE_NAME "camera"
37 #define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
38 #define CAMERA_CHECK_DEVICE_MANAGER \
40 if (access(LIB_CAMERA_DEVICE_MANAGER, F_OK) != 0) {\
41 CAM_LOG_ERROR("no camera device maanger[errno:%d]", errno);\
42 return CAMERA_ERROR_NOT_SUPPORTED;\
47 /* for camera device manager */
48 typedef struct _cdm_symbol_table {
50 const char *func_name;
53 /* for device changed callback */
54 static GMutex g_cam_dev_state_changed_cb_lock;
55 static GList *g_cam_dev_state_changed_cb_list;
56 static int g_cam_dev_state_changed_cb_id;
57 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
58 static guint g_cam_dev_state_changed_cb_subscribe_id;
59 static GMutex g_cam_idle_event_lock;
62 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
64 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
65 static void __camera_release_imported_bo(tbm_bo *bo);
67 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
68 camera_media_packet_data *mp_data, media_packet_h *packet);
69 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
70 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
71 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
73 static gboolean __camera_allocate_preview_buffer(camera_h camera);
74 static void __camera_release_preview_buffer(camera_h camera);
75 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
77 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
78 int type, const char *thread_name, camera_cb_info_s *cb_info);
79 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
83 static gboolean __camera_allocate_preview_buffer(camera_h camera)
86 int ret = CAMERA_ERROR_NONE;
87 int format = CAMERA_PIXEL_FORMAT_INVALID;
91 camera_cli_s *pc = (camera_cli_s *)camera;
92 camera_cb_info_s *cb_info = NULL;
94 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
96 cb_info = pc->cb_info;
98 CAM_LOG_INFO("Enter");
100 /* get preview info and calculate size */
101 ret = camera_get_preview_format(camera, &format);
102 if (ret != CAMERA_ERROR_NONE) {
103 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
107 ret = camera_get_preview_resolution(camera, &width, &height);
108 if (ret != CAMERA_ERROR_NONE) {
109 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
113 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
116 case CAMERA_PIXEL_FORMAT_INVZ:
117 buffer_size = width * height;
119 case CAMERA_PIXEL_FORMAT_NV12:
120 case CAMERA_PIXEL_FORMAT_I420:
121 buffer_size = (width * height * 3) >> 1;
123 case CAMERA_PIXEL_FORMAT_YUYV:
124 case CAMERA_PIXEL_FORMAT_UYVY:
125 buffer_size = width * height * 2;
128 CAM_LOG_ERROR("unhandled format %d", format);
129 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
132 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
134 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
135 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
136 if (!cb_info->bos[i]) {
137 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
138 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
141 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
142 if (cb_info->fds[i] < 0) {
143 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
144 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
147 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
150 CAM_LOG_INFO("Done");
154 _ALLOCATE_PREVIEW_BUFFER_FAILED:
155 __camera_release_preview_buffer(camera);
160 static void __camera_release_preview_buffer(camera_h camera)
163 camera_cli_s *pc = (camera_cli_s *)camera;
164 camera_cb_info_s *cb_info = NULL;
166 CAMERA_CHECK_HANDLE_RETURN(pc);
168 CAM_LOG_INFO("Enter");
170 cb_info = pc->cb_info;
172 /* close exported fd and bos */
173 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
174 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
176 if (cb_info->bos[i]) {
177 tbm_bo_unref(cb_info->bos[i]);
178 cb_info->bos[i] = NULL;
183 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
184 close(cb_info->fds[i]);
185 cb_info->fds[i] = CAMERA_FD_INIT;
189 CAM_LOG_INFO("Done");
193 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
198 CAM_LOG_WARNING("NULL tfd");
202 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
203 if (!CAMERA_IS_FD_VALID(tfd[i]))
207 tfd[i] = CAMERA_FD_INIT;
212 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
215 api < 0 || api >= MUSE_CAMERA_API_MAX) {
216 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
220 g_mutex_lock(&(cb_info->api_mutex[api]));
221 cb_info->api_waiting[api] += value;
222 g_mutex_unlock(&(cb_info->api_mutex[api]));
224 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
225 api, value, cb_info->api_waiting[api]);
229 static void __camera_device_state_changed_cb(GDBusConnection *connection,
230 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
231 const gchar *signal_name, GVariant *param, gpointer user_data)
234 camera_device_e device = CAMERA_DEVICE_CAMERA0;
235 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
236 GList *tmp_list = NULL;
237 camera_cb_info *info = NULL;
239 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
241 if (!g_cam_dev_state_changed_cb_list || !param) {
242 CAM_LOG_WARNING("no callback or NULL param %p", param);
246 /* get device and state */
247 g_variant_get(param, "(i)", &value);
249 device = value >> 16;
250 state = 0x0000ffff & value;
252 CAM_LOG_INFO("device %d, state %d", device, state);
254 tmp_list = g_cam_dev_state_changed_cb_list;
257 info = (camera_cb_info *)tmp_list->data;
260 if (info->callback) {
261 CAM_LOG_INFO("start id[%d] callback", info->id);
262 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
263 CAM_LOG_INFO("returned id[%d] callback", info->id);
265 CAM_LOG_WARNING("NULL callback for id %d", info->id);
269 tmp_list = tmp_list->next;
273 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
277 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
281 int ret_fd = CAMERA_FD_INIT;
282 int preview_fd = CAMERA_FD_INIT;
283 int num_buffer_fd = 0;
284 unsigned char *buf_pos = NULL;
287 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
288 tbm_bo_handle bo_handle = {.ptr = NULL};
289 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
290 tbm_bo data_bo = NULL;
291 tbm_bo_handle data_bo_handle = {.ptr = NULL};
293 camera_msg_param param;
294 camera_preview_data_s frame;
295 MMCamcorderVideoStreamDataType *stream = NULL;
296 camera_media_packet_data *mp_data = NULL;
297 media_packet_h pkt = NULL;
299 /* tfd[0]: MMCamcorderVideoStreamDataType
300 tfd[1]: data_bo or zero copy bo[0]
301 tfd[2]: zero copy bo[1]
302 tfd[3]: zero copy bo[2] */
304 if (!cb_info || !recv_msg || !tfd) {
305 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
309 muse_camera_msg_get(preview_fd, recv_msg);
310 muse_camera_msg_get(num_buffer_fd, recv_msg);
312 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
314 memset(&frame, 0x0, sizeof(camera_preview_data_s));
317 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
322 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
324 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
325 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
326 goto _PREVIEW_CB_HANDLER_DONE;
329 /* import tbm bo and get virtual address */
330 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
331 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
332 goto _PREVIEW_CB_HANDLER_DONE;
335 buf_pos = (unsigned char *)bo_handle.ptr;
337 /* get stream info */
338 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
340 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
341 /* import tbm data_bo and get virtual address */
342 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
343 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
344 goto _PREVIEW_CB_HANDLER_DONE;
347 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
348 stream->data.encoded.data = data_bo_handle.ptr;
350 for (i = 0 ; i < num_buffer_fd ; i++) {
351 /* import buffer bo and get virtual address */
352 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
353 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
354 goto _PREVIEW_CB_HANDLER_DONE;
358 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
359 stream->data.encoded.data = buffer_bo_handle[0].ptr;
362 /* preview callback */
363 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
364 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
365 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
367 /* set stream data for camera_get_preview_frame_rotation() */
368 cb_info->stream_data = stream;
370 if (stream->extra_stream_id < 0) {
371 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
372 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
373 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
375 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
376 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
377 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
380 cb_info->stream_data = NULL;
383 if (stream->extra_stream_id >= 0)
384 goto _PREVIEW_CB_HANDLER_DONE;
386 /* make media packet with below cases.
387 * 1. media_packet_preview_cb is set
388 * 2. EVAS display rendering
389 * 3. media bridge is set
391 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
392 cb_info->is_evas_render ||
394 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
395 if (ret != CAMERA_ERROR_NONE) {
396 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
397 goto _PREVIEW_CB_HANDLER_DONE;
400 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
401 if (ret != CAMERA_ERROR_NONE) {
402 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
403 __camera_release_media_packet_data(mp_data, cb_info);
405 goto _PREVIEW_CB_HANDLER_DONE;
409 /* 1. media packet preview callback */
410 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
411 media_packet_ref(pkt);
412 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
413 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
416 /* 2. call evas renderer */
417 if (cb_info->is_evas_render) {
418 if (cb_info->run_evas_render) {
419 media_packet_ref(pkt);
420 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
421 if (ret != MM_ERROR_NONE) {
422 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
423 media_packet_unref(pkt);
426 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
431 /* 3. media bridge */
432 g_mutex_lock(&cb_info->bridge_lock);
434 if (cb_info->bridge) {
435 media_packet_ref(pkt);
436 ret = media_bridge_push_packet(cb_info->bridge, pkt);
437 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
438 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
439 media_packet_unref(pkt);
444 g_mutex_unlock(&cb_info->bridge_lock);
446 _PREVIEW_CB_HANDLER_DONE:
447 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
448 and preview callback(normal or media packet) is set. */
449 if (num_buffer_fd > 0 &&
450 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
451 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
452 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
455 media_packet_unref(pkt);
460 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
462 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
464 /* release imported bo and fd */
465 __camera_release_imported_bo(&data_bo);
466 __camera_release_imported_bo(&bo);
468 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
469 __camera_release_imported_bo(&buffer_bo[i]);
471 __camera_release_tfd(tfd);
475 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
478 int capture_fd_main = 0;
479 int capture_fd_post = 0;
480 int capture_fd_thumb = 0;
481 unsigned char *buf_pos = NULL;
483 camera_image_data_s *rImage = NULL;
484 camera_image_data_s *rPostview = NULL;
485 camera_image_data_s *rThumbnail = NULL;
487 tbm_bo bo_main = NULL;
488 tbm_bo bo_post = NULL;
489 tbm_bo bo_thumb = NULL;
490 tbm_bo_handle bo_main_handle = {.ptr = NULL};
491 tbm_bo_handle bo_post_handle = {.ptr = NULL};
492 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
494 if (!cb_info || !recv_msg || !tfd) {
495 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
499 muse_camera_msg_get(capture_fd_main, recv_msg);
500 muse_camera_msg_get(capture_fd_post, recv_msg);
501 muse_camera_msg_get(capture_fd_thumb, recv_msg);
503 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
504 capture_fd_main, capture_fd_post, capture_fd_thumb,
505 tfd[0], tfd[1], tfd[2]);
507 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
508 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
509 goto _CAPTURE_CB_HANDLER_DONE;
512 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
513 CAM_LOG_WARNING("NULL callback");
514 goto _CAPTURE_CB_HANDLER_DONE;
517 /* import tbm bo and get virtual address */
518 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
519 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
520 goto _CAPTURE_CB_HANDLER_DONE;
523 buf_pos = (unsigned char *)bo_main_handle.ptr;
524 rImage = (camera_image_data_s *)buf_pos;
525 rImage->data = buf_pos + sizeof(camera_image_data_s);
526 if (rImage->exif && rImage->exif_size > 0) {
527 rImage->exif = rImage->data + rImage->size;
530 rImage->exif_size = 0;
533 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
534 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
537 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
538 /* import tbm bo and get virtual address */
540 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
541 buf_pos = (unsigned char *)bo_post_handle.ptr;
542 rPostview = (camera_image_data_s *)buf_pos;
543 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
544 rPostview->data = buf_pos + sizeof(camera_image_data_s);
546 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
550 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
551 /* import tbm bo and get virtual address */
553 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
554 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
555 rThumbnail = (camera_image_data_s *)buf_pos;
556 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
557 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
559 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
564 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
565 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
567 _CAPTURE_CB_HANDLER_DONE:
569 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
570 __camera_release_imported_bo(&bo_main);
571 _camera_msg_return_buffer(capture_fd_main, cb_info);
574 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
575 __camera_release_imported_bo(&bo_post);
576 _camera_msg_return_buffer(capture_fd_post, cb_info);
579 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
580 __camera_release_imported_bo(&bo_thumb);
581 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
584 __camera_release_tfd(tfd);
586 CAM_LOG_INFO("return buffer done");
591 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
594 int face_fd = CAMERA_FD_INIT;
595 camera_detected_face_s *faces = NULL;
598 tbm_bo_handle bo_handle = {.ptr = NULL};
600 if (!cb_info || !recv_msg || !tfd) {
601 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
605 muse_camera_msg_get(count, recv_msg);
606 muse_camera_msg_get(face_fd, recv_msg);
608 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
609 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
611 if (CAMERA_IS_FD_VALID(tfd[0])) {
612 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
614 faces = bo_handle.ptr;
618 tfd[0] = CAMERA_FD_INIT;
621 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
622 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
625 __camera_release_imported_bo(&bo);
627 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
628 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
632 _camera_msg_return_buffer(face_fd, cb_info);
637 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
639 tbm_bo tmp_bo = NULL;
640 tbm_bo_handle tmp_bo_handle = {NULL, };
642 if (!bufmgr || !bo || !bo_handle || fd < 0) {
643 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
644 bufmgr, bo, bo_handle, fd);
648 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
649 if (tmp_bo == NULL) {
650 CAM_LOG_ERROR("import failed - fd %d", fd);
654 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
655 if (tmp_bo_handle.ptr == NULL) {
656 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
657 tbm_bo_unref(tmp_bo);
662 /* set bo and bo_handle */
664 *bo_handle = tmp_bo_handle;
666 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
671 static void __camera_release_imported_bo(tbm_bo *bo)
674 CAM_LOG_DEBUG("NULL bo");
683 static bool __is_supported(camera_h camera, muse_camera_api_e api)
685 int ret = CAMERA_ERROR_NONE;
686 camera_cli_s *pc = (camera_cli_s *)camera;
688 if (!pc || !pc->cb_info) {
689 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
690 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
694 CAM_LOG_INFO("Enter - api[%d]", api);
696 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
698 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
704 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
706 int ret = CAMERA_ERROR_NONE;
707 camera_cli_s *pc = (camera_cli_s *)camera;
708 camera_msg_param param;
710 if (!pc || !pc->cb_info) {
711 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
712 return CAMERA_ERROR_INVALID_PARAMETER;
715 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
717 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
719 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
721 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
727 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
729 int ret = CAMERA_ERROR_NONE;
730 camera_cli_s *pc = (camera_cli_s *)camera;
731 camera_msg_param param;
733 if (!pc || !pc->cb_info) {
734 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
735 return CAMERA_ERROR_INVALID_PARAMETER;
738 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
740 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
742 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
744 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
750 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
755 CAM_LOG_ERROR("api[%d] message failed", api);
757 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
762 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
763 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
765 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
767 if (cb_info->is_server_connected) {
768 _camera_update_api_waiting(cb_info, api, 1);
770 g_mutex_lock(&cb_info->fd_lock);
771 send_ret = muse_core_msg_send(cb_info->fd, msg);
772 g_mutex_unlock(&cb_info->fd_lock);
776 CAM_LOG_ERROR("message send failed");
778 *ret = CAMERA_ERROR_INVALID_OPERATION;
781 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
784 _camera_update_api_waiting(cb_info, api, -1);
786 muse_core_msg_free(msg);
788 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
789 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
791 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
795 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
797 int ret = CAMERA_ERROR_NONE;
800 if (!cb_info->is_server_connected) {
801 CAM_LOG_ERROR("server is disconnected");
802 return CAMERA_ERROR_SERVICE_DISCONNECTED;
805 g_mutex_lock(&(cb_info->api_mutex[api]));
807 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
809 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
811 while (!cb_info->api_activating[api]) {
812 if (time_out == CAMERA_CB_NO_TIMEOUT) {
813 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
814 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
815 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
816 CAM_LOG_ERROR("api %d TIMED OUT!", api);
817 ret = CAMERA_ERROR_INVALID_OPERATION;
821 if (!cb_info->is_server_connected) {
822 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
826 if (!cb_info->api_activating[api])
827 CAM_LOG_WARNING("invalid signal received, wait again...");
830 ret = cb_info->api_ret[api];
831 cb_info->api_activating[api] = FALSE;
834 g_mutex_unlock(&(cb_info->api_mutex[api]));
836 if (ret != CAMERA_ERROR_NONE)
837 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
843 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
844 int *ret, int timeout)
849 CAM_LOG_ERROR("NULL info - api %d", api);
852 *ret = CAMERA_ERROR_INVALID_PARAMETER;
857 msg = muse_core_msg_new(api, NULL);
859 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
863 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
864 int *ret, camera_msg_param *param, int timeout)
869 if (!cb_info || !param) {
870 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
873 *ret = CAMERA_ERROR_INVALID_PARAMETER;
878 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
880 switch (param->type) {
882 msg = muse_core_msg_new(api,
883 param->type, param->name, param->value.value_INT,
886 case MUSE_TYPE_STRING:
887 msg = muse_core_msg_new(api,
888 param->type, param->name, param->value.value_STRING,
891 case MUSE_TYPE_ARRAY:
892 array_length = param->value_size / sizeof(int) + \
893 (param->value_size % sizeof(int) ? 1 : 0);
895 msg = muse_core_msg_new(api,
896 param->type, param->name, array_length, param->value.value_ARRAY,
900 CAM_LOG_ERROR("unknown type %d", param->type);
904 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
908 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
909 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
913 if (!cb_info || !param0 || !param1) {
914 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
915 cb_info, param0, param1, api);
918 *ret = CAMERA_ERROR_INVALID_PARAMETER;
923 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
925 param0->name, param0->value.value_INT,
926 param1->name, param1->value.value_INT);
928 msg = muse_core_msg_new(api,
929 param0->type, param0->name, param0->value.value_INT,
930 param1->type, param1->name, param1->value.value_INT,
933 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
937 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
939 camera_msg_param param;
942 CAM_LOG_WARNING("invalid fd %d", ret_fd);
946 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
948 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
952 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
954 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
955 in_format >= MM_PIXEL_FORMAT_NUM ||
956 out_format == NULL) {
957 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
958 return CAMERA_ERROR_INVALID_PARAMETER;
962 case MM_PIXEL_FORMAT_NV12:
963 case MM_PIXEL_FORMAT_NV12T:
964 *out_format = TBM_FORMAT_NV12;
967 case MM_PIXEL_FORMAT_NV16:
968 *out_format = TBM_FORMAT_NV16;
970 case MM_PIXEL_FORMAT_NV21:
971 *out_format = TBM_FORMAT_NV21;
973 case MM_PIXEL_FORMAT_YUYV:
974 *out_format = TBM_FORMAT_YUYV;
976 case MM_PIXEL_FORMAT_UYVY:
977 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
978 *out_format = TBM_FORMAT_UYVY;
980 case MM_PIXEL_FORMAT_422P:
981 *out_format = TBM_FORMAT_YUV422;
983 case MM_PIXEL_FORMAT_I420:
984 *out_format = TBM_FORMAT_YUV420;
986 case MM_PIXEL_FORMAT_YV12:
987 *out_format = TBM_FORMAT_YVU420;
989 case MM_PIXEL_FORMAT_RGB565:
990 *out_format = TBM_FORMAT_RGB565;
992 case MM_PIXEL_FORMAT_RGB888:
993 *out_format = TBM_FORMAT_RGB888;
995 case MM_PIXEL_FORMAT_RGBA:
996 *out_format = TBM_FORMAT_RGBA8888;
998 case MM_PIXEL_FORMAT_ARGB:
999 *out_format = TBM_FORMAT_ARGB8888;
1002 CAM_LOG_ERROR("invalid in_format %d", in_format);
1003 return CAMERA_ERROR_INVALID_PARAMETER;
1007 return CAMERA_ERROR_NONE;
1011 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1013 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1014 in_format >= MM_PIXEL_FORMAT_NUM ||
1016 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1017 return CAMERA_ERROR_INVALID_PARAMETER;
1020 switch (in_format) {
1021 case MM_PIXEL_FORMAT_NV12:
1022 case MM_PIXEL_FORMAT_NV12T:
1023 *mimetype = MEDIA_FORMAT_NV12;
1026 case MM_PIXEL_FORMAT_NV16:
1027 *mimetype = MEDIA_FORMAT_NV16;
1029 case MM_PIXEL_FORMAT_NV21:
1030 *mimetype = MEDIA_FORMAT_NV21;
1032 case MM_PIXEL_FORMAT_YUYV:
1033 *mimetype = MEDIA_FORMAT_YUYV;
1035 case MM_PIXEL_FORMAT_UYVY:
1036 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1037 *mimetype = MEDIA_FORMAT_UYVY;
1039 case MM_PIXEL_FORMAT_422P:
1040 *mimetype = MEDIA_FORMAT_422P;
1042 case MM_PIXEL_FORMAT_I420:
1043 *mimetype = MEDIA_FORMAT_I420;
1045 case MM_PIXEL_FORMAT_YV12:
1046 *mimetype = MEDIA_FORMAT_YV12;
1048 case MM_PIXEL_FORMAT_RGB565:
1049 *mimetype = MEDIA_FORMAT_RGB565;
1051 case MM_PIXEL_FORMAT_RGB888:
1052 *mimetype = MEDIA_FORMAT_RGB888;
1054 case MM_PIXEL_FORMAT_RGBA:
1055 *mimetype = MEDIA_FORMAT_RGBA;
1057 case MM_PIXEL_FORMAT_ARGB:
1058 *mimetype = MEDIA_FORMAT_ARGB;
1060 case MM_PIXEL_FORMAT_ENCODED_H264:
1061 /* TODO: How can we determine the profile for H.264 format? */
1062 *mimetype = MEDIA_FORMAT_H264_SP;
1064 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1065 *mimetype = MEDIA_FORMAT_MJPEG;
1067 case MM_PIXEL_FORMAT_ENCODED_VP8:
1068 *mimetype = MEDIA_FORMAT_VP8;
1070 case MM_PIXEL_FORMAT_ENCODED_VP9:
1071 *mimetype = MEDIA_FORMAT_VP9;
1074 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1075 return CAMERA_ERROR_NOT_SUPPORTED;
1079 return CAMERA_ERROR_NONE;
1083 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1084 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1087 int ret = CAMERA_ERROR_NONE;
1088 camera_media_packet_data *new_mp_data = NULL;
1090 if (!tfd || !mp_data) {
1091 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1092 return CAMERA_ERROR_INVALID_PARAMETER;
1095 new_mp_data = g_new0(camera_media_packet_data, 1);
1097 new_mp_data->ret_fd = ret_fd;
1098 new_mp_data->fd = tfd[0];
1099 new_mp_data->num_buffer_fd = num_buffer_fd;
1100 new_mp_data->bo = bo;
1102 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1106 new_mp_data->data_bo = data_bo;
1107 new_mp_data->data_fd = tfd[1];
1109 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1110 new_mp_data->data_bo, new_mp_data->data_fd);
1113 for (i = 0 ; i < num_buffer_fd ; i++) {
1114 new_mp_data->buffer_bo[i] = buffer_bo[i];
1115 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1117 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1118 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1121 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1122 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1124 new_mp_data->data_fd = CAMERA_FD_INIT;
1127 *mp_data = new_mp_data;
1129 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1134 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1138 if (!mp_data || !cb_info) {
1139 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1143 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1145 /* release imported bo and close fd */
1146 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1147 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1148 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1150 tbm_bo_unref(mp_data->buffer_bo[i]);
1152 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1153 close(mp_data->buffer_fd[i]);
1155 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1158 if (mp_data->data_bo) {
1159 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1160 mp_data->data_fd, mp_data->data_bo);
1162 tbm_bo_unref(mp_data->data_bo);
1164 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1165 close(mp_data->data_fd);
1167 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1170 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1172 tbm_bo_unref(mp_data->bo);
1174 if (CAMERA_IS_FD_VALID(mp_data->fd))
1177 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1180 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1186 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1189 int ret = CAMERA_ERROR_NONE;
1190 uint32_t tbm_format = 0;
1191 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1192 tbm_surface_info_s tsurf_info;
1194 if (!stream || !mp_data) {
1195 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1199 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1200 CAM_LOG_ERROR("No valid data");
1204 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1205 if (ret != CAMERA_ERROR_NONE)
1208 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1210 if (mp_data->num_buffer_fd > 0) {
1211 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1212 bos[i] = mp_data->buffer_bo[i];
1214 bos[0] = mp_data->data_bo;
1217 tsurf_info.width = stream->width;
1218 tsurf_info.height = stream->height;
1219 tsurf_info.format = tbm_format;
1220 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1221 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1223 switch (tbm_format) {
1224 case TBM_FORMAT_NV12: /* fall through */
1225 case TBM_FORMAT_NV21: /* fall through */
1226 case TBM_FORMAT_YUV420: /* fall through */
1227 case TBM_FORMAT_YVU420: /* fall through */
1228 case TBM_FORMAT_UYVY: /* fall through */
1229 case TBM_FORMAT_YUYV:
1230 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1231 tsurf_info.planes[i].stride = stream->stride[i];
1232 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1233 if (i != 0 && mp_data->num_buffer_fd <= 1)
1234 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1235 tsurf_info.size += tsurf_info.planes[i].size;
1237 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1238 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1242 case TBM_FORMAT_RGB565: /* fall through */
1243 case TBM_FORMAT_RGB888: /* fall through */
1244 case TBM_FORMAT_RGBA8888: /* fall through */
1245 case TBM_FORMAT_ARGB8888:
1246 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1247 tsurf_info.planes[0].offset = 0;
1248 tsurf_info.size = stream->data.rgb.length_data;
1251 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1256 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1257 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1261 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1263 int ret = CAMERA_ERROR_NONE;
1264 int pkt_fmt_width = 0;
1265 int pkt_fmt_height = 0;
1266 bool make_pkt_fmt = false;
1267 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1268 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1270 if (!cb_info || !stream) {
1271 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1272 return CAMERA_ERROR_INVALID_PARAMETER;
1275 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1276 if (ret != CAMERA_ERROR_NONE)
1279 /* check media packet format */
1280 if (cb_info->pkt_fmt) {
1281 media_format_get_video_info(cb_info->pkt_fmt,
1282 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1284 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1285 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1287 if (pkt_fmt_mimetype != mimetype ||
1288 pkt_fmt_width != stream->width ||
1289 pkt_fmt_height != stream->height) {
1290 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1291 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1293 media_format_unref(cb_info->pkt_fmt);
1294 cb_info->pkt_fmt = NULL;
1295 make_pkt_fmt = true;
1298 make_pkt_fmt = true;
1301 /* create packet format */
1303 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1304 mimetype, stream->width, stream->height);
1306 ret = media_format_create(&cb_info->pkt_fmt);
1307 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1308 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1309 return CAMERA_ERROR_INVALID_OPERATION;
1312 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1313 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1314 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1315 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1316 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1317 return CAMERA_ERROR_INVALID_OPERATION;
1321 return CAMERA_ERROR_NONE;
1325 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1326 camera_media_packet_data *mp_data, media_packet_h *packet)
1328 media_packet_h pkt = NULL;
1329 tbm_surface_h tsurf = NULL;
1330 int ret = CAMERA_ERROR_NONE;
1332 if (!cb_info || !stream || !mp_data || !packet) {
1333 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1334 cb_info, stream, mp_data, packet);
1335 return CAMERA_ERROR_INVALID_PARAMETER;
1338 ret = __camera_update_media_packet_format(cb_info, stream);
1339 if (ret != CAMERA_ERROR_NONE)
1342 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1343 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1344 stream->data.encoded.data, stream->data.encoded.length_data,
1345 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1348 tsurf = __camera_get_tbm_surface(stream, mp_data);
1350 CAM_LOG_ERROR("get tbm surface failed");
1351 ret = CAMERA_ERROR_INVALID_OPERATION;
1352 goto _PACKET_CREATE_FAILED;
1355 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1356 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1357 (void *)cb_info, &pkt);
1360 if (ret != MEDIA_PACKET_ERROR_NONE) {
1361 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1362 goto _PACKET_CREATE_FAILED;
1365 ret = media_packet_set_extra(pkt, (void *)mp_data);
1366 if (ret != MEDIA_PACKET_ERROR_NONE) {
1367 CAM_LOG_ERROR("media_packet_set_extra failed");
1368 goto _PACKET_CREATE_FAILED;
1371 /* set timestamp : msec -> nsec */
1372 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1373 CAM_LOG_WARNING("media_packet_set_pts failed");
1375 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1376 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1378 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1382 return CAMERA_ERROR_NONE;
1384 _PACKET_CREATE_FAILED:
1386 tbm_surface_destroy(tsurf);
1388 media_packet_unref(pkt);
1390 return CAMERA_ERROR_INVALID_OPERATION;
1393 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1396 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1397 camera_media_packet_data *mp_data = NULL;
1398 tbm_surface_h tsurf = NULL;
1400 if (!pkt || !cb_info) {
1401 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1405 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1406 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1407 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1411 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1413 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1414 pkt, mp_data, tsurf);
1417 tbm_surface_destroy(tsurf);
1419 g_mutex_lock(&cb_info->mp_data_mutex);
1420 __camera_release_media_packet_data(mp_data, cb_info);
1421 g_mutex_unlock(&cb_info->mp_data_mutex);
1424 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1429 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1430 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1434 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1436 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1438 if (cb_info->user_cb[event] == NULL) {
1439 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1440 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1441 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1442 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1443 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1444 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1448 /* return buffer message should be sent for some events.
1449 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1450 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1451 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1452 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1457 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1463 muse_camera_msg_get(previous, recv_msg);
1464 muse_camera_msg_get(current, recv_msg);
1465 muse_camera_msg_get(by_policy, recv_msg);
1467 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1468 previous, current, by_policy);
1470 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1471 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1474 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1478 muse_camera_msg_get(state, recv_msg);
1480 CAM_LOG_INFO("FOCUS state - %d", state);
1482 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1485 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1486 CAM_LOG_INFO("CAPTURE_COMPLETED");
1487 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1489 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1490 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1491 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1494 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1498 muse_camera_msg_get(percent, recv_msg);
1500 CAM_LOG_INFO("HDR progress - %d %%", percent);
1502 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1505 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1511 muse_camera_msg_get(policy, recv_msg);
1512 muse_camera_msg_get(previous, recv_msg);
1513 muse_camera_msg_get(current, recv_msg);
1515 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1517 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1518 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1521 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1526 muse_camera_msg_get(policy, recv_msg);
1527 muse_camera_msg_get(state, recv_msg);
1529 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1531 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1532 (camera_state_e)state, cb_info->user_data[event]);
1535 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1536 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1538 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1541 int current_state = 0;
1543 muse_camera_msg_get(error, recv_msg);
1544 muse_camera_msg_get(current_state, recv_msg);
1546 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1548 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1549 (camera_state_e)current_state, cb_info->user_data[event]);
1553 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1555 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1556 muse_camera_msg_get(param1, recv_msg);
1557 muse_camera_msg_get(param2, recv_msg);
1559 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1561 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1562 cb_info->user_cb[event] = NULL;
1563 cb_info->user_data[event] = NULL;
1564 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1567 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1569 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1571 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1573 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1575 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1577 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1579 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1581 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1583 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1585 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1587 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1589 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1591 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1597 muse_camera_msg_get(param1, recv_msg);
1599 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1601 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1602 cb_info->user_cb[event] = NULL;
1603 cb_info->user_data[event] = NULL;
1604 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1608 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1609 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1612 CAM_LOG_WARNING("unhandled event %d", event);
1616 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1619 static gboolean __camera_idle_event_callback(gpointer data)
1621 camera_cb_info_s *cb_info = NULL;
1622 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1624 if (cam_idle_event == NULL) {
1625 CAM_LOG_ERROR("cam_idle_event is NULL");
1630 g_mutex_lock(&g_cam_idle_event_lock);
1632 cb_info = cam_idle_event->cb_info;
1633 if (cb_info == NULL) {
1634 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1635 g_mutex_unlock(&g_cam_idle_event_lock);
1636 goto IDLE_EVENT_CALLBACK_DONE;
1639 /* remove event from list */
1640 if (cb_info->idle_event_list)
1641 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1643 g_mutex_unlock(&g_cam_idle_event_lock);
1646 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1648 IDLE_EVENT_CALLBACK_DONE:
1650 g_free(cam_idle_event);
1651 cam_idle_event = NULL;
1656 static gpointer __camera_msg_handler_func(gpointer data)
1660 camera_message_s *cam_msg = NULL;
1661 camera_idle_event_s *cam_idle_event = NULL;
1662 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1663 camera_cb_info_s *cb_info = NULL;
1664 GThread *thread = NULL;
1666 if (!handler_info || !handler_info->cb_info) {
1667 CAM_LOG_ERROR("NULL handler %p", handler_info);
1671 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1672 type = handler_info->type;
1673 thread = handler_info->thread;
1675 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1677 g_mutex_lock(&handler_info->mutex);
1679 while (g_atomic_int_get(&handler_info->running)) {
1680 if (g_queue_is_empty(handler_info->queue)) {
1681 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1682 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1683 CAM_LOG_VERBOSE("t[%d] signal received", type);
1685 if (g_atomic_int_get(&handler_info->running) == 0) {
1686 CAM_LOG_INFO("t:%d stop event thread", type);
1691 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1693 g_mutex_unlock(&handler_info->mutex);
1695 if (cam_msg == NULL) {
1696 CAM_LOG_ERROR("t:%d NULL message", type);
1697 g_mutex_lock(&handler_info->mutex);
1703 if (api < MUSE_CAMERA_API_MAX) {
1706 g_mutex_lock(&cb_info->api_mutex[api]);
1708 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1709 if (cb_info->api_waiting[api] > 0) {
1710 cb_info->api_ret[api] = ret;
1711 cb_info->api_activating[api] = TRUE;
1713 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1715 g_cond_broadcast(&cb_info->api_cond[api]);
1717 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1720 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1723 g_mutex_unlock(&cb_info->api_mutex[api]);
1724 } else if (api == MUSE_CAMERA_CB_EVENT) {
1725 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1726 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1727 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1730 switch (cam_msg->event_class) {
1731 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1732 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1734 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1735 cam_idle_event = g_new0(camera_idle_event_s, 1);
1736 if (cam_idle_event == NULL) {
1737 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1741 cam_idle_event->event = cam_msg->event;
1742 cam_idle_event->cb_info = cb_info;
1744 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1745 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1747 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1748 type, cam_msg->event, cam_idle_event);
1750 g_mutex_lock(&g_cam_idle_event_lock);
1751 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1752 g_mutex_unlock(&g_cam_idle_event_lock);
1754 g_idle_add_full(G_PRIORITY_DEFAULT,
1755 (GSourceFunc)__camera_idle_event_callback,
1756 (gpointer)cam_idle_event,
1760 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1764 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1770 g_mutex_lock(&handler_info->mutex);
1773 /* remove remained event */
1774 while (!g_queue_is_empty(handler_info->queue)) {
1775 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1777 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1778 __camera_release_tfd(cam_msg->tfd);
1781 CAM_LOG_WARNING("t:%d NULL message", type);
1785 g_mutex_unlock(&handler_info->mutex);
1787 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1793 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1795 camera_idle_event_s *cam_idle_event = NULL;
1798 if (cb_info == NULL) {
1799 CAM_LOG_ERROR("cb_info is NULL");
1803 g_mutex_lock(&g_cam_idle_event_lock);
1805 if (cb_info->idle_event_list == NULL) {
1806 CAM_LOG_INFO("No remained idle event");
1807 g_mutex_unlock(&g_cam_idle_event_lock);
1811 list = cb_info->idle_event_list;
1814 cam_idle_event = list->data;
1815 list = g_list_next(list);
1817 if (!cam_idle_event) {
1818 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1822 if (g_idle_remove_by_data(cam_idle_event)) {
1823 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1825 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1827 g_free(cam_idle_event);
1828 cam_idle_event = NULL;
1833 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1834 cam_idle_event, cam_idle_event->event);
1836 cam_idle_event->cb_info = NULL;
1838 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1841 g_list_free(cb_info->idle_event_list);
1842 cb_info->idle_event_list = NULL;
1844 g_mutex_unlock(&g_cam_idle_event_lock);
1848 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1850 camera_message_s *cam_msg = NULL;
1852 if (!cb_info || !msg) {
1853 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1857 cam_msg = g_new0(camera_message_s, 1);
1859 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1864 cam_msg->event = event;
1865 cam_msg->event_class = event_class;
1868 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1870 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1872 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1873 api, event, event_class);
1875 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1876 if (!cb_info->preview_cb_info.thread) {
1877 LOGI("The thread for preview cb is not created yet, create it now");
1878 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1879 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1880 CAM_LOG_ERROR("failed to create thread for preview cb");
1886 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1887 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1888 g_cond_signal(&cb_info->preview_cb_info.cond);
1889 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1890 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1891 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1892 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1893 g_cond_signal(&cb_info->capture_cb_info.cond);
1894 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1896 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1897 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1898 g_cond_signal(&cb_info->msg_handler_info.cond);
1899 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1906 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1908 int ret = CAMERA_ERROR_NONE;
1912 int event_class = -1;
1916 if (!cb_info || !msg) {
1917 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1921 CAM_LOG_DEBUG("msg[%s]", msg);
1923 if (!muse_camera_msg_get(api, msg)) {
1924 CAM_LOG_ERROR("failed to get camera api");
1928 if (api == MUSE_CAMERA_CB_EVENT) {
1929 if (!muse_camera_msg_get(event, msg) ||
1930 !muse_camera_msg_get(event_class, msg)) {
1931 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1935 if (!muse_camera_msg_get(api_class, msg)) {
1936 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1941 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1942 if (api >= MUSE_CAMERA_API_MAX) {
1943 CAM_LOG_ERROR("invalid api %d", api);
1947 if (!muse_camera_msg_get(ret, msg)) {
1948 CAM_LOG_ERROR("failed to get camera ret");
1952 g_mutex_lock(&cb_info->api_mutex[api]);
1955 case MUSE_CAMERA_API_CREATE:
1956 if (ret != CAMERA_ERROR_NONE) {
1957 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1958 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1961 case MUSE_CAMERA_API_DESTROY:
1962 if (ret == CAMERA_ERROR_NONE) {
1963 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1964 CAM_LOG_INFO("camera destroy done. close client cb handler");
1968 muse_camera_msg_get(get_type, msg);
1969 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1970 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1971 muse_camera_msg_get(get_index, msg);
1974 case MUSE_CAMERA_GET_TYPE_INT:
1975 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1977 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1978 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1979 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1981 case MUSE_CAMERA_GET_TYPE_ARRAY:
1983 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
1984 muse_core_msg_deserialize("get_value",
1985 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1986 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1987 cb_info->get_display_roi_area[0],
1988 cb_info->get_display_roi_area[1],
1989 cb_info->get_display_roi_area[2],
1990 cb_info->get_display_roi_area[3]);
1992 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
1993 muse_core_msg_deserialize("get_value",
1994 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1995 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
1996 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1998 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
1999 muse_core_msg_deserialize("get_value",
2000 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2001 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2002 cb_info->get_extra_preview_stream_format[0],
2003 cb_info->get_extra_preview_stream_format[1],
2004 cb_info->get_extra_preview_stream_format[2],
2005 cb_info->get_extra_preview_stream_format[3]);
2008 CAM_LOG_WARNING("unknown api[%d]", api);
2012 case MUSE_CAMERA_GET_TYPE_STRING:
2013 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2016 CAM_LOG_WARNING("unknown type %d", get_type);
2023 if (cb_info->api_waiting[api] > 0) {
2024 cb_info->api_ret[api] = ret;
2025 cb_info->api_activating[api] = TRUE;
2027 g_cond_broadcast(&cb_info->api_cond[api]);
2029 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2032 g_mutex_unlock(&cb_info->api_mutex[api]);
2033 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2034 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2036 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2041 static gpointer __camera_msg_recv_func(gpointer data)
2044 int recv_length = 0;
2045 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2046 char *recv_msg = NULL;
2047 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2050 CAM_LOG_ERROR("cb_info NULL");
2054 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2056 recv_msg = cb_info->recv_msg;
2058 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2059 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2060 tfd[i] = CAMERA_FD_INIT;
2062 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2063 if (recv_length <= 0) {
2064 cb_info->is_server_connected = FALSE;
2065 CAM_LOG_ERROR("receive msg failed - server disconnected");
2069 if (CAMERA_IS_FD_VALID(tfd[0]))
2070 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2072 recv_msg[recv_length] = '\0';
2074 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2076 __camera_process_msg(cb_info, recv_msg, tfd);
2079 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2082 if (!cb_info->is_server_connected) {
2083 char *error_msg = NULL;
2085 if (cb_info->bufmgr == NULL) {
2086 CAM_LOG_ERROR("No need to send error(handle is not created)");
2090 if (cb_info->fd < 0) {
2091 CAM_LOG_ERROR("fd is closed in client side");
2095 /* send error msg for server disconnection */
2096 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2097 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2098 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2102 CAM_LOG_ERROR("error_msg failed");
2106 __camera_add_msg_to_queue(cb_info,
2107 MUSE_CAMERA_CB_EVENT,
2108 MUSE_CAMERA_EVENT_TYPE_ERROR,
2109 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2113 muse_core_msg_free(error_msg);
2116 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2117 if (cb_info->api_waiting[i])
2118 g_cond_broadcast(&cb_info->api_cond[i]);
2121 CAM_LOG_ERROR("add error msg for service disconnection done");
2129 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2130 int type, const char *thread_name, camera_cb_info_s *cb_info)
2132 if (!handler_info || !thread_name || !cb_info) {
2133 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2134 type, handler_info, thread_name, cb_info);
2138 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2140 if (handler_info->thread) {
2141 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2145 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2147 handler_info->type = type;
2148 handler_info->queue = g_queue_new();
2149 if (handler_info->queue == NULL) {
2150 CAM_LOG_ERROR("t:%d queue failed", type);
2154 handler_info->cb_info = (void *)cb_info;
2155 g_atomic_int_set(&handler_info->running, 1);
2157 handler_info->thread = g_thread_try_new(thread_name,
2158 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2159 if (handler_info->thread == NULL) {
2160 CAM_LOG_ERROR("t:%d thread failed", type);
2162 g_queue_free(handler_info->queue);
2163 handler_info->queue = NULL;
2168 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2174 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2176 GThread *thread = NULL;
2178 if (!handler_info) {
2179 CAM_LOG_ERROR("NULL handler");
2183 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2185 if (!handler_info->thread) {
2186 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2190 thread = handler_info->thread;
2191 handler_info->thread = NULL;
2193 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2195 g_atomic_int_set(&handler_info->running, 0);
2196 g_cond_signal(&handler_info->cond);
2198 g_clear_pointer(&locker, g_mutex_locker_free);
2200 g_thread_join(thread);
2202 g_queue_free(handler_info->queue);
2203 handler_info->queue = NULL;
2205 CAM_LOG_INFO("t:%d done", handler_info->type);
2209 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2214 CAM_LOG_ERROR("NULL cb_info");
2218 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2219 g_mutex_init(&cb_info->api_mutex[i]);
2220 g_cond_init(&cb_info->api_cond[i]);
2223 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2224 g_mutex_init(&cb_info->user_cb_mutex[i]);
2226 g_mutex_init(&cb_info->fd_lock);
2227 g_mutex_init(&cb_info->mp_data_mutex);
2228 g_mutex_init(&cb_info->bridge_lock);
2230 g_mutex_init(&cb_info->msg_handler_info.mutex);
2231 g_mutex_init(&cb_info->preview_cb_info.mutex);
2232 g_mutex_init(&cb_info->capture_cb_info.mutex);
2233 g_cond_init(&cb_info->msg_handler_info.cond);
2234 g_cond_init(&cb_info->preview_cb_info.cond);
2235 g_cond_init(&cb_info->capture_cb_info.cond);
2237 CAM_LOG_INFO("done");
2241 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2246 CAM_LOG_ERROR("NULL cb_info");
2250 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2251 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2252 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2253 g_cond_clear(&cb_info->msg_handler_info.cond);
2254 g_cond_clear(&cb_info->preview_cb_info.cond);
2255 g_cond_clear(&cb_info->capture_cb_info.cond);
2257 g_mutex_clear(&cb_info->fd_lock);
2258 g_mutex_clear(&cb_info->mp_data_mutex);
2259 g_mutex_clear(&cb_info->bridge_lock);
2261 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2262 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2264 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2265 g_mutex_clear(&cb_info->api_mutex[i]);
2266 g_cond_clear(&cb_info->api_cond[i]);
2269 CAM_LOG_INFO("done");
2273 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2275 camera_cb_info_s *cb_info = NULL;
2278 g_return_val_if_fail(sockfd > 0, NULL);
2280 cb_info = g_new0(camera_cb_info_s, 1);
2282 CAM_LOG_ERROR("cb_info failed");
2286 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2288 __camera_mutex_cond_init(cb_info);
2290 /* message handler thread */
2291 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2292 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2293 CAM_LOG_ERROR("msg_handler_info failed");
2297 /* message handler thread for capture callback */
2298 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2299 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2300 CAM_LOG_ERROR("capture_cb_info failed");
2304 cb_info->fd = sockfd;
2306 /* message receive thread */
2307 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2308 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2309 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2310 if (cb_info->msg_recv_thread == NULL) {
2311 CAM_LOG_ERROR("message receive thread creation failed");
2316 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2317 cb_info->fds[i] = CAMERA_FD_INIT;
2319 cb_info->is_server_connected = TRUE;
2325 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2326 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2328 __camera_mutex_cond_clear(cb_info);
2339 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2342 CAM_LOG_ERROR("NULL cb_info");
2346 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2348 g_thread_join(cb_info->msg_recv_thread);
2349 cb_info->msg_recv_thread = NULL;
2351 CAM_LOG_INFO("msg_recv thread removed");
2353 /* destroy msg handler threads */
2354 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2355 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2356 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2358 __camera_mutex_cond_clear(cb_info);
2360 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2361 muse_client_close(cb_info->fd);
2362 cb_info->fd = CAMERA_FD_INIT;
2365 if (cb_info->bufmgr) {
2366 tbm_bufmgr_deinit(cb_info->bufmgr);
2367 cb_info->bufmgr = NULL;
2369 if (cb_info->pkt_fmt) {
2370 media_format_unref(cb_info->pkt_fmt);
2371 cb_info->pkt_fmt = NULL;
2374 if (cb_info->dp_interface) {
2375 mm_display_interface_deinit(cb_info->dp_interface);
2376 cb_info->dp_interface = NULL;
2383 int _camera_start_evas_rendering(camera_h camera)
2385 camera_cli_s *pc = (camera_cli_s *)camera;
2387 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2389 CAM_LOG_INFO("start");
2391 if (!pc->cb_info->is_evas_render) {
2392 CAM_LOG_ERROR("EVAS surface is not set");
2393 return CAMERA_ERROR_NONE;
2396 /* set evas render flag as RUN */
2397 pc->cb_info->run_evas_render = true;
2399 return CAMERA_ERROR_NONE;
2403 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2405 int ret = CAMERA_ERROR_NONE;
2406 camera_cli_s *pc = (camera_cli_s *)camera;
2408 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2410 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2412 if (!pc->cb_info->is_evas_render) {
2413 CAM_LOG_ERROR("EVAS surface is not set");
2414 return CAMERA_ERROR_NONE;
2417 /* set evas render flag as STOP and release buffers */
2418 pc->cb_info->run_evas_render = false;
2420 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2421 if (ret == MM_ERROR_NONE) {
2422 ret = CAMERA_ERROR_NONE;
2424 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2425 ret = CAMERA_ERROR_INVALID_OPERATION;
2432 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2434 int ret = CAMERA_ERROR_NONE;
2435 int sock_fd = CAMERA_FD_INIT;
2436 int module_index = -1;
2438 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2440 /* create muse connection */
2441 if (!key || !value) {
2442 CAM_LOG_ERROR("NULL pointer");
2443 return CAMERA_ERROR_INVALID_PARAMETER;
2446 sock_fd = muse_client_new();
2448 CAM_LOG_ERROR("muse_client_new failed");
2449 return CAMERA_ERROR_INVALID_OPERATION;
2452 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2453 CAM_LOG_ERROR("muse client get module index failed");
2454 ret = CAMERA_ERROR_INVALID_OPERATION;
2458 msg = muse_core_msg_new(api,
2459 MUSE_TYPE_INT, "module", module_index,
2460 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2463 CAM_LOG_ERROR("msg failed");
2464 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2468 ret = muse_core_msg_send(sock_fd, msg);
2470 muse_core_msg_free(msg);
2474 CAM_LOG_ERROR("send msg failed");
2475 ret = CAMERA_ERROR_INVALID_OPERATION;
2479 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2481 CAM_LOG_ERROR("recv msg failed %d", errno);
2482 ret = CAMERA_ERROR_INVALID_OPERATION;
2486 if (!muse_camera_msg_get(ret, recv_msg)) {
2487 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2488 ret = CAMERA_ERROR_INVALID_OPERATION;
2492 if (ret == CAMERA_ERROR_NONE)
2493 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2495 CAM_LOG_INFO("api %d - value %d", api, *value);
2498 if (CAMERA_IS_FD_VALID(sock_fd)) {
2499 muse_client_close(sock_fd);
2500 sock_fd = CAMERA_FD_INIT;
2507 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2509 int sock_fd = CAMERA_FD_INIT;
2510 char *send_msg = NULL;
2512 int ret = CAMERA_ERROR_NONE;
2513 camera_cli_s *pc = NULL;
2514 tbm_bufmgr bufmgr = NULL;
2516 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2517 int module_index = -1;
2518 int device_type = (int)device;
2520 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2522 sock_fd = muse_client_new();
2524 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2525 ret = CAMERA_ERROR_INVALID_OPERATION;
2529 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2530 CAM_LOG_ERROR("muse client get module index failed");
2531 ret = CAMERA_ERROR_INVALID_OPERATION;
2535 send_msg = muse_core_msg_new(api,
2536 MUSE_TYPE_INT, "module", module_index,
2537 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2538 MUSE_TYPE_INT, "is_network", (int)is_network,
2542 CAM_LOG_ERROR("NULL msg");
2543 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2547 send_ret = muse_core_msg_send(sock_fd, send_msg);
2549 muse_core_msg_free(send_msg);
2553 CAM_LOG_ERROR("send msg failed %d", errno);
2554 ret = CAMERA_ERROR_INVALID_OPERATION;
2558 pc = g_new0(camera_cli_s, 1);
2560 CAM_LOG_ERROR("camera_cli_s alloc failed");
2561 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2565 bufmgr = tbm_bufmgr_init(-1);
2566 if (bufmgr == NULL) {
2567 CAM_LOG_ERROR("get tbm bufmgr failed");
2568 ret = CAMERA_ERROR_INVALID_OPERATION;
2572 pc->cb_info = __camera_client_callback_new(sock_fd);
2573 if (pc->cb_info == NULL) {
2574 CAM_LOG_ERROR("cb_info alloc failed");
2575 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2579 sock_fd = CAMERA_FD_INIT;
2581 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2583 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2585 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2587 if (ret == CAMERA_ERROR_NONE) {
2588 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2589 int user_buffer_supported = 0;
2590 int log_level = CAMERA_LOG_LEVEL_INFO;
2591 intptr_t handle = 0;
2593 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2595 CAM_LOG_ERROR("Receiving Handle Failed!!");
2596 ret = CAMERA_ERROR_INVALID_OPERATION;
2600 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2601 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2602 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2604 pc->remote_handle = handle;
2605 pc->cb_info->bufmgr = bufmgr;
2606 pc->cb_info->preview_format = preview_format;
2607 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2608 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2609 pc->cb_info->is_network = is_network;
2610 g_camera_log_level = log_level;
2612 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2613 preview_format, user_buffer_supported, g_camera_log_level);
2616 CAM_LOG_ERROR("NULL out handle");
2617 ret= CAMERA_ERROR_INVALID_PARAMETER;
2621 *camera = (camera_h)pc;
2623 /* get display interface handle */
2624 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2625 CAM_LOG_WARNING("display interface init failed");
2634 tbm_bufmgr_deinit(bufmgr);
2638 if (CAMERA_IS_FD_VALID(sock_fd)) {
2639 muse_client_close(sock_fd);
2640 sock_fd = CAMERA_FD_INIT;
2645 int temp_fd = pc->cb_info->fd;
2647 /* pc->cb_info->fd should be closed,
2648 because g_thread_join for msg_recv_thread is not returned
2649 in __camera_client_callback_destroy. */
2650 if (CAMERA_IS_FD_VALID(temp_fd)) {
2651 pc->cb_info->fd = CAMERA_FD_INIT;
2652 muse_client_close(temp_fd);
2655 __camera_client_callback_destroy(pc->cb_info);
2662 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2669 int camera_create(camera_device_e device, camera_h *camera)
2671 return _camera_create_private(device, false, camera);
2675 int camera_change_device(camera_h camera, camera_device_e device)
2678 int ret = CAMERA_ERROR_NONE;
2679 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2680 camera_cli_s *pc = (camera_cli_s *)camera;
2681 camera_msg_param param;
2683 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2685 CAMERA_MSG_PARAM_SET(param, INT, device);
2687 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2689 if (ret == CAMERA_ERROR_NONE) {
2690 /* reset callback and user data */
2691 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2692 pc->cb_info->user_cb[i] = NULL;
2693 pc->cb_info->user_data[i] = NULL;
2701 int camera_destroy(camera_h camera)
2703 int ret = CAMERA_ERROR_NONE;
2704 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2705 camera_cli_s *pc = (camera_cli_s *)camera;
2707 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2709 CAM_LOG_INFO("Enter");
2711 if (pc->cb_info->is_server_connected)
2712 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2714 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2716 if (ret == CAMERA_ERROR_NONE) {
2717 __camera_deactivate_idle_event_all(pc->cb_info);
2718 __camera_client_callback_destroy(pc->cb_info);
2725 CAM_LOG_INFO("ret : 0x%x", ret);
2730 int camera_start_preview(camera_h camera)
2732 int ret = CAMERA_ERROR_NONE;
2734 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2735 camera_cli_s *pc = (camera_cli_s *)camera;
2736 camera_state_e current_state = CAMERA_STATE_NONE;
2738 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2740 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2741 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2743 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2744 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2745 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2746 pc->cb_info->dp_info.type);
2747 return CAMERA_ERROR_INVALID_OPERATION;
2750 ret = camera_get_state(camera, ¤t_state);
2751 if (ret != CAMERA_ERROR_NONE) {
2752 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2756 if (current_state == CAMERA_STATE_CREATED) {
2757 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2758 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2759 CAM_LOG_ERROR("preview_cb_info failed");
2760 return CAMERA_ERROR_INVALID_OPERATION;
2763 if (pc->cb_info->user_buffer_supported) {
2764 if (!__camera_allocate_preview_buffer(camera)) {
2765 ret = CAMERA_ERROR_INVALID_OPERATION;
2769 fds = pc->cb_info->fds;
2773 _camera_msg_send(api, fds, pc->cb_info, &ret,
2774 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2775 CAMERA_CB_NO_TIMEOUT);
2777 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2779 if (ret != CAMERA_ERROR_NONE)
2782 if (pc->cb_info->is_evas_render) {
2783 ret = _camera_start_evas_rendering(camera);
2784 if (ret != CAMERA_ERROR_NONE) {
2785 CAM_LOG_ERROR("stop preview because of error");
2786 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2791 CAM_LOG_INFO("done");
2793 return CAMERA_ERROR_NONE;
2796 if (current_state == CAMERA_STATE_CREATED) {
2797 if (pc->cb_info->user_buffer_supported)
2798 __camera_release_preview_buffer(camera);
2800 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2803 CAM_LOG_ERROR("failed : 0x%x", ret);
2809 int camera_stop_preview(camera_h camera)
2811 int ret = CAMERA_ERROR_NONE;
2812 camera_cli_s *pc = (camera_cli_s *)camera;
2813 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2814 camera_state_e current_state = CAMERA_STATE_NONE;
2816 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2818 CAM_LOG_INFO("Enter");
2821 if (pc->cb_info->is_evas_render) {
2822 ret = camera_get_state(camera, ¤t_state);
2823 if (ret != CAMERA_ERROR_NONE) {
2824 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2828 if (current_state == CAMERA_STATE_PREVIEW) {
2829 ret = _camera_stop_evas_rendering(camera, false);
2830 if (ret != CAMERA_ERROR_NONE)
2835 /* send stop preview message */
2836 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2838 if (ret == CAMERA_ERROR_NONE) {
2839 if (pc->cb_info->user_buffer_supported)
2840 __camera_release_preview_buffer(camera);
2842 /* release remained message for preview callback */
2843 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2844 } else if (current_state == CAMERA_STATE_PREVIEW) {
2845 CAM_LOG_WARNING("restart evas rendering");
2846 _camera_start_evas_rendering(camera);
2849 CAM_LOG_INFO("ret : 0x%x", ret);
2855 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2857 int ret = CAMERA_ERROR_NONE;
2858 camera_cli_s *pc = (camera_cli_s *)camera;
2859 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2861 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2863 CAM_LOG_INFO("Enter");
2865 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2866 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2868 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2869 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2871 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2873 CAM_LOG_INFO("ret : 0x%x", ret);
2879 bool camera_is_supported_continuous_capture(camera_h camera)
2881 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2885 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)
2887 int ret = CAMERA_ERROR_NONE;
2888 camera_cli_s *pc = (camera_cli_s *)camera;
2889 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2890 camera_msg_param param;
2893 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2895 CAM_LOG_INFO("Enter");
2897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2900 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2901 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2903 value = (count << 16) | interval;
2904 CAMERA_MSG_PARAM_SET(param, INT, value);
2906 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2908 CAM_LOG_INFO("ret : 0x%x", ret);
2914 int camera_stop_continuous_capture(camera_h camera)
2916 int ret = CAMERA_ERROR_NONE;
2917 camera_cli_s *pc = (camera_cli_s *)camera;
2918 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2920 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2922 CAM_LOG_INFO("Enter");
2924 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2926 CAM_LOG_INFO("ret : 0x%x", ret);
2932 bool camera_is_supported_face_detection(camera_h camera)
2934 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2938 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2940 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2944 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2946 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2950 bool camera_is_supported_extra_preview(camera_h camera)
2952 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2956 int camera_get_device_count(camera_h camera, int *device_count)
2958 int ret = CAMERA_ERROR_NONE;
2959 camera_cli_s *pc = (camera_cli_s *)camera;
2960 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2962 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2964 CAM_LOG_INFO("Enter");
2966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2968 if (ret == CAMERA_ERROR_NONE)
2969 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2971 CAM_LOG_INFO("ret : 0x%x", ret);
2976 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2978 int ret = CAMERA_ERROR_NONE;
2979 camera_cli_s *pc = (camera_cli_s *)camera;
2980 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2982 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2984 CAM_LOG_INFO("Enter");
2986 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2988 if (ret == CAMERA_ERROR_NONE) {
2989 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2991 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2992 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2994 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2997 CAM_LOG_INFO("ret : 0x%x", ret);
3002 int camera_stop_face_detection(camera_h camera)
3004 int ret = CAMERA_ERROR_NONE;
3005 camera_cli_s *pc = (camera_cli_s *)camera;
3006 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3008 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3010 CAM_LOG_INFO("Enter");
3012 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3014 if (ret == CAMERA_ERROR_NONE) {
3015 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3017 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3018 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3020 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3023 CAM_LOG_INFO("ret : 0x%x", ret);
3028 int camera_get_state(camera_h camera, camera_state_e *state)
3030 int ret = CAMERA_ERROR_NONE;
3031 camera_cli_s *pc = (camera_cli_s *)camera;
3032 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3034 if (!pc || !pc->cb_info || !state) {
3035 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3036 return CAMERA_ERROR_INVALID_PARAMETER;
3039 CAM_LOG_INFO("Enter");
3041 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3043 if (ret == CAMERA_ERROR_NONE)
3044 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3046 CAM_LOG_INFO("ret : 0x%x", ret);
3051 int camera_start_focusing(camera_h camera, bool continuous)
3053 int ret = CAMERA_ERROR_NONE;
3054 camera_cli_s *pc = (camera_cli_s *)camera;
3055 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3056 camera_msg_param param;
3057 int is_continuous = (int)continuous;
3059 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3061 CAM_LOG_INFO("Enter");
3063 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3065 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3067 CAM_LOG_INFO("ret : 0x%x", ret);
3072 int camera_cancel_focusing(camera_h camera)
3074 int ret = CAMERA_ERROR_NONE;
3075 camera_cli_s *pc = (camera_cli_s *)camera;
3076 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3078 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3080 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3082 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3084 CAM_LOG_INFO("ret : 0x%x", ret);
3090 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3092 int mm_ret = MM_ERROR_NONE;
3093 int ret = CAMERA_ERROR_NONE;
3094 camera_cli_s *pc = (camera_cli_s *)camera;
3095 camera_cb_info_s *cb_info = NULL;
3096 camera_state_e current_state = CAMERA_STATE_NONE;
3097 camera_msg_param param;
3098 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3099 muse_camera_display_info_s *dp_info = NULL;
3101 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3103 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3104 CAM_LOG_ERROR("invalid type %d", type);
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3108 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3109 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3110 return CAMERA_ERROR_INVALID_PARAMETER;
3113 cb_info = (camera_cb_info_s *)pc->cb_info;
3114 dp_info = &cb_info->dp_info;
3116 ret = camera_get_state(camera, ¤t_state);
3117 if (ret != CAMERA_ERROR_NONE) {
3118 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3122 if (current_state != CAMERA_STATE_CREATED) {
3123 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3124 return CAMERA_ERROR_INVALID_STATE;
3127 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3129 if (type != MM_DISPLAY_TYPE_NONE) {
3130 /* check display interface handle */
3131 if (!cb_info->dp_interface) {
3132 CAM_LOG_ERROR("display interface not supported");
3133 return CAMERA_ERROR_NOT_SUPPORTED;
3136 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3137 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3138 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3139 return CAMERA_ERROR_NOT_SUPPORTED;
3140 } else if (mm_ret != MM_ERROR_NONE) {
3141 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3142 return CAMERA_ERROR_INVALID_OPERATION;
3145 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3146 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3148 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3149 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3150 dp_info->window_rect.width, dp_info->window_rect.height);
3151 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3153 camera_flip_e flip = CAMERA_FLIP_NONE;
3154 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3155 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3162 camera_get_display_flip(camera, &flip);
3163 camera_get_display_mode(camera, &mode);
3164 camera_get_display_rotation(camera, &rotation);
3165 camera_is_display_visible(camera, &visible);
3167 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3168 flip, mode, rotation, visible);
3170 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3171 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3172 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3173 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3175 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3176 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3177 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3178 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3184 if (mm_ret != MM_ERROR_NONE) {
3185 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3186 return CAMERA_ERROR_INVALID_OPERATION;
3189 dp_info->type = type;
3191 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3193 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3195 if (ret == CAMERA_ERROR_NONE)
3196 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3202 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3204 CAM_LOG_INFO("type %d, display %p", type, display);
3205 return _camera_set_display(camera, (mm_display_type_e)type, display);
3209 int camera_set_preview_resolution(camera_h camera, int width, int height)
3211 int ret = CAMERA_ERROR_NONE;
3212 camera_state_e current_state = CAMERA_STATE_NONE;
3213 camera_cli_s *pc = (camera_cli_s *)camera;
3214 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3215 camera_msg_param param;
3218 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3220 if (pc->cb_info->is_evas_render) {
3221 ret = camera_get_state(camera, ¤t_state);
3222 if (ret != CAMERA_ERROR_NONE) {
3223 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3227 if (current_state == CAMERA_STATE_PREVIEW) {
3228 ret = _camera_stop_evas_rendering(camera, true);
3229 if (ret != CAMERA_ERROR_NONE)
3234 value = (width << 16) | height;
3235 CAMERA_MSG_PARAM_SET(param, INT, value);
3237 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3239 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3241 CAM_LOG_INFO("ret : 0x%x", ret);
3243 if (current_state == CAMERA_STATE_PREVIEW) {
3244 CAM_LOG_WARNING("restart evas rendering");
3245 _camera_start_evas_rendering(camera);
3252 int camera_set_capture_resolution(camera_h camera, int width, int height)
3254 int ret = CAMERA_ERROR_NONE;
3255 camera_cli_s *pc = (camera_cli_s *)camera;
3256 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3257 camera_msg_param param;
3260 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3262 CAM_LOG_INFO("Enter");
3264 value = (width << 16) | height;
3265 CAMERA_MSG_PARAM_SET(param, INT, value);
3267 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3269 CAM_LOG_INFO("ret : 0x%x", ret);
3275 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3277 int ret = CAMERA_ERROR_NONE;
3278 int set_format = (int)format;
3279 camera_cli_s *pc = (camera_cli_s *)camera;
3280 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3281 camera_msg_param param;
3283 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3285 CAM_LOG_INFO("Enter - format %d", set_format);
3287 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3289 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3291 CAM_LOG_INFO("ret : 0x%x", ret);
3297 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3299 int ret = CAMERA_ERROR_NONE;
3300 int set_format = (int)format;
3301 camera_msg_param param;
3302 camera_cli_s *pc = (camera_cli_s *)camera;
3303 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3305 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3307 CAM_LOG_INFO("Enter - format %d", set_format);
3309 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3311 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3313 if (ret == CAMERA_ERROR_NONE)
3314 pc->cb_info->preview_format = set_format;
3316 CAM_LOG_INFO("ret : 0x%x", ret);
3322 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3324 int ret = CAMERA_ERROR_NONE;
3325 camera_cli_s *pc = (camera_cli_s *)camera;
3326 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3328 if (!pc || !pc->cb_info || !width || !height) {
3329 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3330 return CAMERA_ERROR_INVALID_PARAMETER;
3333 CAM_LOG_INFO("Enter");
3335 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3337 if (ret == CAMERA_ERROR_NONE) {
3338 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3339 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3342 CAM_LOG_INFO("ret : 0x%x", ret);
3348 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3350 int ret = CAMERA_ERROR_NONE;
3351 int set_rotation = (int)rotation;
3352 camera_cli_s *pc = (camera_cli_s *)camera;
3353 camera_msg_param param;
3355 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3357 if (pc->cb_info->is_evas_render) {
3358 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3359 if (ret != MM_ERROR_NONE) {
3360 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3361 return CAMERA_ERROR_INVALID_OPERATION;
3365 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3367 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3373 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3375 int ret = CAMERA_ERROR_NONE;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3378 if (!pc || !pc->cb_info || !rotation) {
3379 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3380 return CAMERA_ERROR_INVALID_PARAMETER;
3383 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3385 if (ret == CAMERA_ERROR_NONE)
3386 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3392 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3394 int ret = CAMERA_ERROR_NONE;
3395 int set_flip = (int)flip;
3396 camera_cli_s *pc = (camera_cli_s *)camera;
3397 camera_msg_param param;
3399 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3401 if (pc->cb_info->is_evas_render) {
3402 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3403 if (ret != MM_ERROR_NONE) {
3404 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3405 return CAMERA_ERROR_INVALID_OPERATION;
3409 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3411 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3417 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3419 int ret = CAMERA_ERROR_NONE;
3420 camera_cli_s *pc = (camera_cli_s *)camera;
3422 if (!pc || !pc->cb_info || !flip) {
3423 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3427 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3429 if (ret == CAMERA_ERROR_NONE)
3430 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3436 int camera_set_display_visible(camera_h camera, bool visible)
3438 int ret = CAMERA_ERROR_NONE;
3439 int set_visible = (int)visible;
3440 camera_cli_s *pc = (camera_cli_s *)camera;
3441 camera_msg_param param;
3443 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3445 if (pc->cb_info->is_evas_render) {
3446 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3447 if (ret != MM_ERROR_NONE) {
3448 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3449 return CAMERA_ERROR_INVALID_OPERATION;
3453 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3455 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3461 int camera_is_display_visible(camera_h camera, bool *visible)
3463 int ret = CAMERA_ERROR_NONE;
3464 camera_cli_s *pc = (camera_cli_s *)camera;
3466 if (!pc || !pc->cb_info || !visible) {
3467 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3468 return CAMERA_ERROR_INVALID_PARAMETER;
3471 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3473 if (ret == CAMERA_ERROR_NONE)
3474 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3480 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3482 int ret = CAMERA_ERROR_NONE;
3483 int set_mode = (int)mode;
3484 camera_cli_s *pc = (camera_cli_s *)camera;
3485 camera_msg_param param;
3487 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3489 if (pc->cb_info->is_evas_render) {
3490 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3491 if (ret != MM_ERROR_NONE) {
3492 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3493 return CAMERA_ERROR_INVALID_OPERATION;
3497 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3499 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3505 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3507 int ret = CAMERA_ERROR_NONE;
3508 camera_cli_s *pc = (camera_cli_s *)camera;
3510 if (!pc || !pc->cb_info || !mode) {
3511 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3512 return CAMERA_ERROR_INVALID_PARAMETER;
3515 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3517 if (ret == CAMERA_ERROR_NONE)
3518 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3524 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3526 int ret = CAMERA_ERROR_NONE;
3527 int set_hint = (int)hint;
3528 camera_cli_s *pc = (camera_cli_s *)camera;
3529 camera_msg_param param;
3531 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3533 CAM_LOG_INFO("Enter - hint %d", set_hint);
3535 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3537 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3543 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3545 int ret = CAMERA_ERROR_NONE;
3546 camera_cli_s *pc = (camera_cli_s *)camera;
3547 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3549 if (!pc || !pc->cb_info || !hint) {
3550 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3551 return CAMERA_ERROR_INVALID_PARAMETER;
3554 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3556 if (ret == CAMERA_ERROR_NONE) {
3557 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3558 CAM_LOG_INFO("display reuse hint %d", *hint);
3565 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3567 int ret = CAMERA_ERROR_NONE;
3568 camera_cli_s *pc = (camera_cli_s *)camera;
3569 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3571 if (!pc || !pc->cb_info || !width || !height) {
3572 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3573 return CAMERA_ERROR_INVALID_PARAMETER;
3576 CAM_LOG_INFO("Enter");
3578 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3580 if (ret == CAMERA_ERROR_NONE) {
3581 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3582 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3585 CAM_LOG_INFO("ret : 0x%x", ret);
3591 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3593 int ret = CAMERA_ERROR_NONE;
3594 camera_cli_s *pc = (camera_cli_s *)camera;
3595 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3597 if (!pc || !pc->cb_info || !format) {
3598 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3599 return CAMERA_ERROR_INVALID_PARAMETER;
3602 CAM_LOG_INFO("Enter");
3604 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3606 if (ret == CAMERA_ERROR_NONE)
3607 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3609 CAM_LOG_INFO("ret : 0x%x", ret);
3615 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3617 int ret = CAMERA_ERROR_NONE;
3618 camera_cli_s *pc = (camera_cli_s *)camera;
3619 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3621 if (!pc || !pc->cb_info || !format) {
3622 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3623 return CAMERA_ERROR_INVALID_PARAMETER;
3626 CAM_LOG_INFO("Enter");
3628 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3630 if (ret == CAMERA_ERROR_NONE)
3631 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3633 CAM_LOG_INFO("ret : 0x%x", ret);
3639 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3641 int ret = CAMERA_ERROR_NONE;
3642 camera_cli_s *pc = (camera_cli_s *)camera;
3643 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3645 if (!pc || !pc->cb_info || !facing_direction) {
3646 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3647 return CAMERA_ERROR_INVALID_PARAMETER;
3650 CAM_LOG_INFO("Enter");
3652 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3654 if (ret == CAMERA_ERROR_NONE)
3655 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3657 CAM_LOG_INFO("ret : 0x%x", ret);
3663 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3665 int ret = CAMERA_ERROR_NONE;
3666 camera_cli_s *pc = (camera_cli_s *)camera;
3667 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3669 if (!pc || !pc->cb_info || !callback) {
3670 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3671 return CAMERA_ERROR_INVALID_PARAMETER;
3674 CAM_LOG_INFO("Enter");
3676 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3678 if (ret == CAMERA_ERROR_NONE) {
3679 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3681 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3682 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3684 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3687 CAM_LOG_INFO("ret : 0x%x", ret);
3693 int camera_unset_preview_cb(camera_h camera)
3695 int ret = CAMERA_ERROR_NONE;
3696 camera_cli_s *pc = (camera_cli_s *)camera;
3697 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3699 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3701 CAM_LOG_INFO("Enter");
3703 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3705 if (ret == CAMERA_ERROR_NONE) {
3706 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3708 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3709 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3711 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3714 CAM_LOG_INFO("ret : 0x%x", ret);
3720 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3722 int ret = CAMERA_ERROR_NONE;
3723 camera_cli_s *pc = (camera_cli_s *)camera;
3724 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3726 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3728 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3729 CAM_LOG_ERROR("NOT SUPPORTED");
3730 return CAMERA_ERROR_NOT_SUPPORTED;
3733 if (callback == NULL) {
3734 CAM_LOG_ERROR("NULL callback");
3735 return CAMERA_ERROR_INVALID_PARAMETER;
3738 CAM_LOG_INFO("Enter");
3740 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3742 if (ret == CAMERA_ERROR_NONE) {
3743 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3745 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3746 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3748 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3751 CAM_LOG_INFO("ret : 0x%x", ret);
3757 int camera_unset_media_packet_preview_cb(camera_h camera)
3759 int ret = CAMERA_ERROR_NONE;
3760 camera_cli_s *pc = (camera_cli_s *)camera;
3761 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3763 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3765 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3766 CAM_LOG_ERROR("NOT SUPPORTED");
3767 return CAMERA_ERROR_NOT_SUPPORTED;
3770 CAM_LOG_INFO("Enter");
3772 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3774 if (ret == CAMERA_ERROR_NONE) {
3775 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3777 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3778 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3780 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3783 CAM_LOG_INFO("ret : 0x%x", ret);
3789 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3791 int ret = CAMERA_ERROR_NONE;
3792 camera_cli_s *pc = (camera_cli_s *)camera;
3793 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3795 if (!pc || !pc->cb_info || !callback) {
3796 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3797 return CAMERA_ERROR_INVALID_PARAMETER;
3800 CAM_LOG_INFO("Enter");
3802 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3804 if (ret == CAMERA_ERROR_NONE) {
3805 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3807 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3808 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3810 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3813 CAM_LOG_INFO("ret : 0x%x", ret);
3819 int camera_unset_state_changed_cb(camera_h camera)
3821 int ret = CAMERA_ERROR_NONE;
3822 camera_cli_s *pc = (camera_cli_s *)camera;
3823 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3825 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3827 CAM_LOG_INFO("Enter");
3829 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3831 if (ret == CAMERA_ERROR_NONE) {
3832 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3834 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3835 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3837 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3840 CAM_LOG_INFO("ret : 0x%x", ret);
3846 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3848 int ret = CAMERA_ERROR_NONE;
3849 camera_cli_s *pc = (camera_cli_s *)camera;
3850 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3852 if (!pc || !pc->cb_info || !callback) {
3853 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3854 return CAMERA_ERROR_INVALID_PARAMETER;
3857 CAM_LOG_INFO("Enter");
3859 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3861 if (ret == CAMERA_ERROR_NONE) {
3862 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3867 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3870 CAM_LOG_INFO("ret : 0x%x", ret);
3876 int camera_unset_interrupted_cb(camera_h camera)
3878 int ret = CAMERA_ERROR_NONE;
3879 camera_cli_s *pc = (camera_cli_s *)camera;
3880 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3882 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3884 CAM_LOG_INFO("Enter");
3886 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3888 if (ret == CAMERA_ERROR_NONE) {
3889 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3891 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3892 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3894 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3897 CAM_LOG_INFO("ret : 0x%x", ret);
3903 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3905 int ret = CAMERA_ERROR_NONE;
3906 camera_cli_s *pc = (camera_cli_s *)camera;
3907 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3909 if (!pc || !pc->cb_info || !callback) {
3910 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3911 return CAMERA_ERROR_INVALID_PARAMETER;
3914 CAM_LOG_INFO("Enter");
3916 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3918 if (ret == CAMERA_ERROR_NONE) {
3919 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3921 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3922 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3924 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3927 CAM_LOG_INFO("ret : 0x%x", ret);
3933 int camera_unset_interrupt_started_cb(camera_h camera)
3935 int ret = CAMERA_ERROR_NONE;
3936 camera_cli_s *pc = (camera_cli_s *)camera;
3937 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3939 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3941 CAM_LOG_INFO("Enter");
3943 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3945 if (ret == CAMERA_ERROR_NONE) {
3946 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3951 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3954 CAM_LOG_INFO("ret : 0x%x", ret);
3960 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3962 int ret = CAMERA_ERROR_NONE;
3963 camera_cli_s *pc = (camera_cli_s *)camera;
3964 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3966 if (!pc || !pc->cb_info || !callback) {
3967 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3968 return CAMERA_ERROR_INVALID_PARAMETER;
3971 CAM_LOG_INFO("Enter");
3973 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3975 if (ret == CAMERA_ERROR_NONE) {
3976 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3978 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3979 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3981 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3984 CAM_LOG_INFO("ret : 0x%x", ret);
3990 int camera_unset_focus_changed_cb(camera_h camera)
3992 int ret = CAMERA_ERROR_NONE;
3993 camera_cli_s *pc = (camera_cli_s *)camera;
3994 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3996 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3998 CAM_LOG_INFO("Enter");
4000 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4002 if (ret == CAMERA_ERROR_NONE) {
4003 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4005 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4006 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4008 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4011 CAM_LOG_INFO("ret : 0x%x", ret);
4017 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4019 int ret = CAMERA_ERROR_NONE;
4020 camera_cli_s *pc = (camera_cli_s *)camera;
4021 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4023 if (!pc || !pc->cb_info || !callback) {
4024 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4025 return CAMERA_ERROR_INVALID_PARAMETER;
4028 CAM_LOG_INFO("Enter");
4030 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4032 if (ret == CAMERA_ERROR_NONE) {
4033 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4035 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4036 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4038 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4041 CAM_LOG_INFO("ret : 0x%x", ret);
4047 int camera_unset_error_cb(camera_h camera)
4049 int ret = CAMERA_ERROR_NONE;
4050 camera_cli_s *pc = (camera_cli_s *)camera;
4051 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4053 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4055 CAM_LOG_INFO("Enter");
4057 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4059 if (ret == CAMERA_ERROR_NONE) {
4060 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4062 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4063 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4065 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4068 CAM_LOG_INFO("ret : 0x%x", ret);
4074 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4076 int ret = CAMERA_ERROR_NONE;
4077 camera_cli_s *pc = (camera_cli_s *)camera;
4078 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4080 if (!pc || !pc->cb_info || !foreach_cb) {
4081 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4082 return CAMERA_ERROR_INVALID_PARAMETER;
4085 CAM_LOG_INFO("Enter");
4087 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4088 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4090 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4092 CAM_LOG_INFO("ret : 0x%x", ret);
4098 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4100 int ret = CAMERA_ERROR_NONE;
4101 camera_cli_s *pc = (camera_cli_s *)camera;
4102 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4104 if (!pc || !pc->cb_info || !foreach_cb) {
4105 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4106 return CAMERA_ERROR_INVALID_PARAMETER;
4109 CAM_LOG_INFO("Enter");
4111 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4112 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4114 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4116 CAM_LOG_INFO("ret : 0x%x", ret);
4122 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4124 int ret = CAMERA_ERROR_NONE;
4125 camera_cli_s *pc = (camera_cli_s *)camera;
4126 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4128 if (!pc || !pc->cb_info || !foreach_cb) {
4129 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4130 return CAMERA_ERROR_INVALID_PARAMETER;
4133 CAM_LOG_INFO("Enter");
4135 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4136 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4140 CAM_LOG_INFO("ret : 0x%x", ret);
4146 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4148 int ret = CAMERA_ERROR_NONE;
4149 camera_cli_s *pc = (camera_cli_s *)camera;
4150 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4152 if (!pc || !pc->cb_info || !foreach_cb) {
4153 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4154 return CAMERA_ERROR_INVALID_PARAMETER;
4157 CAM_LOG_INFO("Enter");
4159 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4160 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4164 CAM_LOG_INFO("ret : 0x%x", ret);
4170 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4172 int ret = CAMERA_ERROR_NONE;
4173 camera_cli_s *pc = (camera_cli_s *)camera;
4174 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4176 if (!pc || !pc->cb_info || !width || !height) {
4177 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4178 return CAMERA_ERROR_INVALID_PARAMETER;
4181 CAM_LOG_INFO("Enter");
4182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4184 if (ret == CAMERA_ERROR_NONE) {
4185 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4186 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4189 CAM_LOG_INFO("ret : 0x%x", ret);
4195 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4197 int ret = CAMERA_ERROR_NONE;
4198 camera_cli_s *pc = (camera_cli_s *)camera;
4199 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4201 if (!pc || !pc->cb_info || !angle) {
4202 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4203 return CAMERA_ERROR_INVALID_PARAMETER;
4206 CAM_LOG_INFO("Enter");
4208 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4210 if (ret == CAMERA_ERROR_NONE)
4211 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4213 CAM_LOG_INFO("ret : 0x%x", ret);
4219 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4221 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4225 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4227 int ret = CAMERA_ERROR_NONE;
4228 camera_cli_s *pc = (camera_cli_s *)camera;
4229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4231 if (!pc || !pc->cb_info || !mode) {
4232 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4233 return CAMERA_ERROR_INVALID_PARAMETER;
4236 CAM_LOG_INFO("Enter");
4238 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4240 if (ret == CAMERA_ERROR_NONE)
4241 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4243 CAM_LOG_INFO("ret : 0x%x", ret);
4249 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4251 int ret = CAMERA_ERROR_NONE;
4252 camera_cli_s *pc = (camera_cli_s *)camera;
4253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4255 if (!pc || !pc->cb_info || !foreach_cb) {
4256 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4257 return CAMERA_ERROR_INVALID_PARAMETER;
4260 CAM_LOG_INFO("Enter");
4262 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4263 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4265 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4267 CAM_LOG_INFO("Finish, return :%x", ret);
4273 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4275 int ret = CAMERA_ERROR_NONE;
4276 camera_cli_s *pc = (camera_cli_s *)camera;
4277 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4278 camera_msg_param param;
4279 int set_fps = (int)fps;
4281 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4283 CAM_LOG_INFO("Enter");
4285 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4287 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4289 CAM_LOG_INFO("ret : 0x%x", ret);
4295 int camera_attr_set_image_quality(camera_h camera, int quality)
4297 int ret = CAMERA_ERROR_NONE;
4298 camera_cli_s *pc = (camera_cli_s *)camera;
4299 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4300 camera_msg_param param;
4302 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4304 CAM_LOG_INFO("Enter");
4306 CAMERA_MSG_PARAM_SET(param, INT, quality);
4308 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4310 CAM_LOG_INFO("ret : 0x%x", ret);
4316 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4318 int ret = CAMERA_ERROR_NONE;
4319 camera_cli_s *pc = (camera_cli_s *)camera;
4320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4322 if (!pc || !pc->cb_info || !fps) {
4323 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4327 CAM_LOG_INFO("Enter");
4329 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4331 if (ret == CAMERA_ERROR_NONE)
4332 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4334 CAM_LOG_INFO("ret : 0x%x", ret);
4340 int camera_attr_get_image_quality(camera_h camera, int *quality)
4342 int ret = CAMERA_ERROR_NONE;
4343 camera_cli_s *pc = (camera_cli_s *)camera;
4344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4346 if (!pc || !pc->cb_info || !quality) {
4347 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4351 CAM_LOG_INFO("Enter");
4353 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4355 if (ret == CAMERA_ERROR_NONE)
4356 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4358 CAM_LOG_INFO("ret : 0x%x", ret);
4364 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4366 int ret = CAMERA_ERROR_NONE;
4367 camera_cli_s *pc = (camera_cli_s *)camera;
4368 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4370 if (!pc || !pc->cb_info || !bitrate) {
4371 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4372 return CAMERA_ERROR_INVALID_PARAMETER;
4375 CAM_LOG_INFO("Enter");
4377 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4379 if (ret == CAMERA_ERROR_NONE)
4380 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4382 CAM_LOG_INFO("ret : 0x%x", ret);
4388 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4390 int ret = CAMERA_ERROR_NONE;
4391 camera_cli_s *pc = (camera_cli_s *)camera;
4392 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4393 camera_msg_param param;
4394 int set_bitrate = bitrate;
4396 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4398 CAM_LOG_INFO("Enter");
4400 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4402 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4404 CAM_LOG_INFO("ret : 0x%x", ret);
4410 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4412 int ret = CAMERA_ERROR_NONE;
4413 camera_cli_s *pc = (camera_cli_s *)camera;
4414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4416 if (!pc || !pc->cb_info || !interval) {
4417 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4418 return CAMERA_ERROR_INVALID_PARAMETER;
4421 CAM_LOG_INFO("Enter");
4423 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4425 if (ret == CAMERA_ERROR_NONE)
4426 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4428 CAM_LOG_INFO("ret : 0x%x", ret);
4434 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4436 int ret = CAMERA_ERROR_NONE;
4437 camera_cli_s *pc = (camera_cli_s *)camera;
4438 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4439 camera_msg_param param;
4440 int set_gop_interval = interval;
4442 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4444 CAM_LOG_INFO("Enter");
4446 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4448 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4450 CAM_LOG_INFO("ret : 0x%x", ret);
4456 int camera_attr_set_zoom(camera_h camera, int zoom)
4458 int ret = CAMERA_ERROR_NONE;
4459 camera_cli_s *pc = (camera_cli_s *)camera;
4460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4461 camera_msg_param param;
4463 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4465 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4467 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4469 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4471 CAM_LOG_INFO("ret : 0x%x", ret);
4477 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4479 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4483 int camera_attr_set_af_area(camera_h camera, int x, int y)
4485 int ret = CAMERA_ERROR_NONE;
4486 camera_cli_s *pc = (camera_cli_s *)camera;
4487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4488 camera_msg_param param;
4491 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4493 CAM_LOG_INFO("Enter - %d,%d", x, y);
4495 value = (x << 16) | y;
4496 CAMERA_MSG_PARAM_SET(param, INT, value);
4498 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4500 CAM_LOG_INFO("ret : 0x%x", ret);
4506 int camera_attr_clear_af_area(camera_h camera)
4508 int ret = CAMERA_ERROR_NONE;
4509 camera_cli_s *pc = (camera_cli_s *)camera;
4510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4512 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4514 CAM_LOG_INFO("Enter");
4516 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4518 CAM_LOG_INFO("ret : 0x%x", ret);
4524 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4526 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4530 int camera_attr_set_exposure(camera_h camera, int value)
4532 int ret = CAMERA_ERROR_NONE;
4533 camera_cli_s *pc = (camera_cli_s *)camera;
4534 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4535 camera_msg_param param;
4537 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4539 CAM_LOG_INFO("Enter");
4541 CAMERA_MSG_PARAM_SET(param, INT, value);
4543 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4545 CAM_LOG_INFO("ret : 0x%x", ret);
4551 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4553 int ret = CAMERA_ERROR_NONE;
4554 camera_cli_s *pc = (camera_cli_s *)camera;
4555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4556 camera_msg_param param;
4557 int set_iso = (int)iso;
4559 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4561 CAM_LOG_INFO("Enter");
4563 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4565 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4567 CAM_LOG_INFO("ret : 0x%x", ret);
4573 int camera_attr_set_brightness(camera_h camera, int level)
4575 int ret = CAMERA_ERROR_NONE;
4576 camera_cli_s *pc = (camera_cli_s *)camera;
4577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4578 camera_msg_param param;
4580 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4582 CAM_LOG_INFO("Enter");
4584 CAMERA_MSG_PARAM_SET(param, INT, level);
4586 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4588 CAM_LOG_INFO("ret : 0x%x", ret);
4594 int camera_attr_set_contrast(camera_h camera, int level)
4596 int ret = CAMERA_ERROR_NONE;
4597 camera_cli_s *pc = (camera_cli_s *)camera;
4598 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4599 camera_msg_param param;
4601 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4603 CAM_LOG_INFO("Enter");
4605 CAMERA_MSG_PARAM_SET(param, INT, level);
4607 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4609 CAM_LOG_INFO("ret : 0x%x", ret);
4615 int camera_attr_set_hue(camera_h camera, int level)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4620 camera_msg_param param;
4622 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4624 CAM_LOG_INFO("Enter");
4626 CAMERA_MSG_PARAM_SET(param, INT, level);
4628 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4630 CAM_LOG_INFO("ret : 0x%x", ret);
4636 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4638 int ret = CAMERA_ERROR_NONE;
4639 camera_cli_s *pc = (camera_cli_s *)camera;
4640 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4641 camera_msg_param param;
4642 int set_whitebalance = (int)wb;
4644 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4646 CAM_LOG_INFO("Enter");
4648 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4650 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4652 CAM_LOG_INFO("ret : 0x%x", ret);
4658 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4660 int ret = CAMERA_ERROR_NONE;
4661 camera_cli_s *pc = (camera_cli_s *)camera;
4662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4663 camera_msg_param param;
4664 int set_effect = (int)effect;
4666 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4668 CAM_LOG_INFO("Enter");
4670 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4672 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4674 CAM_LOG_INFO("ret : 0x%x", ret);
4680 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4682 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4686 int camera_attr_enable_tag(camera_h camera, bool enable)
4688 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4692 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4694 int ret = CAMERA_ERROR_NONE;
4695 camera_cli_s *pc = (camera_cli_s *)camera;
4696 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4697 camera_msg_param param;
4699 if (!pc || !pc->cb_info || !description) {
4700 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4701 return CAMERA_ERROR_INVALID_PARAMETER;
4704 CAM_LOG_INFO("Enter");
4706 CAMERA_MSG_PARAM_SET(param, STRING, description);
4708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4710 CAM_LOG_INFO("ret : 0x%x", ret);
4716 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4718 int ret = CAMERA_ERROR_NONE;
4719 camera_cli_s *pc = (camera_cli_s *)camera;
4720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4721 camera_msg_param param;
4722 int set_orientation = (int)orientation;
4724 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4726 CAM_LOG_INFO("Enter");
4728 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 CAM_LOG_INFO("ret : 0x%x", ret);
4738 int camera_attr_set_tag_software(camera_h camera, const char *software)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4743 camera_msg_param param;
4745 if (!pc || !pc->cb_info || !software) {
4746 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4747 return CAMERA_ERROR_INVALID_PARAMETER;
4750 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4752 CAMERA_MSG_PARAM_SET(param, STRING, software);
4754 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4756 CAM_LOG_INFO("ret : 0x%x", ret);
4762 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4764 int ret = CAMERA_ERROR_NONE;
4765 camera_cli_s *pc = (camera_cli_s *)camera;
4766 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4767 double set_geotag[3] = {latitude, longitude, altitude};
4771 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4773 CAM_LOG_INFO("Enter");
4775 length = sizeof(set_geotag) / sizeof(int) + \
4776 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4778 msg = muse_core_msg_new(api,
4779 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4782 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4788 int camera_attr_remove_geotag(camera_h camera)
4790 int ret = CAMERA_ERROR_NONE;
4791 camera_cli_s *pc = (camera_cli_s *)camera;
4792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4794 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4796 CAM_LOG_INFO("Enter");
4798 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4800 CAM_LOG_INFO("ret : 0x%x", ret);
4806 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4808 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4812 int camera_attr_get_zoom(camera_h camera, int *zoom)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4818 if (!pc || !pc->cb_info || !zoom) {
4819 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4820 return CAMERA_ERROR_INVALID_PARAMETER;
4823 CAM_LOG_INFO("Enter");
4825 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4827 if (ret == CAMERA_ERROR_NONE)
4828 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4830 CAM_LOG_INFO("ret : 0x%x", ret);
4836 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4838 int ret = CAMERA_ERROR_NONE;
4839 camera_cli_s *pc = (camera_cli_s *)camera;
4840 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4842 if (!pc || !pc->cb_info || !min || !max) {
4843 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4844 return CAMERA_ERROR_INVALID_PARAMETER;
4847 CAM_LOG_INFO("Enter");
4849 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4851 if (ret == CAMERA_ERROR_NONE) {
4852 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4853 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4856 CAM_LOG_INFO("ret : 0x%x", ret);
4862 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4864 int ret = CAMERA_ERROR_NONE;
4865 camera_cli_s *pc = (camera_cli_s *)camera;
4866 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4868 if (!pc || !pc->cb_info || !mode) {
4869 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4870 return CAMERA_ERROR_INVALID_PARAMETER;
4873 CAM_LOG_INFO("Enter");
4875 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4877 if (ret == CAMERA_ERROR_NONE)
4878 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4880 CAM_LOG_INFO("ret : 0x%x", ret);
4886 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4888 int ret = CAMERA_ERROR_NONE;
4889 camera_cli_s *pc = (camera_cli_s *)camera;
4890 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4892 if (!pc || !pc->cb_info || !mode) {
4893 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4894 return CAMERA_ERROR_INVALID_PARAMETER;
4897 CAM_LOG_INFO("Enter");
4899 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4901 if (ret == CAMERA_ERROR_NONE)
4902 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4904 CAM_LOG_INFO("ret : 0x%x", ret);
4910 int camera_attr_get_exposure(camera_h camera, int *value)
4912 int ret = CAMERA_ERROR_NONE;
4913 camera_cli_s *pc = (camera_cli_s *)camera;
4914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4916 if (!pc || !pc->cb_info || !value) {
4917 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
4918 return CAMERA_ERROR_INVALID_PARAMETER;
4921 CAM_LOG_INFO("Enter");
4923 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4925 if (ret == CAMERA_ERROR_NONE)
4926 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
4928 CAM_LOG_INFO("ret : 0x%x", ret);
4934 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4936 int ret = CAMERA_ERROR_NONE;
4937 camera_cli_s *pc = (camera_cli_s *)camera;
4938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4940 if (!pc || !pc->cb_info || !min || !max) {
4941 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4942 return CAMERA_ERROR_INVALID_PARAMETER;
4945 CAM_LOG_INFO("Enter");
4947 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4949 if (ret == CAMERA_ERROR_NONE) {
4950 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
4951 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
4954 CAM_LOG_INFO("ret : 0x%x", ret);
4960 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4962 int ret = CAMERA_ERROR_NONE;
4963 camera_cli_s *pc = (camera_cli_s *)camera;
4964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4966 if (!pc || !pc->cb_info || !iso) {
4967 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
4968 return CAMERA_ERROR_INVALID_PARAMETER;
4971 CAM_LOG_INFO("Enter");
4973 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4975 if (ret == CAMERA_ERROR_NONE)
4976 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
4978 CAM_LOG_INFO("ret : 0x%x", ret);
4984 int camera_attr_get_brightness(camera_h camera, int *level)
4986 int ret = CAMERA_ERROR_NONE;
4987 camera_cli_s *pc = (camera_cli_s *)camera;
4988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4990 if (!pc || !pc->cb_info || !level) {
4991 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
4992 return CAMERA_ERROR_INVALID_PARAMETER;
4995 CAM_LOG_INFO("Enter");
4997 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4999 if (ret == CAMERA_ERROR_NONE)
5000 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5002 CAM_LOG_INFO("ret : 0x%x", ret);
5008 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
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_BRIGHTNESS_RANGE;
5014 if (!pc || !pc->cb_info || !min || !max) {
5015 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5025 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5028 CAM_LOG_INFO("ret : 0x%x", ret);
5034 int camera_attr_get_contrast(camera_h camera, int *level)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5040 if (!pc || !pc->cb_info || !level) {
5041 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5045 CAM_LOG_INFO("Enter");
5047 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE)
5050 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5052 CAM_LOG_INFO("ret : 0x%x", ret);
5058 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5060 int ret = CAMERA_ERROR_NONE;
5061 camera_cli_s *pc = (camera_cli_s *)camera;
5062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5064 if (!pc || !pc->cb_info || !min || !max) {
5065 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5066 return CAMERA_ERROR_INVALID_PARAMETER;
5069 CAM_LOG_INFO("Enter");
5071 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5073 if (ret == CAMERA_ERROR_NONE) {
5074 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5075 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5076 CAM_LOG_INFO("min %d, max %d", *min, *max);
5079 CAM_LOG_INFO("ret : 0x%x", ret);
5085 int camera_attr_get_hue(camera_h camera, int *level)
5087 int ret = CAMERA_ERROR_NONE;
5088 camera_cli_s *pc = (camera_cli_s *)camera;
5089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5091 if (!pc || !pc->cb_info || !level) {
5092 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5093 return CAMERA_ERROR_INVALID_PARAMETER;
5096 CAM_LOG_INFO("Enter");
5098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5100 if (ret == CAMERA_ERROR_NONE)
5101 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5103 CAM_LOG_INFO("ret : 0x%x", ret);
5109 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5111 int ret = CAMERA_ERROR_NONE;
5112 camera_cli_s *pc = (camera_cli_s *)camera;
5113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5115 if (!pc || !pc->cb_info || !min || !max) {
5116 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5117 return CAMERA_ERROR_INVALID_PARAMETER;
5120 CAM_LOG_INFO("Enter");
5122 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5124 if (ret == CAMERA_ERROR_NONE) {
5125 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5126 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5127 CAM_LOG_INFO("min %d, max %d", *min, *max);
5130 CAM_LOG_INFO("ret : 0x%x", ret);
5136 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5138 int ret = CAMERA_ERROR_NONE;
5139 camera_cli_s *pc = (camera_cli_s *)camera;
5140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5142 if (!pc || !pc->cb_info || !wb) {
5143 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5144 return CAMERA_ERROR_INVALID_PARAMETER;
5147 CAM_LOG_INFO("Enter");
5149 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5151 if (ret == CAMERA_ERROR_NONE)
5152 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5154 CAM_LOG_INFO("ret : 0x%x", ret);
5160 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5162 int ret = CAMERA_ERROR_NONE;
5163 camera_cli_s *pc = (camera_cli_s *)camera;
5164 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5166 if (!pc || !pc->cb_info || !effect) {
5167 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5168 return CAMERA_ERROR_INVALID_PARAMETER;
5171 CAM_LOG_INFO("Enter");
5173 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5175 if (ret == CAMERA_ERROR_NONE)
5176 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5178 CAM_LOG_INFO("ret : 0x%x", ret);
5184 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5186 int ret = CAMERA_ERROR_NONE;
5187 camera_cli_s *pc = (camera_cli_s *)camera;
5188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5190 if (!pc || !pc->cb_info || !mode) {
5191 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5192 return CAMERA_ERROR_INVALID_PARAMETER;
5195 CAM_LOG_INFO("Enter");
5197 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5199 if (ret == CAMERA_ERROR_NONE)
5200 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5202 CAM_LOG_INFO("ret : 0x%x", ret);
5208 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5210 int ret = CAMERA_ERROR_NONE;
5211 camera_cli_s *pc = (camera_cli_s *)camera;
5212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5214 if (!pc || !pc->cb_info || !enable) {
5215 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5216 return CAMERA_ERROR_INVALID_PARAMETER;
5219 CAM_LOG_INFO("Enter");
5221 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5223 if (ret == CAMERA_ERROR_NONE)
5224 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5226 CAM_LOG_INFO("ret : 0x%x", ret);
5232 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5234 int ret = CAMERA_ERROR_NONE;
5235 camera_cli_s *pc = (camera_cli_s *)camera;
5236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5238 if (!pc || !pc->cb_info || !description) {
5239 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5240 return CAMERA_ERROR_INVALID_PARAMETER;
5243 CAM_LOG_INFO("Enter");
5245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5247 if (ret == CAMERA_ERROR_NONE)
5248 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5250 CAM_LOG_INFO("ret : 0x%x", ret);
5256 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5258 int ret = CAMERA_ERROR_NONE;
5259 camera_cli_s *pc = (camera_cli_s *)camera;
5260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5262 if (!pc || !pc->cb_info || !orientation) {
5263 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5264 return CAMERA_ERROR_INVALID_PARAMETER;
5267 CAM_LOG_INFO("Enter");
5269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5271 if (ret == CAMERA_ERROR_NONE)
5272 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5274 CAM_LOG_INFO("ret : 0x%x", ret);
5280 int camera_attr_get_tag_software(camera_h camera, char **software)
5282 int ret = CAMERA_ERROR_NONE;
5283 camera_cli_s *pc = (camera_cli_s *)camera;
5284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5286 if (!pc || !pc->cb_info || !software) {
5287 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5288 return CAMERA_ERROR_INVALID_PARAMETER;
5291 CAM_LOG_INFO("Enter");
5293 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5295 if (ret == CAMERA_ERROR_NONE)
5296 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5298 CAM_LOG_INFO("ret : 0x%x", ret);
5304 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5306 int ret = CAMERA_ERROR_NONE;
5307 camera_cli_s *pc = (camera_cli_s *)camera;
5308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5310 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5311 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5312 return CAMERA_ERROR_INVALID_PARAMETER;
5315 CAM_LOG_INFO("Enter");
5317 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5319 if (ret == CAMERA_ERROR_NONE) {
5320 *latitude = pc->cb_info->get_geotag[0];
5321 *longitude = pc->cb_info->get_geotag[1];
5322 *altitude = pc->cb_info->get_geotag[2];
5325 CAM_LOG_INFO("ret : 0x%x", ret);
5331 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5337 if (!pc || !pc->cb_info || !mode) {
5338 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5342 CAM_LOG_INFO("Enter");
5344 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE)
5347 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5349 CAM_LOG_INFO("ret : 0x%x", ret);
5355 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5357 int ret = CAMERA_ERROR_NONE;
5358 int get_flash_state = 0;
5361 CAM_LOG_ERROR("NULL pointer");
5362 return CAMERA_ERROR_INVALID_PARAMETER;
5365 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5366 (int)device, "get_flash_state", &get_flash_state);
5368 if (ret == CAMERA_ERROR_NONE) {
5369 *state = (camera_flash_state_e)get_flash_state;
5370 CAM_LOG_INFO("flash state %d", *state);
5372 CAM_LOG_ERROR("failed 0x%x", ret);
5379 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5381 int ret = CAMERA_ERROR_NONE;
5382 camera_cli_s *pc = (camera_cli_s *)camera;
5383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5385 if (!pc || !pc->cb_info || !foreach_cb) {
5386 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5387 return CAMERA_ERROR_INVALID_PARAMETER;
5390 CAM_LOG_INFO("Enter");
5392 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5393 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5395 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5397 CAM_LOG_INFO("ret : 0x%x", ret);
5403 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5405 int ret = CAMERA_ERROR_NONE;
5406 camera_cli_s *pc = (camera_cli_s *)camera;
5407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5409 if (!pc || !pc->cb_info || !foreach_cb) {
5410 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5411 return CAMERA_ERROR_INVALID_PARAMETER;
5414 CAM_LOG_INFO("Enter");
5416 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5417 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5419 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5421 CAM_LOG_INFO("ret : 0x%x", ret);
5427 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5429 int ret = CAMERA_ERROR_NONE;
5430 camera_cli_s *pc = (camera_cli_s *)camera;
5431 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5433 if (!pc || !pc->cb_info || !foreach_cb) {
5434 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5435 return CAMERA_ERROR_INVALID_PARAMETER;
5438 CAM_LOG_INFO("Enter");
5440 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5441 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5443 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5445 CAM_LOG_INFO("ret : 0x%x", ret);
5451 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5453 int ret = CAMERA_ERROR_NONE;
5454 camera_cli_s *pc = (camera_cli_s *)camera;
5455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5457 if (!pc || !pc->cb_info || !foreach_cb) {
5458 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5459 return CAMERA_ERROR_INVALID_PARAMETER;
5462 CAM_LOG_INFO("Enter");
5464 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5465 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5467 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5469 CAM_LOG_INFO("ret : 0x%x", ret);
5475 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5477 int ret = CAMERA_ERROR_NONE;
5478 camera_cli_s *pc = (camera_cli_s *)camera;
5479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5481 if (!pc || !pc->cb_info || !foreach_cb) {
5482 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5483 return CAMERA_ERROR_INVALID_PARAMETER;
5486 CAM_LOG_INFO("Enter");
5488 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5489 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5493 CAM_LOG_INFO("ret : 0x%x", ret);
5499 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5501 int ret = CAMERA_ERROR_NONE;
5502 camera_cli_s *pc = (camera_cli_s *)camera;
5503 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5505 if (!pc || !pc->cb_info || !foreach_cb) {
5506 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5507 return CAMERA_ERROR_INVALID_PARAMETER;
5510 CAM_LOG_INFO("Enter");
5512 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5513 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5515 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5517 CAM_LOG_INFO("ret : 0x%x", ret);
5523 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5525 int ret = CAMERA_ERROR_NONE;
5526 camera_cli_s *pc = (camera_cli_s *)camera;
5527 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5529 if (!pc || !pc->cb_info || !foreach_cb) {
5530 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5531 return CAMERA_ERROR_INVALID_PARAMETER;
5534 CAM_LOG_INFO("Enter");
5536 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5537 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5539 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5541 CAM_LOG_INFO("ret : 0x%x", ret);
5547 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5549 int ret = CAMERA_ERROR_NONE;
5550 camera_cli_s *pc = (camera_cli_s *)camera;
5551 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5553 if (!pc || !pc->cb_info || !foreach_cb) {
5554 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5555 return CAMERA_ERROR_INVALID_PARAMETER;
5558 CAM_LOG_INFO("Enter");
5560 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5561 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5563 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5565 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5571 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)
5573 int ret = CAMERA_ERROR_NONE;
5574 camera_cli_s *pc = (camera_cli_s *)camera;
5575 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5576 camera_msg_param param;
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_FPS_BY_RESOLUTION] = foreach_cb;
5587 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5589 value = (width << 16) | height;
5590 CAMERA_MSG_PARAM_SET(param, INT, value);
5592 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5594 CAM_LOG_INFO("ret : 0x%x", ret);
5600 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5602 int ret = CAMERA_ERROR_NONE;
5603 camera_cli_s *pc = (camera_cli_s *)camera;
5604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5606 if (!pc || !pc->cb_info || !foreach_cb) {
5607 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5608 return CAMERA_ERROR_INVALID_PARAMETER;
5611 CAM_LOG_INFO("Enter");
5613 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5614 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5616 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5618 CAM_LOG_INFO("ret : 0x%x", ret);
5624 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5626 int ret = CAMERA_ERROR_NONE;
5627 camera_cli_s *pc = (camera_cli_s *)camera;
5628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5630 if (!pc || !pc->cb_info || !foreach_cb) {
5631 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5632 return CAMERA_ERROR_INVALID_PARAMETER;
5635 CAM_LOG_INFO("Enter");
5637 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5638 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5640 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5642 CAM_LOG_INFO("ret : 0x%x", ret);
5648 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5650 int ret = CAMERA_ERROR_NONE;
5651 camera_cli_s *pc = (camera_cli_s *)camera;
5652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5653 camera_msg_param param;
5654 int set_rotation = (int)rotation;
5656 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5658 CAM_LOG_INFO("Enter");
5660 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5662 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5664 CAM_LOG_INFO("ret : 0x%x", ret);
5670 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5672 int ret = CAMERA_ERROR_NONE;
5673 camera_cli_s *pc = (camera_cli_s *)camera;
5674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5676 if (!pc || !pc->cb_info || !rotation) {
5677 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5678 return CAMERA_ERROR_INVALID_PARAMETER;
5681 CAM_LOG_INFO("Enter");
5683 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5685 if (ret == CAMERA_ERROR_NONE)
5686 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5688 CAM_LOG_INFO("ret : 0x%x", ret);
5694 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5696 int ret = CAMERA_ERROR_NONE;
5697 camera_cli_s *pc = (camera_cli_s *)camera;
5698 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5699 camera_msg_param param;
5700 int set_flip = (int)flip;
5702 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5704 CAM_LOG_INFO("Enter");
5706 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5710 CAM_LOG_INFO("ret : 0x%x", ret);
5716 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5718 int ret = CAMERA_ERROR_NONE;
5719 camera_cli_s *pc = (camera_cli_s *)camera;
5720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5722 if (!pc || !pc->cb_info || !flip) {
5723 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5724 return CAMERA_ERROR_INVALID_PARAMETER;
5727 CAM_LOG_INFO("Enter");
5729 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5731 if (ret == CAMERA_ERROR_NONE)
5732 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5734 CAM_LOG_INFO("ret : 0x%x", ret);
5739 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5741 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5745 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5747 int ret = CAMERA_ERROR_NONE;
5748 camera_cli_s *pc = (camera_cli_s *)camera;
5749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5751 if (!pc || !pc->cb_info || !mode) {
5752 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5753 return CAMERA_ERROR_INVALID_PARAMETER;
5756 CAM_LOG_INFO("Enter");
5758 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5760 if (ret == CAMERA_ERROR_NONE)
5761 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5763 CAM_LOG_INFO("ret : 0x%x", ret);
5769 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5771 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5775 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5777 int ret = CAMERA_ERROR_NONE;
5778 camera_cli_s *pc = (camera_cli_s *)camera;
5779 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5781 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5783 CAM_LOG_INFO("Enter");
5785 if (!camera_attr_is_supported_hdr_capture(camera)) {
5786 CAM_LOG_ERROR("HDR not supported");
5787 return CAMERA_ERROR_NOT_SUPPORTED;
5791 CAM_LOG_ERROR("NULL callback");
5792 return CAMERA_ERROR_INVALID_PARAMETER;
5795 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5797 if (ret == CAMERA_ERROR_NONE) {
5798 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5800 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5801 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5803 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5806 CAM_LOG_INFO("ret : 0x%x", ret);
5812 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5814 int ret = CAMERA_ERROR_NONE;
5815 camera_cli_s *pc = (camera_cli_s *)camera;
5816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5818 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5820 CAM_LOG_INFO("Enter");
5822 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5824 if (ret == CAMERA_ERROR_NONE) {
5825 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5827 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5828 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5830 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5833 CAM_LOG_INFO("ret : 0x%x", ret);
5839 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5841 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5845 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5847 int ret = CAMERA_ERROR_NONE;
5848 camera_cli_s *pc = (camera_cli_s *)camera;
5849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5851 if (!pc || !pc->cb_info || !enabled) {
5852 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5853 return CAMERA_ERROR_INVALID_PARAMETER;
5856 CAM_LOG_INFO("Enter");
5858 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5860 if (ret == CAMERA_ERROR_NONE)
5861 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5863 CAM_LOG_INFO("ret : 0x%x", ret);
5869 bool camera_attr_is_supported_anti_shake(camera_h camera)
5871 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
5875 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5877 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
5881 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5883 int ret = CAMERA_ERROR_NONE;
5884 camera_cli_s *pc = (camera_cli_s *)camera;
5885 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5887 if (!pc || !pc->cb_info || !enabled) {
5888 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5889 return CAMERA_ERROR_INVALID_PARAMETER;
5892 CAM_LOG_INFO("Enter");
5894 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5896 if (ret == CAMERA_ERROR_NONE)
5897 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
5899 CAM_LOG_INFO("ret : 0x%x", ret);
5905 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5907 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
5911 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5913 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
5917 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5919 int ret = CAMERA_ERROR_NONE;
5920 camera_cli_s *pc = (camera_cli_s *)camera;
5921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5923 if (!pc || !pc->cb_info || !enabled) {
5924 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5925 return CAMERA_ERROR_INVALID_PARAMETER;
5928 CAM_LOG_INFO("Enter");
5930 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5932 if (ret == CAMERA_ERROR_NONE)
5933 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
5935 CAM_LOG_INFO("ret : 0x%x", ret);
5941 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5943 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
5947 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5949 int ret = CAMERA_ERROR_NONE;
5950 camera_cli_s *pc = (camera_cli_s *)camera;
5951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5952 camera_msg_param param;
5953 int set_disable = (int)disable;
5955 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5957 CAM_LOG_INFO("Enter");
5959 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5961 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5963 CAM_LOG_INFO("ret : 0x%x", ret);
5969 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5971 int ret = CAMERA_ERROR_NONE;
5972 camera_cli_s *pc = (camera_cli_s *)camera;
5973 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5974 camera_msg_param param0;
5975 camera_msg_param param1;
5977 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5979 CAM_LOG_INFO("Enter");
5981 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
5982 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
5984 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
5985 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
5987 CAM_LOG_INFO("ret : 0x%x", ret);
5993 int camera_attr_get_pan(camera_h camera, int *pan_step)
5995 int ret = CAMERA_ERROR_NONE;
5996 camera_cli_s *pc = (camera_cli_s *)camera;
5997 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
5999 if (!pc || !pc->cb_info || !pan_step) {
6000 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6001 return CAMERA_ERROR_INVALID_PARAMETER;
6004 CAM_LOG_INFO("Enter");
6006 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6008 if (ret == CAMERA_ERROR_NONE)
6009 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6011 CAM_LOG_INFO("ret : 0x%x", ret);
6017 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6019 int ret = CAMERA_ERROR_NONE;
6020 camera_cli_s *pc = (camera_cli_s *)camera;
6021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6023 if (!pc || !pc->cb_info || !min || !max) {
6024 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6025 return CAMERA_ERROR_INVALID_PARAMETER;
6028 CAM_LOG_INFO("Enter");
6030 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6032 if (ret == CAMERA_ERROR_NONE) {
6033 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6034 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6037 CAM_LOG_INFO("ret : 0x%x", ret);
6043 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6045 int ret = CAMERA_ERROR_NONE;
6046 camera_cli_s *pc = (camera_cli_s *)camera;
6047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6048 camera_msg_param param0;
6049 camera_msg_param param1;
6051 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6053 CAM_LOG_INFO("Enter");
6055 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6056 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6058 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6059 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6061 CAM_LOG_INFO("ret : 0x%x", ret);
6067 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6069 int ret = CAMERA_ERROR_NONE;
6070 camera_cli_s *pc = (camera_cli_s *)camera;
6071 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6073 if (!pc || !pc->cb_info || !tilt_step) {
6074 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6075 return CAMERA_ERROR_INVALID_PARAMETER;
6078 CAM_LOG_INFO("Enter");
6080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6082 if (ret == CAMERA_ERROR_NONE)
6083 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6085 CAM_LOG_INFO("ret : 0x%x", ret);
6091 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6093 int ret = CAMERA_ERROR_NONE;
6094 camera_cli_s *pc = (camera_cli_s *)camera;
6095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6097 if (!pc || !pc->cb_info || !min || !max) {
6098 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6099 return CAMERA_ERROR_INVALID_PARAMETER;
6102 CAM_LOG_INFO("Enter");
6104 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6106 if (ret == CAMERA_ERROR_NONE) {
6107 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6108 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6111 CAM_LOG_INFO("ret : 0x%x", ret);
6117 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6119 int ret = CAMERA_ERROR_NONE;
6120 camera_cli_s *pc = (camera_cli_s *)camera;
6121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6122 camera_msg_param param;
6123 int set_ptz_type = (int)ptz_type;
6125 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6127 CAM_LOG_INFO("Enter");
6129 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6131 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6133 CAM_LOG_INFO("ret : 0x%x", ret);
6139 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6141 int ret = CAMERA_ERROR_NONE;
6142 camera_cli_s *pc = (camera_cli_s *)camera;
6143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6145 if (!pc || !pc->cb_info || !foreach_cb) {
6146 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6147 return CAMERA_ERROR_INVALID_PARAMETER;
6150 CAM_LOG_INFO("Enter");
6152 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6153 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6155 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6157 CAM_LOG_INFO("ret : 0x%x", ret);
6163 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6168 int set_display_roi_area[4] = {x, y, width, height};
6172 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6174 CAM_LOG_INFO("Enter");
6176 if (pc->cb_info->is_evas_render) {
6177 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6178 if (ret != MM_ERROR_NONE) {
6179 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6180 return CAMERA_ERROR_INVALID_OPERATION;
6184 length = sizeof(set_display_roi_area) / sizeof(int) + \
6185 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6187 msg = muse_core_msg_new(api,
6188 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6191 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6197 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6199 camera_cli_s *pc = (camera_cli_s *)camera;
6200 int ret = CAMERA_ERROR_NONE;
6201 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6203 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6204 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6205 return CAMERA_ERROR_INVALID_PARAMETER;
6208 CAM_LOG_INFO("Enter");
6210 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6212 if (ret == CAMERA_ERROR_NONE) {
6213 *x = pc->cb_info->get_display_roi_area[0];
6214 *y = pc->cb_info->get_display_roi_area[1];
6215 *width = pc->cb_info->get_display_roi_area[2];
6216 *height = pc->cb_info->get_display_roi_area[3];
6219 CAM_LOG_INFO("ret : 0x%x", ret);
6225 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6227 int ret = CAMERA_ERROR_NONE;
6228 int get_device_state = 0;
6231 CAM_LOG_ERROR("NULL pointer");
6232 return CAMERA_ERROR_INVALID_PARAMETER;
6235 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6236 (int)device, "get_device_state", &get_device_state);
6238 if (ret == CAMERA_ERROR_NONE) {
6239 *state = (camera_device_state_e)get_device_state;
6240 CAM_LOG_INFO("device state %d", *state);
6242 CAM_LOG_ERROR("failed 0x%x", ret);
6249 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6251 int ret = CAMERA_ERROR_NONE;
6252 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6253 camera_cb_info *info = NULL;
6255 if (!callback || !cb_id) {
6256 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6257 return CAMERA_ERROR_INVALID_PARAMETER;
6260 /* check camera support */
6261 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6262 if (ret != CAMERA_ERROR_NONE) {
6263 CAM_LOG_ERROR("get device state failed");
6267 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6269 info = g_new0(camera_cb_info, 1);
6271 CAM_LOG_ERROR("info failed");
6272 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6276 info->id = ++g_cam_dev_state_changed_cb_id;
6277 info->callback = (void *)callback;
6278 info->user_data = user_data;
6282 /* subscribe dbus signal for camera state change */
6283 if (!g_cam_dev_state_changed_cb_conn) {
6284 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6285 if (!g_cam_dev_state_changed_cb_conn) {
6286 CAM_LOG_ERROR("failed to get gdbus connection");
6287 ret = CAMERA_ERROR_INVALID_OPERATION;
6291 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6292 MM_CAMCORDER_DBUS_OBJECT,
6293 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6294 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6296 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6297 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6298 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6299 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6300 CAM_LOG_ERROR("failed to get gdbus connection");
6301 ret = CAMERA_ERROR_INVALID_OPERATION;
6305 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6308 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6310 CAM_LOG_INFO("callback id %d", info->id);
6313 if (ret != CAMERA_ERROR_NONE) {
6319 if (g_cam_dev_state_changed_cb_conn) {
6320 g_object_unref(g_cam_dev_state_changed_cb_conn);
6321 g_cam_dev_state_changed_cb_conn = NULL;
6325 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6331 int camera_remove_device_state_changed_cb(int cb_id)
6333 int ret = CAMERA_ERROR_NONE;
6334 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6335 GList *tmp_list = NULL;
6336 camera_cb_info *info = NULL;
6338 /* check camera support */
6339 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6340 if (ret != CAMERA_ERROR_NONE) {
6341 CAM_LOG_ERROR("get device state failed");
6345 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6347 if (!g_cam_dev_state_changed_cb_list) {
6348 CAM_LOG_ERROR("there is no callback info");
6349 ret = CAMERA_ERROR_INVALID_OPERATION;
6353 tmp_list = g_cam_dev_state_changed_cb_list;
6356 info = tmp_list->data;
6357 tmp_list = tmp_list->next;
6360 CAM_LOG_WARNING("NULL info");
6364 if (info->id == cb_id) {
6365 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6370 if (!g_cam_dev_state_changed_cb_list) {
6371 /* no remained callback */
6372 if (g_cam_dev_state_changed_cb_conn) {
6373 /* unsubscribe signal */
6374 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6375 g_cam_dev_state_changed_cb_subscribe_id = 0;
6377 /* unref connection */
6378 g_object_unref(g_cam_dev_state_changed_cb_conn);
6379 g_cam_dev_state_changed_cb_conn = NULL;
6383 CAM_LOG_INFO("id %d callback removed", cb_id);
6384 ret = CAMERA_ERROR_NONE;
6390 CAM_LOG_ERROR("id %d callback not found", cb_id);
6391 ret = CAMERA_ERROR_INVALID_PARAMETER;
6394 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6401 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6403 int ret = CAMERA_ERROR_NONE;
6404 camera_cli_s *pc = (camera_cli_s *)camera;
6405 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6407 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6409 g_mutex_lock(&pc->cb_info->bridge_lock);
6411 if (pc->cb_info->bridge) {
6412 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6413 ret = CAMERA_ERROR_INVALID_OPERATION;
6414 goto _SET_MEDIA_BRIDGE_DONE;
6417 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6418 if (ret != CAMERA_ERROR_NONE) {
6419 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6420 goto _SET_MEDIA_BRIDGE_DONE;
6423 pc->cb_info->bridge = bridge;
6425 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6427 _SET_MEDIA_BRIDGE_DONE:
6428 g_mutex_unlock(&pc->cb_info->bridge_lock);
6434 int camera_media_bridge_unset_bridge(camera_h camera)
6436 int ret = CAMERA_ERROR_NONE;
6437 camera_cli_s *pc = (camera_cli_s *)camera;
6438 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6440 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6442 g_mutex_lock(&pc->cb_info->bridge_lock);
6444 if (!pc->cb_info->bridge) {
6445 CAM_LOG_ERROR("no media bridge");
6446 ret = CAMERA_ERROR_INVALID_OPERATION;
6447 goto _UNSET_MEDIA_BRIDGE_DONE;
6450 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6451 if (ret != CAMERA_ERROR_NONE) {
6452 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6453 goto _UNSET_MEDIA_BRIDGE_DONE;
6456 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6458 pc->cb_info->bridge = NULL;
6460 _UNSET_MEDIA_BRIDGE_DONE:
6461 g_mutex_unlock(&pc->cb_info->bridge_lock);
6468 int camera_create_network(camera_device_e device, camera_h *camera)
6470 return _camera_create_private(device, true, camera);
6474 int camera_device_manager_initialize(camera_device_manager_h *manager)
6477 int ret = CAMERA_ERROR_NONE;
6478 void *dl_handle = NULL;
6479 g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6480 cdm_symbol_table sym_table[] = {
6481 {(void **)&new_manager->initialize, "cdm_initialize"},
6482 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6483 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6484 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6485 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6488 CAMERA_CHECK_DEVICE_MANAGER;
6491 CAM_LOG_ERROR("NULL manager");
6492 ret = CAMERA_ERROR_INVALID_PARAMETER;
6493 goto _INITIALIZE_FAILED;
6496 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6498 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6499 ret = CAMERA_ERROR_INVALID_OPERATION;
6500 goto _INITIALIZE_FAILED;
6504 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6505 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6506 if (*sym_table[i].func_ptr == NULL) {
6507 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6508 ret = CAMERA_ERROR_INVALID_OPERATION;
6509 goto _INITIALIZE_FAILED;
6513 ret = new_manager->initialize();
6514 if (ret != CAMERA_ERROR_NONE) {
6515 CAM_LOG_ERROR("failed[0x%x]", ret);
6516 goto _INITIALIZE_FAILED;
6519 new_manager->dl_handle = dl_handle;
6520 *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
6522 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6523 *manager, dl_handle);
6525 return CAMERA_ERROR_NONE;
6536 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6538 int ret = CAMERA_ERROR_NONE;
6539 camera_device_manager *m = (camera_device_manager *)manager;
6541 CAMERA_CHECK_DEVICE_MANAGER;
6544 CAM_LOG_ERROR("NULL manager");
6545 return CAMERA_ERROR_INVALID_PARAMETER;
6548 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6550 ret = m->deinitialize();
6551 if (ret != CAMERA_ERROR_NONE) {
6552 CAM_LOG_ERROR("failed[0x%x]", ret);
6556 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6558 dlclose(m->dl_handle);
6560 memset(m, 0x0, sizeof(camera_device_manager));
6563 return CAMERA_ERROR_NONE;
6567 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6569 int ret = CAMERA_ERROR_NONE;
6571 camera_device_list_s device_list;
6572 camera_device_s *device = NULL;
6573 camera_device_manager *m = (camera_device_manager *)manager;
6575 CAMERA_CHECK_DEVICE_MANAGER;
6577 if (!m || !callback) {
6578 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6579 return CAMERA_ERROR_INVALID_PARAMETER;
6582 CAM_LOG_INFO("enter");
6584 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6586 ret = m->get_device_list(&device_list);
6587 if (ret != CAMERA_ERROR_NONE) {
6588 CAM_LOG_ERROR("failed[0x%x]", ret);
6592 CAM_LOG_INFO("device count[%d]", device_list.count);
6594 for (i = 0 ; i < device_list.count ; i++) {
6595 device = &device_list.device[i];
6597 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6598 i, device->type, device->index,
6599 device->name, device->id, device->extra_stream_num);
6601 if (!callback(device, user_data)) {
6602 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6603 i + 1, device_list.count);
6608 return CAMERA_ERROR_NONE;
6612 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6613 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6615 int ret = CAMERA_ERROR_NONE;
6616 camera_device_manager *m = (camera_device_manager *)manager;
6618 CAMERA_CHECK_DEVICE_MANAGER;
6620 if (!m || !callback || !cb_id) {
6621 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6622 return CAMERA_ERROR_INVALID_PARAMETER;
6625 CAM_LOG_INFO("enter");
6627 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6628 if (ret != CAMERA_ERROR_NONE) {
6629 CAM_LOG_ERROR("failed[0x%x]", ret);
6633 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6635 return CAMERA_ERROR_NONE;
6639 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6641 int ret = CAMERA_ERROR_NONE;
6642 camera_device_manager *m = (camera_device_manager *)manager;
6644 CAMERA_CHECK_DEVICE_MANAGER;
6647 CAM_LOG_ERROR("NULL manager");
6648 return CAMERA_ERROR_INVALID_PARAMETER;
6651 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6653 ret = m->remove_device_connection_changed_cb(cb_id);
6654 if (ret != CAMERA_ERROR_NONE) {
6655 CAM_LOG_ERROR("failed[0x%x]", ret);
6659 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6661 return CAMERA_ERROR_NONE;
6666 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6668 int ret = CAMERA_ERROR_NONE;
6669 camera_cli_s *pc = (camera_cli_s *)camera;
6670 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6672 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6674 if (!camera_is_supported_extra_preview(camera)) {
6675 CAM_LOG_ERROR("extra preview is not supported");
6676 return CAMERA_ERROR_NOT_SUPPORTED;
6680 CAM_LOG_ERROR("NULL callback");
6681 return CAMERA_ERROR_INVALID_PARAMETER;
6684 CAM_LOG_INFO("Enter");
6686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6688 if (ret == CAMERA_ERROR_NONE) {
6689 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6691 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6692 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6694 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6697 CAM_LOG_INFO("ret : 0x%x", ret);
6703 int camera_unset_extra_preview_cb(camera_h camera)
6705 int ret = CAMERA_ERROR_NONE;
6706 camera_cli_s *pc = (camera_cli_s *)camera;
6707 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6709 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6711 if (!camera_is_supported_extra_preview(camera)) {
6712 CAM_LOG_ERROR("extra preview is not supported");
6713 return CAMERA_ERROR_NOT_SUPPORTED;
6716 CAM_LOG_INFO("Enter");
6718 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6720 if (ret == CAMERA_ERROR_NONE) {
6721 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6723 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6724 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6726 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6729 CAM_LOG_INFO("ret : 0x%x", ret);
6735 int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
6737 int ret = CAMERA_ERROR_NONE;
6738 int stream_format[4] = {pixel_format, width, height, fps};
6740 camera_cli_s *pc = (camera_cli_s *)camera;
6741 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6743 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6745 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6746 stream_id, pixel_format, width, height, fps);
6748 msg = muse_core_msg_new(api,
6749 MUSE_TYPE_INT, "stream_id", stream_id,
6750 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6753 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6759 int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e *pixel_format, int *width, int *height, int *fps)
6761 int ret = CAMERA_ERROR_NONE;
6762 camera_cli_s *pc = (camera_cli_s *)camera;
6763 camera_msg_param param;
6764 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6766 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6767 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6768 return CAMERA_ERROR_INVALID_PARAMETER;
6771 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6773 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6775 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6777 if (ret == CAMERA_ERROR_NONE) {
6778 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6779 *width = pc->cb_info->get_extra_preview_stream_format[1];
6780 *height = pc->cb_info->get_extra_preview_stream_format[2];
6781 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6784 CAM_LOG_INFO("ret : 0x%x", ret);
6790 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6792 int ret = CAMERA_ERROR_NONE;
6793 camera_cli_s *pc = (camera_cli_s *)camera;
6794 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6795 camera_msg_param param0;
6796 camera_msg_param param1;
6798 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6800 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6802 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6803 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6805 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6806 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6808 CAM_LOG_INFO("ret : 0x%x", ret);
6814 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6816 int ret = CAMERA_ERROR_NONE;
6817 camera_cli_s *pc = (camera_cli_s *)camera;
6818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6819 camera_msg_param param;
6821 if (!pc || !pc->cb_info || !bitrate) {
6822 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6823 return CAMERA_ERROR_INVALID_PARAMETER;
6826 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6828 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6832 if (ret == CAMERA_ERROR_NONE) {
6833 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6834 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6836 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6843 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6845 int ret = CAMERA_ERROR_NONE;
6846 camera_cli_s *pc = (camera_cli_s *)camera;
6847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6848 camera_msg_param param0;
6849 camera_msg_param param1;
6851 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6853 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6855 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6856 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6858 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6859 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6861 CAM_LOG_INFO("ret : 0x%x", ret);
6867 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6869 int ret = CAMERA_ERROR_NONE;
6870 camera_cli_s *pc = (camera_cli_s *)camera;
6871 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6872 camera_msg_param param;
6874 if (!pc || !pc->cb_info || !interval) {
6875 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6876 return CAMERA_ERROR_INVALID_PARAMETER;
6879 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6881 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6883 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6885 if (ret == CAMERA_ERROR_NONE) {
6886 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6887 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6889 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6896 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6898 camera_cli_s *pc = (camera_cli_s *)camera;
6900 if (!pc || !pc->cb_info || !rotation) {
6901 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6902 return CAMERA_ERROR_INVALID_PARAMETER;
6905 if (!pc->cb_info->stream_data) {
6906 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6907 return CAMERA_ERROR_INVALID_OPERATION;
6910 *rotation = pc->cb_info->stream_data->rotation;
6912 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6914 return CAMERA_ERROR_NONE;
6918 int _camera_get_log_level(void)
6920 return g_camera_log_level;