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;\
45 #define CAMERA_CHECK_HANDLE_RETURN(pc) \
47 if (!pc || !pc->cb_info) {\
48 CAM_LOG_ERROR("NULL handle[%p]", pc);\
52 #define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \
54 if (!pc || !pc->cb_info) {\
55 CAM_LOG_ERROR("NULL handle[%p]", pc);\
60 /* for camera device manager */
61 typedef struct _cdm_symbol_table {
63 const char *func_name;
66 /* for device changed callback */
67 static GMutex g_cam_dev_state_changed_cb_lock;
68 static GList *g_cam_dev_state_changed_cb_list;
69 static int g_cam_dev_state_changed_cb_id;
70 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
71 static guint g_cam_dev_state_changed_cb_subscribe_id;
72 static GMutex g_cam_idle_event_lock;
75 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
77 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
78 static void __camera_release_imported_bo(tbm_bo *bo);
80 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
81 camera_media_packet_data *mp_data, media_packet_h *packet);
82 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
83 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
84 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
86 static gboolean __camera_allocate_preview_buffer(camera_h camera);
87 static void __camera_release_preview_buffer(camera_h camera);
88 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
90 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
91 int type, const char *thread_name, camera_cb_info_s *cb_info);
92 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
96 static gboolean __camera_allocate_preview_buffer(camera_h camera)
99 int ret = CAMERA_ERROR_NONE;
100 int format = CAMERA_PIXEL_FORMAT_INVALID;
104 camera_cli_s *pc = (camera_cli_s *)camera;
105 camera_cb_info_s *cb_info = NULL;
107 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
109 cb_info = pc->cb_info;
111 CAM_LOG_INFO("Enter");
113 /* get preview info and calculate size */
114 ret = camera_get_preview_format(camera, &format);
115 if (ret != CAMERA_ERROR_NONE) {
116 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
120 ret = camera_get_preview_resolution(camera, &width, &height);
121 if (ret != CAMERA_ERROR_NONE) {
122 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
126 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
129 case CAMERA_PIXEL_FORMAT_INVZ:
130 buffer_size = width * height;
132 case CAMERA_PIXEL_FORMAT_NV12:
133 case CAMERA_PIXEL_FORMAT_I420:
134 buffer_size = (width * height * 3) >> 1;
136 case CAMERA_PIXEL_FORMAT_YUYV:
137 case CAMERA_PIXEL_FORMAT_UYVY:
138 buffer_size = width * height * 2;
141 CAM_LOG_ERROR("unhandled format %d", format);
142 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
145 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
147 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
148 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
149 if (!cb_info->bos[i]) {
150 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
151 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
154 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
155 if (cb_info->fds[i] < 0) {
156 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
157 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
160 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
163 CAM_LOG_INFO("Done");
167 _ALLOCATE_PREVIEW_BUFFER_FAILED:
168 __camera_release_preview_buffer(camera);
173 static void __camera_release_preview_buffer(camera_h camera)
176 camera_cli_s *pc = (camera_cli_s *)camera;
177 camera_cb_info_s *cb_info = NULL;
179 CAMERA_CHECK_HANDLE_RETURN(pc);
181 CAM_LOG_INFO("Enter");
183 cb_info = pc->cb_info;
185 /* close exported fd and bos */
186 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
187 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
189 if (cb_info->bos[i]) {
190 tbm_bo_unref(cb_info->bos[i]);
191 cb_info->bos[i] = NULL;
196 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
197 close(cb_info->fds[i]);
198 cb_info->fds[i] = CAMERA_FD_INIT;
202 CAM_LOG_INFO("Done");
206 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
211 CAM_LOG_WARNING("NULL tfd");
215 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
216 if (!CAMERA_IS_FD_VALID(tfd[i]))
220 tfd[i] = CAMERA_FD_INIT;
225 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
228 api < 0 || api >= MUSE_CAMERA_API_MAX) {
229 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
233 g_mutex_lock(&(cb_info->api_mutex[api]));
234 cb_info->api_waiting[api] += value;
235 g_mutex_unlock(&(cb_info->api_mutex[api]));
237 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
238 api, value, cb_info->api_waiting[api]);
242 static void __camera_device_state_changed_cb(GDBusConnection *connection,
243 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
244 const gchar *signal_name, GVariant *param, gpointer user_data)
247 camera_device_e device = CAMERA_DEVICE_CAMERA0;
248 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
249 GList *tmp_list = NULL;
250 camera_cb_info *info = NULL;
252 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
254 if (!g_cam_dev_state_changed_cb_list || !param) {
255 CAM_LOG_WARNING("no callback or NULL param %p", param);
259 /* get device and state */
260 g_variant_get(param, "(i)", &value);
262 device = value >> 16;
263 state = 0x0000ffff & value;
265 CAM_LOG_INFO("device %d, state %d", device, state);
267 tmp_list = g_cam_dev_state_changed_cb_list;
270 info = (camera_cb_info *)tmp_list->data;
273 if (info->callback) {
274 CAM_LOG_INFO("start id[%d] callback", info->id);
275 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
276 CAM_LOG_INFO("returned id[%d] callback", info->id);
278 CAM_LOG_WARNING("NULL callback for id %d", info->id);
282 tmp_list = tmp_list->next;
286 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
290 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
294 int ret_fd = CAMERA_FD_INIT;
295 int preview_fd = CAMERA_FD_INIT;
296 int num_buffer_fd = 0;
297 unsigned char *buf_pos = NULL;
300 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
301 tbm_bo_handle bo_handle = {.ptr = NULL};
302 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
303 tbm_bo data_bo = NULL;
304 tbm_bo_handle data_bo_handle = {.ptr = NULL};
306 camera_msg_param param;
307 camera_preview_data_s frame;
308 MMCamcorderVideoStreamDataType *stream = NULL;
309 camera_media_packet_data *mp_data = NULL;
310 media_packet_h pkt = NULL;
312 /* tfd[0]: MMCamcorderVideoStreamDataType
313 tfd[1]: data_bo or zero copy bo[0]
314 tfd[2]: zero copy bo[1]
315 tfd[3]: zero copy bo[2] */
317 if (!cb_info || !recv_msg || !tfd) {
318 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
322 muse_camera_msg_get(preview_fd, recv_msg);
323 muse_camera_msg_get(num_buffer_fd, recv_msg);
325 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
327 memset(&frame, 0x0, sizeof(camera_preview_data_s));
330 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
335 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
337 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
338 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
339 goto _PREVIEW_CB_HANDLER_DONE;
342 /* import tbm bo and get virtual address */
343 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
344 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
345 goto _PREVIEW_CB_HANDLER_DONE;
348 buf_pos = (unsigned char *)bo_handle.ptr;
350 /* get stream info */
351 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
353 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
354 /* import tbm data_bo and get virtual address */
355 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
356 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
357 goto _PREVIEW_CB_HANDLER_DONE;
360 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
361 stream->data.encoded.data = data_bo_handle.ptr;
363 for (i = 0 ; i < num_buffer_fd ; i++) {
364 /* import buffer bo and get virtual address */
365 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
366 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
367 goto _PREVIEW_CB_HANDLER_DONE;
371 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
372 stream->data.encoded.data = buffer_bo_handle[0].ptr;
375 /* preview callback */
376 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
377 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
378 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
380 /* set stream data for camera_get_preview_frame_rotation() */
381 cb_info->stream_data = stream;
383 if (stream->extra_stream_id < 0) {
384 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
385 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
386 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
388 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
389 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
390 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
393 cb_info->stream_data = NULL;
396 if (stream->extra_stream_id >= 0)
397 goto _PREVIEW_CB_HANDLER_DONE;
399 /* make media packet with below cases.
400 * 1. media_packet_preview_cb is set
401 * 2. EVAS display rendering
402 * 3. media bridge is set
404 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
405 cb_info->is_evas_render ||
407 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
408 if (ret != CAMERA_ERROR_NONE) {
409 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
410 goto _PREVIEW_CB_HANDLER_DONE;
413 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
414 if (ret != CAMERA_ERROR_NONE) {
415 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
416 __camera_release_media_packet_data(mp_data, cb_info);
418 goto _PREVIEW_CB_HANDLER_DONE;
422 /* 1. media packet preview callback */
423 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
424 media_packet_ref(pkt);
425 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
426 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
429 /* 2. call evas renderer */
430 if (cb_info->is_evas_render) {
431 if (cb_info->run_evas_render) {
432 media_packet_ref(pkt);
433 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
434 if (ret != MM_ERROR_NONE) {
435 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
436 media_packet_unref(pkt);
439 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
444 /* 3. media bridge */
445 g_mutex_lock(&cb_info->bridge_lock);
447 if (cb_info->bridge) {
448 media_packet_ref(pkt);
449 ret = media_bridge_push_packet(cb_info->bridge, pkt);
450 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
451 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
452 media_packet_unref(pkt);
457 g_mutex_unlock(&cb_info->bridge_lock);
459 _PREVIEW_CB_HANDLER_DONE:
460 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
461 and preview callback(normal or media packet) is set. */
462 if (num_buffer_fd > 0 &&
463 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
464 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
465 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
468 media_packet_unref(pkt);
473 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
475 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
477 /* release imported bo and fd */
478 __camera_release_imported_bo(&data_bo);
479 __camera_release_imported_bo(&bo);
481 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
482 __camera_release_imported_bo(&buffer_bo[i]);
484 __camera_release_tfd(tfd);
488 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
491 int capture_fd_main = 0;
492 int capture_fd_post = 0;
493 int capture_fd_thumb = 0;
494 unsigned char *buf_pos = NULL;
496 camera_image_data_s *rImage = NULL;
497 camera_image_data_s *rPostview = NULL;
498 camera_image_data_s *rThumbnail = NULL;
500 tbm_bo bo_main = NULL;
501 tbm_bo bo_post = NULL;
502 tbm_bo bo_thumb = NULL;
503 tbm_bo_handle bo_main_handle = {.ptr = NULL};
504 tbm_bo_handle bo_post_handle = {.ptr = NULL};
505 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
507 if (!cb_info || !recv_msg || !tfd) {
508 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
512 muse_camera_msg_get(capture_fd_main, recv_msg);
513 muse_camera_msg_get(capture_fd_post, recv_msg);
514 muse_camera_msg_get(capture_fd_thumb, recv_msg);
516 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
517 capture_fd_main, capture_fd_post, capture_fd_thumb,
518 tfd[0], tfd[1], tfd[2]);
520 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
521 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
522 goto _CAPTURE_CB_HANDLER_DONE;
525 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
526 CAM_LOG_WARNING("NULL callback");
527 goto _CAPTURE_CB_HANDLER_DONE;
530 /* import tbm bo and get virtual address */
531 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
532 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
533 goto _CAPTURE_CB_HANDLER_DONE;
536 buf_pos = (unsigned char *)bo_main_handle.ptr;
537 rImage = (camera_image_data_s *)buf_pos;
538 rImage->data = buf_pos + sizeof(camera_image_data_s);
539 if (rImage->exif && rImage->exif_size > 0) {
540 rImage->exif = rImage->data + rImage->size;
543 rImage->exif_size = 0;
546 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
547 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
550 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
551 /* import tbm bo and get virtual address */
553 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
554 buf_pos = (unsigned char *)bo_post_handle.ptr;
555 rPostview = (camera_image_data_s *)buf_pos;
556 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
557 rPostview->data = buf_pos + sizeof(camera_image_data_s);
559 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
563 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
564 /* import tbm bo and get virtual address */
566 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
567 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
568 rThumbnail = (camera_image_data_s *)buf_pos;
569 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
570 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
572 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
577 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
578 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
580 _CAPTURE_CB_HANDLER_DONE:
582 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
583 __camera_release_imported_bo(&bo_main);
584 _camera_msg_return_buffer(capture_fd_main, cb_info);
587 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
588 __camera_release_imported_bo(&bo_post);
589 _camera_msg_return_buffer(capture_fd_post, cb_info);
592 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
593 __camera_release_imported_bo(&bo_thumb);
594 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
597 __camera_release_tfd(tfd);
599 CAM_LOG_INFO("return buffer done");
604 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
607 int face_fd = CAMERA_FD_INIT;
608 camera_detected_face_s *faces = NULL;
611 tbm_bo_handle bo_handle = {.ptr = NULL};
613 if (!cb_info || !recv_msg || !tfd) {
614 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
618 muse_camera_msg_get(count, recv_msg);
619 muse_camera_msg_get(face_fd, recv_msg);
621 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
622 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
624 if (CAMERA_IS_FD_VALID(tfd[0])) {
625 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
627 faces = bo_handle.ptr;
631 tfd[0] = CAMERA_FD_INIT;
634 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
635 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
638 __camera_release_imported_bo(&bo);
640 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
641 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
645 _camera_msg_return_buffer(face_fd, cb_info);
650 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
652 tbm_bo tmp_bo = NULL;
653 tbm_bo_handle tmp_bo_handle = {NULL, };
655 if (!bufmgr || !bo || !bo_handle || fd < 0) {
656 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
657 bufmgr, bo, bo_handle, fd);
661 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
662 if (tmp_bo == NULL) {
663 CAM_LOG_ERROR("import failed - fd %d", fd);
667 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
668 if (tmp_bo_handle.ptr == NULL) {
669 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
670 tbm_bo_unref(tmp_bo);
675 /* set bo and bo_handle */
677 *bo_handle = tmp_bo_handle;
679 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
684 static void __camera_release_imported_bo(tbm_bo *bo)
687 CAM_LOG_DEBUG("NULL bo");
696 static bool __is_supported(camera_h camera, muse_camera_api_e api)
698 int ret = CAMERA_ERROR_NONE;
699 camera_cli_s *pc = (camera_cli_s *)camera;
701 if (!pc || !pc->cb_info) {
702 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
703 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
707 CAM_LOG_INFO("Enter - api[%d]", api);
709 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
711 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
717 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
719 int ret = CAMERA_ERROR_NONE;
720 camera_cli_s *pc = (camera_cli_s *)camera;
721 camera_msg_param param;
723 if (!pc || !pc->cb_info) {
724 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
725 return CAMERA_ERROR_INVALID_PARAMETER;
728 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
730 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
734 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
740 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
742 int ret = CAMERA_ERROR_NONE;
743 camera_cli_s *pc = (camera_cli_s *)camera;
744 camera_msg_param param;
746 if (!pc || !pc->cb_info) {
747 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
748 return CAMERA_ERROR_INVALID_PARAMETER;
751 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
753 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
755 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
757 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
763 static void __send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
768 CAM_LOG_ERROR("api[%d] message failed", api);
770 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
775 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
776 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
778 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
780 if (cb_info->is_server_connected) {
781 _camera_update_api_waiting(cb_info, api, 1);
783 g_mutex_lock(&cb_info->fd_lock);
784 send_ret = muse_core_msg_send(cb_info->fd, msg);
785 g_mutex_unlock(&cb_info->fd_lock);
789 CAM_LOG_ERROR("message send failed");
791 *ret = CAMERA_ERROR_INVALID_OPERATION;
794 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
797 _camera_update_api_waiting(cb_info, api, -1);
799 muse_core_msg_free(msg);
801 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
802 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
804 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
808 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
810 int ret = CAMERA_ERROR_NONE;
813 if (!cb_info->is_server_connected) {
814 CAM_LOG_ERROR("server is disconnected");
815 return CAMERA_ERROR_SERVICE_DISCONNECTED;
818 g_mutex_lock(&(cb_info->api_mutex[api]));
820 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
822 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
824 while (!cb_info->api_activating[api]) {
825 if (time_out == CAMERA_CB_NO_TIMEOUT) {
826 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
827 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
828 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
829 CAM_LOG_ERROR("api %d TIMED OUT!", api);
830 ret = CAMERA_ERROR_INVALID_OPERATION;
834 if (!cb_info->is_server_connected) {
835 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
839 if (!cb_info->api_activating[api])
840 CAM_LOG_WARNING("invalid signal received, wait again...");
843 ret = cb_info->api_ret[api];
844 cb_info->api_activating[api] = FALSE;
847 g_mutex_unlock(&(cb_info->api_mutex[api]));
849 if (ret != CAMERA_ERROR_NONE)
850 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
856 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
857 int *ret, int timeout)
862 CAM_LOG_ERROR("NULL info - api %d", api);
865 *ret = CAMERA_ERROR_INVALID_PARAMETER;
870 msg = muse_core_msg_new(api, NULL);
872 __send_message_get_return(cb_info, api, msg, timeout, ret);
876 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
877 int *ret, camera_msg_param *param, int timeout)
882 if (!cb_info || !param) {
883 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
886 *ret = CAMERA_ERROR_INVALID_PARAMETER;
891 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
893 switch (param->type) {
895 msg = muse_core_msg_new(api,
896 param->type, param->name, param->value.value_INT,
899 case MUSE_TYPE_STRING:
900 msg = muse_core_msg_new(api,
901 param->type, param->name, param->value.value_STRING,
904 case MUSE_TYPE_ARRAY:
905 array_length = param->value_size / sizeof(int) + \
906 (param->value_size % sizeof(int) ? 1 : 0);
908 msg = muse_core_msg_new(api,
909 param->type, param->name, array_length, param->value.value_ARRAY,
913 CAM_LOG_ERROR("unknown type %d", param->type);
917 __send_message_get_return(cb_info, api, msg, timeout, ret);
921 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
922 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
926 if (!cb_info || !param0 || !param1) {
927 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
928 cb_info, param0, param1, api);
931 *ret = CAMERA_ERROR_INVALID_PARAMETER;
936 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
938 param0->name, param0->value.value_INT,
939 param1->name, param1->value.value_INT);
941 msg = muse_core_msg_new(api,
942 param0->type, param0->name, param0->value.value_INT,
943 param1->type, param1->name, param1->value.value_INT,
946 __send_message_get_return(cb_info, api, msg, timeout, ret);
950 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
952 camera_msg_param param;
955 CAM_LOG_WARNING("invalid fd %d", ret_fd);
959 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
961 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
965 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
967 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
968 in_format >= MM_PIXEL_FORMAT_NUM ||
969 out_format == NULL) {
970 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
971 return CAMERA_ERROR_INVALID_PARAMETER;
975 case MM_PIXEL_FORMAT_NV12:
976 case MM_PIXEL_FORMAT_NV12T:
977 *out_format = TBM_FORMAT_NV12;
980 case MM_PIXEL_FORMAT_NV16:
981 *out_format = TBM_FORMAT_NV16;
983 case MM_PIXEL_FORMAT_NV21:
984 *out_format = TBM_FORMAT_NV21;
986 case MM_PIXEL_FORMAT_YUYV:
987 *out_format = TBM_FORMAT_YUYV;
989 case MM_PIXEL_FORMAT_UYVY:
990 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
991 *out_format = TBM_FORMAT_UYVY;
993 case MM_PIXEL_FORMAT_422P:
994 *out_format = TBM_FORMAT_YUV422;
996 case MM_PIXEL_FORMAT_I420:
997 *out_format = TBM_FORMAT_YUV420;
999 case MM_PIXEL_FORMAT_YV12:
1000 *out_format = TBM_FORMAT_YVU420;
1002 case MM_PIXEL_FORMAT_RGB565:
1003 *out_format = TBM_FORMAT_RGB565;
1005 case MM_PIXEL_FORMAT_RGB888:
1006 *out_format = TBM_FORMAT_RGB888;
1008 case MM_PIXEL_FORMAT_RGBA:
1009 *out_format = TBM_FORMAT_RGBA8888;
1011 case MM_PIXEL_FORMAT_ARGB:
1012 *out_format = TBM_FORMAT_ARGB8888;
1015 CAM_LOG_ERROR("invalid in_format %d", in_format);
1016 return CAMERA_ERROR_INVALID_PARAMETER;
1020 return CAMERA_ERROR_NONE;
1024 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1026 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1027 in_format >= MM_PIXEL_FORMAT_NUM ||
1029 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1030 return CAMERA_ERROR_INVALID_PARAMETER;
1033 switch (in_format) {
1034 case MM_PIXEL_FORMAT_NV12:
1035 case MM_PIXEL_FORMAT_NV12T:
1036 *mimetype = MEDIA_FORMAT_NV12;
1039 case MM_PIXEL_FORMAT_NV16:
1040 *mimetype = MEDIA_FORMAT_NV16;
1042 case MM_PIXEL_FORMAT_NV21:
1043 *mimetype = MEDIA_FORMAT_NV21;
1045 case MM_PIXEL_FORMAT_YUYV:
1046 *mimetype = MEDIA_FORMAT_YUYV;
1048 case MM_PIXEL_FORMAT_UYVY:
1049 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1050 *mimetype = MEDIA_FORMAT_UYVY;
1052 case MM_PIXEL_FORMAT_422P:
1053 *mimetype = MEDIA_FORMAT_422P;
1055 case MM_PIXEL_FORMAT_I420:
1056 *mimetype = MEDIA_FORMAT_I420;
1058 case MM_PIXEL_FORMAT_YV12:
1059 *mimetype = MEDIA_FORMAT_YV12;
1061 case MM_PIXEL_FORMAT_RGB565:
1062 *mimetype = MEDIA_FORMAT_RGB565;
1064 case MM_PIXEL_FORMAT_RGB888:
1065 *mimetype = MEDIA_FORMAT_RGB888;
1067 case MM_PIXEL_FORMAT_RGBA:
1068 *mimetype = MEDIA_FORMAT_RGBA;
1070 case MM_PIXEL_FORMAT_ARGB:
1071 *mimetype = MEDIA_FORMAT_ARGB;
1073 case MM_PIXEL_FORMAT_ENCODED_H264:
1074 /* TODO: How can we determine the profile for H.264 format? */
1075 *mimetype = MEDIA_FORMAT_H264_SP;
1077 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1078 *mimetype = MEDIA_FORMAT_MJPEG;
1080 case MM_PIXEL_FORMAT_ENCODED_VP8:
1081 *mimetype = MEDIA_FORMAT_VP8;
1083 case MM_PIXEL_FORMAT_ENCODED_VP9:
1084 *mimetype = MEDIA_FORMAT_VP9;
1087 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1088 return CAMERA_ERROR_NOT_SUPPORTED;
1092 return CAMERA_ERROR_NONE;
1096 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1097 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1100 int ret = CAMERA_ERROR_NONE;
1101 camera_media_packet_data *new_mp_data = NULL;
1103 if (!tfd || !mp_data) {
1104 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1105 return CAMERA_ERROR_INVALID_PARAMETER;
1108 new_mp_data = g_new0(camera_media_packet_data, 1);
1110 new_mp_data->ret_fd = ret_fd;
1111 new_mp_data->fd = tfd[0];
1112 new_mp_data->num_buffer_fd = num_buffer_fd;
1113 new_mp_data->bo = bo;
1115 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1119 new_mp_data->data_bo = data_bo;
1120 new_mp_data->data_fd = tfd[1];
1122 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1123 new_mp_data->data_bo, new_mp_data->data_fd);
1126 for (i = 0 ; i < num_buffer_fd ; i++) {
1127 new_mp_data->buffer_bo[i] = buffer_bo[i];
1128 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1130 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1131 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1134 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1135 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1137 new_mp_data->data_fd = CAMERA_FD_INIT;
1140 *mp_data = new_mp_data;
1142 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1147 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1151 if (!mp_data || !cb_info) {
1152 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1156 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1158 /* release imported bo and close fd */
1159 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1160 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1161 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1163 tbm_bo_unref(mp_data->buffer_bo[i]);
1165 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1166 close(mp_data->buffer_fd[i]);
1168 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1171 if (mp_data->data_bo) {
1172 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1173 mp_data->data_fd, mp_data->data_bo);
1175 tbm_bo_unref(mp_data->data_bo);
1177 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1178 close(mp_data->data_fd);
1180 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1183 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1185 tbm_bo_unref(mp_data->bo);
1187 if (CAMERA_IS_FD_VALID(mp_data->fd))
1190 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1193 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1199 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1202 int ret = CAMERA_ERROR_NONE;
1203 uint32_t tbm_format = 0;
1204 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1205 tbm_surface_info_s tsurf_info;
1207 if (!stream || !mp_data) {
1208 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1212 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1213 CAM_LOG_ERROR("No valid data");
1217 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1218 if (ret != CAMERA_ERROR_NONE)
1221 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1223 if (mp_data->num_buffer_fd > 0) {
1224 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1225 bos[i] = mp_data->buffer_bo[i];
1227 bos[0] = mp_data->data_bo;
1230 tsurf_info.width = stream->width;
1231 tsurf_info.height = stream->height;
1232 tsurf_info.format = tbm_format;
1233 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1234 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1236 switch (tbm_format) {
1237 case TBM_FORMAT_NV12: /* fall through */
1238 case TBM_FORMAT_NV21: /* fall through */
1239 case TBM_FORMAT_YUV420: /* fall through */
1240 case TBM_FORMAT_YVU420: /* fall through */
1241 case TBM_FORMAT_UYVY: /* fall through */
1242 case TBM_FORMAT_YUYV:
1243 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1244 tsurf_info.planes[i].stride = stream->stride[i];
1245 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1246 if (i != 0 && mp_data->num_buffer_fd <= 1)
1247 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1248 tsurf_info.size += tsurf_info.planes[i].size;
1250 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1251 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1255 case TBM_FORMAT_RGB565: /* fall through */
1256 case TBM_FORMAT_RGB888: /* fall through */
1257 case TBM_FORMAT_RGBA8888: /* fall through */
1258 case TBM_FORMAT_ARGB8888:
1259 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1260 tsurf_info.planes[0].offset = 0;
1261 tsurf_info.size = stream->data.rgb.length_data;
1264 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1269 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1270 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1274 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1276 int ret = CAMERA_ERROR_NONE;
1277 int pkt_fmt_width = 0;
1278 int pkt_fmt_height = 0;
1279 bool make_pkt_fmt = false;
1280 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1281 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1283 if (!cb_info || !stream) {
1284 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1285 return CAMERA_ERROR_INVALID_PARAMETER;
1288 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1289 if (ret != CAMERA_ERROR_NONE)
1292 /* check media packet format */
1293 if (cb_info->pkt_fmt) {
1294 media_format_get_video_info(cb_info->pkt_fmt,
1295 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1297 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1298 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1300 if (pkt_fmt_mimetype != mimetype ||
1301 pkt_fmt_width != stream->width ||
1302 pkt_fmt_height != stream->height) {
1303 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1304 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1306 media_format_unref(cb_info->pkt_fmt);
1307 cb_info->pkt_fmt = NULL;
1308 make_pkt_fmt = true;
1311 make_pkt_fmt = true;
1314 /* create packet format */
1316 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1317 mimetype, stream->width, stream->height);
1319 ret = media_format_create(&cb_info->pkt_fmt);
1320 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1321 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1322 return CAMERA_ERROR_INVALID_OPERATION;
1325 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1326 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1327 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1328 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1329 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1330 return CAMERA_ERROR_INVALID_OPERATION;
1334 return CAMERA_ERROR_NONE;
1338 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1339 camera_media_packet_data *mp_data, media_packet_h *packet)
1341 media_packet_h pkt = NULL;
1342 tbm_surface_h tsurf = NULL;
1343 int ret = CAMERA_ERROR_NONE;
1345 if (!cb_info || !stream || !mp_data || !packet) {
1346 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1347 cb_info, stream, mp_data, packet);
1348 return CAMERA_ERROR_INVALID_PARAMETER;
1351 ret = __camera_update_media_packet_format(cb_info, stream);
1352 if (ret != CAMERA_ERROR_NONE)
1355 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1356 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1357 stream->data.encoded.data, stream->data.encoded.length_data,
1358 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1361 tsurf = __camera_get_tbm_surface(stream, mp_data);
1363 CAM_LOG_ERROR("get tbm surface failed");
1364 ret = CAMERA_ERROR_INVALID_OPERATION;
1365 goto _PACKET_CREATE_FAILED;
1368 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1369 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1370 (void *)cb_info, &pkt);
1373 if (ret != MEDIA_PACKET_ERROR_NONE) {
1374 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1375 goto _PACKET_CREATE_FAILED;
1378 ret = media_packet_set_extra(pkt, (void *)mp_data);
1379 if (ret != MEDIA_PACKET_ERROR_NONE) {
1380 CAM_LOG_ERROR("media_packet_set_extra failed");
1381 goto _PACKET_CREATE_FAILED;
1384 /* set timestamp : msec -> nsec */
1385 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1386 CAM_LOG_WARNING("media_packet_set_pts failed");
1388 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1389 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1391 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1395 return CAMERA_ERROR_NONE;
1397 _PACKET_CREATE_FAILED:
1399 tbm_surface_destroy(tsurf);
1401 media_packet_unref(pkt);
1403 return CAMERA_ERROR_INVALID_OPERATION;
1406 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1409 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1410 camera_media_packet_data *mp_data = NULL;
1411 tbm_surface_h tsurf = NULL;
1413 if (!pkt || !cb_info) {
1414 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1418 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1419 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1420 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1424 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1426 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1427 pkt, mp_data, tsurf);
1430 tbm_surface_destroy(tsurf);
1432 g_mutex_lock(&cb_info->mp_data_mutex);
1433 __camera_release_media_packet_data(mp_data, cb_info);
1434 g_mutex_unlock(&cb_info->mp_data_mutex);
1437 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1442 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1443 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1447 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1449 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1451 if (cb_info->user_cb[event] == NULL) {
1452 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1453 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1454 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1455 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1456 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1457 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1461 /* return buffer message should be sent for some events.
1462 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1463 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1464 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1465 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1470 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1476 muse_camera_msg_get(previous, recv_msg);
1477 muse_camera_msg_get(current, recv_msg);
1478 muse_camera_msg_get(by_policy, recv_msg);
1480 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1481 previous, current, by_policy);
1483 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1484 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1487 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1491 muse_camera_msg_get(state, recv_msg);
1493 CAM_LOG_INFO("FOCUS state - %d", state);
1495 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1498 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1499 CAM_LOG_INFO("CAPTURE_COMPLETED");
1500 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1502 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1503 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1504 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1507 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1511 muse_camera_msg_get(percent, recv_msg);
1513 CAM_LOG_INFO("HDR progress - %d %%", percent);
1515 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1518 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1524 muse_camera_msg_get(policy, recv_msg);
1525 muse_camera_msg_get(previous, recv_msg);
1526 muse_camera_msg_get(current, recv_msg);
1528 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1530 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1531 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1534 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1539 muse_camera_msg_get(policy, recv_msg);
1540 muse_camera_msg_get(state, recv_msg);
1542 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1544 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1545 (camera_state_e)state, cb_info->user_data[event]);
1548 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1549 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1551 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1554 int current_state = 0;
1556 muse_camera_msg_get(error, recv_msg);
1557 muse_camera_msg_get(current_state, recv_msg);
1559 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1561 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1562 (camera_state_e)current_state, cb_info->user_data[event]);
1566 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1568 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1569 muse_camera_msg_get(param1, recv_msg);
1570 muse_camera_msg_get(param2, recv_msg);
1572 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1574 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1575 cb_info->user_cb[event] = NULL;
1576 cb_info->user_data[event] = NULL;
1577 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1582 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1584 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1604 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1607 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1609 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1610 muse_camera_msg_get(param1, recv_msg);
1612 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1614 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1615 cb_info->user_cb[event] = NULL;
1616 cb_info->user_data[event] = NULL;
1617 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1621 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1622 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1625 CAM_LOG_WARNING("unhandled event %d", event);
1629 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1632 static gboolean __camera_idle_event_callback(gpointer data)
1634 camera_cb_info_s *cb_info = NULL;
1635 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1637 if (cam_idle_event == NULL) {
1638 CAM_LOG_ERROR("cam_idle_event is NULL");
1643 g_mutex_lock(&g_cam_idle_event_lock);
1645 cb_info = cam_idle_event->cb_info;
1646 if (cb_info == NULL) {
1647 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1648 g_mutex_unlock(&g_cam_idle_event_lock);
1649 goto IDLE_EVENT_CALLBACK_DONE;
1652 /* remove event from list */
1653 if (cb_info->idle_event_list)
1654 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1656 g_mutex_unlock(&g_cam_idle_event_lock);
1659 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1661 IDLE_EVENT_CALLBACK_DONE:
1663 g_free(cam_idle_event);
1664 cam_idle_event = NULL;
1669 static gpointer __camera_msg_handler_func(gpointer data)
1673 camera_message_s *cam_msg = NULL;
1674 camera_idle_event_s *cam_idle_event = NULL;
1675 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1676 camera_cb_info_s *cb_info = NULL;
1677 GThread *thread = NULL;
1679 if (!handler_info || !handler_info->cb_info) {
1680 CAM_LOG_ERROR("NULL handler %p", handler_info);
1684 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1685 type = handler_info->type;
1686 thread = handler_info->thread;
1688 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1690 g_mutex_lock(&handler_info->mutex);
1692 while (g_atomic_int_get(&handler_info->running)) {
1693 if (g_queue_is_empty(handler_info->queue)) {
1694 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1695 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1696 CAM_LOG_VERBOSE("t[%d] signal received", type);
1698 if (g_atomic_int_get(&handler_info->running) == 0) {
1699 CAM_LOG_INFO("t:%d stop event thread", type);
1704 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1706 g_mutex_unlock(&handler_info->mutex);
1708 if (cam_msg == NULL) {
1709 CAM_LOG_ERROR("t:%d NULL message", type);
1710 g_mutex_lock(&handler_info->mutex);
1716 if (api < MUSE_CAMERA_API_MAX) {
1719 g_mutex_lock(&cb_info->api_mutex[api]);
1721 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1722 if (cb_info->api_waiting[api] > 0) {
1723 cb_info->api_ret[api] = ret;
1724 cb_info->api_activating[api] = TRUE;
1726 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1728 g_cond_broadcast(&cb_info->api_cond[api]);
1730 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1733 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1736 g_mutex_unlock(&cb_info->api_mutex[api]);
1737 } else if (api == MUSE_CAMERA_CB_EVENT) {
1738 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1739 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1740 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1743 switch (cam_msg->event_class) {
1744 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1745 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1747 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1748 cam_idle_event = g_new0(camera_idle_event_s, 1);
1749 if (cam_idle_event == NULL) {
1750 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1754 cam_idle_event->event = cam_msg->event;
1755 cam_idle_event->cb_info = cb_info;
1757 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1758 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1760 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1761 type, cam_msg->event, cam_idle_event);
1763 g_mutex_lock(&g_cam_idle_event_lock);
1764 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1765 g_mutex_unlock(&g_cam_idle_event_lock);
1767 g_idle_add_full(G_PRIORITY_DEFAULT,
1768 (GSourceFunc)__camera_idle_event_callback,
1769 (gpointer)cam_idle_event,
1773 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1777 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1783 g_mutex_lock(&handler_info->mutex);
1786 /* remove remained event */
1787 while (!g_queue_is_empty(handler_info->queue)) {
1788 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1790 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1791 __camera_release_tfd(cam_msg->tfd);
1794 CAM_LOG_WARNING("t:%d NULL message", type);
1798 g_mutex_unlock(&handler_info->mutex);
1800 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1806 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1808 camera_idle_event_s *cam_idle_event = NULL;
1811 if (cb_info == NULL) {
1812 CAM_LOG_ERROR("cb_info is NULL");
1816 g_mutex_lock(&g_cam_idle_event_lock);
1818 if (cb_info->idle_event_list == NULL) {
1819 CAM_LOG_INFO("No remained idle event");
1820 g_mutex_unlock(&g_cam_idle_event_lock);
1824 list = cb_info->idle_event_list;
1827 cam_idle_event = list->data;
1828 list = g_list_next(list);
1830 if (!cam_idle_event) {
1831 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1835 if (g_idle_remove_by_data(cam_idle_event)) {
1836 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1838 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1840 g_free(cam_idle_event);
1841 cam_idle_event = NULL;
1846 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1847 cam_idle_event, cam_idle_event->event);
1849 cam_idle_event->cb_info = NULL;
1851 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1854 g_list_free(cb_info->idle_event_list);
1855 cb_info->idle_event_list = NULL;
1857 g_mutex_unlock(&g_cam_idle_event_lock);
1861 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1863 camera_message_s *cam_msg = NULL;
1865 if (!cb_info || !msg) {
1866 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1870 cam_msg = g_new0(camera_message_s, 1);
1872 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1877 cam_msg->event = event;
1878 cam_msg->event_class = event_class;
1881 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1883 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1885 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1886 api, event, event_class);
1888 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1889 if (!cb_info->preview_cb_info.thread) {
1890 LOGI("The thread for preview cb is not created yet, create it now");
1891 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1892 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1893 CAM_LOG_ERROR("failed to create thread for preview cb");
1899 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1900 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1901 g_cond_signal(&cb_info->preview_cb_info.cond);
1902 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1903 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1904 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1905 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1906 g_cond_signal(&cb_info->capture_cb_info.cond);
1907 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1909 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1910 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1911 g_cond_signal(&cb_info->msg_handler_info.cond);
1912 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1919 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1921 int ret = CAMERA_ERROR_NONE;
1925 int event_class = -1;
1929 if (!cb_info || !msg) {
1930 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1934 CAM_LOG_DEBUG("msg[%s]", msg);
1936 if (!muse_camera_msg_get(api, msg)) {
1937 CAM_LOG_ERROR("failed to get camera api");
1941 if (api == MUSE_CAMERA_CB_EVENT) {
1942 if (!muse_camera_msg_get(event, msg) ||
1943 !muse_camera_msg_get(event_class, msg)) {
1944 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1948 if (!muse_camera_msg_get(api_class, msg)) {
1949 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1954 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1955 if (api >= MUSE_CAMERA_API_MAX) {
1956 CAM_LOG_ERROR("invalid api %d", api);
1960 if (!muse_camera_msg_get(ret, msg)) {
1961 CAM_LOG_ERROR("failed to get camera ret");
1965 g_mutex_lock(&cb_info->api_mutex[api]);
1968 case MUSE_CAMERA_API_CREATE:
1969 if (ret != CAMERA_ERROR_NONE) {
1970 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1971 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1974 case MUSE_CAMERA_API_DESTROY:
1975 if (ret == CAMERA_ERROR_NONE) {
1976 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1977 CAM_LOG_INFO("camera destroy done. close client cb handler");
1981 muse_camera_msg_get(get_type, msg);
1982 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1983 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1984 muse_camera_msg_get(get_index, msg);
1987 case MUSE_CAMERA_GET_TYPE_INT:
1988 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1990 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1991 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1992 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1994 case MUSE_CAMERA_GET_TYPE_ARRAY:
1996 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
1997 muse_core_msg_deserialize("get_value",
1998 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1999 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2000 cb_info->get_display_roi_area[0],
2001 cb_info->get_display_roi_area[1],
2002 cb_info->get_display_roi_area[2],
2003 cb_info->get_display_roi_area[3]);
2005 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2006 muse_core_msg_deserialize("get_value",
2007 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2008 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2009 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2011 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2012 muse_core_msg_deserialize("get_value",
2013 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2014 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2015 cb_info->get_extra_preview_stream_format[0],
2016 cb_info->get_extra_preview_stream_format[1],
2017 cb_info->get_extra_preview_stream_format[2],
2018 cb_info->get_extra_preview_stream_format[3]);
2021 CAM_LOG_WARNING("unknown api[%d]", api);
2025 case MUSE_CAMERA_GET_TYPE_STRING:
2026 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2029 CAM_LOG_WARNING("unknown type %d", get_type);
2036 if (cb_info->api_waiting[api] > 0) {
2037 cb_info->api_ret[api] = ret;
2038 cb_info->api_activating[api] = TRUE;
2040 g_cond_broadcast(&cb_info->api_cond[api]);
2042 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2045 g_mutex_unlock(&cb_info->api_mutex[api]);
2046 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2047 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2049 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2054 static gpointer __camera_msg_recv_func(gpointer data)
2057 int recv_length = 0;
2058 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2059 char *recv_msg = NULL;
2060 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2063 CAM_LOG_ERROR("cb_info NULL");
2067 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2069 recv_msg = cb_info->recv_msg;
2071 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2072 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2073 tfd[i] = CAMERA_FD_INIT;
2075 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2076 if (recv_length <= 0) {
2077 cb_info->is_server_connected = FALSE;
2078 CAM_LOG_ERROR("receive msg failed - server disconnected");
2082 if (CAMERA_IS_FD_VALID(tfd[0]))
2083 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2085 recv_msg[recv_length] = '\0';
2087 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2089 __camera_process_msg(cb_info, recv_msg, tfd);
2092 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2095 if (!cb_info->is_server_connected) {
2096 char *error_msg = NULL;
2098 if (cb_info->bufmgr == NULL) {
2099 CAM_LOG_ERROR("No need to send error(handle is not created)");
2103 if (cb_info->fd < 0) {
2104 CAM_LOG_ERROR("fd is closed in client side");
2108 /* send error msg for server disconnection */
2109 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2110 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2111 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2115 CAM_LOG_ERROR("error_msg failed");
2119 __camera_add_msg_to_queue(cb_info,
2120 MUSE_CAMERA_CB_EVENT,
2121 MUSE_CAMERA_EVENT_TYPE_ERROR,
2122 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2126 muse_core_msg_free(error_msg);
2129 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2130 if (cb_info->api_waiting[i])
2131 g_cond_broadcast(&cb_info->api_cond[i]);
2134 CAM_LOG_ERROR("add error msg for service disconnection done");
2142 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2143 int type, const char *thread_name, camera_cb_info_s *cb_info)
2145 if (!handler_info || !thread_name || !cb_info) {
2146 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2147 type, handler_info, thread_name, cb_info);
2151 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2153 if (handler_info->thread) {
2154 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2158 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2160 handler_info->type = type;
2161 handler_info->queue = g_queue_new();
2162 if (handler_info->queue == NULL) {
2163 CAM_LOG_ERROR("t:%d queue failed", type);
2167 handler_info->cb_info = (void *)cb_info;
2168 g_atomic_int_set(&handler_info->running, 1);
2170 handler_info->thread = g_thread_try_new(thread_name,
2171 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2172 if (handler_info->thread == NULL) {
2173 CAM_LOG_ERROR("t:%d thread failed", type);
2175 g_queue_free(handler_info->queue);
2176 handler_info->queue = NULL;
2181 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2187 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2189 GThread *thread = NULL;
2191 if (!handler_info) {
2192 CAM_LOG_ERROR("NULL handler");
2196 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2198 if (!handler_info->thread) {
2199 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2203 thread = handler_info->thread;
2204 handler_info->thread = NULL;
2206 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2208 g_atomic_int_set(&handler_info->running, 0);
2209 g_cond_signal(&handler_info->cond);
2211 g_clear_pointer(&locker, g_mutex_locker_free);
2213 g_thread_join(thread);
2215 g_queue_free(handler_info->queue);
2216 handler_info->queue = NULL;
2218 CAM_LOG_INFO("t:%d done", handler_info->type);
2222 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2227 CAM_LOG_ERROR("NULL cb_info");
2231 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2232 g_mutex_init(&cb_info->api_mutex[i]);
2233 g_cond_init(&cb_info->api_cond[i]);
2236 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2237 g_mutex_init(&cb_info->user_cb_mutex[i]);
2239 g_mutex_init(&cb_info->fd_lock);
2240 g_mutex_init(&cb_info->mp_data_mutex);
2241 g_mutex_init(&cb_info->bridge_lock);
2243 g_mutex_init(&cb_info->msg_handler_info.mutex);
2244 g_mutex_init(&cb_info->preview_cb_info.mutex);
2245 g_mutex_init(&cb_info->capture_cb_info.mutex);
2246 g_cond_init(&cb_info->msg_handler_info.cond);
2247 g_cond_init(&cb_info->preview_cb_info.cond);
2248 g_cond_init(&cb_info->capture_cb_info.cond);
2250 CAM_LOG_INFO("done");
2254 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2259 CAM_LOG_ERROR("NULL cb_info");
2263 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2264 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2265 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2266 g_cond_clear(&cb_info->msg_handler_info.cond);
2267 g_cond_clear(&cb_info->preview_cb_info.cond);
2268 g_cond_clear(&cb_info->capture_cb_info.cond);
2270 g_mutex_clear(&cb_info->fd_lock);
2271 g_mutex_clear(&cb_info->mp_data_mutex);
2272 g_mutex_clear(&cb_info->bridge_lock);
2274 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2275 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2277 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2278 g_mutex_clear(&cb_info->api_mutex[i]);
2279 g_cond_clear(&cb_info->api_cond[i]);
2282 CAM_LOG_INFO("done");
2286 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2288 camera_cb_info_s *cb_info = NULL;
2291 g_return_val_if_fail(sockfd > 0, NULL);
2293 cb_info = g_new0(camera_cb_info_s, 1);
2295 CAM_LOG_ERROR("cb_info failed");
2299 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2301 __camera_mutex_cond_init(cb_info);
2303 /* message handler thread */
2304 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2305 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2306 CAM_LOG_ERROR("msg_handler_info failed");
2310 /* message handler thread for capture callback */
2311 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2312 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2313 CAM_LOG_ERROR("capture_cb_info failed");
2317 cb_info->fd = sockfd;
2319 /* message receive thread */
2320 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2321 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2322 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2323 if (cb_info->msg_recv_thread == NULL) {
2324 CAM_LOG_ERROR("message receive thread creation failed");
2329 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2330 cb_info->fds[i] = CAMERA_FD_INIT;
2332 cb_info->is_server_connected = TRUE;
2338 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2339 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2341 __camera_mutex_cond_clear(cb_info);
2352 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2355 CAM_LOG_ERROR("NULL cb_info");
2359 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2361 g_thread_join(cb_info->msg_recv_thread);
2362 cb_info->msg_recv_thread = NULL;
2364 CAM_LOG_INFO("msg_recv thread removed");
2366 /* destroy msg handler threads */
2367 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2368 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2369 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2371 __camera_mutex_cond_clear(cb_info);
2373 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2374 muse_client_close(cb_info->fd);
2375 cb_info->fd = CAMERA_FD_INIT;
2378 if (cb_info->bufmgr) {
2379 tbm_bufmgr_deinit(cb_info->bufmgr);
2380 cb_info->bufmgr = NULL;
2382 if (cb_info->pkt_fmt) {
2383 media_format_unref(cb_info->pkt_fmt);
2384 cb_info->pkt_fmt = NULL;
2387 if (cb_info->dp_interface) {
2388 mm_display_interface_deinit(cb_info->dp_interface);
2389 cb_info->dp_interface = NULL;
2396 int _camera_start_evas_rendering(camera_h camera)
2398 camera_cli_s *pc = (camera_cli_s *)camera;
2400 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2402 CAM_LOG_INFO("start");
2404 if (!pc->cb_info->is_evas_render) {
2405 CAM_LOG_ERROR("EVAS surface is not set");
2406 return CAMERA_ERROR_NONE;
2409 /* set evas render flag as RUN */
2410 pc->cb_info->run_evas_render = true;
2412 return CAMERA_ERROR_NONE;
2416 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2418 int ret = CAMERA_ERROR_NONE;
2419 camera_cli_s *pc = (camera_cli_s *)camera;
2421 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2423 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2425 if (!pc->cb_info->is_evas_render) {
2426 CAM_LOG_ERROR("EVAS surface is not set");
2427 return CAMERA_ERROR_NONE;
2430 /* set evas render flag as STOP and release buffers */
2431 pc->cb_info->run_evas_render = false;
2433 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2434 if (ret == MM_ERROR_NONE) {
2435 ret = CAMERA_ERROR_NONE;
2437 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2438 ret = CAMERA_ERROR_INVALID_OPERATION;
2445 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2447 int ret = CAMERA_ERROR_NONE;
2448 int sock_fd = CAMERA_FD_INIT;
2449 int module_index = -1;
2451 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2453 /* create muse connection */
2454 if (!key || !value) {
2455 CAM_LOG_ERROR("NULL pointer");
2456 return CAMERA_ERROR_INVALID_PARAMETER;
2459 sock_fd = muse_client_new();
2461 CAM_LOG_ERROR("muse_client_new failed");
2462 return CAMERA_ERROR_INVALID_OPERATION;
2465 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2466 CAM_LOG_ERROR("muse client get module index failed");
2467 ret = CAMERA_ERROR_INVALID_OPERATION;
2471 msg = muse_core_msg_new(api,
2472 MUSE_TYPE_INT, "module", module_index,
2473 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2476 CAM_LOG_ERROR("msg failed");
2477 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2481 ret = muse_core_msg_send(sock_fd, msg);
2483 muse_core_msg_free(msg);
2487 CAM_LOG_ERROR("send msg failed");
2488 ret = CAMERA_ERROR_INVALID_OPERATION;
2492 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2494 CAM_LOG_ERROR("recv msg failed %d", errno);
2495 ret = CAMERA_ERROR_INVALID_OPERATION;
2499 if (!muse_camera_msg_get(ret, recv_msg)) {
2500 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2501 ret = CAMERA_ERROR_INVALID_OPERATION;
2505 if (ret == CAMERA_ERROR_NONE)
2506 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2508 CAM_LOG_INFO("api %d - value %d", api, *value);
2511 if (CAMERA_IS_FD_VALID(sock_fd)) {
2512 muse_client_close(sock_fd);
2513 sock_fd = CAMERA_FD_INIT;
2520 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2522 int sock_fd = CAMERA_FD_INIT;
2523 char *send_msg = NULL;
2525 int ret = CAMERA_ERROR_NONE;
2526 camera_cli_s *pc = NULL;
2527 tbm_bufmgr bufmgr = NULL;
2529 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2530 int module_index = -1;
2531 int device_type = (int)device;
2533 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2535 sock_fd = muse_client_new();
2537 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2538 ret = CAMERA_ERROR_INVALID_OPERATION;
2542 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2543 CAM_LOG_ERROR("muse client get module index failed");
2544 ret = CAMERA_ERROR_INVALID_OPERATION;
2548 send_msg = muse_core_msg_new(api,
2549 MUSE_TYPE_INT, "module", module_index,
2550 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2551 MUSE_TYPE_INT, "is_network", (int)is_network,
2555 CAM_LOG_ERROR("NULL msg");
2556 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2560 send_ret = muse_core_msg_send(sock_fd, send_msg);
2562 muse_core_msg_free(send_msg);
2566 CAM_LOG_ERROR("send msg failed %d", errno);
2567 ret = CAMERA_ERROR_INVALID_OPERATION;
2571 pc = g_new0(camera_cli_s, 1);
2573 CAM_LOG_ERROR("camera_cli_s alloc failed");
2574 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2578 bufmgr = tbm_bufmgr_init(-1);
2579 if (bufmgr == NULL) {
2580 CAM_LOG_ERROR("get tbm bufmgr failed");
2581 ret = CAMERA_ERROR_INVALID_OPERATION;
2585 pc->cb_info = __camera_client_callback_new(sock_fd);
2586 if (pc->cb_info == NULL) {
2587 CAM_LOG_ERROR("cb_info alloc failed");
2588 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2592 sock_fd = CAMERA_FD_INIT;
2594 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2596 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2598 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2600 if (ret == CAMERA_ERROR_NONE) {
2601 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2602 int user_buffer_supported = 0;
2603 int log_level = CAMERA_LOG_LEVEL_INFO;
2604 intptr_t handle = 0;
2606 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2608 CAM_LOG_ERROR("Receiving Handle Failed!!");
2609 ret = CAMERA_ERROR_INVALID_OPERATION;
2613 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2614 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2615 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2617 pc->remote_handle = handle;
2618 pc->cb_info->bufmgr = bufmgr;
2619 pc->cb_info->preview_format = preview_format;
2620 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2621 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2622 pc->cb_info->is_network = is_network;
2623 g_camera_log_level = log_level;
2625 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2626 preview_format, user_buffer_supported, g_camera_log_level);
2629 CAM_LOG_ERROR("NULL out handle");
2630 ret= CAMERA_ERROR_INVALID_PARAMETER;
2634 *camera = (camera_h)pc;
2636 /* get display interface handle */
2637 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2638 CAM_LOG_WARNING("display interface init failed");
2647 tbm_bufmgr_deinit(bufmgr);
2651 if (CAMERA_IS_FD_VALID(sock_fd)) {
2652 muse_client_close(sock_fd);
2653 sock_fd = CAMERA_FD_INIT;
2658 int temp_fd = pc->cb_info->fd;
2660 /* pc->cb_info->fd should be closed,
2661 because g_thread_join for msg_recv_thread is not returned
2662 in __camera_client_callback_destroy. */
2663 if (CAMERA_IS_FD_VALID(temp_fd)) {
2664 pc->cb_info->fd = CAMERA_FD_INIT;
2665 muse_client_close(temp_fd);
2668 __camera_client_callback_destroy(pc->cb_info);
2675 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2682 int camera_create(camera_device_e device, camera_h *camera)
2684 return _camera_create_private(device, false, camera);
2688 int camera_change_device(camera_h camera, camera_device_e device)
2691 int ret = CAMERA_ERROR_NONE;
2692 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2693 camera_cli_s *pc = (camera_cli_s *)camera;
2694 camera_msg_param param;
2696 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2698 CAMERA_MSG_PARAM_SET(param, INT, device);
2700 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2702 if (ret == CAMERA_ERROR_NONE) {
2703 /* reset callback and user data */
2704 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2705 pc->cb_info->user_cb[i] = NULL;
2706 pc->cb_info->user_data[i] = NULL;
2714 int camera_destroy(camera_h camera)
2716 int ret = CAMERA_ERROR_NONE;
2717 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2718 camera_cli_s *pc = (camera_cli_s *)camera;
2720 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2722 CAM_LOG_INFO("Enter");
2724 if (pc->cb_info->is_server_connected)
2725 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2727 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2729 if (ret == CAMERA_ERROR_NONE) {
2730 __camera_deactivate_idle_event_all(pc->cb_info);
2731 __camera_client_callback_destroy(pc->cb_info);
2738 CAM_LOG_INFO("ret : 0x%x", ret);
2743 int camera_start_preview(camera_h camera)
2745 int ret = CAMERA_ERROR_NONE;
2747 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2748 camera_cli_s *pc = (camera_cli_s *)camera;
2749 camera_state_e current_state = CAMERA_STATE_NONE;
2751 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2753 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2754 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2756 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2757 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2758 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2759 pc->cb_info->dp_info.type);
2760 return CAMERA_ERROR_INVALID_OPERATION;
2763 ret = camera_get_state(camera, ¤t_state);
2764 if (ret != CAMERA_ERROR_NONE) {
2765 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2769 if (current_state == CAMERA_STATE_CREATED) {
2770 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2771 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2772 CAM_LOG_ERROR("preview_cb_info failed");
2773 return CAMERA_ERROR_INVALID_OPERATION;
2776 if (pc->cb_info->user_buffer_supported) {
2777 if (!__camera_allocate_preview_buffer(camera)) {
2778 ret = CAMERA_ERROR_INVALID_OPERATION;
2782 fds = pc->cb_info->fds;
2786 _camera_msg_send(api, fds, pc->cb_info, &ret,
2787 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2788 CAMERA_CB_NO_TIMEOUT);
2790 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2792 if (ret != CAMERA_ERROR_NONE)
2795 if (pc->cb_info->is_evas_render) {
2796 ret = _camera_start_evas_rendering(camera);
2797 if (ret != CAMERA_ERROR_NONE) {
2798 CAM_LOG_ERROR("stop preview because of error");
2799 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2804 CAM_LOG_INFO("done");
2806 return CAMERA_ERROR_NONE;
2809 if (current_state == CAMERA_STATE_CREATED) {
2810 if (pc->cb_info->user_buffer_supported)
2811 __camera_release_preview_buffer(camera);
2813 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2816 CAM_LOG_ERROR("failed : 0x%x", ret);
2822 int camera_stop_preview(camera_h camera)
2824 int ret = CAMERA_ERROR_NONE;
2825 camera_cli_s *pc = (camera_cli_s *)camera;
2826 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2827 camera_state_e current_state = CAMERA_STATE_NONE;
2829 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2831 CAM_LOG_INFO("Enter");
2834 if (pc->cb_info->is_evas_render) {
2835 ret = camera_get_state(camera, ¤t_state);
2836 if (ret != CAMERA_ERROR_NONE) {
2837 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2841 if (current_state == CAMERA_STATE_PREVIEW) {
2842 ret = _camera_stop_evas_rendering(camera, false);
2843 if (ret != CAMERA_ERROR_NONE)
2848 /* send stop preview message */
2849 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2851 if (ret == CAMERA_ERROR_NONE) {
2852 if (pc->cb_info->user_buffer_supported)
2853 __camera_release_preview_buffer(camera);
2855 /* release remained message for preview callback */
2856 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2857 } else if (current_state == CAMERA_STATE_PREVIEW) {
2858 CAM_LOG_WARNING("restart evas rendering");
2859 _camera_start_evas_rendering(camera);
2862 CAM_LOG_INFO("ret : 0x%x", ret);
2868 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2870 int ret = CAMERA_ERROR_NONE;
2871 camera_cli_s *pc = (camera_cli_s *)camera;
2872 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2874 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2876 CAM_LOG_INFO("Enter");
2878 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2879 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2886 CAM_LOG_INFO("ret : 0x%x", ret);
2892 bool camera_is_supported_continuous_capture(camera_h camera)
2894 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2898 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)
2900 int ret = CAMERA_ERROR_NONE;
2901 camera_cli_s *pc = (camera_cli_s *)camera;
2902 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2903 camera_msg_param param;
2906 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2908 CAM_LOG_INFO("Enter");
2910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2913 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2914 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2916 value = (count << 16) | interval;
2917 CAMERA_MSG_PARAM_SET(param, INT, value);
2919 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2921 CAM_LOG_INFO("ret : 0x%x", ret);
2927 int camera_stop_continuous_capture(camera_h camera)
2929 int ret = CAMERA_ERROR_NONE;
2930 camera_cli_s *pc = (camera_cli_s *)camera;
2931 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2933 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2935 CAM_LOG_INFO("Enter");
2937 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2939 CAM_LOG_INFO("ret : 0x%x", ret);
2945 bool camera_is_supported_face_detection(camera_h camera)
2947 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2951 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2953 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2957 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2959 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2963 bool camera_is_supported_extra_preview(camera_h camera)
2965 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2969 int camera_get_device_count(camera_h camera, int *device_count)
2971 int ret = CAMERA_ERROR_NONE;
2972 camera_cli_s *pc = (camera_cli_s *)camera;
2973 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2975 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2977 CAM_LOG_INFO("Enter");
2979 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2981 if (ret == CAMERA_ERROR_NONE)
2982 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2984 CAM_LOG_INFO("ret : 0x%x", ret);
2989 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2991 int ret = CAMERA_ERROR_NONE;
2992 camera_cli_s *pc = (camera_cli_s *)camera;
2993 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2995 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2997 CAM_LOG_INFO("Enter");
2999 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3001 if (ret == CAMERA_ERROR_NONE) {
3002 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3004 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3005 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3007 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3010 CAM_LOG_INFO("ret : 0x%x", ret);
3015 int camera_stop_face_detection(camera_h camera)
3017 int ret = CAMERA_ERROR_NONE;
3018 camera_cli_s *pc = (camera_cli_s *)camera;
3019 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3021 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3023 CAM_LOG_INFO("Enter");
3025 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3027 if (ret == CAMERA_ERROR_NONE) {
3028 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3030 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3031 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3033 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3036 CAM_LOG_INFO("ret : 0x%x", ret);
3041 int camera_get_state(camera_h camera, camera_state_e *state)
3043 int ret = CAMERA_ERROR_NONE;
3044 camera_cli_s *pc = (camera_cli_s *)camera;
3045 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3047 if (!pc || !pc->cb_info || !state) {
3048 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3049 return CAMERA_ERROR_INVALID_PARAMETER;
3052 CAM_LOG_INFO("Enter");
3054 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3056 if (ret == CAMERA_ERROR_NONE)
3057 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3059 CAM_LOG_INFO("ret : 0x%x", ret);
3064 int camera_start_focusing(camera_h camera, bool continuous)
3066 int ret = CAMERA_ERROR_NONE;
3067 camera_cli_s *pc = (camera_cli_s *)camera;
3068 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3069 camera_msg_param param;
3070 int is_continuous = (int)continuous;
3072 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3074 CAM_LOG_INFO("Enter");
3076 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3078 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3080 CAM_LOG_INFO("ret : 0x%x", ret);
3085 int camera_cancel_focusing(camera_h camera)
3087 int ret = CAMERA_ERROR_NONE;
3088 camera_cli_s *pc = (camera_cli_s *)camera;
3089 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3091 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3093 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3095 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3097 CAM_LOG_INFO("ret : 0x%x", ret);
3103 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3105 int mm_ret = MM_ERROR_NONE;
3106 int ret = CAMERA_ERROR_NONE;
3107 camera_cli_s *pc = (camera_cli_s *)camera;
3108 camera_cb_info_s *cb_info = NULL;
3109 camera_state_e current_state = CAMERA_STATE_NONE;
3110 camera_msg_param param;
3111 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3112 muse_camera_display_info_s *dp_info = NULL;
3114 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3116 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3117 CAM_LOG_ERROR("invalid type %d", type);
3118 return CAMERA_ERROR_INVALID_PARAMETER;
3121 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3122 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3123 return CAMERA_ERROR_INVALID_PARAMETER;
3126 cb_info = (camera_cb_info_s *)pc->cb_info;
3127 dp_info = &cb_info->dp_info;
3129 ret = camera_get_state(camera, ¤t_state);
3130 if (ret != CAMERA_ERROR_NONE) {
3131 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3135 if (current_state != CAMERA_STATE_CREATED) {
3136 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3137 return CAMERA_ERROR_INVALID_STATE;
3140 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3142 if (type != MM_DISPLAY_TYPE_NONE) {
3143 /* check display interface handle */
3144 if (!cb_info->dp_interface) {
3145 CAM_LOG_ERROR("display interface not supported");
3146 return CAMERA_ERROR_NOT_SUPPORTED;
3149 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3150 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3151 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3152 return CAMERA_ERROR_NOT_SUPPORTED;
3153 } else if (mm_ret != MM_ERROR_NONE) {
3154 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3155 return CAMERA_ERROR_INVALID_OPERATION;
3158 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3159 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3161 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3162 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3163 dp_info->window_rect.width, dp_info->window_rect.height);
3164 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3166 camera_flip_e flip = CAMERA_FLIP_NONE;
3167 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3168 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3175 camera_get_display_flip(camera, &flip);
3176 camera_get_display_mode(camera, &mode);
3177 camera_get_display_rotation(camera, &rotation);
3178 camera_is_display_visible(camera, &visible);
3180 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3181 flip, mode, rotation, visible);
3183 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3184 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3185 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3186 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3188 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3189 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3190 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3191 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3197 if (mm_ret != MM_ERROR_NONE) {
3198 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3199 return CAMERA_ERROR_INVALID_OPERATION;
3202 dp_info->type = type;
3204 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3206 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3208 if (ret == CAMERA_ERROR_NONE)
3209 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3215 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3217 CAM_LOG_INFO("type %d, display %p", type, display);
3218 return _camera_set_display(camera, (mm_display_type_e)type, display);
3222 int camera_set_preview_resolution(camera_h camera, int width, int height)
3224 int ret = CAMERA_ERROR_NONE;
3225 camera_state_e current_state = CAMERA_STATE_NONE;
3226 camera_cli_s *pc = (camera_cli_s *)camera;
3227 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3228 camera_msg_param param;
3231 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3233 if (pc->cb_info->is_evas_render) {
3234 ret = camera_get_state(camera, ¤t_state);
3235 if (ret != CAMERA_ERROR_NONE) {
3236 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3240 if (current_state == CAMERA_STATE_PREVIEW) {
3241 ret = _camera_stop_evas_rendering(camera, true);
3242 if (ret != CAMERA_ERROR_NONE)
3247 value = (width << 16) | height;
3248 CAMERA_MSG_PARAM_SET(param, INT, value);
3250 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3252 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3254 CAM_LOG_INFO("ret : 0x%x", ret);
3256 if (current_state == CAMERA_STATE_PREVIEW) {
3257 CAM_LOG_WARNING("restart evas rendering");
3258 _camera_start_evas_rendering(camera);
3265 int camera_set_capture_resolution(camera_h camera, int width, int height)
3267 int ret = CAMERA_ERROR_NONE;
3268 camera_cli_s *pc = (camera_cli_s *)camera;
3269 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3270 camera_msg_param param;
3273 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3275 CAM_LOG_INFO("Enter");
3277 value = (width << 16) | height;
3278 CAMERA_MSG_PARAM_SET(param, INT, value);
3280 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3282 CAM_LOG_INFO("ret : 0x%x", ret);
3288 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3290 int ret = CAMERA_ERROR_NONE;
3291 int set_format = (int)format;
3292 camera_cli_s *pc = (camera_cli_s *)camera;
3293 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3294 camera_msg_param param;
3296 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3298 CAM_LOG_INFO("Enter - format %d", set_format);
3300 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3302 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3304 CAM_LOG_INFO("ret : 0x%x", ret);
3310 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3312 int ret = CAMERA_ERROR_NONE;
3313 int set_format = (int)format;
3314 camera_msg_param param;
3315 camera_cli_s *pc = (camera_cli_s *)camera;
3316 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3318 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3320 CAM_LOG_INFO("Enter - format %d", set_format);
3322 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3324 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3326 if (ret == CAMERA_ERROR_NONE)
3327 pc->cb_info->preview_format = set_format;
3329 CAM_LOG_INFO("ret : 0x%x", ret);
3335 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3337 int ret = CAMERA_ERROR_NONE;
3338 camera_cli_s *pc = (camera_cli_s *)camera;
3339 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3341 if (!pc || !pc->cb_info || !width || !height) {
3342 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3343 return CAMERA_ERROR_INVALID_PARAMETER;
3346 CAM_LOG_INFO("Enter");
3348 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3350 if (ret == CAMERA_ERROR_NONE) {
3351 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3352 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3355 CAM_LOG_INFO("ret : 0x%x", ret);
3361 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3363 int ret = CAMERA_ERROR_NONE;
3364 int set_rotation = (int)rotation;
3365 camera_cli_s *pc = (camera_cli_s *)camera;
3366 camera_msg_param param;
3368 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3370 if (pc->cb_info->is_evas_render) {
3371 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3372 if (ret != MM_ERROR_NONE) {
3373 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3374 return CAMERA_ERROR_INVALID_OPERATION;
3378 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3380 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3386 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3388 int ret = CAMERA_ERROR_NONE;
3389 camera_cli_s *pc = (camera_cli_s *)camera;
3391 if (!pc || !pc->cb_info || !rotation) {
3392 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3393 return CAMERA_ERROR_INVALID_PARAMETER;
3396 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3398 if (ret == CAMERA_ERROR_NONE)
3399 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3405 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3407 int ret = CAMERA_ERROR_NONE;
3408 int set_flip = (int)flip;
3409 camera_cli_s *pc = (camera_cli_s *)camera;
3410 camera_msg_param param;
3412 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3414 if (pc->cb_info->is_evas_render) {
3415 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3416 if (ret != MM_ERROR_NONE) {
3417 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3418 return CAMERA_ERROR_INVALID_OPERATION;
3422 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3424 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3430 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3432 int ret = CAMERA_ERROR_NONE;
3433 camera_cli_s *pc = (camera_cli_s *)camera;
3435 if (!pc || !pc->cb_info || !flip) {
3436 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3437 return CAMERA_ERROR_INVALID_PARAMETER;
3440 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3442 if (ret == CAMERA_ERROR_NONE)
3443 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3449 int camera_set_display_visible(camera_h camera, bool visible)
3451 int ret = CAMERA_ERROR_NONE;
3452 int set_visible = (int)visible;
3453 camera_cli_s *pc = (camera_cli_s *)camera;
3454 camera_msg_param param;
3456 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3458 if (pc->cb_info->is_evas_render) {
3459 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3460 if (ret != MM_ERROR_NONE) {
3461 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3462 return CAMERA_ERROR_INVALID_OPERATION;
3466 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3468 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3474 int camera_is_display_visible(camera_h camera, bool *visible)
3476 int ret = CAMERA_ERROR_NONE;
3477 camera_cli_s *pc = (camera_cli_s *)camera;
3479 if (!pc || !pc->cb_info || !visible) {
3480 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3481 return CAMERA_ERROR_INVALID_PARAMETER;
3484 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3486 if (ret == CAMERA_ERROR_NONE)
3487 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3493 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3495 int ret = CAMERA_ERROR_NONE;
3496 int set_mode = (int)mode;
3497 camera_cli_s *pc = (camera_cli_s *)camera;
3498 camera_msg_param param;
3500 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3502 if (pc->cb_info->is_evas_render) {
3503 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3504 if (ret != MM_ERROR_NONE) {
3505 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3506 return CAMERA_ERROR_INVALID_OPERATION;
3510 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3512 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3518 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3520 int ret = CAMERA_ERROR_NONE;
3521 camera_cli_s *pc = (camera_cli_s *)camera;
3523 if (!pc || !pc->cb_info || !mode) {
3524 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3525 return CAMERA_ERROR_INVALID_PARAMETER;
3528 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3530 if (ret == CAMERA_ERROR_NONE)
3531 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3537 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3539 int ret = CAMERA_ERROR_NONE;
3540 int set_hint = (int)hint;
3541 camera_cli_s *pc = (camera_cli_s *)camera;
3542 camera_msg_param param;
3544 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3546 CAM_LOG_INFO("Enter - hint %d", set_hint);
3548 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3550 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3556 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3558 int ret = CAMERA_ERROR_NONE;
3559 camera_cli_s *pc = (camera_cli_s *)camera;
3560 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3562 if (!pc || !pc->cb_info || !hint) {
3563 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3564 return CAMERA_ERROR_INVALID_PARAMETER;
3567 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3569 if (ret == CAMERA_ERROR_NONE) {
3570 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3571 CAM_LOG_INFO("display reuse hint %d", *hint);
3578 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3580 int ret = CAMERA_ERROR_NONE;
3581 camera_cli_s *pc = (camera_cli_s *)camera;
3582 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3584 if (!pc || !pc->cb_info || !width || !height) {
3585 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3586 return CAMERA_ERROR_INVALID_PARAMETER;
3589 CAM_LOG_INFO("Enter");
3591 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3593 if (ret == CAMERA_ERROR_NONE) {
3594 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3595 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3598 CAM_LOG_INFO("ret : 0x%x", ret);
3604 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3606 int ret = CAMERA_ERROR_NONE;
3607 camera_cli_s *pc = (camera_cli_s *)camera;
3608 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3610 if (!pc || !pc->cb_info || !format) {
3611 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3612 return CAMERA_ERROR_INVALID_PARAMETER;
3615 CAM_LOG_INFO("Enter");
3617 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3619 if (ret == CAMERA_ERROR_NONE)
3620 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3622 CAM_LOG_INFO("ret : 0x%x", ret);
3628 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3630 int ret = CAMERA_ERROR_NONE;
3631 camera_cli_s *pc = (camera_cli_s *)camera;
3632 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3634 if (!pc || !pc->cb_info || !format) {
3635 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3636 return CAMERA_ERROR_INVALID_PARAMETER;
3639 CAM_LOG_INFO("Enter");
3641 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3643 if (ret == CAMERA_ERROR_NONE)
3644 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3646 CAM_LOG_INFO("ret : 0x%x", ret);
3652 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3654 int ret = CAMERA_ERROR_NONE;
3655 camera_cli_s *pc = (camera_cli_s *)camera;
3656 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3658 if (!pc || !pc->cb_info || !facing_direction) {
3659 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3660 return CAMERA_ERROR_INVALID_PARAMETER;
3663 CAM_LOG_INFO("Enter");
3665 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3667 if (ret == CAMERA_ERROR_NONE)
3668 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3670 CAM_LOG_INFO("ret : 0x%x", ret);
3676 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3678 int ret = CAMERA_ERROR_NONE;
3679 camera_cli_s *pc = (camera_cli_s *)camera;
3680 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3682 if (!pc || !pc->cb_info || !callback) {
3683 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3684 return CAMERA_ERROR_INVALID_PARAMETER;
3687 CAM_LOG_INFO("Enter");
3689 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3691 if (ret == CAMERA_ERROR_NONE) {
3692 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3694 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3697 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3700 CAM_LOG_INFO("ret : 0x%x", ret);
3706 int camera_unset_preview_cb(camera_h camera)
3708 int ret = CAMERA_ERROR_NONE;
3709 camera_cli_s *pc = (camera_cli_s *)camera;
3710 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3712 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3714 CAM_LOG_INFO("Enter");
3716 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3718 if (ret == CAMERA_ERROR_NONE) {
3719 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3721 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3722 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3724 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3727 CAM_LOG_INFO("ret : 0x%x", ret);
3733 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3735 int ret = CAMERA_ERROR_NONE;
3736 camera_cli_s *pc = (camera_cli_s *)camera;
3737 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3739 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3741 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3742 CAM_LOG_ERROR("NOT SUPPORTED");
3743 return CAMERA_ERROR_NOT_SUPPORTED;
3746 if (callback == NULL) {
3747 CAM_LOG_ERROR("NULL callback");
3748 return CAMERA_ERROR_INVALID_PARAMETER;
3751 CAM_LOG_INFO("Enter");
3753 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3755 if (ret == CAMERA_ERROR_NONE) {
3756 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3758 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3759 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3761 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3764 CAM_LOG_INFO("ret : 0x%x", ret);
3770 int camera_unset_media_packet_preview_cb(camera_h camera)
3772 int ret = CAMERA_ERROR_NONE;
3773 camera_cli_s *pc = (camera_cli_s *)camera;
3774 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3776 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3778 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3779 CAM_LOG_ERROR("NOT SUPPORTED");
3780 return CAMERA_ERROR_NOT_SUPPORTED;
3783 CAM_LOG_INFO("Enter");
3785 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3787 if (ret == CAMERA_ERROR_NONE) {
3788 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3793 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3796 CAM_LOG_INFO("ret : 0x%x", ret);
3802 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3808 if (!pc || !pc->cb_info || !callback) {
3809 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3813 CAM_LOG_INFO("Enter");
3815 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE) {
3818 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3823 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3826 CAM_LOG_INFO("ret : 0x%x", ret);
3832 int camera_unset_state_changed_cb(camera_h camera)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3838 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3840 CAM_LOG_INFO("Enter");
3842 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3844 if (ret == CAMERA_ERROR_NONE) {
3845 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3847 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3848 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3850 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3853 CAM_LOG_INFO("ret : 0x%x", ret);
3859 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3861 int ret = CAMERA_ERROR_NONE;
3862 camera_cli_s *pc = (camera_cli_s *)camera;
3863 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3865 if (!pc || !pc->cb_info || !callback) {
3866 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3867 return CAMERA_ERROR_INVALID_PARAMETER;
3870 CAM_LOG_INFO("Enter");
3872 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3874 if (ret == CAMERA_ERROR_NONE) {
3875 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3877 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3878 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3880 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3883 CAM_LOG_INFO("ret : 0x%x", ret);
3889 int camera_unset_interrupted_cb(camera_h camera)
3891 int ret = CAMERA_ERROR_NONE;
3892 camera_cli_s *pc = (camera_cli_s *)camera;
3893 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3895 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3897 CAM_LOG_INFO("Enter");
3899 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3901 if (ret == CAMERA_ERROR_NONE) {
3902 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3904 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3905 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3907 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3910 CAM_LOG_INFO("ret : 0x%x", ret);
3916 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3918 int ret = CAMERA_ERROR_NONE;
3919 camera_cli_s *pc = (camera_cli_s *)camera;
3920 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3922 if (!pc || !pc->cb_info || !callback) {
3923 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3924 return CAMERA_ERROR_INVALID_PARAMETER;
3927 CAM_LOG_INFO("Enter");
3929 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3931 if (ret == CAMERA_ERROR_NONE) {
3932 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3934 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3935 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3937 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3940 CAM_LOG_INFO("ret : 0x%x", ret);
3946 int camera_unset_interrupt_started_cb(camera_h camera)
3948 int ret = CAMERA_ERROR_NONE;
3949 camera_cli_s *pc = (camera_cli_s *)camera;
3950 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3952 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3954 CAM_LOG_INFO("Enter");
3956 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3958 if (ret == CAMERA_ERROR_NONE) {
3959 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3961 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3962 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3964 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3967 CAM_LOG_INFO("ret : 0x%x", ret);
3973 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3975 int ret = CAMERA_ERROR_NONE;
3976 camera_cli_s *pc = (camera_cli_s *)camera;
3977 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3979 if (!pc || !pc->cb_info || !callback) {
3980 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3981 return CAMERA_ERROR_INVALID_PARAMETER;
3984 CAM_LOG_INFO("Enter");
3986 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3988 if (ret == CAMERA_ERROR_NONE) {
3989 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3991 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3992 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3994 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3997 CAM_LOG_INFO("ret : 0x%x", ret);
4003 int camera_unset_focus_changed_cb(camera_h camera)
4005 int ret = CAMERA_ERROR_NONE;
4006 camera_cli_s *pc = (camera_cli_s *)camera;
4007 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4009 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4011 CAM_LOG_INFO("Enter");
4013 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4015 if (ret == CAMERA_ERROR_NONE) {
4016 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4018 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4019 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4021 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4024 CAM_LOG_INFO("ret : 0x%x", ret);
4030 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4032 int ret = CAMERA_ERROR_NONE;
4033 camera_cli_s *pc = (camera_cli_s *)camera;
4034 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4036 if (!pc || !pc->cb_info || !callback) {
4037 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4038 return CAMERA_ERROR_INVALID_PARAMETER;
4041 CAM_LOG_INFO("Enter");
4043 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4045 if (ret == CAMERA_ERROR_NONE) {
4046 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4048 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4049 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4051 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4054 CAM_LOG_INFO("ret : 0x%x", ret);
4060 int camera_unset_error_cb(camera_h camera)
4062 int ret = CAMERA_ERROR_NONE;
4063 camera_cli_s *pc = (camera_cli_s *)camera;
4064 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4066 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4068 CAM_LOG_INFO("Enter");
4070 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4072 if (ret == CAMERA_ERROR_NONE) {
4073 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4075 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4076 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4078 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4081 CAM_LOG_INFO("ret : 0x%x", ret);
4087 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4089 int ret = CAMERA_ERROR_NONE;
4090 camera_cli_s *pc = (camera_cli_s *)camera;
4091 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4093 if (!pc || !pc->cb_info || !foreach_cb) {
4094 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4095 return CAMERA_ERROR_INVALID_PARAMETER;
4098 CAM_LOG_INFO("Enter");
4100 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4101 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4103 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4105 CAM_LOG_INFO("ret : 0x%x", ret);
4111 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4113 int ret = CAMERA_ERROR_NONE;
4114 camera_cli_s *pc = (camera_cli_s *)camera;
4115 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4117 if (!pc || !pc->cb_info || !foreach_cb) {
4118 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4119 return CAMERA_ERROR_INVALID_PARAMETER;
4122 CAM_LOG_INFO("Enter");
4124 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4125 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4127 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4129 CAM_LOG_INFO("ret : 0x%x", ret);
4135 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4137 int ret = CAMERA_ERROR_NONE;
4138 camera_cli_s *pc = (camera_cli_s *)camera;
4139 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4141 if (!pc || !pc->cb_info || !foreach_cb) {
4142 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4143 return CAMERA_ERROR_INVALID_PARAMETER;
4146 CAM_LOG_INFO("Enter");
4148 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4149 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4151 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4153 CAM_LOG_INFO("ret : 0x%x", ret);
4159 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4161 int ret = CAMERA_ERROR_NONE;
4162 camera_cli_s *pc = (camera_cli_s *)camera;
4163 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4165 if (!pc || !pc->cb_info || !foreach_cb) {
4166 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4167 return CAMERA_ERROR_INVALID_PARAMETER;
4170 CAM_LOG_INFO("Enter");
4172 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4173 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4175 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4177 CAM_LOG_INFO("ret : 0x%x", ret);
4183 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4185 int ret = CAMERA_ERROR_NONE;
4186 camera_cli_s *pc = (camera_cli_s *)camera;
4187 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4189 if (!pc || !pc->cb_info || !width || !height) {
4190 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4191 return CAMERA_ERROR_INVALID_PARAMETER;
4194 CAM_LOG_INFO("Enter");
4195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 if (ret == CAMERA_ERROR_NONE) {
4198 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4199 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4202 CAM_LOG_INFO("ret : 0x%x", ret);
4208 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4210 int ret = CAMERA_ERROR_NONE;
4211 camera_cli_s *pc = (camera_cli_s *)camera;
4212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4214 if (!pc || !pc->cb_info || !angle) {
4215 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4216 return CAMERA_ERROR_INVALID_PARAMETER;
4219 CAM_LOG_INFO("Enter");
4221 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4223 if (ret == CAMERA_ERROR_NONE)
4224 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4226 CAM_LOG_INFO("ret : 0x%x", ret);
4232 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4234 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4238 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4240 int ret = CAMERA_ERROR_NONE;
4241 camera_cli_s *pc = (camera_cli_s *)camera;
4242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4244 if (!pc || !pc->cb_info || !mode) {
4245 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4246 return CAMERA_ERROR_INVALID_PARAMETER;
4249 CAM_LOG_INFO("Enter");
4251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4253 if (ret == CAMERA_ERROR_NONE)
4254 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4256 CAM_LOG_INFO("ret : 0x%x", ret);
4262 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4264 int ret = CAMERA_ERROR_NONE;
4265 camera_cli_s *pc = (camera_cli_s *)camera;
4266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4268 if (!pc || !pc->cb_info || !foreach_cb) {
4269 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4273 CAM_LOG_INFO("Enter");
4275 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4276 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4278 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4280 CAM_LOG_INFO("Finish, return :%x", ret);
4286 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4288 int ret = CAMERA_ERROR_NONE;
4289 camera_cli_s *pc = (camera_cli_s *)camera;
4290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4291 camera_msg_param param;
4292 int set_fps = (int)fps;
4294 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4296 CAM_LOG_INFO("Enter");
4298 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4300 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4302 CAM_LOG_INFO("ret : 0x%x", ret);
4308 int camera_attr_set_image_quality(camera_h camera, int quality)
4310 int ret = CAMERA_ERROR_NONE;
4311 camera_cli_s *pc = (camera_cli_s *)camera;
4312 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4313 camera_msg_param param;
4315 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4317 CAM_LOG_INFO("Enter");
4319 CAMERA_MSG_PARAM_SET(param, INT, quality);
4321 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4323 CAM_LOG_INFO("ret : 0x%x", ret);
4329 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4331 int ret = CAMERA_ERROR_NONE;
4332 camera_cli_s *pc = (camera_cli_s *)camera;
4333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4335 if (!pc || !pc->cb_info || !fps) {
4336 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4337 return CAMERA_ERROR_INVALID_PARAMETER;
4340 CAM_LOG_INFO("Enter");
4342 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4344 if (ret == CAMERA_ERROR_NONE)
4345 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4347 CAM_LOG_INFO("ret : 0x%x", ret);
4353 int camera_attr_get_image_quality(camera_h camera, int *quality)
4355 int ret = CAMERA_ERROR_NONE;
4356 camera_cli_s *pc = (camera_cli_s *)camera;
4357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4359 if (!pc || !pc->cb_info || !quality) {
4360 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4361 return CAMERA_ERROR_INVALID_PARAMETER;
4364 CAM_LOG_INFO("Enter");
4366 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4368 if (ret == CAMERA_ERROR_NONE)
4369 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4371 CAM_LOG_INFO("ret : 0x%x", ret);
4377 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4379 int ret = CAMERA_ERROR_NONE;
4380 camera_cli_s *pc = (camera_cli_s *)camera;
4381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4383 if (!pc || !pc->cb_info || !bitrate) {
4384 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4385 return CAMERA_ERROR_INVALID_PARAMETER;
4388 CAM_LOG_INFO("Enter");
4390 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4392 if (ret == CAMERA_ERROR_NONE)
4393 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4395 CAM_LOG_INFO("ret : 0x%x", ret);
4401 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4403 int ret = CAMERA_ERROR_NONE;
4404 camera_cli_s *pc = (camera_cli_s *)camera;
4405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4406 camera_msg_param param;
4407 int set_bitrate = bitrate;
4409 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4411 CAM_LOG_INFO("Enter");
4413 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4417 CAM_LOG_INFO("ret : 0x%x", ret);
4423 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4425 int ret = CAMERA_ERROR_NONE;
4426 camera_cli_s *pc = (camera_cli_s *)camera;
4427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4429 if (!pc || !pc->cb_info || !interval) {
4430 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 CAM_LOG_INFO("Enter");
4436 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4438 if (ret == CAMERA_ERROR_NONE)
4439 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4441 CAM_LOG_INFO("ret : 0x%x", ret);
4447 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4449 int ret = CAMERA_ERROR_NONE;
4450 camera_cli_s *pc = (camera_cli_s *)camera;
4451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4452 camera_msg_param param;
4453 int set_gop_interval = interval;
4455 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4457 CAM_LOG_INFO("Enter");
4459 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4461 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4463 CAM_LOG_INFO("ret : 0x%x", ret);
4469 int camera_attr_set_zoom(camera_h camera, int zoom)
4471 int ret = CAMERA_ERROR_NONE;
4472 camera_cli_s *pc = (camera_cli_s *)camera;
4473 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4474 camera_msg_param param;
4476 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4478 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4480 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4482 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4484 CAM_LOG_INFO("ret : 0x%x", ret);
4490 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4492 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4496 int camera_attr_set_af_area(camera_h camera, int x, int y)
4498 int ret = CAMERA_ERROR_NONE;
4499 camera_cli_s *pc = (camera_cli_s *)camera;
4500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4501 camera_msg_param param;
4504 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4506 CAM_LOG_INFO("Enter - %d,%d", x, y);
4508 value = (x << 16) | y;
4509 CAMERA_MSG_PARAM_SET(param, INT, value);
4511 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4513 CAM_LOG_INFO("ret : 0x%x", ret);
4519 int camera_attr_clear_af_area(camera_h camera)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4525 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4527 CAM_LOG_INFO("Enter");
4529 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4531 CAM_LOG_INFO("ret : 0x%x", ret);
4537 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4539 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4543 int camera_attr_set_exposure(camera_h camera, int value)
4545 int ret = CAMERA_ERROR_NONE;
4546 camera_cli_s *pc = (camera_cli_s *)camera;
4547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4548 camera_msg_param param;
4550 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4552 CAM_LOG_INFO("Enter");
4554 CAMERA_MSG_PARAM_SET(param, INT, value);
4556 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4558 CAM_LOG_INFO("ret : 0x%x", ret);
4564 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4566 int ret = CAMERA_ERROR_NONE;
4567 camera_cli_s *pc = (camera_cli_s *)camera;
4568 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4569 camera_msg_param param;
4570 int set_iso = (int)iso;
4572 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4574 CAM_LOG_INFO("Enter");
4576 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4578 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4580 CAM_LOG_INFO("ret : 0x%x", ret);
4586 int camera_attr_set_brightness(camera_h camera, int level)
4588 int ret = CAMERA_ERROR_NONE;
4589 camera_cli_s *pc = (camera_cli_s *)camera;
4590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4591 camera_msg_param param;
4593 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4595 CAM_LOG_INFO("Enter");
4597 CAMERA_MSG_PARAM_SET(param, INT, level);
4599 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4601 CAM_LOG_INFO("ret : 0x%x", ret);
4607 int camera_attr_set_contrast(camera_h camera, int level)
4609 int ret = CAMERA_ERROR_NONE;
4610 camera_cli_s *pc = (camera_cli_s *)camera;
4611 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4612 camera_msg_param param;
4614 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4616 CAM_LOG_INFO("Enter");
4618 CAMERA_MSG_PARAM_SET(param, INT, level);
4620 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4622 CAM_LOG_INFO("ret : 0x%x", ret);
4628 int camera_attr_set_hue(camera_h camera, int level)
4630 int ret = CAMERA_ERROR_NONE;
4631 camera_cli_s *pc = (camera_cli_s *)camera;
4632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4633 camera_msg_param param;
4635 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4637 CAM_LOG_INFO("Enter");
4639 CAMERA_MSG_PARAM_SET(param, INT, level);
4641 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4643 CAM_LOG_INFO("ret : 0x%x", ret);
4649 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4651 int ret = CAMERA_ERROR_NONE;
4652 camera_cli_s *pc = (camera_cli_s *)camera;
4653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4654 camera_msg_param param;
4655 int set_whitebalance = (int)wb;
4657 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4659 CAM_LOG_INFO("Enter");
4661 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4665 CAM_LOG_INFO("ret : 0x%x", ret);
4671 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4673 int ret = CAMERA_ERROR_NONE;
4674 camera_cli_s *pc = (camera_cli_s *)camera;
4675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4676 camera_msg_param param;
4677 int set_effect = (int)effect;
4679 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4681 CAM_LOG_INFO("Enter");
4683 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4685 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4687 CAM_LOG_INFO("ret : 0x%x", ret);
4693 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4695 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4699 int camera_attr_enable_tag(camera_h camera, bool enable)
4701 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4705 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4707 int ret = CAMERA_ERROR_NONE;
4708 camera_cli_s *pc = (camera_cli_s *)camera;
4709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4710 camera_msg_param param;
4712 if (!pc || !pc->cb_info || !description) {
4713 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4714 return CAMERA_ERROR_INVALID_PARAMETER;
4717 CAM_LOG_INFO("Enter");
4719 CAMERA_MSG_PARAM_SET(param, STRING, description);
4721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4723 CAM_LOG_INFO("ret : 0x%x", ret);
4729 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4731 int ret = CAMERA_ERROR_NONE;
4732 camera_cli_s *pc = (camera_cli_s *)camera;
4733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4734 camera_msg_param param;
4735 int set_orientation = (int)orientation;
4737 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4739 CAM_LOG_INFO("Enter");
4741 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4743 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4745 CAM_LOG_INFO("ret : 0x%x", ret);
4751 int camera_attr_set_tag_software(camera_h camera, const char *software)
4753 int ret = CAMERA_ERROR_NONE;
4754 camera_cli_s *pc = (camera_cli_s *)camera;
4755 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4756 camera_msg_param param;
4758 if (!pc || !pc->cb_info || !software) {
4759 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4760 return CAMERA_ERROR_INVALID_PARAMETER;
4763 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4765 CAMERA_MSG_PARAM_SET(param, STRING, software);
4767 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4769 CAM_LOG_INFO("ret : 0x%x", ret);
4775 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4777 int ret = CAMERA_ERROR_NONE;
4778 camera_cli_s *pc = (camera_cli_s *)camera;
4779 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4780 double set_geotag[3] = {latitude, longitude, altitude};
4784 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4786 CAM_LOG_INFO("Enter");
4788 length = sizeof(set_geotag) / sizeof(int) + \
4789 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4791 msg = muse_core_msg_new(api,
4792 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4795 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4801 int camera_attr_remove_geotag(camera_h camera)
4803 int ret = CAMERA_ERROR_NONE;
4804 camera_cli_s *pc = (camera_cli_s *)camera;
4805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4807 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4809 CAM_LOG_INFO("Enter");
4811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4813 CAM_LOG_INFO("ret : 0x%x", ret);
4819 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4821 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4825 int camera_attr_get_zoom(camera_h camera, int *zoom)
4827 int ret = CAMERA_ERROR_NONE;
4828 camera_cli_s *pc = (camera_cli_s *)camera;
4829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4831 if (!pc || !pc->cb_info || !zoom) {
4832 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4833 return CAMERA_ERROR_INVALID_PARAMETER;
4836 CAM_LOG_INFO("Enter");
4838 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4840 if (ret == CAMERA_ERROR_NONE)
4841 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4843 CAM_LOG_INFO("ret : 0x%x", ret);
4849 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4851 int ret = CAMERA_ERROR_NONE;
4852 camera_cli_s *pc = (camera_cli_s *)camera;
4853 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4855 if (!pc || !pc->cb_info || !min || !max) {
4856 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4857 return CAMERA_ERROR_INVALID_PARAMETER;
4860 CAM_LOG_INFO("Enter");
4862 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4864 if (ret == CAMERA_ERROR_NONE) {
4865 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4866 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4869 CAM_LOG_INFO("ret : 0x%x", ret);
4875 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4877 int ret = CAMERA_ERROR_NONE;
4878 camera_cli_s *pc = (camera_cli_s *)camera;
4879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4881 if (!pc || !pc->cb_info || !mode) {
4882 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4883 return CAMERA_ERROR_INVALID_PARAMETER;
4886 CAM_LOG_INFO("Enter");
4888 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4890 if (ret == CAMERA_ERROR_NONE)
4891 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4893 CAM_LOG_INFO("ret : 0x%x", ret);
4899 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4901 int ret = CAMERA_ERROR_NONE;
4902 camera_cli_s *pc = (camera_cli_s *)camera;
4903 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4905 if (!pc || !pc->cb_info || !mode) {
4906 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4907 return CAMERA_ERROR_INVALID_PARAMETER;
4910 CAM_LOG_INFO("Enter");
4912 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4914 if (ret == CAMERA_ERROR_NONE)
4915 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4917 CAM_LOG_INFO("ret : 0x%x", ret);
4923 int camera_attr_get_exposure(camera_h camera, int *value)
4925 int ret = CAMERA_ERROR_NONE;
4926 camera_cli_s *pc = (camera_cli_s *)camera;
4927 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4929 if (!pc || !pc->cb_info || !value) {
4930 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
4931 return CAMERA_ERROR_INVALID_PARAMETER;
4934 CAM_LOG_INFO("Enter");
4936 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4938 if (ret == CAMERA_ERROR_NONE)
4939 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
4941 CAM_LOG_INFO("ret : 0x%x", ret);
4947 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4949 int ret = CAMERA_ERROR_NONE;
4950 camera_cli_s *pc = (camera_cli_s *)camera;
4951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4953 if (!pc || !pc->cb_info || !min || !max) {
4954 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4958 CAM_LOG_INFO("Enter");
4960 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4962 if (ret == CAMERA_ERROR_NONE) {
4963 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
4964 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
4967 CAM_LOG_INFO("ret : 0x%x", ret);
4973 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4975 int ret = CAMERA_ERROR_NONE;
4976 camera_cli_s *pc = (camera_cli_s *)camera;
4977 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4979 if (!pc || !pc->cb_info || !iso) {
4980 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
4981 return CAMERA_ERROR_INVALID_PARAMETER;
4984 CAM_LOG_INFO("Enter");
4986 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4988 if (ret == CAMERA_ERROR_NONE)
4989 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
4991 CAM_LOG_INFO("ret : 0x%x", ret);
4997 int camera_attr_get_brightness(camera_h camera, int *level)
4999 int ret = CAMERA_ERROR_NONE;
5000 camera_cli_s *pc = (camera_cli_s *)camera;
5001 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5003 if (!pc || !pc->cb_info || !level) {
5004 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5005 return CAMERA_ERROR_INVALID_PARAMETER;
5008 CAM_LOG_INFO("Enter");
5010 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5012 if (ret == CAMERA_ERROR_NONE)
5013 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5015 CAM_LOG_INFO("ret : 0x%x", ret);
5021 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5023 int ret = CAMERA_ERROR_NONE;
5024 camera_cli_s *pc = (camera_cli_s *)camera;
5025 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5027 if (!pc || !pc->cb_info || !min || !max) {
5028 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5029 return CAMERA_ERROR_INVALID_PARAMETER;
5032 CAM_LOG_INFO("Enter");
5034 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5036 if (ret == CAMERA_ERROR_NONE) {
5037 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5038 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5041 CAM_LOG_INFO("ret : 0x%x", ret);
5047 int camera_attr_get_contrast(camera_h camera, int *level)
5049 int ret = CAMERA_ERROR_NONE;
5050 camera_cli_s *pc = (camera_cli_s *)camera;
5051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5053 if (!pc || !pc->cb_info || !level) {
5054 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5058 CAM_LOG_INFO("Enter");
5060 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5062 if (ret == CAMERA_ERROR_NONE)
5063 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5065 CAM_LOG_INFO("ret : 0x%x", ret);
5071 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5073 int ret = CAMERA_ERROR_NONE;
5074 camera_cli_s *pc = (camera_cli_s *)camera;
5075 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5077 if (!pc || !pc->cb_info || !min || !max) {
5078 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5079 return CAMERA_ERROR_INVALID_PARAMETER;
5082 CAM_LOG_INFO("Enter");
5084 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5086 if (ret == CAMERA_ERROR_NONE) {
5087 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5088 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5089 CAM_LOG_INFO("min %d, max %d", *min, *max);
5092 CAM_LOG_INFO("ret : 0x%x", ret);
5098 int camera_attr_get_hue(camera_h camera, int *level)
5100 int ret = CAMERA_ERROR_NONE;
5101 camera_cli_s *pc = (camera_cli_s *)camera;
5102 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5104 if (!pc || !pc->cb_info || !level) {
5105 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5106 return CAMERA_ERROR_INVALID_PARAMETER;
5109 CAM_LOG_INFO("Enter");
5111 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5113 if (ret == CAMERA_ERROR_NONE)
5114 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5116 CAM_LOG_INFO("ret : 0x%x", ret);
5122 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5124 int ret = CAMERA_ERROR_NONE;
5125 camera_cli_s *pc = (camera_cli_s *)camera;
5126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5128 if (!pc || !pc->cb_info || !min || !max) {
5129 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5130 return CAMERA_ERROR_INVALID_PARAMETER;
5133 CAM_LOG_INFO("Enter");
5135 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5137 if (ret == CAMERA_ERROR_NONE) {
5138 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5139 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5140 CAM_LOG_INFO("min %d, max %d", *min, *max);
5143 CAM_LOG_INFO("ret : 0x%x", ret);
5149 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5151 int ret = CAMERA_ERROR_NONE;
5152 camera_cli_s *pc = (camera_cli_s *)camera;
5153 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5155 if (!pc || !pc->cb_info || !wb) {
5156 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5157 return CAMERA_ERROR_INVALID_PARAMETER;
5160 CAM_LOG_INFO("Enter");
5162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5164 if (ret == CAMERA_ERROR_NONE)
5165 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5167 CAM_LOG_INFO("ret : 0x%x", ret);
5173 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5175 int ret = CAMERA_ERROR_NONE;
5176 camera_cli_s *pc = (camera_cli_s *)camera;
5177 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5179 if (!pc || !pc->cb_info || !effect) {
5180 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5181 return CAMERA_ERROR_INVALID_PARAMETER;
5184 CAM_LOG_INFO("Enter");
5186 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5188 if (ret == CAMERA_ERROR_NONE)
5189 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5191 CAM_LOG_INFO("ret : 0x%x", ret);
5197 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5199 int ret = CAMERA_ERROR_NONE;
5200 camera_cli_s *pc = (camera_cli_s *)camera;
5201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5203 if (!pc || !pc->cb_info || !mode) {
5204 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5205 return CAMERA_ERROR_INVALID_PARAMETER;
5208 CAM_LOG_INFO("Enter");
5210 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5212 if (ret == CAMERA_ERROR_NONE)
5213 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5215 CAM_LOG_INFO("ret : 0x%x", ret);
5221 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5223 int ret = CAMERA_ERROR_NONE;
5224 camera_cli_s *pc = (camera_cli_s *)camera;
5225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5227 if (!pc || !pc->cb_info || !enable) {
5228 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5229 return CAMERA_ERROR_INVALID_PARAMETER;
5232 CAM_LOG_INFO("Enter");
5234 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5236 if (ret == CAMERA_ERROR_NONE)
5237 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5239 CAM_LOG_INFO("ret : 0x%x", ret);
5245 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5247 int ret = CAMERA_ERROR_NONE;
5248 camera_cli_s *pc = (camera_cli_s *)camera;
5249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5251 if (!pc || !pc->cb_info || !description) {
5252 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5253 return CAMERA_ERROR_INVALID_PARAMETER;
5256 CAM_LOG_INFO("Enter");
5258 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5260 if (ret == CAMERA_ERROR_NONE)
5261 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5263 CAM_LOG_INFO("ret : 0x%x", ret);
5269 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5271 int ret = CAMERA_ERROR_NONE;
5272 camera_cli_s *pc = (camera_cli_s *)camera;
5273 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5275 if (!pc || !pc->cb_info || !orientation) {
5276 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5277 return CAMERA_ERROR_INVALID_PARAMETER;
5280 CAM_LOG_INFO("Enter");
5282 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5284 if (ret == CAMERA_ERROR_NONE)
5285 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5287 CAM_LOG_INFO("ret : 0x%x", ret);
5293 int camera_attr_get_tag_software(camera_h camera, char **software)
5295 int ret = CAMERA_ERROR_NONE;
5296 camera_cli_s *pc = (camera_cli_s *)camera;
5297 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5299 if (!pc || !pc->cb_info || !software) {
5300 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5301 return CAMERA_ERROR_INVALID_PARAMETER;
5304 CAM_LOG_INFO("Enter");
5306 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5308 if (ret == CAMERA_ERROR_NONE)
5309 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5311 CAM_LOG_INFO("ret : 0x%x", ret);
5317 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5319 int ret = CAMERA_ERROR_NONE;
5320 camera_cli_s *pc = (camera_cli_s *)camera;
5321 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5323 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5324 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5325 return CAMERA_ERROR_INVALID_PARAMETER;
5328 CAM_LOG_INFO("Enter");
5330 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5332 if (ret == CAMERA_ERROR_NONE) {
5333 *latitude = pc->cb_info->get_geotag[0];
5334 *longitude = pc->cb_info->get_geotag[1];
5335 *altitude = pc->cb_info->get_geotag[2];
5338 CAM_LOG_INFO("ret : 0x%x", ret);
5344 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5346 int ret = CAMERA_ERROR_NONE;
5347 camera_cli_s *pc = (camera_cli_s *)camera;
5348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5350 if (!pc || !pc->cb_info || !mode) {
5351 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5352 return CAMERA_ERROR_INVALID_PARAMETER;
5355 CAM_LOG_INFO("Enter");
5357 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5359 if (ret == CAMERA_ERROR_NONE)
5360 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5362 CAM_LOG_INFO("ret : 0x%x", ret);
5368 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5370 int ret = CAMERA_ERROR_NONE;
5371 int get_flash_state = 0;
5374 CAM_LOG_ERROR("NULL pointer");
5375 return CAMERA_ERROR_INVALID_PARAMETER;
5378 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5379 (int)device, "get_flash_state", &get_flash_state);
5381 if (ret == CAMERA_ERROR_NONE) {
5382 *state = (camera_flash_state_e)get_flash_state;
5383 CAM_LOG_INFO("flash state %d", *state);
5385 CAM_LOG_ERROR("failed 0x%x", ret);
5392 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5394 int ret = CAMERA_ERROR_NONE;
5395 camera_cli_s *pc = (camera_cli_s *)camera;
5396 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5398 if (!pc || !pc->cb_info || !foreach_cb) {
5399 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5400 return CAMERA_ERROR_INVALID_PARAMETER;
5403 CAM_LOG_INFO("Enter");
5405 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5406 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5408 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5410 CAM_LOG_INFO("ret : 0x%x", ret);
5416 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5418 int ret = CAMERA_ERROR_NONE;
5419 camera_cli_s *pc = (camera_cli_s *)camera;
5420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5422 if (!pc || !pc->cb_info || !foreach_cb) {
5423 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5424 return CAMERA_ERROR_INVALID_PARAMETER;
5427 CAM_LOG_INFO("Enter");
5429 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5430 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5432 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5434 CAM_LOG_INFO("ret : 0x%x", ret);
5440 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5442 int ret = CAMERA_ERROR_NONE;
5443 camera_cli_s *pc = (camera_cli_s *)camera;
5444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5446 if (!pc || !pc->cb_info || !foreach_cb) {
5447 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5448 return CAMERA_ERROR_INVALID_PARAMETER;
5451 CAM_LOG_INFO("Enter");
5453 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5454 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5456 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5458 CAM_LOG_INFO("ret : 0x%x", ret);
5464 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5466 int ret = CAMERA_ERROR_NONE;
5467 camera_cli_s *pc = (camera_cli_s *)camera;
5468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5470 if (!pc || !pc->cb_info || !foreach_cb) {
5471 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5475 CAM_LOG_INFO("Enter");
5477 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5478 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5480 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5482 CAM_LOG_INFO("ret : 0x%x", ret);
5488 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5490 int ret = CAMERA_ERROR_NONE;
5491 camera_cli_s *pc = (camera_cli_s *)camera;
5492 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5494 if (!pc || !pc->cb_info || !foreach_cb) {
5495 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5496 return CAMERA_ERROR_INVALID_PARAMETER;
5499 CAM_LOG_INFO("Enter");
5501 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5502 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5504 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5506 CAM_LOG_INFO("ret : 0x%x", ret);
5512 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5514 int ret = CAMERA_ERROR_NONE;
5515 camera_cli_s *pc = (camera_cli_s *)camera;
5516 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5518 if (!pc || !pc->cb_info || !foreach_cb) {
5519 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5520 return CAMERA_ERROR_INVALID_PARAMETER;
5523 CAM_LOG_INFO("Enter");
5525 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5526 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5528 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5530 CAM_LOG_INFO("ret : 0x%x", ret);
5536 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5538 int ret = CAMERA_ERROR_NONE;
5539 camera_cli_s *pc = (camera_cli_s *)camera;
5540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5542 if (!pc || !pc->cb_info || !foreach_cb) {
5543 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5544 return CAMERA_ERROR_INVALID_PARAMETER;
5547 CAM_LOG_INFO("Enter");
5549 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5550 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5552 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5554 CAM_LOG_INFO("ret : 0x%x", ret);
5560 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5562 int ret = CAMERA_ERROR_NONE;
5563 camera_cli_s *pc = (camera_cli_s *)camera;
5564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5566 if (!pc || !pc->cb_info || !foreach_cb) {
5567 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5568 return CAMERA_ERROR_INVALID_PARAMETER;
5571 CAM_LOG_INFO("Enter");
5573 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5574 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5576 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5578 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5584 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)
5586 int ret = CAMERA_ERROR_NONE;
5587 camera_cli_s *pc = (camera_cli_s *)camera;
5588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5589 camera_msg_param param;
5592 if (!pc || !pc->cb_info || !foreach_cb) {
5593 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5594 return CAMERA_ERROR_INVALID_PARAMETER;
5597 CAM_LOG_INFO("Enter");
5599 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5600 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5602 value = (width << 16) | height;
5603 CAMERA_MSG_PARAM_SET(param, INT, value);
5605 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5607 CAM_LOG_INFO("ret : 0x%x", ret);
5613 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5615 int ret = CAMERA_ERROR_NONE;
5616 camera_cli_s *pc = (camera_cli_s *)camera;
5617 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5619 if (!pc || !pc->cb_info || !foreach_cb) {
5620 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5621 return CAMERA_ERROR_INVALID_PARAMETER;
5624 CAM_LOG_INFO("Enter");
5626 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5627 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5629 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5631 CAM_LOG_INFO("ret : 0x%x", ret);
5637 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5639 int ret = CAMERA_ERROR_NONE;
5640 camera_cli_s *pc = (camera_cli_s *)camera;
5641 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5643 if (!pc || !pc->cb_info || !foreach_cb) {
5644 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5645 return CAMERA_ERROR_INVALID_PARAMETER;
5648 CAM_LOG_INFO("Enter");
5650 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5651 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5653 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5655 CAM_LOG_INFO("ret : 0x%x", ret);
5661 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5663 int ret = CAMERA_ERROR_NONE;
5664 camera_cli_s *pc = (camera_cli_s *)camera;
5665 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5666 camera_msg_param param;
5667 int set_rotation = (int)rotation;
5669 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5671 CAM_LOG_INFO("Enter");
5673 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5675 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5677 CAM_LOG_INFO("ret : 0x%x", ret);
5683 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5685 int ret = CAMERA_ERROR_NONE;
5686 camera_cli_s *pc = (camera_cli_s *)camera;
5687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5689 if (!pc || !pc->cb_info || !rotation) {
5690 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5691 return CAMERA_ERROR_INVALID_PARAMETER;
5694 CAM_LOG_INFO("Enter");
5696 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5698 if (ret == CAMERA_ERROR_NONE)
5699 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5701 CAM_LOG_INFO("ret : 0x%x", ret);
5707 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5709 int ret = CAMERA_ERROR_NONE;
5710 camera_cli_s *pc = (camera_cli_s *)camera;
5711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5712 camera_msg_param param;
5713 int set_flip = (int)flip;
5715 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5717 CAM_LOG_INFO("Enter");
5719 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5723 CAM_LOG_INFO("ret : 0x%x", ret);
5729 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5735 if (!pc || !pc->cb_info || !flip) {
5736 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5737 return CAMERA_ERROR_INVALID_PARAMETER;
5740 CAM_LOG_INFO("Enter");
5742 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5744 if (ret == CAMERA_ERROR_NONE)
5745 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5747 CAM_LOG_INFO("ret : 0x%x", ret);
5752 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5754 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5758 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5760 int ret = CAMERA_ERROR_NONE;
5761 camera_cli_s *pc = (camera_cli_s *)camera;
5762 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5764 if (!pc || !pc->cb_info || !mode) {
5765 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5766 return CAMERA_ERROR_INVALID_PARAMETER;
5769 CAM_LOG_INFO("Enter");
5771 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5773 if (ret == CAMERA_ERROR_NONE)
5774 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5776 CAM_LOG_INFO("ret : 0x%x", ret);
5782 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5784 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5788 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5790 int ret = CAMERA_ERROR_NONE;
5791 camera_cli_s *pc = (camera_cli_s *)camera;
5792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5794 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5796 CAM_LOG_INFO("Enter");
5798 if (!camera_attr_is_supported_hdr_capture(camera)) {
5799 CAM_LOG_ERROR("HDR not supported");
5800 return CAMERA_ERROR_NOT_SUPPORTED;
5804 CAM_LOG_ERROR("NULL callback");
5805 return CAMERA_ERROR_INVALID_PARAMETER;
5808 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5810 if (ret == CAMERA_ERROR_NONE) {
5811 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5813 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5814 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5816 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5819 CAM_LOG_INFO("ret : 0x%x", ret);
5825 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5827 int ret = CAMERA_ERROR_NONE;
5828 camera_cli_s *pc = (camera_cli_s *)camera;
5829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5831 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5833 CAM_LOG_INFO("Enter");
5835 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5837 if (ret == CAMERA_ERROR_NONE) {
5838 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5843 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5846 CAM_LOG_INFO("ret : 0x%x", ret);
5852 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5854 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5858 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5860 int ret = CAMERA_ERROR_NONE;
5861 camera_cli_s *pc = (camera_cli_s *)camera;
5862 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5864 if (!pc || !pc->cb_info || !enabled) {
5865 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5866 return CAMERA_ERROR_INVALID_PARAMETER;
5869 CAM_LOG_INFO("Enter");
5871 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5873 if (ret == CAMERA_ERROR_NONE)
5874 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5876 CAM_LOG_INFO("ret : 0x%x", ret);
5882 bool camera_attr_is_supported_anti_shake(camera_h camera)
5884 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
5888 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5890 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
5894 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5896 int ret = CAMERA_ERROR_NONE;
5897 camera_cli_s *pc = (camera_cli_s *)camera;
5898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5900 if (!pc || !pc->cb_info || !enabled) {
5901 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5902 return CAMERA_ERROR_INVALID_PARAMETER;
5905 CAM_LOG_INFO("Enter");
5907 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5909 if (ret == CAMERA_ERROR_NONE)
5910 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
5912 CAM_LOG_INFO("ret : 0x%x", ret);
5918 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5920 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
5924 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5926 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
5930 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5932 int ret = CAMERA_ERROR_NONE;
5933 camera_cli_s *pc = (camera_cli_s *)camera;
5934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5936 if (!pc || !pc->cb_info || !enabled) {
5937 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5941 CAM_LOG_INFO("Enter");
5943 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5945 if (ret == CAMERA_ERROR_NONE)
5946 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
5948 CAM_LOG_INFO("ret : 0x%x", ret);
5954 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5956 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
5960 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5962 int ret = CAMERA_ERROR_NONE;
5963 camera_cli_s *pc = (camera_cli_s *)camera;
5964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5965 camera_msg_param param;
5966 int set_disable = (int)disable;
5968 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5970 CAM_LOG_INFO("Enter");
5972 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5974 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5976 CAM_LOG_INFO("ret : 0x%x", ret);
5982 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5984 int ret = CAMERA_ERROR_NONE;
5985 camera_cli_s *pc = (camera_cli_s *)camera;
5986 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5987 camera_msg_param param0;
5988 camera_msg_param param1;
5990 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5992 CAM_LOG_INFO("Enter");
5994 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
5995 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
5997 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
5998 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6000 CAM_LOG_INFO("ret : 0x%x", ret);
6006 int camera_attr_get_pan(camera_h camera, int *pan_step)
6008 int ret = CAMERA_ERROR_NONE;
6009 camera_cli_s *pc = (camera_cli_s *)camera;
6010 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6012 if (!pc || !pc->cb_info || !pan_step) {
6013 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6014 return CAMERA_ERROR_INVALID_PARAMETER;
6017 CAM_LOG_INFO("Enter");
6019 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6021 if (ret == CAMERA_ERROR_NONE)
6022 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6024 CAM_LOG_INFO("ret : 0x%x", ret);
6030 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6032 int ret = CAMERA_ERROR_NONE;
6033 camera_cli_s *pc = (camera_cli_s *)camera;
6034 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6036 if (!pc || !pc->cb_info || !min || !max) {
6037 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6038 return CAMERA_ERROR_INVALID_PARAMETER;
6041 CAM_LOG_INFO("Enter");
6043 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6045 if (ret == CAMERA_ERROR_NONE) {
6046 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6047 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6050 CAM_LOG_INFO("ret : 0x%x", ret);
6056 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6058 int ret = CAMERA_ERROR_NONE;
6059 camera_cli_s *pc = (camera_cli_s *)camera;
6060 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6061 camera_msg_param param0;
6062 camera_msg_param param1;
6064 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6066 CAM_LOG_INFO("Enter");
6068 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6069 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6071 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6072 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6074 CAM_LOG_INFO("ret : 0x%x", ret);
6080 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6082 int ret = CAMERA_ERROR_NONE;
6083 camera_cli_s *pc = (camera_cli_s *)camera;
6084 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6086 if (!pc || !pc->cb_info || !tilt_step) {
6087 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6088 return CAMERA_ERROR_INVALID_PARAMETER;
6091 CAM_LOG_INFO("Enter");
6093 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6095 if (ret == CAMERA_ERROR_NONE)
6096 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6098 CAM_LOG_INFO("ret : 0x%x", ret);
6104 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6106 int ret = CAMERA_ERROR_NONE;
6107 camera_cli_s *pc = (camera_cli_s *)camera;
6108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6110 if (!pc || !pc->cb_info || !min || !max) {
6111 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6112 return CAMERA_ERROR_INVALID_PARAMETER;
6115 CAM_LOG_INFO("Enter");
6117 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6119 if (ret == CAMERA_ERROR_NONE) {
6120 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6121 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6124 CAM_LOG_INFO("ret : 0x%x", ret);
6130 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6132 int ret = CAMERA_ERROR_NONE;
6133 camera_cli_s *pc = (camera_cli_s *)camera;
6134 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6135 camera_msg_param param;
6136 int set_ptz_type = (int)ptz_type;
6138 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6140 CAM_LOG_INFO("Enter");
6142 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6144 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6146 CAM_LOG_INFO("ret : 0x%x", ret);
6152 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6154 int ret = CAMERA_ERROR_NONE;
6155 camera_cli_s *pc = (camera_cli_s *)camera;
6156 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6158 if (!pc || !pc->cb_info || !foreach_cb) {
6159 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6160 return CAMERA_ERROR_INVALID_PARAMETER;
6163 CAM_LOG_INFO("Enter");
6165 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6166 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6168 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6170 CAM_LOG_INFO("ret : 0x%x", ret);
6176 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6178 int ret = CAMERA_ERROR_NONE;
6179 camera_cli_s *pc = (camera_cli_s *)camera;
6180 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6181 int set_display_roi_area[4] = {x, y, width, height};
6185 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6187 CAM_LOG_INFO("Enter");
6189 if (pc->cb_info->is_evas_render) {
6190 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6191 if (ret != MM_ERROR_NONE) {
6192 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6193 return CAMERA_ERROR_INVALID_OPERATION;
6197 length = sizeof(set_display_roi_area) / sizeof(int) + \
6198 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6200 msg = muse_core_msg_new(api,
6201 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6204 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6210 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6212 camera_cli_s *pc = (camera_cli_s *)camera;
6213 int ret = CAMERA_ERROR_NONE;
6214 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6216 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6217 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6218 return CAMERA_ERROR_INVALID_PARAMETER;
6221 CAM_LOG_INFO("Enter");
6223 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6225 if (ret == CAMERA_ERROR_NONE) {
6226 *x = pc->cb_info->get_display_roi_area[0];
6227 *y = pc->cb_info->get_display_roi_area[1];
6228 *width = pc->cb_info->get_display_roi_area[2];
6229 *height = pc->cb_info->get_display_roi_area[3];
6232 CAM_LOG_INFO("ret : 0x%x", ret);
6238 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6240 int ret = CAMERA_ERROR_NONE;
6241 int get_device_state = 0;
6244 CAM_LOG_ERROR("NULL pointer");
6245 return CAMERA_ERROR_INVALID_PARAMETER;
6248 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6249 (int)device, "get_device_state", &get_device_state);
6251 if (ret == CAMERA_ERROR_NONE) {
6252 *state = (camera_device_state_e)get_device_state;
6253 CAM_LOG_INFO("device state %d", *state);
6255 CAM_LOG_ERROR("failed 0x%x", ret);
6262 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6266 camera_cb_info *info = NULL;
6268 if (!callback || !cb_id) {
6269 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6270 return CAMERA_ERROR_INVALID_PARAMETER;
6273 /* check camera support */
6274 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6275 if (ret != CAMERA_ERROR_NONE) {
6276 CAM_LOG_ERROR("get device state failed");
6280 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6282 info = g_new0(camera_cb_info, 1);
6284 CAM_LOG_ERROR("info failed");
6285 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6289 info->id = ++g_cam_dev_state_changed_cb_id;
6290 info->callback = (void *)callback;
6291 info->user_data = user_data;
6295 /* subscribe dbus signal for camera state change */
6296 if (!g_cam_dev_state_changed_cb_conn) {
6297 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6298 if (!g_cam_dev_state_changed_cb_conn) {
6299 CAM_LOG_ERROR("failed to get gdbus connection");
6300 ret = CAMERA_ERROR_INVALID_OPERATION;
6304 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6305 MM_CAMCORDER_DBUS_OBJECT,
6306 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6307 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6309 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6310 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6311 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6312 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6313 CAM_LOG_ERROR("failed to get gdbus connection");
6314 ret = CAMERA_ERROR_INVALID_OPERATION;
6318 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6321 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6323 CAM_LOG_INFO("callback id %d", info->id);
6326 if (ret != CAMERA_ERROR_NONE) {
6332 if (g_cam_dev_state_changed_cb_conn) {
6333 g_object_unref(g_cam_dev_state_changed_cb_conn);
6334 g_cam_dev_state_changed_cb_conn = NULL;
6338 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6344 int camera_remove_device_state_changed_cb(int cb_id)
6346 int ret = CAMERA_ERROR_NONE;
6347 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6348 GList *tmp_list = NULL;
6349 camera_cb_info *info = NULL;
6351 /* check camera support */
6352 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6353 if (ret != CAMERA_ERROR_NONE) {
6354 CAM_LOG_ERROR("get device state failed");
6358 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6360 if (!g_cam_dev_state_changed_cb_list) {
6361 CAM_LOG_ERROR("there is no callback info");
6362 ret = CAMERA_ERROR_INVALID_OPERATION;
6366 tmp_list = g_cam_dev_state_changed_cb_list;
6369 info = tmp_list->data;
6370 tmp_list = tmp_list->next;
6373 CAM_LOG_WARNING("NULL info");
6377 if (info->id == cb_id) {
6378 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6383 if (!g_cam_dev_state_changed_cb_list) {
6384 /* no remained callback */
6385 if (g_cam_dev_state_changed_cb_conn) {
6386 /* unsubscribe signal */
6387 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6388 g_cam_dev_state_changed_cb_subscribe_id = 0;
6390 /* unref connection */
6391 g_object_unref(g_cam_dev_state_changed_cb_conn);
6392 g_cam_dev_state_changed_cb_conn = NULL;
6396 CAM_LOG_INFO("id %d callback removed", cb_id);
6397 ret = CAMERA_ERROR_NONE;
6403 CAM_LOG_ERROR("id %d callback not found", cb_id);
6404 ret = CAMERA_ERROR_INVALID_PARAMETER;
6407 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6414 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_cli_s *pc = (camera_cli_s *)camera;
6418 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6420 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6422 g_mutex_lock(&pc->cb_info->bridge_lock);
6424 if (pc->cb_info->bridge) {
6425 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6426 ret = CAMERA_ERROR_INVALID_OPERATION;
6427 goto _SET_MEDIA_BRIDGE_DONE;
6430 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6431 if (ret != CAMERA_ERROR_NONE) {
6432 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6433 goto _SET_MEDIA_BRIDGE_DONE;
6436 pc->cb_info->bridge = bridge;
6438 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6440 _SET_MEDIA_BRIDGE_DONE:
6441 g_mutex_unlock(&pc->cb_info->bridge_lock);
6447 int camera_media_bridge_unset_bridge(camera_h camera)
6449 int ret = CAMERA_ERROR_NONE;
6450 camera_cli_s *pc = (camera_cli_s *)camera;
6451 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6453 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6455 g_mutex_lock(&pc->cb_info->bridge_lock);
6457 if (!pc->cb_info->bridge) {
6458 CAM_LOG_ERROR("no media bridge");
6459 ret = CAMERA_ERROR_INVALID_OPERATION;
6460 goto _UNSET_MEDIA_BRIDGE_DONE;
6463 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6464 if (ret != CAMERA_ERROR_NONE) {
6465 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6466 goto _UNSET_MEDIA_BRIDGE_DONE;
6469 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6471 pc->cb_info->bridge = NULL;
6473 _UNSET_MEDIA_BRIDGE_DONE:
6474 g_mutex_unlock(&pc->cb_info->bridge_lock);
6481 int camera_create_network(camera_device_e device, camera_h *camera)
6483 return _camera_create_private(device, true, camera);
6487 int camera_device_manager_initialize(camera_device_manager_h *manager)
6490 int ret = CAMERA_ERROR_NONE;
6491 void *dl_handle = NULL;
6492 g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6493 cdm_symbol_table sym_table[] = {
6494 {(void **)&new_manager->initialize, "cdm_initialize"},
6495 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6496 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6497 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6498 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6501 CAMERA_CHECK_DEVICE_MANAGER;
6504 CAM_LOG_ERROR("NULL manager");
6505 ret = CAMERA_ERROR_INVALID_PARAMETER;
6506 goto _INITIALIZE_FAILED;
6509 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6511 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6512 ret = CAMERA_ERROR_INVALID_OPERATION;
6513 goto _INITIALIZE_FAILED;
6517 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6518 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6519 if (*sym_table[i].func_ptr == NULL) {
6520 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6521 ret = CAMERA_ERROR_INVALID_OPERATION;
6522 goto _INITIALIZE_FAILED;
6526 ret = new_manager->initialize();
6527 if (ret != CAMERA_ERROR_NONE) {
6528 CAM_LOG_ERROR("failed[0x%x]", ret);
6529 goto _INITIALIZE_FAILED;
6532 new_manager->dl_handle = dl_handle;
6533 *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
6535 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6536 *manager, dl_handle);
6538 return CAMERA_ERROR_NONE;
6549 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6551 int ret = CAMERA_ERROR_NONE;
6552 camera_device_manager *m = (camera_device_manager *)manager;
6554 CAMERA_CHECK_DEVICE_MANAGER;
6557 CAM_LOG_ERROR("NULL manager");
6558 return CAMERA_ERROR_INVALID_PARAMETER;
6561 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6563 ret = m->deinitialize();
6564 if (ret != CAMERA_ERROR_NONE) {
6565 CAM_LOG_ERROR("failed[0x%x]", ret);
6569 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6571 dlclose(m->dl_handle);
6573 memset(m, 0x0, sizeof(camera_device_manager));
6576 return CAMERA_ERROR_NONE;
6580 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6582 int ret = CAMERA_ERROR_NONE;
6584 camera_device_list_s device_list;
6585 camera_device_s *device = NULL;
6586 camera_device_manager *m = (camera_device_manager *)manager;
6588 CAMERA_CHECK_DEVICE_MANAGER;
6590 if (!m || !callback) {
6591 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6592 return CAMERA_ERROR_INVALID_PARAMETER;
6595 CAM_LOG_INFO("enter");
6597 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6599 ret = m->get_device_list(&device_list);
6600 if (ret != CAMERA_ERROR_NONE) {
6601 CAM_LOG_ERROR("failed[0x%x]", ret);
6605 CAM_LOG_INFO("device count[%d]", device_list.count);
6607 for (i = 0 ; i < device_list.count ; i++) {
6608 device = &device_list.device[i];
6610 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6611 i, device->type, device->index,
6612 device->name, device->id, device->extra_stream_num);
6614 if (!callback(device, user_data)) {
6615 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6616 i + 1, device_list.count);
6621 return CAMERA_ERROR_NONE;
6625 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6626 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6628 int ret = CAMERA_ERROR_NONE;
6629 camera_device_manager *m = (camera_device_manager *)manager;
6631 CAMERA_CHECK_DEVICE_MANAGER;
6633 if (!m || !callback || !cb_id) {
6634 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6635 return CAMERA_ERROR_INVALID_PARAMETER;
6638 CAM_LOG_INFO("enter");
6640 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6641 if (ret != CAMERA_ERROR_NONE) {
6642 CAM_LOG_ERROR("failed[0x%x]", ret);
6646 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6648 return CAMERA_ERROR_NONE;
6652 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6654 int ret = CAMERA_ERROR_NONE;
6655 camera_device_manager *m = (camera_device_manager *)manager;
6657 CAMERA_CHECK_DEVICE_MANAGER;
6660 CAM_LOG_ERROR("NULL manager");
6661 return CAMERA_ERROR_INVALID_PARAMETER;
6664 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6666 ret = m->remove_device_connection_changed_cb(cb_id);
6667 if (ret != CAMERA_ERROR_NONE) {
6668 CAM_LOG_ERROR("failed[0x%x]", ret);
6672 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6674 return CAMERA_ERROR_NONE;
6679 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6681 int ret = CAMERA_ERROR_NONE;
6682 camera_cli_s *pc = (camera_cli_s *)camera;
6683 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6685 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6687 if (!camera_is_supported_extra_preview(camera)) {
6688 CAM_LOG_ERROR("extra preview is not supported");
6689 return CAMERA_ERROR_NOT_SUPPORTED;
6693 CAM_LOG_ERROR("NULL callback");
6694 return CAMERA_ERROR_INVALID_PARAMETER;
6697 CAM_LOG_INFO("Enter");
6699 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6701 if (ret == CAMERA_ERROR_NONE) {
6702 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6704 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6705 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6707 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6710 CAM_LOG_INFO("ret : 0x%x", ret);
6716 int camera_unset_extra_preview_cb(camera_h camera)
6718 int ret = CAMERA_ERROR_NONE;
6719 camera_cli_s *pc = (camera_cli_s *)camera;
6720 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6722 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6724 if (!camera_is_supported_extra_preview(camera)) {
6725 CAM_LOG_ERROR("extra preview is not supported");
6726 return CAMERA_ERROR_NOT_SUPPORTED;
6729 CAM_LOG_INFO("Enter");
6731 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6733 if (ret == CAMERA_ERROR_NONE) {
6734 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6739 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6742 CAM_LOG_INFO("ret : 0x%x", ret);
6748 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)
6750 int ret = CAMERA_ERROR_NONE;
6751 int stream_format[4] = {pixel_format, width, height, fps};
6753 camera_cli_s *pc = (camera_cli_s *)camera;
6754 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6756 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6758 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6759 stream_id, pixel_format, width, height, fps);
6761 msg = muse_core_msg_new(api,
6762 MUSE_TYPE_INT, "stream_id", stream_id,
6763 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6766 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6772 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)
6774 int ret = CAMERA_ERROR_NONE;
6775 camera_cli_s *pc = (camera_cli_s *)camera;
6776 camera_msg_param param;
6777 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6779 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6780 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6781 return CAMERA_ERROR_INVALID_PARAMETER;
6784 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6786 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6790 if (ret == CAMERA_ERROR_NONE) {
6791 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6792 *width = pc->cb_info->get_extra_preview_stream_format[1];
6793 *height = pc->cb_info->get_extra_preview_stream_format[2];
6794 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6797 CAM_LOG_INFO("ret : 0x%x", ret);
6803 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6805 int ret = CAMERA_ERROR_NONE;
6806 camera_cli_s *pc = (camera_cli_s *)camera;
6807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6808 camera_msg_param param0;
6809 camera_msg_param param1;
6811 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6813 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6815 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6816 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6818 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6819 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6821 CAM_LOG_INFO("ret : 0x%x", ret);
6827 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6829 int ret = CAMERA_ERROR_NONE;
6830 camera_cli_s *pc = (camera_cli_s *)camera;
6831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6832 camera_msg_param param;
6834 if (!pc || !pc->cb_info || !bitrate) {
6835 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6836 return CAMERA_ERROR_INVALID_PARAMETER;
6839 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6841 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6843 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6845 if (ret == CAMERA_ERROR_NONE) {
6846 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6847 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6849 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6856 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6858 int ret = CAMERA_ERROR_NONE;
6859 camera_cli_s *pc = (camera_cli_s *)camera;
6860 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6861 camera_msg_param param0;
6862 camera_msg_param param1;
6864 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6866 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6868 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6869 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6871 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6872 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6874 CAM_LOG_INFO("ret : 0x%x", ret);
6880 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6882 int ret = CAMERA_ERROR_NONE;
6883 camera_cli_s *pc = (camera_cli_s *)camera;
6884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6885 camera_msg_param param;
6887 if (!pc || !pc->cb_info || !interval) {
6888 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6889 return CAMERA_ERROR_INVALID_PARAMETER;
6892 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6894 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6896 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6898 if (ret == CAMERA_ERROR_NONE) {
6899 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6900 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6902 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6909 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6911 camera_cli_s *pc = (camera_cli_s *)camera;
6913 if (!pc || !pc->cb_info || !rotation) {
6914 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6915 return CAMERA_ERROR_INVALID_PARAMETER;
6918 if (!pc->cb_info->stream_data) {
6919 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6920 return CAMERA_ERROR_INVALID_OPERATION;
6923 *rotation = pc->cb_info->stream_data->rotation;
6925 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6927 return CAMERA_ERROR_NONE;
6931 int _camera_get_log_level(void)
6933 return g_camera_log_level;