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 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
777 if (cb_info->is_server_connected) {
778 _camera_update_api_waiting(cb_info, api, 1);
780 g_mutex_lock(&cb_info->fd_lock);
781 send_ret = muse_core_msg_send(cb_info->fd, msg);
782 g_mutex_unlock(&cb_info->fd_lock);
786 CAM_LOG_ERROR("message send failed");
788 *ret = CAMERA_ERROR_INVALID_OPERATION;
791 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
794 _camera_update_api_waiting(cb_info, api, -1);
796 muse_core_msg_free(msg);
798 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
802 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
804 int ret = CAMERA_ERROR_NONE;
807 if (!cb_info->is_server_connected) {
808 CAM_LOG_ERROR("server is disconnected");
809 return CAMERA_ERROR_SERVICE_DISCONNECTED;
812 g_mutex_lock(&(cb_info->api_mutex[api]));
814 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
816 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
818 while (!cb_info->api_activating[api]) {
819 if (time_out == CAMERA_CB_NO_TIMEOUT) {
820 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
821 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
822 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
823 CAM_LOG_ERROR("api %d TIMED OUT!", api);
824 ret = CAMERA_ERROR_INVALID_OPERATION;
828 if (!cb_info->is_server_connected) {
829 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
833 if (!cb_info->api_activating[api])
834 CAM_LOG_WARNING("invalid signal received, wait again...");
837 ret = cb_info->api_ret[api];
838 cb_info->api_activating[api] = FALSE;
841 g_mutex_unlock(&(cb_info->api_mutex[api]));
843 if (ret != CAMERA_ERROR_NONE)
844 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
850 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
851 int *ret, int timeout)
856 CAM_LOG_ERROR("NULL info - api %d", api);
859 *ret = CAMERA_ERROR_INVALID_PARAMETER;
864 msg = muse_core_msg_new(api, NULL);
866 __send_message_get_return(cb_info, api, msg, timeout, ret);
870 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
871 int *ret, camera_msg_param *param, int timeout)
876 if (!cb_info || !param) {
877 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
880 *ret = CAMERA_ERROR_INVALID_PARAMETER;
885 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
887 switch (param->type) {
889 msg = muse_core_msg_new(api,
890 param->type, param->name, param->value.value_INT,
893 case MUSE_TYPE_STRING:
894 msg = muse_core_msg_new(api,
895 param->type, param->name, param->value.value_STRING,
898 case MUSE_TYPE_ARRAY:
899 array_length = param->value_size / sizeof(int) + \
900 (param->value_size % sizeof(int) ? 1 : 0);
902 msg = muse_core_msg_new(api,
903 param->type, param->name, array_length, param->value.value_ARRAY,
907 CAM_LOG_ERROR("unknown type %d", param->type);
911 __send_message_get_return(cb_info, api, msg, timeout, ret);
915 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
916 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
920 if (!cb_info || !param0 || !param1) {
921 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
922 cb_info, param0, param1, api);
925 *ret = CAMERA_ERROR_INVALID_PARAMETER;
930 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
932 param0->name, param0->value.value_INT,
933 param1->name, param1->value.value_INT);
935 msg = muse_core_msg_new(api,
936 param0->type, param0->name, param0->value.value_INT,
937 param1->type, param1->name, param1->value.value_INT,
940 __send_message_get_return(cb_info, api, msg, timeout, ret);
944 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
946 camera_msg_param param;
949 CAM_LOG_WARNING("invalid fd %d", ret_fd);
953 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
955 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
959 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
961 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
962 in_format >= MM_PIXEL_FORMAT_NUM ||
963 out_format == NULL) {
964 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
965 return CAMERA_ERROR_INVALID_PARAMETER;
969 case MM_PIXEL_FORMAT_NV12:
970 case MM_PIXEL_FORMAT_NV12T:
971 *out_format = TBM_FORMAT_NV12;
974 case MM_PIXEL_FORMAT_NV16:
975 *out_format = TBM_FORMAT_NV16;
977 case MM_PIXEL_FORMAT_NV21:
978 *out_format = TBM_FORMAT_NV21;
980 case MM_PIXEL_FORMAT_YUYV:
981 *out_format = TBM_FORMAT_YUYV;
983 case MM_PIXEL_FORMAT_UYVY:
984 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
985 *out_format = TBM_FORMAT_UYVY;
987 case MM_PIXEL_FORMAT_422P:
988 *out_format = TBM_FORMAT_YUV422;
990 case MM_PIXEL_FORMAT_I420:
991 *out_format = TBM_FORMAT_YUV420;
993 case MM_PIXEL_FORMAT_YV12:
994 *out_format = TBM_FORMAT_YVU420;
996 case MM_PIXEL_FORMAT_RGB565:
997 *out_format = TBM_FORMAT_RGB565;
999 case MM_PIXEL_FORMAT_RGB888:
1000 *out_format = TBM_FORMAT_RGB888;
1002 case MM_PIXEL_FORMAT_RGBA:
1003 *out_format = TBM_FORMAT_RGBA8888;
1005 case MM_PIXEL_FORMAT_ARGB:
1006 *out_format = TBM_FORMAT_ARGB8888;
1009 CAM_LOG_ERROR("invalid in_format %d", in_format);
1010 return CAMERA_ERROR_INVALID_PARAMETER;
1014 return CAMERA_ERROR_NONE;
1018 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1020 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1021 in_format >= MM_PIXEL_FORMAT_NUM ||
1023 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1024 return CAMERA_ERROR_INVALID_PARAMETER;
1027 switch (in_format) {
1028 case MM_PIXEL_FORMAT_NV12:
1029 case MM_PIXEL_FORMAT_NV12T:
1030 *mimetype = MEDIA_FORMAT_NV12;
1033 case MM_PIXEL_FORMAT_NV16:
1034 *mimetype = MEDIA_FORMAT_NV16;
1036 case MM_PIXEL_FORMAT_NV21:
1037 *mimetype = MEDIA_FORMAT_NV21;
1039 case MM_PIXEL_FORMAT_YUYV:
1040 *mimetype = MEDIA_FORMAT_YUYV;
1042 case MM_PIXEL_FORMAT_UYVY:
1043 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1044 *mimetype = MEDIA_FORMAT_UYVY;
1046 case MM_PIXEL_FORMAT_422P:
1047 *mimetype = MEDIA_FORMAT_422P;
1049 case MM_PIXEL_FORMAT_I420:
1050 *mimetype = MEDIA_FORMAT_I420;
1052 case MM_PIXEL_FORMAT_YV12:
1053 *mimetype = MEDIA_FORMAT_YV12;
1055 case MM_PIXEL_FORMAT_RGB565:
1056 *mimetype = MEDIA_FORMAT_RGB565;
1058 case MM_PIXEL_FORMAT_RGB888:
1059 *mimetype = MEDIA_FORMAT_RGB888;
1061 case MM_PIXEL_FORMAT_RGBA:
1062 *mimetype = MEDIA_FORMAT_RGBA;
1064 case MM_PIXEL_FORMAT_ARGB:
1065 *mimetype = MEDIA_FORMAT_ARGB;
1067 case MM_PIXEL_FORMAT_ENCODED_H264:
1068 /* TODO: How can we determine the profile for H.264 format? */
1069 *mimetype = MEDIA_FORMAT_H264_SP;
1071 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1072 *mimetype = MEDIA_FORMAT_MJPEG;
1074 case MM_PIXEL_FORMAT_ENCODED_VP8:
1075 *mimetype = MEDIA_FORMAT_VP8;
1077 case MM_PIXEL_FORMAT_ENCODED_VP9:
1078 *mimetype = MEDIA_FORMAT_VP9;
1081 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1082 return CAMERA_ERROR_NOT_SUPPORTED;
1086 return CAMERA_ERROR_NONE;
1090 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1091 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1094 int ret = CAMERA_ERROR_NONE;
1095 camera_media_packet_data *new_mp_data = NULL;
1097 if (!tfd || !mp_data) {
1098 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1099 return CAMERA_ERROR_INVALID_PARAMETER;
1102 new_mp_data = g_new0(camera_media_packet_data, 1);
1104 new_mp_data->ret_fd = ret_fd;
1105 new_mp_data->fd = tfd[0];
1106 new_mp_data->num_buffer_fd = num_buffer_fd;
1107 new_mp_data->bo = bo;
1109 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1113 new_mp_data->data_bo = data_bo;
1114 new_mp_data->data_fd = tfd[1];
1116 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1117 new_mp_data->data_bo, new_mp_data->data_fd);
1120 for (i = 0 ; i < num_buffer_fd ; i++) {
1121 new_mp_data->buffer_bo[i] = buffer_bo[i];
1122 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1124 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1125 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1128 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1129 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1131 new_mp_data->data_fd = CAMERA_FD_INIT;
1134 *mp_data = new_mp_data;
1136 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1141 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1145 if (!mp_data || !cb_info) {
1146 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1150 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1152 /* release imported bo and close fd */
1153 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1154 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1155 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1157 tbm_bo_unref(mp_data->buffer_bo[i]);
1159 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1160 close(mp_data->buffer_fd[i]);
1162 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1165 if (mp_data->data_bo) {
1166 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1167 mp_data->data_fd, mp_data->data_bo);
1169 tbm_bo_unref(mp_data->data_bo);
1171 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1172 close(mp_data->data_fd);
1174 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1177 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1179 tbm_bo_unref(mp_data->bo);
1181 if (CAMERA_IS_FD_VALID(mp_data->fd))
1184 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1187 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1193 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1196 int ret = CAMERA_ERROR_NONE;
1197 uint32_t tbm_format = 0;
1198 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1199 tbm_surface_info_s tsurf_info;
1201 if (!stream || !mp_data) {
1202 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1206 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1207 CAM_LOG_ERROR("No valid data");
1211 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1212 if (ret != CAMERA_ERROR_NONE)
1215 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1217 if (mp_data->num_buffer_fd > 0) {
1218 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1219 bos[i] = mp_data->buffer_bo[i];
1221 bos[0] = mp_data->data_bo;
1224 tsurf_info.width = stream->width;
1225 tsurf_info.height = stream->height;
1226 tsurf_info.format = tbm_format;
1227 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1228 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1230 switch (tbm_format) {
1231 case TBM_FORMAT_NV12: /* fall through */
1232 case TBM_FORMAT_NV21: /* fall through */
1233 case TBM_FORMAT_YUV420: /* fall through */
1234 case TBM_FORMAT_YVU420: /* fall through */
1235 case TBM_FORMAT_UYVY: /* fall through */
1236 case TBM_FORMAT_YUYV:
1237 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1238 tsurf_info.planes[i].stride = stream->stride[i];
1239 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1240 if (i != 0 && mp_data->num_buffer_fd <= 1)
1241 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1242 tsurf_info.size += tsurf_info.planes[i].size;
1244 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1245 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1249 case TBM_FORMAT_RGB565: /* fall through */
1250 case TBM_FORMAT_RGB888: /* fall through */
1251 case TBM_FORMAT_RGBA8888: /* fall through */
1252 case TBM_FORMAT_ARGB8888:
1253 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1254 tsurf_info.planes[0].offset = 0;
1255 tsurf_info.size = stream->data.rgb.length_data;
1258 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1263 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1264 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1268 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1270 int ret = CAMERA_ERROR_NONE;
1271 int pkt_fmt_width = 0;
1272 int pkt_fmt_height = 0;
1273 bool make_pkt_fmt = false;
1274 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1275 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1277 if (!cb_info || !stream) {
1278 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1279 return CAMERA_ERROR_INVALID_PARAMETER;
1282 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1283 if (ret != CAMERA_ERROR_NONE)
1286 /* check media packet format */
1287 if (cb_info->pkt_fmt) {
1288 media_format_get_video_info(cb_info->pkt_fmt,
1289 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1291 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1292 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1294 if (pkt_fmt_mimetype != mimetype ||
1295 pkt_fmt_width != stream->width ||
1296 pkt_fmt_height != stream->height) {
1297 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1298 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1300 media_format_unref(cb_info->pkt_fmt);
1301 cb_info->pkt_fmt = NULL;
1302 make_pkt_fmt = true;
1305 make_pkt_fmt = true;
1308 /* create packet format */
1310 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1311 mimetype, stream->width, stream->height);
1313 ret = media_format_create(&cb_info->pkt_fmt);
1314 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1315 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1316 return CAMERA_ERROR_INVALID_OPERATION;
1319 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1320 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1321 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1322 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1323 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1324 return CAMERA_ERROR_INVALID_OPERATION;
1328 return CAMERA_ERROR_NONE;
1332 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1333 camera_media_packet_data *mp_data, media_packet_h *packet)
1335 media_packet_h pkt = NULL;
1336 tbm_surface_h tsurf = NULL;
1337 int ret = CAMERA_ERROR_NONE;
1339 if (!cb_info || !stream || !mp_data || !packet) {
1340 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1341 cb_info, stream, mp_data, packet);
1342 return CAMERA_ERROR_INVALID_PARAMETER;
1345 ret = __camera_update_media_packet_format(cb_info, stream);
1346 if (ret != CAMERA_ERROR_NONE)
1349 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1350 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1351 stream->data.encoded.data, stream->data.encoded.length_data,
1352 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1355 tsurf = __camera_get_tbm_surface(stream, mp_data);
1357 CAM_LOG_ERROR("get tbm surface failed");
1358 ret = CAMERA_ERROR_INVALID_OPERATION;
1359 goto _PACKET_CREATE_FAILED;
1362 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1363 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1364 (void *)cb_info, &pkt);
1367 if (ret != MEDIA_PACKET_ERROR_NONE) {
1368 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1369 goto _PACKET_CREATE_FAILED;
1372 ret = media_packet_set_extra(pkt, (void *)mp_data);
1373 if (ret != MEDIA_PACKET_ERROR_NONE) {
1374 CAM_LOG_ERROR("media_packet_set_extra failed");
1375 goto _PACKET_CREATE_FAILED;
1378 /* set timestamp : msec -> nsec */
1379 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1380 CAM_LOG_WARNING("media_packet_set_pts failed");
1382 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1383 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1385 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1389 return CAMERA_ERROR_NONE;
1391 _PACKET_CREATE_FAILED:
1393 tbm_surface_destroy(tsurf);
1395 media_packet_unref(pkt);
1397 return CAMERA_ERROR_INVALID_OPERATION;
1400 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1403 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1404 camera_media_packet_data *mp_data = NULL;
1405 tbm_surface_h tsurf = NULL;
1407 if (!pkt || !cb_info) {
1408 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1412 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1413 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1414 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1418 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1420 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1421 pkt, mp_data, tsurf);
1424 tbm_surface_destroy(tsurf);
1426 g_mutex_lock(&cb_info->mp_data_mutex);
1427 __camera_release_media_packet_data(mp_data, cb_info);
1428 g_mutex_unlock(&cb_info->mp_data_mutex);
1431 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1436 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1437 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1441 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1443 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1445 if (cb_info->user_cb[event] == NULL) {
1446 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1447 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1448 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1449 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1450 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1451 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1455 /* return buffer message should be sent for some events.
1456 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1457 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1458 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1459 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1464 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1470 muse_camera_msg_get(previous, recv_msg);
1471 muse_camera_msg_get(current, recv_msg);
1472 muse_camera_msg_get(by_policy, recv_msg);
1474 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1475 previous, current, by_policy);
1477 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1478 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1481 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1485 muse_camera_msg_get(state, recv_msg);
1487 CAM_LOG_INFO("FOCUS state - %d", state);
1489 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1492 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1493 CAM_LOG_INFO("CAPTURE_COMPLETED");
1494 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1496 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1497 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1498 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1501 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1505 muse_camera_msg_get(percent, recv_msg);
1507 CAM_LOG_INFO("HDR progress - %d %%", percent);
1509 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1512 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1518 muse_camera_msg_get(policy, recv_msg);
1519 muse_camera_msg_get(previous, recv_msg);
1520 muse_camera_msg_get(current, recv_msg);
1522 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1524 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1525 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1528 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1533 muse_camera_msg_get(policy, recv_msg);
1534 muse_camera_msg_get(state, recv_msg);
1536 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1538 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1539 (camera_state_e)state, cb_info->user_data[event]);
1542 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1543 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1545 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1548 int current_state = 0;
1550 muse_camera_msg_get(error, recv_msg);
1551 muse_camera_msg_get(current_state, recv_msg);
1553 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1555 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1556 (camera_state_e)current_state, cb_info->user_data[event]);
1560 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1562 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1563 muse_camera_msg_get(param1, recv_msg);
1564 muse_camera_msg_get(param2, recv_msg);
1566 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1568 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1569 cb_info->user_cb[event] = NULL;
1570 cb_info->user_data[event] = NULL;
1571 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1574 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1576 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1578 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1582 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1584 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1601 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1603 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1604 muse_camera_msg_get(param1, recv_msg);
1606 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1608 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1609 cb_info->user_cb[event] = NULL;
1610 cb_info->user_data[event] = NULL;
1611 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1615 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1616 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1619 CAM_LOG_WARNING("unhandled event %d", event);
1623 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1626 static gboolean __camera_idle_event_callback(gpointer data)
1628 camera_cb_info_s *cb_info = NULL;
1629 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1631 if (cam_idle_event == NULL) {
1632 CAM_LOG_ERROR("cam_idle_event is NULL");
1637 g_mutex_lock(&g_cam_idle_event_lock);
1639 cb_info = cam_idle_event->cb_info;
1640 if (cb_info == NULL) {
1641 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1642 g_mutex_unlock(&g_cam_idle_event_lock);
1643 goto IDLE_EVENT_CALLBACK_DONE;
1646 /* remove event from list */
1647 if (cb_info->idle_event_list)
1648 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1650 g_mutex_unlock(&g_cam_idle_event_lock);
1653 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1655 IDLE_EVENT_CALLBACK_DONE:
1657 g_free(cam_idle_event);
1658 cam_idle_event = NULL;
1663 static gpointer __camera_msg_handler_func(gpointer data)
1667 camera_message_s *cam_msg = NULL;
1668 camera_idle_event_s *cam_idle_event = NULL;
1669 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1670 camera_cb_info_s *cb_info = NULL;
1671 GThread *thread = NULL;
1673 if (!handler_info || !handler_info->cb_info) {
1674 CAM_LOG_ERROR("NULL handler %p", handler_info);
1678 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1679 type = handler_info->type;
1680 thread = handler_info->thread;
1682 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1684 g_mutex_lock(&handler_info->mutex);
1686 while (g_atomic_int_get(&handler_info->running)) {
1687 if (g_queue_is_empty(handler_info->queue)) {
1688 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1689 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1690 CAM_LOG_VERBOSE("t[%d] signal received", type);
1692 if (g_atomic_int_get(&handler_info->running) == 0) {
1693 CAM_LOG_INFO("t:%d stop event thread", type);
1698 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1700 g_mutex_unlock(&handler_info->mutex);
1702 if (cam_msg == NULL) {
1703 CAM_LOG_ERROR("t:%d NULL message", type);
1704 g_mutex_lock(&handler_info->mutex);
1710 if (api < MUSE_CAMERA_API_MAX) {
1713 g_mutex_lock(&cb_info->api_mutex[api]);
1715 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1716 if (cb_info->api_waiting[api] > 0) {
1717 cb_info->api_ret[api] = ret;
1718 cb_info->api_activating[api] = TRUE;
1720 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1722 g_cond_broadcast(&cb_info->api_cond[api]);
1724 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1727 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1730 g_mutex_unlock(&cb_info->api_mutex[api]);
1731 } else if (api == MUSE_CAMERA_CB_EVENT) {
1732 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1733 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1734 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1737 switch (cam_msg->event_class) {
1738 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1739 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1741 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1742 cam_idle_event = g_new0(camera_idle_event_s, 1);
1743 if (cam_idle_event == NULL) {
1744 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1748 cam_idle_event->event = cam_msg->event;
1749 cam_idle_event->cb_info = cb_info;
1751 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1752 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1754 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1755 type, cam_msg->event, cam_idle_event);
1757 g_mutex_lock(&g_cam_idle_event_lock);
1758 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1759 g_mutex_unlock(&g_cam_idle_event_lock);
1761 g_idle_add_full(G_PRIORITY_DEFAULT,
1762 (GSourceFunc)__camera_idle_event_callback,
1763 (gpointer)cam_idle_event,
1767 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1771 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1777 g_mutex_lock(&handler_info->mutex);
1780 /* remove remained event */
1781 while (!g_queue_is_empty(handler_info->queue)) {
1782 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1784 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1785 __camera_release_tfd(cam_msg->tfd);
1788 CAM_LOG_WARNING("t:%d NULL message", type);
1792 g_mutex_unlock(&handler_info->mutex);
1794 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1800 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1802 camera_idle_event_s *cam_idle_event = NULL;
1805 if (cb_info == NULL) {
1806 CAM_LOG_ERROR("cb_info is NULL");
1810 g_mutex_lock(&g_cam_idle_event_lock);
1812 if (cb_info->idle_event_list == NULL) {
1813 CAM_LOG_INFO("No remained idle event");
1814 g_mutex_unlock(&g_cam_idle_event_lock);
1818 list = cb_info->idle_event_list;
1821 cam_idle_event = list->data;
1822 list = g_list_next(list);
1824 if (!cam_idle_event) {
1825 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1829 if (g_idle_remove_by_data(cam_idle_event)) {
1830 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1832 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1834 g_free(cam_idle_event);
1835 cam_idle_event = NULL;
1840 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1841 cam_idle_event, cam_idle_event->event);
1843 cam_idle_event->cb_info = NULL;
1845 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1848 g_list_free(cb_info->idle_event_list);
1849 cb_info->idle_event_list = NULL;
1851 g_mutex_unlock(&g_cam_idle_event_lock);
1855 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1857 camera_message_s *cam_msg = NULL;
1859 if (!cb_info || !msg) {
1860 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1864 cam_msg = g_new0(camera_message_s, 1);
1866 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1871 cam_msg->event = event;
1872 cam_msg->event_class = event_class;
1875 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1877 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1879 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1880 api, event, event_class);
1882 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1883 if (!cb_info->preview_cb_info.thread) {
1884 LOGI("The thread for preview cb is not created yet, create it now");
1885 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1886 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1887 CAM_LOG_ERROR("failed to create thread for preview cb");
1893 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1894 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1895 g_cond_signal(&cb_info->preview_cb_info.cond);
1896 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1897 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1898 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1899 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1900 g_cond_signal(&cb_info->capture_cb_info.cond);
1901 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1903 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1904 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1905 g_cond_signal(&cb_info->msg_handler_info.cond);
1906 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1913 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1915 int ret = CAMERA_ERROR_NONE;
1919 int event_class = -1;
1923 if (!cb_info || !msg) {
1924 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1928 CAM_LOG_DEBUG("msg[%s]", msg);
1930 if (!muse_camera_msg_get(api, msg)) {
1931 CAM_LOG_ERROR("failed to get camera api");
1935 if (api == MUSE_CAMERA_CB_EVENT) {
1936 if (!muse_camera_msg_get(event, msg) ||
1937 !muse_camera_msg_get(event_class, msg)) {
1938 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1942 if (!muse_camera_msg_get(api_class, msg)) {
1943 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1948 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1949 if (api >= MUSE_CAMERA_API_MAX) {
1950 CAM_LOG_ERROR("invalid api %d", api);
1954 if (!muse_camera_msg_get(ret, msg)) {
1955 CAM_LOG_ERROR("failed to get camera ret");
1959 g_mutex_lock(&cb_info->api_mutex[api]);
1962 case MUSE_CAMERA_API_CREATE:
1963 if (ret != CAMERA_ERROR_NONE) {
1964 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1965 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1968 case MUSE_CAMERA_API_DESTROY:
1969 if (ret == CAMERA_ERROR_NONE) {
1970 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1971 CAM_LOG_INFO("camera destroy done. close client cb handler");
1975 muse_camera_msg_get(get_type, msg);
1976 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1977 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1978 muse_camera_msg_get(get_index, msg);
1981 case MUSE_CAMERA_GET_TYPE_INT:
1982 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1984 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1985 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1986 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1988 case MUSE_CAMERA_GET_TYPE_ARRAY:
1990 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
1991 muse_core_msg_deserialize("get_value",
1992 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1993 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1994 cb_info->get_display_roi_area[0],
1995 cb_info->get_display_roi_area[1],
1996 cb_info->get_display_roi_area[2],
1997 cb_info->get_display_roi_area[3]);
1999 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2000 muse_core_msg_deserialize("get_value",
2001 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2002 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2003 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2005 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2006 muse_core_msg_deserialize("get_value",
2007 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2008 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2009 cb_info->get_extra_preview_stream_format[0],
2010 cb_info->get_extra_preview_stream_format[1],
2011 cb_info->get_extra_preview_stream_format[2],
2012 cb_info->get_extra_preview_stream_format[3]);
2015 CAM_LOG_WARNING("unknown api[%d]", api);
2019 case MUSE_CAMERA_GET_TYPE_STRING:
2020 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2023 CAM_LOG_WARNING("unknown type %d", get_type);
2030 if (cb_info->api_waiting[api] > 0) {
2031 cb_info->api_ret[api] = ret;
2032 cb_info->api_activating[api] = TRUE;
2034 g_cond_broadcast(&cb_info->api_cond[api]);
2036 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2039 g_mutex_unlock(&cb_info->api_mutex[api]);
2040 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2041 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2043 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2048 static gpointer __camera_msg_recv_func(gpointer data)
2051 int recv_length = 0;
2052 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2053 char *recv_msg = NULL;
2054 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2057 CAM_LOG_ERROR("cb_info NULL");
2061 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2063 recv_msg = cb_info->recv_msg;
2065 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2066 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2067 tfd[i] = CAMERA_FD_INIT;
2069 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2070 if (recv_length <= 0) {
2071 cb_info->is_server_connected = FALSE;
2072 CAM_LOG_ERROR("receive msg failed - server disconnected");
2076 if (CAMERA_IS_FD_VALID(tfd[0]))
2077 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2079 recv_msg[recv_length] = '\0';
2081 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2083 __camera_process_msg(cb_info, recv_msg, tfd);
2086 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2089 if (!cb_info->is_server_connected) {
2090 char *error_msg = NULL;
2092 if (cb_info->bufmgr == NULL) {
2093 CAM_LOG_ERROR("No need to send error(handle is not created)");
2097 if (cb_info->fd < 0) {
2098 CAM_LOG_ERROR("fd is closed in client side");
2102 /* send error msg for server disconnection */
2103 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2104 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2105 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2109 CAM_LOG_ERROR("error_msg failed");
2113 __camera_add_msg_to_queue(cb_info,
2114 MUSE_CAMERA_CB_EVENT,
2115 MUSE_CAMERA_EVENT_TYPE_ERROR,
2116 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2120 muse_core_msg_free(error_msg);
2123 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2124 if (cb_info->api_waiting[i])
2125 g_cond_broadcast(&cb_info->api_cond[i]);
2128 CAM_LOG_ERROR("add error msg for service disconnection done");
2136 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2137 int type, const char *thread_name, camera_cb_info_s *cb_info)
2139 if (!handler_info || !thread_name || !cb_info) {
2140 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2141 type, handler_info, thread_name, cb_info);
2145 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2147 if (handler_info->thread) {
2148 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2152 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2154 handler_info->type = type;
2155 handler_info->queue = g_queue_new();
2156 if (handler_info->queue == NULL) {
2157 CAM_LOG_ERROR("t:%d queue failed", type);
2161 handler_info->cb_info = (void *)cb_info;
2162 g_atomic_int_set(&handler_info->running, 1);
2164 handler_info->thread = g_thread_try_new(thread_name,
2165 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2166 if (handler_info->thread == NULL) {
2167 CAM_LOG_ERROR("t:%d thread failed", type);
2169 g_queue_free(handler_info->queue);
2170 handler_info->queue = NULL;
2175 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2181 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2183 GThread *thread = NULL;
2185 if (!handler_info) {
2186 CAM_LOG_ERROR("NULL handler");
2190 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2192 if (!handler_info->thread) {
2193 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2197 thread = handler_info->thread;
2198 handler_info->thread = NULL;
2200 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2202 g_atomic_int_set(&handler_info->running, 0);
2203 g_cond_signal(&handler_info->cond);
2205 g_clear_pointer(&locker, g_mutex_locker_free);
2207 g_thread_join(thread);
2209 g_queue_free(handler_info->queue);
2210 handler_info->queue = NULL;
2212 CAM_LOG_INFO("t:%d done", handler_info->type);
2216 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2221 CAM_LOG_ERROR("NULL cb_info");
2225 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2226 g_mutex_init(&cb_info->api_mutex[i]);
2227 g_cond_init(&cb_info->api_cond[i]);
2230 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2231 g_mutex_init(&cb_info->user_cb_mutex[i]);
2233 g_mutex_init(&cb_info->fd_lock);
2234 g_mutex_init(&cb_info->mp_data_mutex);
2235 g_mutex_init(&cb_info->bridge_lock);
2237 g_mutex_init(&cb_info->msg_handler_info.mutex);
2238 g_mutex_init(&cb_info->preview_cb_info.mutex);
2239 g_mutex_init(&cb_info->capture_cb_info.mutex);
2240 g_cond_init(&cb_info->msg_handler_info.cond);
2241 g_cond_init(&cb_info->preview_cb_info.cond);
2242 g_cond_init(&cb_info->capture_cb_info.cond);
2244 CAM_LOG_INFO("done");
2248 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2253 CAM_LOG_ERROR("NULL cb_info");
2257 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2258 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2259 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2260 g_cond_clear(&cb_info->msg_handler_info.cond);
2261 g_cond_clear(&cb_info->preview_cb_info.cond);
2262 g_cond_clear(&cb_info->capture_cb_info.cond);
2264 g_mutex_clear(&cb_info->fd_lock);
2265 g_mutex_clear(&cb_info->mp_data_mutex);
2266 g_mutex_clear(&cb_info->bridge_lock);
2268 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2269 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2271 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2272 g_mutex_clear(&cb_info->api_mutex[i]);
2273 g_cond_clear(&cb_info->api_cond[i]);
2276 CAM_LOG_INFO("done");
2280 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2282 camera_cb_info_s *cb_info = NULL;
2285 g_return_val_if_fail(sockfd > 0, NULL);
2287 cb_info = g_new0(camera_cb_info_s, 1);
2289 CAM_LOG_ERROR("cb_info failed");
2293 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2295 __camera_mutex_cond_init(cb_info);
2297 /* message handler thread */
2298 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2299 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2300 CAM_LOG_ERROR("msg_handler_info failed");
2304 /* message handler thread for capture callback */
2305 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2306 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2307 CAM_LOG_ERROR("capture_cb_info failed");
2311 cb_info->fd = sockfd;
2313 /* message receive thread */
2314 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2315 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2316 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2317 if (cb_info->msg_recv_thread == NULL) {
2318 CAM_LOG_ERROR("message receive thread creation failed");
2323 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2324 cb_info->fds[i] = CAMERA_FD_INIT;
2326 cb_info->is_server_connected = TRUE;
2332 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2333 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2335 __camera_mutex_cond_clear(cb_info);
2346 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2349 CAM_LOG_ERROR("NULL cb_info");
2353 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2355 g_thread_join(cb_info->msg_recv_thread);
2356 cb_info->msg_recv_thread = NULL;
2358 CAM_LOG_INFO("msg_recv thread removed");
2360 /* destroy msg handler threads */
2361 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2362 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2363 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2365 __camera_mutex_cond_clear(cb_info);
2367 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2368 muse_client_close(cb_info->fd);
2369 cb_info->fd = CAMERA_FD_INIT;
2372 if (cb_info->bufmgr) {
2373 tbm_bufmgr_deinit(cb_info->bufmgr);
2374 cb_info->bufmgr = NULL;
2376 if (cb_info->pkt_fmt) {
2377 media_format_unref(cb_info->pkt_fmt);
2378 cb_info->pkt_fmt = NULL;
2381 if (cb_info->dp_interface) {
2382 mm_display_interface_deinit(cb_info->dp_interface);
2383 cb_info->dp_interface = NULL;
2390 int _camera_start_evas_rendering(camera_h camera)
2392 camera_cli_s *pc = (camera_cli_s *)camera;
2394 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2396 CAM_LOG_INFO("start");
2398 if (!pc->cb_info->is_evas_render) {
2399 CAM_LOG_ERROR("EVAS surface is not set");
2400 return CAMERA_ERROR_NONE;
2403 /* set evas render flag as RUN */
2404 pc->cb_info->run_evas_render = true;
2406 return CAMERA_ERROR_NONE;
2410 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2412 int ret = CAMERA_ERROR_NONE;
2413 camera_cli_s *pc = (camera_cli_s *)camera;
2415 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2417 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2419 if (!pc->cb_info->is_evas_render) {
2420 CAM_LOG_ERROR("EVAS surface is not set");
2421 return CAMERA_ERROR_NONE;
2424 /* set evas render flag as STOP and release buffers */
2425 pc->cb_info->run_evas_render = false;
2427 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2428 if (ret == MM_ERROR_NONE) {
2429 ret = CAMERA_ERROR_NONE;
2431 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2432 ret = CAMERA_ERROR_INVALID_OPERATION;
2439 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2441 int ret = CAMERA_ERROR_NONE;
2442 int sock_fd = CAMERA_FD_INIT;
2443 int module_index = -1;
2445 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2447 /* create muse connection */
2448 if (!key || !value) {
2449 CAM_LOG_ERROR("NULL pointer");
2450 return CAMERA_ERROR_INVALID_PARAMETER;
2453 sock_fd = muse_client_new();
2455 CAM_LOG_ERROR("muse_client_new failed");
2456 return CAMERA_ERROR_INVALID_OPERATION;
2459 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2460 CAM_LOG_ERROR("muse client get module index failed");
2461 ret = CAMERA_ERROR_INVALID_OPERATION;
2465 msg = muse_core_msg_new(api,
2466 MUSE_TYPE_INT, "module", module_index,
2467 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2470 CAM_LOG_ERROR("msg failed");
2471 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2475 ret = muse_core_msg_send(sock_fd, msg);
2477 muse_core_msg_free(msg);
2481 CAM_LOG_ERROR("send msg failed");
2482 ret = CAMERA_ERROR_INVALID_OPERATION;
2486 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2488 CAM_LOG_ERROR("recv msg failed %d", errno);
2489 ret = CAMERA_ERROR_INVALID_OPERATION;
2493 if (!muse_camera_msg_get(ret, recv_msg)) {
2494 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2495 ret = CAMERA_ERROR_INVALID_OPERATION;
2499 if (ret == CAMERA_ERROR_NONE)
2500 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2502 CAM_LOG_INFO("api %d - value %d", api, *value);
2505 if (CAMERA_IS_FD_VALID(sock_fd)) {
2506 muse_client_close(sock_fd);
2507 sock_fd = CAMERA_FD_INIT;
2514 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2516 int sock_fd = CAMERA_FD_INIT;
2517 char *send_msg = NULL;
2519 int ret = CAMERA_ERROR_NONE;
2520 camera_cli_s *pc = NULL;
2521 tbm_bufmgr bufmgr = NULL;
2523 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2524 int module_index = -1;
2525 int device_type = (int)device;
2527 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2529 sock_fd = muse_client_new();
2531 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2532 ret = CAMERA_ERROR_INVALID_OPERATION;
2536 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2537 CAM_LOG_ERROR("muse client get module index failed");
2538 ret = CAMERA_ERROR_INVALID_OPERATION;
2542 send_msg = muse_core_msg_new(api,
2543 MUSE_TYPE_INT, "module", module_index,
2544 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2545 MUSE_TYPE_INT, "is_network", (int)is_network,
2549 CAM_LOG_ERROR("NULL msg");
2550 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2554 send_ret = muse_core_msg_send(sock_fd, send_msg);
2556 muse_core_msg_free(send_msg);
2560 CAM_LOG_ERROR("send msg failed %d", errno);
2561 ret = CAMERA_ERROR_INVALID_OPERATION;
2565 pc = g_new0(camera_cli_s, 1);
2567 CAM_LOG_ERROR("camera_cli_s alloc failed");
2568 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2572 bufmgr = tbm_bufmgr_init(-1);
2573 if (bufmgr == NULL) {
2574 CAM_LOG_ERROR("get tbm bufmgr failed");
2575 ret = CAMERA_ERROR_INVALID_OPERATION;
2579 pc->cb_info = __camera_client_callback_new(sock_fd);
2580 if (pc->cb_info == NULL) {
2581 CAM_LOG_ERROR("cb_info alloc failed");
2582 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2586 sock_fd = CAMERA_FD_INIT;
2588 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2590 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2592 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2594 if (ret == CAMERA_ERROR_NONE) {
2595 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2596 int user_buffer_supported = 0;
2597 int log_level = CAMERA_LOG_LEVEL_INFO;
2598 intptr_t handle = 0;
2600 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2602 CAM_LOG_ERROR("Receiving Handle Failed!!");
2603 ret = CAMERA_ERROR_INVALID_OPERATION;
2607 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2608 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2609 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2611 pc->remote_handle = handle;
2612 pc->cb_info->bufmgr = bufmgr;
2613 pc->cb_info->preview_format = preview_format;
2614 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2615 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2616 pc->cb_info->is_network = is_network;
2617 g_camera_log_level = log_level;
2619 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2620 preview_format, user_buffer_supported, g_camera_log_level);
2623 CAM_LOG_ERROR("NULL out handle");
2624 ret= CAMERA_ERROR_INVALID_PARAMETER;
2628 *camera = (camera_h)pc;
2630 /* get display interface handle */
2631 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2632 CAM_LOG_WARNING("display interface init failed");
2641 tbm_bufmgr_deinit(bufmgr);
2645 if (CAMERA_IS_FD_VALID(sock_fd)) {
2646 muse_client_close(sock_fd);
2647 sock_fd = CAMERA_FD_INIT;
2652 int temp_fd = pc->cb_info->fd;
2654 /* pc->cb_info->fd should be closed,
2655 because g_thread_join for msg_recv_thread is not returned
2656 in __camera_client_callback_destroy. */
2657 if (CAMERA_IS_FD_VALID(temp_fd)) {
2658 pc->cb_info->fd = CAMERA_FD_INIT;
2659 muse_client_close(temp_fd);
2662 __camera_client_callback_destroy(pc->cb_info);
2669 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2676 int camera_create(camera_device_e device, camera_h *camera)
2678 return _camera_create_private(device, false, camera);
2682 int camera_change_device(camera_h camera, camera_device_e device)
2685 int ret = CAMERA_ERROR_NONE;
2686 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2687 camera_cli_s *pc = (camera_cli_s *)camera;
2688 camera_msg_param param;
2690 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2692 CAMERA_MSG_PARAM_SET(param, INT, device);
2694 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2696 if (ret == CAMERA_ERROR_NONE) {
2697 /* reset callback and user data */
2698 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2699 pc->cb_info->user_cb[i] = NULL;
2700 pc->cb_info->user_data[i] = NULL;
2708 int camera_destroy(camera_h camera)
2710 int ret = CAMERA_ERROR_NONE;
2711 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2712 camera_cli_s *pc = (camera_cli_s *)camera;
2714 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2716 CAM_LOG_INFO("Enter");
2718 if (pc->cb_info->is_server_connected)
2719 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2721 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2723 if (ret == CAMERA_ERROR_NONE) {
2724 __camera_deactivate_idle_event_all(pc->cb_info);
2725 __camera_client_callback_destroy(pc->cb_info);
2732 CAM_LOG_INFO("ret : 0x%x", ret);
2737 int camera_start_preview(camera_h camera)
2739 int ret = CAMERA_ERROR_NONE;
2741 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2742 camera_cli_s *pc = (camera_cli_s *)camera;
2743 camera_state_e current_state = CAMERA_STATE_NONE;
2745 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2747 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2748 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2750 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2751 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2752 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2753 pc->cb_info->dp_info.type);
2754 return CAMERA_ERROR_INVALID_OPERATION;
2757 ret = camera_get_state(camera, ¤t_state);
2758 if (ret != CAMERA_ERROR_NONE) {
2759 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2763 if (current_state == CAMERA_STATE_CREATED) {
2764 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2765 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2766 CAM_LOG_ERROR("preview_cb_info failed");
2767 return CAMERA_ERROR_INVALID_OPERATION;
2770 if (pc->cb_info->user_buffer_supported) {
2771 if (!__camera_allocate_preview_buffer(camera)) {
2772 ret = CAMERA_ERROR_INVALID_OPERATION;
2776 fds = pc->cb_info->fds;
2780 _camera_msg_send(api, fds, pc->cb_info, &ret,
2781 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2782 CAMERA_CB_NO_TIMEOUT);
2784 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2786 if (ret != CAMERA_ERROR_NONE)
2789 if (pc->cb_info->is_evas_render) {
2790 ret = _camera_start_evas_rendering(camera);
2791 if (ret != CAMERA_ERROR_NONE) {
2792 CAM_LOG_ERROR("stop preview because of error");
2793 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2798 CAM_LOG_INFO("done");
2800 return CAMERA_ERROR_NONE;
2803 if (current_state == CAMERA_STATE_CREATED) {
2804 if (pc->cb_info->user_buffer_supported)
2805 __camera_release_preview_buffer(camera);
2807 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2810 CAM_LOG_ERROR("failed : 0x%x", ret);
2816 int camera_stop_preview(camera_h camera)
2818 int ret = CAMERA_ERROR_NONE;
2819 camera_cli_s *pc = (camera_cli_s *)camera;
2820 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2821 camera_state_e current_state = CAMERA_STATE_NONE;
2823 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2825 CAM_LOG_INFO("Enter");
2828 if (pc->cb_info->is_evas_render) {
2829 ret = camera_get_state(camera, ¤t_state);
2830 if (ret != CAMERA_ERROR_NONE) {
2831 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2835 if (current_state == CAMERA_STATE_PREVIEW) {
2836 ret = _camera_stop_evas_rendering(camera, false);
2837 if (ret != CAMERA_ERROR_NONE)
2842 /* send stop preview message */
2843 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2845 if (ret == CAMERA_ERROR_NONE) {
2846 if (pc->cb_info->user_buffer_supported)
2847 __camera_release_preview_buffer(camera);
2849 /* release remained message for preview callback */
2850 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2851 } else if (current_state == CAMERA_STATE_PREVIEW) {
2852 CAM_LOG_WARNING("restart evas rendering");
2853 _camera_start_evas_rendering(camera);
2856 CAM_LOG_INFO("ret : 0x%x", ret);
2862 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2864 int ret = CAMERA_ERROR_NONE;
2865 camera_cli_s *pc = (camera_cli_s *)camera;
2866 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2868 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2870 CAM_LOG_INFO("Enter");
2872 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2873 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2875 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2876 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2878 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2880 CAM_LOG_INFO("ret : 0x%x", ret);
2886 bool camera_is_supported_continuous_capture(camera_h camera)
2888 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2892 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)
2894 int ret = CAMERA_ERROR_NONE;
2895 camera_cli_s *pc = (camera_cli_s *)camera;
2896 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2897 camera_msg_param param;
2900 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2902 CAM_LOG_INFO("Enter");
2904 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2905 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2907 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2908 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2910 value = (count << 16) | interval;
2911 CAMERA_MSG_PARAM_SET(param, INT, value);
2913 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2915 CAM_LOG_INFO("ret : 0x%x", ret);
2921 int camera_stop_continuous_capture(camera_h camera)
2923 int ret = CAMERA_ERROR_NONE;
2924 camera_cli_s *pc = (camera_cli_s *)camera;
2925 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2927 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2929 CAM_LOG_INFO("Enter");
2931 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2933 CAM_LOG_INFO("ret : 0x%x", ret);
2939 bool camera_is_supported_face_detection(camera_h camera)
2941 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2945 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2947 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2951 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2953 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2957 bool camera_is_supported_extra_preview(camera_h camera)
2959 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2963 int camera_get_device_count(camera_h camera, int *device_count)
2965 int ret = CAMERA_ERROR_NONE;
2966 camera_cli_s *pc = (camera_cli_s *)camera;
2967 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2969 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2971 CAM_LOG_INFO("Enter");
2973 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2975 if (ret == CAMERA_ERROR_NONE)
2976 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2978 CAM_LOG_INFO("ret : 0x%x", ret);
2983 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2985 int ret = CAMERA_ERROR_NONE;
2986 camera_cli_s *pc = (camera_cli_s *)camera;
2987 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2989 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2991 CAM_LOG_INFO("Enter");
2993 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2995 if (ret == CAMERA_ERROR_NONE) {
2996 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3001 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3004 CAM_LOG_INFO("ret : 0x%x", ret);
3009 int camera_stop_face_detection(camera_h camera)
3011 int ret = CAMERA_ERROR_NONE;
3012 camera_cli_s *pc = (camera_cli_s *)camera;
3013 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3015 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3017 CAM_LOG_INFO("Enter");
3019 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3021 if (ret == CAMERA_ERROR_NONE) {
3022 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3027 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3030 CAM_LOG_INFO("ret : 0x%x", ret);
3035 int camera_get_state(camera_h camera, camera_state_e *state)
3037 int ret = CAMERA_ERROR_NONE;
3038 camera_cli_s *pc = (camera_cli_s *)camera;
3039 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3041 if (!pc || !pc->cb_info || !state) {
3042 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3043 return CAMERA_ERROR_INVALID_PARAMETER;
3046 CAM_LOG_INFO("Enter");
3048 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3050 if (ret == CAMERA_ERROR_NONE)
3051 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3053 CAM_LOG_INFO("ret : 0x%x", ret);
3058 int camera_start_focusing(camera_h camera, bool continuous)
3060 int ret = CAMERA_ERROR_NONE;
3061 camera_cli_s *pc = (camera_cli_s *)camera;
3062 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3063 camera_msg_param param;
3064 int is_continuous = (int)continuous;
3066 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3068 CAM_LOG_INFO("Enter");
3070 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3072 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3074 CAM_LOG_INFO("ret : 0x%x", ret);
3079 int camera_cancel_focusing(camera_h camera)
3081 int ret = CAMERA_ERROR_NONE;
3082 camera_cli_s *pc = (camera_cli_s *)camera;
3083 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3085 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3087 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3091 CAM_LOG_INFO("ret : 0x%x", ret);
3097 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3099 int mm_ret = MM_ERROR_NONE;
3100 int ret = CAMERA_ERROR_NONE;
3101 camera_cli_s *pc = (camera_cli_s *)camera;
3102 camera_cb_info_s *cb_info = NULL;
3103 camera_state_e current_state = CAMERA_STATE_NONE;
3104 camera_msg_param param;
3105 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3106 muse_camera_display_info_s *dp_info = NULL;
3108 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3110 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3111 CAM_LOG_ERROR("invalid type %d", type);
3112 return CAMERA_ERROR_INVALID_PARAMETER;
3115 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3116 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3117 return CAMERA_ERROR_INVALID_PARAMETER;
3120 cb_info = (camera_cb_info_s *)pc->cb_info;
3121 dp_info = &cb_info->dp_info;
3123 ret = camera_get_state(camera, ¤t_state);
3124 if (ret != CAMERA_ERROR_NONE) {
3125 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3129 if (current_state != CAMERA_STATE_CREATED) {
3130 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3131 return CAMERA_ERROR_INVALID_STATE;
3134 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3136 if (type != MM_DISPLAY_TYPE_NONE) {
3137 /* check display interface handle */
3138 if (!cb_info->dp_interface) {
3139 CAM_LOG_ERROR("display interface not supported");
3140 return CAMERA_ERROR_NOT_SUPPORTED;
3143 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3144 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3145 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3146 return CAMERA_ERROR_NOT_SUPPORTED;
3147 } else if (mm_ret != MM_ERROR_NONE) {
3148 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3149 return CAMERA_ERROR_INVALID_OPERATION;
3152 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3153 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3155 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3156 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3157 dp_info->window_rect.width, dp_info->window_rect.height);
3158 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3160 camera_flip_e flip = CAMERA_FLIP_NONE;
3161 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3162 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3169 camera_get_display_flip(camera, &flip);
3170 camera_get_display_mode(camera, &mode);
3171 camera_get_display_rotation(camera, &rotation);
3172 camera_is_display_visible(camera, &visible);
3174 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3175 flip, mode, rotation, visible);
3177 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3178 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3179 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3180 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3182 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3183 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3184 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3185 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3191 if (mm_ret != MM_ERROR_NONE) {
3192 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3193 return CAMERA_ERROR_INVALID_OPERATION;
3196 dp_info->type = type;
3198 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3200 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3202 if (ret == CAMERA_ERROR_NONE)
3203 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3209 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3211 CAM_LOG_INFO("type %d, display %p", type, display);
3212 return _camera_set_display(camera, (mm_display_type_e)type, display);
3216 int camera_set_preview_resolution(camera_h camera, int width, int height)
3218 int ret = CAMERA_ERROR_NONE;
3219 camera_state_e current_state = CAMERA_STATE_NONE;
3220 camera_cli_s *pc = (camera_cli_s *)camera;
3221 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3222 camera_msg_param param;
3225 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3227 if (pc->cb_info->is_evas_render) {
3228 ret = camera_get_state(camera, ¤t_state);
3229 if (ret != CAMERA_ERROR_NONE) {
3230 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3234 if (current_state == CAMERA_STATE_PREVIEW) {
3235 ret = _camera_stop_evas_rendering(camera, true);
3236 if (ret != CAMERA_ERROR_NONE)
3241 value = (width << 16) | height;
3242 CAMERA_MSG_PARAM_SET(param, INT, value);
3244 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3246 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3248 CAM_LOG_INFO("ret : 0x%x", ret);
3250 if (current_state == CAMERA_STATE_PREVIEW) {
3251 CAM_LOG_WARNING("restart evas rendering");
3252 _camera_start_evas_rendering(camera);
3259 int camera_set_capture_resolution(camera_h camera, int width, int height)
3261 int ret = CAMERA_ERROR_NONE;
3262 camera_cli_s *pc = (camera_cli_s *)camera;
3263 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3264 camera_msg_param param;
3267 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3269 CAM_LOG_INFO("Enter");
3271 value = (width << 16) | height;
3272 CAMERA_MSG_PARAM_SET(param, INT, value);
3274 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3276 CAM_LOG_INFO("ret : 0x%x", ret);
3282 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3284 int ret = CAMERA_ERROR_NONE;
3285 int set_format = (int)format;
3286 camera_cli_s *pc = (camera_cli_s *)camera;
3287 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3288 camera_msg_param param;
3290 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3292 CAM_LOG_INFO("Enter - format %d", set_format);
3294 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3296 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3298 CAM_LOG_INFO("ret : 0x%x", ret);
3304 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3306 int ret = CAMERA_ERROR_NONE;
3307 int set_format = (int)format;
3308 camera_msg_param param;
3309 camera_cli_s *pc = (camera_cli_s *)camera;
3310 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3312 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3314 CAM_LOG_INFO("Enter - format %d", set_format);
3316 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3318 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3320 if (ret == CAMERA_ERROR_NONE)
3321 pc->cb_info->preview_format = set_format;
3323 CAM_LOG_INFO("ret : 0x%x", ret);
3329 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3331 int ret = CAMERA_ERROR_NONE;
3332 camera_cli_s *pc = (camera_cli_s *)camera;
3333 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3335 if (!pc || !pc->cb_info || !width || !height) {
3336 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3337 return CAMERA_ERROR_INVALID_PARAMETER;
3340 CAM_LOG_INFO("Enter");
3342 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3344 if (ret == CAMERA_ERROR_NONE) {
3345 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3346 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3349 CAM_LOG_INFO("ret : 0x%x", ret);
3355 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3357 int ret = CAMERA_ERROR_NONE;
3358 int set_rotation = (int)rotation;
3359 camera_cli_s *pc = (camera_cli_s *)camera;
3360 camera_msg_param param;
3362 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3364 if (pc->cb_info->is_evas_render) {
3365 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3366 if (ret != MM_ERROR_NONE) {
3367 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3368 return CAMERA_ERROR_INVALID_OPERATION;
3372 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3374 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3380 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3382 int ret = CAMERA_ERROR_NONE;
3383 camera_cli_s *pc = (camera_cli_s *)camera;
3385 if (!pc || !pc->cb_info || !rotation) {
3386 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3387 return CAMERA_ERROR_INVALID_PARAMETER;
3390 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3392 if (ret == CAMERA_ERROR_NONE)
3393 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3399 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3401 int ret = CAMERA_ERROR_NONE;
3402 int set_flip = (int)flip;
3403 camera_cli_s *pc = (camera_cli_s *)camera;
3404 camera_msg_param param;
3406 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3408 if (pc->cb_info->is_evas_render) {
3409 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3410 if (ret != MM_ERROR_NONE) {
3411 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3412 return CAMERA_ERROR_INVALID_OPERATION;
3416 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3418 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3424 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3426 int ret = CAMERA_ERROR_NONE;
3427 camera_cli_s *pc = (camera_cli_s *)camera;
3429 if (!pc || !pc->cb_info || !flip) {
3430 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3431 return CAMERA_ERROR_INVALID_PARAMETER;
3434 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3436 if (ret == CAMERA_ERROR_NONE)
3437 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3443 int camera_set_display_visible(camera_h camera, bool visible)
3445 int ret = CAMERA_ERROR_NONE;
3446 int set_visible = (int)visible;
3447 camera_cli_s *pc = (camera_cli_s *)camera;
3448 camera_msg_param param;
3450 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3452 if (pc->cb_info->is_evas_render) {
3453 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3454 if (ret != MM_ERROR_NONE) {
3455 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3456 return CAMERA_ERROR_INVALID_OPERATION;
3460 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3462 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3468 int camera_is_display_visible(camera_h camera, bool *visible)
3470 int ret = CAMERA_ERROR_NONE;
3471 camera_cli_s *pc = (camera_cli_s *)camera;
3473 if (!pc || !pc->cb_info || !visible) {
3474 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3475 return CAMERA_ERROR_INVALID_PARAMETER;
3478 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3480 if (ret == CAMERA_ERROR_NONE)
3481 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3487 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3489 int ret = CAMERA_ERROR_NONE;
3490 int set_mode = (int)mode;
3491 camera_cli_s *pc = (camera_cli_s *)camera;
3492 camera_msg_param param;
3494 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3496 if (pc->cb_info->is_evas_render) {
3497 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3498 if (ret != MM_ERROR_NONE) {
3499 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3500 return CAMERA_ERROR_INVALID_OPERATION;
3504 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3506 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3512 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3514 int ret = CAMERA_ERROR_NONE;
3515 camera_cli_s *pc = (camera_cli_s *)camera;
3517 if (!pc || !pc->cb_info || !mode) {
3518 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3519 return CAMERA_ERROR_INVALID_PARAMETER;
3522 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3524 if (ret == CAMERA_ERROR_NONE)
3525 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3531 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3533 int ret = CAMERA_ERROR_NONE;
3534 int set_hint = (int)hint;
3535 camera_cli_s *pc = (camera_cli_s *)camera;
3536 camera_msg_param param;
3538 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3540 CAM_LOG_INFO("Enter - hint %d", set_hint);
3542 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3544 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3550 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3552 int ret = CAMERA_ERROR_NONE;
3553 camera_cli_s *pc = (camera_cli_s *)camera;
3554 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3556 if (!pc || !pc->cb_info || !hint) {
3557 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3558 return CAMERA_ERROR_INVALID_PARAMETER;
3561 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3563 if (ret == CAMERA_ERROR_NONE) {
3564 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3565 CAM_LOG_INFO("display reuse hint %d", *hint);
3572 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3574 int ret = CAMERA_ERROR_NONE;
3575 camera_cli_s *pc = (camera_cli_s *)camera;
3576 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3578 if (!pc || !pc->cb_info || !width || !height) {
3579 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3580 return CAMERA_ERROR_INVALID_PARAMETER;
3583 CAM_LOG_INFO("Enter");
3585 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3587 if (ret == CAMERA_ERROR_NONE) {
3588 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3589 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3592 CAM_LOG_INFO("ret : 0x%x", ret);
3598 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3600 int ret = CAMERA_ERROR_NONE;
3601 camera_cli_s *pc = (camera_cli_s *)camera;
3602 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3604 if (!pc || !pc->cb_info || !format) {
3605 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3606 return CAMERA_ERROR_INVALID_PARAMETER;
3609 CAM_LOG_INFO("Enter");
3611 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3613 if (ret == CAMERA_ERROR_NONE)
3614 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3616 CAM_LOG_INFO("ret : 0x%x", ret);
3622 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3624 int ret = CAMERA_ERROR_NONE;
3625 camera_cli_s *pc = (camera_cli_s *)camera;
3626 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3628 if (!pc || !pc->cb_info || !format) {
3629 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3630 return CAMERA_ERROR_INVALID_PARAMETER;
3633 CAM_LOG_INFO("Enter");
3635 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3637 if (ret == CAMERA_ERROR_NONE)
3638 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3640 CAM_LOG_INFO("ret : 0x%x", ret);
3646 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3648 int ret = CAMERA_ERROR_NONE;
3649 camera_cli_s *pc = (camera_cli_s *)camera;
3650 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3652 if (!pc || !pc->cb_info || !facing_direction) {
3653 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3654 return CAMERA_ERROR_INVALID_PARAMETER;
3657 CAM_LOG_INFO("Enter");
3659 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3661 if (ret == CAMERA_ERROR_NONE)
3662 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3664 CAM_LOG_INFO("ret : 0x%x", ret);
3670 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3672 int ret = CAMERA_ERROR_NONE;
3673 camera_cli_s *pc = (camera_cli_s *)camera;
3674 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3676 if (!pc || !pc->cb_info || !callback) {
3677 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3678 return CAMERA_ERROR_INVALID_PARAMETER;
3681 CAM_LOG_INFO("Enter");
3683 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3685 if (ret == CAMERA_ERROR_NONE) {
3686 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3688 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3689 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3691 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3694 CAM_LOG_INFO("ret : 0x%x", ret);
3700 int camera_unset_preview_cb(camera_h camera)
3702 int ret = CAMERA_ERROR_NONE;
3703 camera_cli_s *pc = (camera_cli_s *)camera;
3704 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3706 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3708 CAM_LOG_INFO("Enter");
3710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3712 if (ret == CAMERA_ERROR_NONE) {
3713 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3715 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3716 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3718 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3721 CAM_LOG_INFO("ret : 0x%x", ret);
3727 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3729 int ret = CAMERA_ERROR_NONE;
3730 camera_cli_s *pc = (camera_cli_s *)camera;
3731 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3733 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3735 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3736 CAM_LOG_ERROR("NOT SUPPORTED");
3737 return CAMERA_ERROR_NOT_SUPPORTED;
3740 if (callback == NULL) {
3741 CAM_LOG_ERROR("NULL callback");
3742 return CAMERA_ERROR_INVALID_PARAMETER;
3745 CAM_LOG_INFO("Enter");
3747 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3749 if (ret == CAMERA_ERROR_NONE) {
3750 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3752 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3753 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3755 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3758 CAM_LOG_INFO("ret : 0x%x", ret);
3764 int camera_unset_media_packet_preview_cb(camera_h camera)
3766 int ret = CAMERA_ERROR_NONE;
3767 camera_cli_s *pc = (camera_cli_s *)camera;
3768 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3770 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3772 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3773 CAM_LOG_ERROR("NOT SUPPORTED");
3774 return CAMERA_ERROR_NOT_SUPPORTED;
3777 CAM_LOG_INFO("Enter");
3779 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3781 if (ret == CAMERA_ERROR_NONE) {
3782 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3784 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3785 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3787 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3790 CAM_LOG_INFO("ret : 0x%x", ret);
3796 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3798 int ret = CAMERA_ERROR_NONE;
3799 camera_cli_s *pc = (camera_cli_s *)camera;
3800 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3802 if (!pc || !pc->cb_info || !callback) {
3803 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3804 return CAMERA_ERROR_INVALID_PARAMETER;
3807 CAM_LOG_INFO("Enter");
3809 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3811 if (ret == CAMERA_ERROR_NONE) {
3812 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3814 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3815 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3817 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3820 CAM_LOG_INFO("ret : 0x%x", ret);
3826 int camera_unset_state_changed_cb(camera_h camera)
3828 int ret = CAMERA_ERROR_NONE;
3829 camera_cli_s *pc = (camera_cli_s *)camera;
3830 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3832 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3834 CAM_LOG_INFO("Enter");
3836 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3838 if (ret == CAMERA_ERROR_NONE) {
3839 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3841 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3842 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3844 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3847 CAM_LOG_INFO("ret : 0x%x", ret);
3853 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3855 int ret = CAMERA_ERROR_NONE;
3856 camera_cli_s *pc = (camera_cli_s *)camera;
3857 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3859 if (!pc || !pc->cb_info || !callback) {
3860 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3861 return CAMERA_ERROR_INVALID_PARAMETER;
3864 CAM_LOG_INFO("Enter");
3866 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3868 if (ret == CAMERA_ERROR_NONE) {
3869 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3871 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3872 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3874 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3877 CAM_LOG_INFO("ret : 0x%x", ret);
3883 int camera_unset_interrupted_cb(camera_h camera)
3885 int ret = CAMERA_ERROR_NONE;
3886 camera_cli_s *pc = (camera_cli_s *)camera;
3887 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3889 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3891 CAM_LOG_INFO("Enter");
3893 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3895 if (ret == CAMERA_ERROR_NONE) {
3896 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3898 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3899 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3901 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3904 CAM_LOG_INFO("ret : 0x%x", ret);
3910 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3912 int ret = CAMERA_ERROR_NONE;
3913 camera_cli_s *pc = (camera_cli_s *)camera;
3914 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3916 if (!pc || !pc->cb_info || !callback) {
3917 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3918 return CAMERA_ERROR_INVALID_PARAMETER;
3921 CAM_LOG_INFO("Enter");
3923 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3925 if (ret == CAMERA_ERROR_NONE) {
3926 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3928 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3929 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3931 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3934 CAM_LOG_INFO("ret : 0x%x", ret);
3940 int camera_unset_interrupt_started_cb(camera_h camera)
3942 int ret = CAMERA_ERROR_NONE;
3943 camera_cli_s *pc = (camera_cli_s *)camera;
3944 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3946 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3948 CAM_LOG_INFO("Enter");
3950 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3952 if (ret == CAMERA_ERROR_NONE) {
3953 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3955 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3956 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3958 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3961 CAM_LOG_INFO("ret : 0x%x", ret);
3967 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3969 int ret = CAMERA_ERROR_NONE;
3970 camera_cli_s *pc = (camera_cli_s *)camera;
3971 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3973 if (!pc || !pc->cb_info || !callback) {
3974 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3975 return CAMERA_ERROR_INVALID_PARAMETER;
3978 CAM_LOG_INFO("Enter");
3980 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3982 if (ret == CAMERA_ERROR_NONE) {
3983 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3985 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3986 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3988 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3991 CAM_LOG_INFO("ret : 0x%x", ret);
3997 int camera_unset_focus_changed_cb(camera_h camera)
3999 int ret = CAMERA_ERROR_NONE;
4000 camera_cli_s *pc = (camera_cli_s *)camera;
4001 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4003 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4005 CAM_LOG_INFO("Enter");
4007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4009 if (ret == CAMERA_ERROR_NONE) {
4010 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4012 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4013 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4015 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4018 CAM_LOG_INFO("ret : 0x%x", ret);
4024 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4026 int ret = CAMERA_ERROR_NONE;
4027 camera_cli_s *pc = (camera_cli_s *)camera;
4028 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4030 if (!pc || !pc->cb_info || !callback) {
4031 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4032 return CAMERA_ERROR_INVALID_PARAMETER;
4035 CAM_LOG_INFO("Enter");
4037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4039 if (ret == CAMERA_ERROR_NONE) {
4040 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4042 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4043 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4045 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4048 CAM_LOG_INFO("ret : 0x%x", ret);
4054 int camera_unset_error_cb(camera_h camera)
4056 int ret = CAMERA_ERROR_NONE;
4057 camera_cli_s *pc = (camera_cli_s *)camera;
4058 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4060 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4062 CAM_LOG_INFO("Enter");
4064 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4066 if (ret == CAMERA_ERROR_NONE) {
4067 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4069 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4070 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4072 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4075 CAM_LOG_INFO("ret : 0x%x", ret);
4081 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4083 int ret = CAMERA_ERROR_NONE;
4084 camera_cli_s *pc = (camera_cli_s *)camera;
4085 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4087 if (!pc || !pc->cb_info || !foreach_cb) {
4088 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4089 return CAMERA_ERROR_INVALID_PARAMETER;
4092 CAM_LOG_INFO("Enter");
4094 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4095 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4099 CAM_LOG_INFO("ret : 0x%x", ret);
4105 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4107 int ret = CAMERA_ERROR_NONE;
4108 camera_cli_s *pc = (camera_cli_s *)camera;
4109 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4111 if (!pc || !pc->cb_info || !foreach_cb) {
4112 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4113 return CAMERA_ERROR_INVALID_PARAMETER;
4116 CAM_LOG_INFO("Enter");
4118 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4119 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4121 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4123 CAM_LOG_INFO("ret : 0x%x", ret);
4129 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4131 int ret = CAMERA_ERROR_NONE;
4132 camera_cli_s *pc = (camera_cli_s *)camera;
4133 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4135 if (!pc || !pc->cb_info || !foreach_cb) {
4136 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4137 return CAMERA_ERROR_INVALID_PARAMETER;
4140 CAM_LOG_INFO("Enter");
4142 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4143 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4145 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4147 CAM_LOG_INFO("ret : 0x%x", ret);
4153 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4155 int ret = CAMERA_ERROR_NONE;
4156 camera_cli_s *pc = (camera_cli_s *)camera;
4157 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4159 if (!pc || !pc->cb_info || !foreach_cb) {
4160 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4161 return CAMERA_ERROR_INVALID_PARAMETER;
4164 CAM_LOG_INFO("Enter");
4166 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4167 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4169 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4171 CAM_LOG_INFO("ret : 0x%x", ret);
4177 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4179 int ret = CAMERA_ERROR_NONE;
4180 camera_cli_s *pc = (camera_cli_s *)camera;
4181 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4183 if (!pc || !pc->cb_info || !width || !height) {
4184 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4185 return CAMERA_ERROR_INVALID_PARAMETER;
4188 CAM_LOG_INFO("Enter");
4189 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4191 if (ret == CAMERA_ERROR_NONE) {
4192 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4193 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4196 CAM_LOG_INFO("ret : 0x%x", ret);
4202 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4204 int ret = CAMERA_ERROR_NONE;
4205 camera_cli_s *pc = (camera_cli_s *)camera;
4206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4208 if (!pc || !pc->cb_info || !angle) {
4209 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4210 return CAMERA_ERROR_INVALID_PARAMETER;
4213 CAM_LOG_INFO("Enter");
4215 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4217 if (ret == CAMERA_ERROR_NONE)
4218 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4220 CAM_LOG_INFO("ret : 0x%x", ret);
4226 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4228 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4232 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4234 int ret = CAMERA_ERROR_NONE;
4235 camera_cli_s *pc = (camera_cli_s *)camera;
4236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4238 if (!pc || !pc->cb_info || !mode) {
4239 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4240 return CAMERA_ERROR_INVALID_PARAMETER;
4243 CAM_LOG_INFO("Enter");
4245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4247 if (ret == CAMERA_ERROR_NONE)
4248 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4250 CAM_LOG_INFO("ret : 0x%x", ret);
4256 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4258 int ret = CAMERA_ERROR_NONE;
4259 camera_cli_s *pc = (camera_cli_s *)camera;
4260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4262 if (!pc || !pc->cb_info || !foreach_cb) {
4263 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4264 return CAMERA_ERROR_INVALID_PARAMETER;
4267 CAM_LOG_INFO("Enter");
4269 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4270 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4272 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4274 CAM_LOG_INFO("Finish, return :%x", ret);
4280 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4282 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4285 camera_msg_param param;
4286 int set_fps = (int)fps;
4288 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4290 CAM_LOG_INFO("Enter");
4292 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4294 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4296 CAM_LOG_INFO("ret : 0x%x", ret);
4302 int camera_attr_set_image_quality(camera_h camera, int quality)
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4307 camera_msg_param param;
4309 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4311 CAM_LOG_INFO("Enter");
4313 CAMERA_MSG_PARAM_SET(param, INT, quality);
4315 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4317 CAM_LOG_INFO("ret : 0x%x", ret);
4323 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4325 int ret = CAMERA_ERROR_NONE;
4326 camera_cli_s *pc = (camera_cli_s *)camera;
4327 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4329 if (!pc || !pc->cb_info || !fps) {
4330 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4331 return CAMERA_ERROR_INVALID_PARAMETER;
4334 CAM_LOG_INFO("Enter");
4336 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4338 if (ret == CAMERA_ERROR_NONE)
4339 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4341 CAM_LOG_INFO("ret : 0x%x", ret);
4347 int camera_attr_get_image_quality(camera_h camera, int *quality)
4349 int ret = CAMERA_ERROR_NONE;
4350 camera_cli_s *pc = (camera_cli_s *)camera;
4351 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4353 if (!pc || !pc->cb_info || !quality) {
4354 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4355 return CAMERA_ERROR_INVALID_PARAMETER;
4358 CAM_LOG_INFO("Enter");
4360 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4362 if (ret == CAMERA_ERROR_NONE)
4363 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4365 CAM_LOG_INFO("ret : 0x%x", ret);
4371 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4373 int ret = CAMERA_ERROR_NONE;
4374 camera_cli_s *pc = (camera_cli_s *)camera;
4375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4377 if (!pc || !pc->cb_info || !bitrate) {
4378 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4379 return CAMERA_ERROR_INVALID_PARAMETER;
4382 CAM_LOG_INFO("Enter");
4384 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4386 if (ret == CAMERA_ERROR_NONE)
4387 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4389 CAM_LOG_INFO("ret : 0x%x", ret);
4395 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4397 int ret = CAMERA_ERROR_NONE;
4398 camera_cli_s *pc = (camera_cli_s *)camera;
4399 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4400 camera_msg_param param;
4401 int set_bitrate = bitrate;
4403 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4405 CAM_LOG_INFO("Enter");
4407 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4409 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4411 CAM_LOG_INFO("ret : 0x%x", ret);
4417 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4419 int ret = CAMERA_ERROR_NONE;
4420 camera_cli_s *pc = (camera_cli_s *)camera;
4421 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4423 if (!pc || !pc->cb_info || !interval) {
4424 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4425 return CAMERA_ERROR_INVALID_PARAMETER;
4428 CAM_LOG_INFO("Enter");
4430 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4432 if (ret == CAMERA_ERROR_NONE)
4433 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4435 CAM_LOG_INFO("ret : 0x%x", ret);
4441 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4443 int ret = CAMERA_ERROR_NONE;
4444 camera_cli_s *pc = (camera_cli_s *)camera;
4445 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4446 camera_msg_param param;
4447 int set_gop_interval = interval;
4449 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4451 CAM_LOG_INFO("Enter");
4453 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4455 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4457 CAM_LOG_INFO("ret : 0x%x", ret);
4463 int camera_attr_set_zoom(camera_h camera, int zoom)
4465 int ret = CAMERA_ERROR_NONE;
4466 camera_cli_s *pc = (camera_cli_s *)camera;
4467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4468 camera_msg_param param;
4470 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4472 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4474 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4476 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4478 CAM_LOG_INFO("ret : 0x%x", ret);
4484 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4486 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4490 int camera_attr_set_af_area(camera_h camera, int x, int y)
4492 int ret = CAMERA_ERROR_NONE;
4493 camera_cli_s *pc = (camera_cli_s *)camera;
4494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4495 camera_msg_param param;
4498 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4500 CAM_LOG_INFO("Enter - %d,%d", x, y);
4502 value = (x << 16) | y;
4503 CAMERA_MSG_PARAM_SET(param, INT, value);
4505 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4507 CAM_LOG_INFO("ret : 0x%x", ret);
4513 int camera_attr_clear_af_area(camera_h camera)
4515 int ret = CAMERA_ERROR_NONE;
4516 camera_cli_s *pc = (camera_cli_s *)camera;
4517 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4519 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4521 CAM_LOG_INFO("Enter");
4523 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4525 CAM_LOG_INFO("ret : 0x%x", ret);
4531 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4533 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4537 int camera_attr_set_exposure(camera_h camera, int value)
4539 int ret = CAMERA_ERROR_NONE;
4540 camera_cli_s *pc = (camera_cli_s *)camera;
4541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4542 camera_msg_param param;
4544 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4546 CAM_LOG_INFO("Enter");
4548 CAMERA_MSG_PARAM_SET(param, INT, value);
4550 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4552 CAM_LOG_INFO("ret : 0x%x", ret);
4558 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4560 int ret = CAMERA_ERROR_NONE;
4561 camera_cli_s *pc = (camera_cli_s *)camera;
4562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4563 camera_msg_param param;
4564 int set_iso = (int)iso;
4566 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4568 CAM_LOG_INFO("Enter");
4570 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4572 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4574 CAM_LOG_INFO("ret : 0x%x", ret);
4580 int camera_attr_set_brightness(camera_h camera, int level)
4582 int ret = CAMERA_ERROR_NONE;
4583 camera_cli_s *pc = (camera_cli_s *)camera;
4584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4585 camera_msg_param param;
4587 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4589 CAM_LOG_INFO("Enter");
4591 CAMERA_MSG_PARAM_SET(param, INT, level);
4593 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4595 CAM_LOG_INFO("ret : 0x%x", ret);
4601 int camera_attr_set_contrast(camera_h camera, int level)
4603 int ret = CAMERA_ERROR_NONE;
4604 camera_cli_s *pc = (camera_cli_s *)camera;
4605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4606 camera_msg_param param;
4608 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4610 CAM_LOG_INFO("Enter");
4612 CAMERA_MSG_PARAM_SET(param, INT, level);
4614 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4616 CAM_LOG_INFO("ret : 0x%x", ret);
4622 int camera_attr_set_hue(camera_h camera, int level)
4624 int ret = CAMERA_ERROR_NONE;
4625 camera_cli_s *pc = (camera_cli_s *)camera;
4626 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4627 camera_msg_param param;
4629 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4631 CAM_LOG_INFO("Enter");
4633 CAMERA_MSG_PARAM_SET(param, INT, level);
4635 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4637 CAM_LOG_INFO("ret : 0x%x", ret);
4643 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4645 int ret = CAMERA_ERROR_NONE;
4646 camera_cli_s *pc = (camera_cli_s *)camera;
4647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4648 camera_msg_param param;
4649 int set_whitebalance = (int)wb;
4651 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4653 CAM_LOG_INFO("Enter");
4655 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 CAM_LOG_INFO("ret : 0x%x", ret);
4665 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4670 camera_msg_param param;
4671 int set_effect = (int)effect;
4673 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4675 CAM_LOG_INFO("Enter");
4677 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4679 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4681 CAM_LOG_INFO("ret : 0x%x", ret);
4687 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4689 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4693 int camera_attr_enable_tag(camera_h camera, bool enable)
4695 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4699 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4701 int ret = CAMERA_ERROR_NONE;
4702 camera_cli_s *pc = (camera_cli_s *)camera;
4703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4704 camera_msg_param param;
4706 if (!pc || !pc->cb_info || !description) {
4707 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4708 return CAMERA_ERROR_INVALID_PARAMETER;
4711 CAM_LOG_INFO("Enter");
4713 CAMERA_MSG_PARAM_SET(param, STRING, description);
4715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4717 CAM_LOG_INFO("ret : 0x%x", ret);
4723 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4725 int ret = CAMERA_ERROR_NONE;
4726 camera_cli_s *pc = (camera_cli_s *)camera;
4727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4728 camera_msg_param param;
4729 int set_orientation = (int)orientation;
4731 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4733 CAM_LOG_INFO("Enter");
4735 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4737 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4739 CAM_LOG_INFO("ret : 0x%x", ret);
4745 int camera_attr_set_tag_software(camera_h camera, const char *software)
4747 int ret = CAMERA_ERROR_NONE;
4748 camera_cli_s *pc = (camera_cli_s *)camera;
4749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4750 camera_msg_param param;
4752 if (!pc || !pc->cb_info || !software) {
4753 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4754 return CAMERA_ERROR_INVALID_PARAMETER;
4757 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4759 CAMERA_MSG_PARAM_SET(param, STRING, software);
4761 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4763 CAM_LOG_INFO("ret : 0x%x", ret);
4769 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4771 int ret = CAMERA_ERROR_NONE;
4772 camera_cli_s *pc = (camera_cli_s *)camera;
4773 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4774 double set_geotag[3] = {latitude, longitude, altitude};
4778 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4780 CAM_LOG_INFO("Enter");
4782 length = sizeof(set_geotag) / sizeof(int) + \
4783 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4785 msg = muse_core_msg_new(api,
4786 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4789 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4795 int camera_attr_remove_geotag(camera_h camera)
4797 int ret = CAMERA_ERROR_NONE;
4798 camera_cli_s *pc = (camera_cli_s *)camera;
4799 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4801 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4803 CAM_LOG_INFO("Enter");
4805 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4807 CAM_LOG_INFO("ret : 0x%x", ret);
4813 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4815 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4819 int camera_attr_get_zoom(camera_h camera, int *zoom)
4821 int ret = CAMERA_ERROR_NONE;
4822 camera_cli_s *pc = (camera_cli_s *)camera;
4823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4825 if (!pc || !pc->cb_info || !zoom) {
4826 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4827 return CAMERA_ERROR_INVALID_PARAMETER;
4830 CAM_LOG_INFO("Enter");
4832 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4834 if (ret == CAMERA_ERROR_NONE)
4835 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4837 CAM_LOG_INFO("ret : 0x%x", ret);
4843 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4845 int ret = CAMERA_ERROR_NONE;
4846 camera_cli_s *pc = (camera_cli_s *)camera;
4847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4849 if (!pc || !pc->cb_info || !min || !max) {
4850 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4851 return CAMERA_ERROR_INVALID_PARAMETER;
4854 CAM_LOG_INFO("Enter");
4856 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4858 if (ret == CAMERA_ERROR_NONE) {
4859 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4860 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4863 CAM_LOG_INFO("ret : 0x%x", ret);
4869 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4871 int ret = CAMERA_ERROR_NONE;
4872 camera_cli_s *pc = (camera_cli_s *)camera;
4873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4875 if (!pc || !pc->cb_info || !mode) {
4876 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4877 return CAMERA_ERROR_INVALID_PARAMETER;
4880 CAM_LOG_INFO("Enter");
4882 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4884 if (ret == CAMERA_ERROR_NONE)
4885 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4887 CAM_LOG_INFO("ret : 0x%x", ret);
4893 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4895 int ret = CAMERA_ERROR_NONE;
4896 camera_cli_s *pc = (camera_cli_s *)camera;
4897 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4899 if (!pc || !pc->cb_info || !mode) {
4900 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4901 return CAMERA_ERROR_INVALID_PARAMETER;
4904 CAM_LOG_INFO("Enter");
4906 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4908 if (ret == CAMERA_ERROR_NONE)
4909 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4911 CAM_LOG_INFO("ret : 0x%x", ret);
4917 int camera_attr_get_exposure(camera_h camera, int *value)
4919 int ret = CAMERA_ERROR_NONE;
4920 camera_cli_s *pc = (camera_cli_s *)camera;
4921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4923 if (!pc || !pc->cb_info || !value) {
4924 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
4925 return CAMERA_ERROR_INVALID_PARAMETER;
4928 CAM_LOG_INFO("Enter");
4930 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4932 if (ret == CAMERA_ERROR_NONE)
4933 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
4935 CAM_LOG_INFO("ret : 0x%x", ret);
4941 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4943 int ret = CAMERA_ERROR_NONE;
4944 camera_cli_s *pc = (camera_cli_s *)camera;
4945 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4947 if (!pc || !pc->cb_info || !min || !max) {
4948 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4949 return CAMERA_ERROR_INVALID_PARAMETER;
4952 CAM_LOG_INFO("Enter");
4954 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4956 if (ret == CAMERA_ERROR_NONE) {
4957 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
4958 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
4961 CAM_LOG_INFO("ret : 0x%x", ret);
4967 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4969 int ret = CAMERA_ERROR_NONE;
4970 camera_cli_s *pc = (camera_cli_s *)camera;
4971 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4973 if (!pc || !pc->cb_info || !iso) {
4974 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
4975 return CAMERA_ERROR_INVALID_PARAMETER;
4978 CAM_LOG_INFO("Enter");
4980 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4982 if (ret == CAMERA_ERROR_NONE)
4983 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
4985 CAM_LOG_INFO("ret : 0x%x", ret);
4991 int camera_attr_get_brightness(camera_h camera, int *level)
4993 int ret = CAMERA_ERROR_NONE;
4994 camera_cli_s *pc = (camera_cli_s *)camera;
4995 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4997 if (!pc || !pc->cb_info || !level) {
4998 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
4999 return CAMERA_ERROR_INVALID_PARAMETER;
5002 CAM_LOG_INFO("Enter");
5004 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5006 if (ret == CAMERA_ERROR_NONE)
5007 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5009 CAM_LOG_INFO("ret : 0x%x", ret);
5015 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5017 int ret = CAMERA_ERROR_NONE;
5018 camera_cli_s *pc = (camera_cli_s *)camera;
5019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5021 if (!pc || !pc->cb_info || !min || !max) {
5022 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5023 return CAMERA_ERROR_INVALID_PARAMETER;
5026 CAM_LOG_INFO("Enter");
5028 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5030 if (ret == CAMERA_ERROR_NONE) {
5031 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5032 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5035 CAM_LOG_INFO("ret : 0x%x", ret);
5041 int camera_attr_get_contrast(camera_h camera, int *level)
5043 int ret = CAMERA_ERROR_NONE;
5044 camera_cli_s *pc = (camera_cli_s *)camera;
5045 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5047 if (!pc || !pc->cb_info || !level) {
5048 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5049 return CAMERA_ERROR_INVALID_PARAMETER;
5052 CAM_LOG_INFO("Enter");
5054 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5056 if (ret == CAMERA_ERROR_NONE)
5057 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5059 CAM_LOG_INFO("ret : 0x%x", ret);
5065 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5067 int ret = CAMERA_ERROR_NONE;
5068 camera_cli_s *pc = (camera_cli_s *)camera;
5069 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5071 if (!pc || !pc->cb_info || !min || !max) {
5072 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5073 return CAMERA_ERROR_INVALID_PARAMETER;
5076 CAM_LOG_INFO("Enter");
5078 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5080 if (ret == CAMERA_ERROR_NONE) {
5081 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5082 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5083 CAM_LOG_INFO("min %d, max %d", *min, *max);
5086 CAM_LOG_INFO("ret : 0x%x", ret);
5092 int camera_attr_get_hue(camera_h camera, int *level)
5094 int ret = CAMERA_ERROR_NONE;
5095 camera_cli_s *pc = (camera_cli_s *)camera;
5096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5098 if (!pc || !pc->cb_info || !level) {
5099 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5100 return CAMERA_ERROR_INVALID_PARAMETER;
5103 CAM_LOG_INFO("Enter");
5105 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5107 if (ret == CAMERA_ERROR_NONE)
5108 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5110 CAM_LOG_INFO("ret : 0x%x", ret);
5116 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5118 int ret = CAMERA_ERROR_NONE;
5119 camera_cli_s *pc = (camera_cli_s *)camera;
5120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5122 if (!pc || !pc->cb_info || !min || !max) {
5123 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5124 return CAMERA_ERROR_INVALID_PARAMETER;
5127 CAM_LOG_INFO("Enter");
5129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5131 if (ret == CAMERA_ERROR_NONE) {
5132 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5133 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5134 CAM_LOG_INFO("min %d, max %d", *min, *max);
5137 CAM_LOG_INFO("ret : 0x%x", ret);
5143 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5145 int ret = CAMERA_ERROR_NONE;
5146 camera_cli_s *pc = (camera_cli_s *)camera;
5147 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5149 if (!pc || !pc->cb_info || !wb) {
5150 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5151 return CAMERA_ERROR_INVALID_PARAMETER;
5154 CAM_LOG_INFO("Enter");
5156 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5158 if (ret == CAMERA_ERROR_NONE)
5159 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5161 CAM_LOG_INFO("ret : 0x%x", ret);
5167 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5169 int ret = CAMERA_ERROR_NONE;
5170 camera_cli_s *pc = (camera_cli_s *)camera;
5171 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5173 if (!pc || !pc->cb_info || !effect) {
5174 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5175 return CAMERA_ERROR_INVALID_PARAMETER;
5178 CAM_LOG_INFO("Enter");
5180 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5182 if (ret == CAMERA_ERROR_NONE)
5183 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5185 CAM_LOG_INFO("ret : 0x%x", ret);
5191 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5193 int ret = CAMERA_ERROR_NONE;
5194 camera_cli_s *pc = (camera_cli_s *)camera;
5195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5197 if (!pc || !pc->cb_info || !mode) {
5198 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5199 return CAMERA_ERROR_INVALID_PARAMETER;
5202 CAM_LOG_INFO("Enter");
5204 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5206 if (ret == CAMERA_ERROR_NONE)
5207 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5209 CAM_LOG_INFO("ret : 0x%x", ret);
5215 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5217 int ret = CAMERA_ERROR_NONE;
5218 camera_cli_s *pc = (camera_cli_s *)camera;
5219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5221 if (!pc || !pc->cb_info || !enable) {
5222 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5223 return CAMERA_ERROR_INVALID_PARAMETER;
5226 CAM_LOG_INFO("Enter");
5228 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5230 if (ret == CAMERA_ERROR_NONE)
5231 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5233 CAM_LOG_INFO("ret : 0x%x", ret);
5239 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5241 int ret = CAMERA_ERROR_NONE;
5242 camera_cli_s *pc = (camera_cli_s *)camera;
5243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5245 if (!pc || !pc->cb_info || !description) {
5246 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5247 return CAMERA_ERROR_INVALID_PARAMETER;
5250 CAM_LOG_INFO("Enter");
5252 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5254 if (ret == CAMERA_ERROR_NONE)
5255 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5257 CAM_LOG_INFO("ret : 0x%x", ret);
5263 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5265 int ret = CAMERA_ERROR_NONE;
5266 camera_cli_s *pc = (camera_cli_s *)camera;
5267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5269 if (!pc || !pc->cb_info || !orientation) {
5270 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5271 return CAMERA_ERROR_INVALID_PARAMETER;
5274 CAM_LOG_INFO("Enter");
5276 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5278 if (ret == CAMERA_ERROR_NONE)
5279 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5281 CAM_LOG_INFO("ret : 0x%x", ret);
5287 int camera_attr_get_tag_software(camera_h camera, char **software)
5289 int ret = CAMERA_ERROR_NONE;
5290 camera_cli_s *pc = (camera_cli_s *)camera;
5291 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5293 if (!pc || !pc->cb_info || !software) {
5294 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5295 return CAMERA_ERROR_INVALID_PARAMETER;
5298 CAM_LOG_INFO("Enter");
5300 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5302 if (ret == CAMERA_ERROR_NONE)
5303 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5305 CAM_LOG_INFO("ret : 0x%x", ret);
5311 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5313 int ret = CAMERA_ERROR_NONE;
5314 camera_cli_s *pc = (camera_cli_s *)camera;
5315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5317 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5318 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5319 return CAMERA_ERROR_INVALID_PARAMETER;
5322 CAM_LOG_INFO("Enter");
5324 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5326 if (ret == CAMERA_ERROR_NONE) {
5327 *latitude = pc->cb_info->get_geotag[0];
5328 *longitude = pc->cb_info->get_geotag[1];
5329 *altitude = pc->cb_info->get_geotag[2];
5332 CAM_LOG_INFO("ret : 0x%x", ret);
5338 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5340 int ret = CAMERA_ERROR_NONE;
5341 camera_cli_s *pc = (camera_cli_s *)camera;
5342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5344 if (!pc || !pc->cb_info || !mode) {
5345 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5346 return CAMERA_ERROR_INVALID_PARAMETER;
5349 CAM_LOG_INFO("Enter");
5351 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5353 if (ret == CAMERA_ERROR_NONE)
5354 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5356 CAM_LOG_INFO("ret : 0x%x", ret);
5362 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5364 int ret = CAMERA_ERROR_NONE;
5365 int get_flash_state = 0;
5368 CAM_LOG_ERROR("NULL pointer");
5369 return CAMERA_ERROR_INVALID_PARAMETER;
5372 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5373 (int)device, "get_flash_state", &get_flash_state);
5375 if (ret == CAMERA_ERROR_NONE) {
5376 *state = (camera_flash_state_e)get_flash_state;
5377 CAM_LOG_INFO("flash state %d", *state);
5379 CAM_LOG_ERROR("failed 0x%x", ret);
5386 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5388 int ret = CAMERA_ERROR_NONE;
5389 camera_cli_s *pc = (camera_cli_s *)camera;
5390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5392 if (!pc || !pc->cb_info || !foreach_cb) {
5393 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5394 return CAMERA_ERROR_INVALID_PARAMETER;
5397 CAM_LOG_INFO("Enter");
5399 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5400 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5402 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5404 CAM_LOG_INFO("ret : 0x%x", ret);
5410 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5412 int ret = CAMERA_ERROR_NONE;
5413 camera_cli_s *pc = (camera_cli_s *)camera;
5414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5416 if (!pc || !pc->cb_info || !foreach_cb) {
5417 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5418 return CAMERA_ERROR_INVALID_PARAMETER;
5421 CAM_LOG_INFO("Enter");
5423 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5424 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5426 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5428 CAM_LOG_INFO("ret : 0x%x", ret);
5434 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5436 int ret = CAMERA_ERROR_NONE;
5437 camera_cli_s *pc = (camera_cli_s *)camera;
5438 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5440 if (!pc || !pc->cb_info || !foreach_cb) {
5441 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5442 return CAMERA_ERROR_INVALID_PARAMETER;
5445 CAM_LOG_INFO("Enter");
5447 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5448 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5450 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5452 CAM_LOG_INFO("ret : 0x%x", ret);
5458 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5460 int ret = CAMERA_ERROR_NONE;
5461 camera_cli_s *pc = (camera_cli_s *)camera;
5462 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5464 if (!pc || !pc->cb_info || !foreach_cb) {
5465 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5466 return CAMERA_ERROR_INVALID_PARAMETER;
5469 CAM_LOG_INFO("Enter");
5471 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5472 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5474 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5476 CAM_LOG_INFO("ret : 0x%x", ret);
5482 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5484 int ret = CAMERA_ERROR_NONE;
5485 camera_cli_s *pc = (camera_cli_s *)camera;
5486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5488 if (!pc || !pc->cb_info || !foreach_cb) {
5489 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5490 return CAMERA_ERROR_INVALID_PARAMETER;
5493 CAM_LOG_INFO("Enter");
5495 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5496 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5498 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5500 CAM_LOG_INFO("ret : 0x%x", ret);
5506 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5508 int ret = CAMERA_ERROR_NONE;
5509 camera_cli_s *pc = (camera_cli_s *)camera;
5510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5512 if (!pc || !pc->cb_info || !foreach_cb) {
5513 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5514 return CAMERA_ERROR_INVALID_PARAMETER;
5517 CAM_LOG_INFO("Enter");
5519 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5520 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5522 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5524 CAM_LOG_INFO("ret : 0x%x", ret);
5530 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5532 int ret = CAMERA_ERROR_NONE;
5533 camera_cli_s *pc = (camera_cli_s *)camera;
5534 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5536 if (!pc || !pc->cb_info || !foreach_cb) {
5537 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5538 return CAMERA_ERROR_INVALID_PARAMETER;
5541 CAM_LOG_INFO("Enter");
5543 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5544 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5546 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5548 CAM_LOG_INFO("ret : 0x%x", ret);
5554 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5556 int ret = CAMERA_ERROR_NONE;
5557 camera_cli_s *pc = (camera_cli_s *)camera;
5558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5560 if (!pc || !pc->cb_info || !foreach_cb) {
5561 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5562 return CAMERA_ERROR_INVALID_PARAMETER;
5565 CAM_LOG_INFO("Enter");
5567 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5568 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5570 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5572 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5578 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)
5580 int ret = CAMERA_ERROR_NONE;
5581 camera_cli_s *pc = (camera_cli_s *)camera;
5582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5583 camera_msg_param param;
5586 if (!pc || !pc->cb_info || !foreach_cb) {
5587 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5588 return CAMERA_ERROR_INVALID_PARAMETER;
5591 CAM_LOG_INFO("Enter");
5593 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5594 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5596 value = (width << 16) | height;
5597 CAMERA_MSG_PARAM_SET(param, INT, value);
5599 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5601 CAM_LOG_INFO("ret : 0x%x", ret);
5607 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5609 int ret = CAMERA_ERROR_NONE;
5610 camera_cli_s *pc = (camera_cli_s *)camera;
5611 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5613 if (!pc || !pc->cb_info || !foreach_cb) {
5614 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5615 return CAMERA_ERROR_INVALID_PARAMETER;
5618 CAM_LOG_INFO("Enter");
5620 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5621 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5623 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5625 CAM_LOG_INFO("ret : 0x%x", ret);
5631 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5633 int ret = CAMERA_ERROR_NONE;
5634 camera_cli_s *pc = (camera_cli_s *)camera;
5635 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5637 if (!pc || !pc->cb_info || !foreach_cb) {
5638 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5639 return CAMERA_ERROR_INVALID_PARAMETER;
5642 CAM_LOG_INFO("Enter");
5644 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5645 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5647 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5649 CAM_LOG_INFO("ret : 0x%x", ret);
5655 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5657 int ret = CAMERA_ERROR_NONE;
5658 camera_cli_s *pc = (camera_cli_s *)camera;
5659 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5660 camera_msg_param param;
5661 int set_rotation = (int)rotation;
5663 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5665 CAM_LOG_INFO("Enter");
5667 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5669 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5671 CAM_LOG_INFO("ret : 0x%x", ret);
5677 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5679 int ret = CAMERA_ERROR_NONE;
5680 camera_cli_s *pc = (camera_cli_s *)camera;
5681 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5683 if (!pc || !pc->cb_info || !rotation) {
5684 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5685 return CAMERA_ERROR_INVALID_PARAMETER;
5688 CAM_LOG_INFO("Enter");
5690 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5692 if (ret == CAMERA_ERROR_NONE)
5693 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5695 CAM_LOG_INFO("ret : 0x%x", ret);
5701 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5703 int ret = CAMERA_ERROR_NONE;
5704 camera_cli_s *pc = (camera_cli_s *)camera;
5705 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5706 camera_msg_param param;
5707 int set_flip = (int)flip;
5709 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5711 CAM_LOG_INFO("Enter");
5713 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5717 CAM_LOG_INFO("ret : 0x%x", ret);
5723 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5725 int ret = CAMERA_ERROR_NONE;
5726 camera_cli_s *pc = (camera_cli_s *)camera;
5727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5729 if (!pc || !pc->cb_info || !flip) {
5730 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5731 return CAMERA_ERROR_INVALID_PARAMETER;
5734 CAM_LOG_INFO("Enter");
5736 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5738 if (ret == CAMERA_ERROR_NONE)
5739 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5741 CAM_LOG_INFO("ret : 0x%x", ret);
5746 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5748 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5752 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5754 int ret = CAMERA_ERROR_NONE;
5755 camera_cli_s *pc = (camera_cli_s *)camera;
5756 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5758 if (!pc || !pc->cb_info || !mode) {
5759 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5760 return CAMERA_ERROR_INVALID_PARAMETER;
5763 CAM_LOG_INFO("Enter");
5765 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5767 if (ret == CAMERA_ERROR_NONE)
5768 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5770 CAM_LOG_INFO("ret : 0x%x", ret);
5776 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5778 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5782 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5784 int ret = CAMERA_ERROR_NONE;
5785 camera_cli_s *pc = (camera_cli_s *)camera;
5786 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5788 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5790 CAM_LOG_INFO("Enter");
5792 if (!camera_attr_is_supported_hdr_capture(camera)) {
5793 CAM_LOG_ERROR("HDR not supported");
5794 return CAMERA_ERROR_NOT_SUPPORTED;
5798 CAM_LOG_ERROR("NULL callback");
5799 return CAMERA_ERROR_INVALID_PARAMETER;
5802 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5804 if (ret == CAMERA_ERROR_NONE) {
5805 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5807 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5808 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5810 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5813 CAM_LOG_INFO("ret : 0x%x", ret);
5819 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5825 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5827 CAM_LOG_INFO("Enter");
5829 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5831 if (ret == CAMERA_ERROR_NONE) {
5832 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5834 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5835 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5837 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5840 CAM_LOG_INFO("ret : 0x%x", ret);
5846 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5848 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5852 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5854 int ret = CAMERA_ERROR_NONE;
5855 camera_cli_s *pc = (camera_cli_s *)camera;
5856 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5858 if (!pc || !pc->cb_info || !enabled) {
5859 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5860 return CAMERA_ERROR_INVALID_PARAMETER;
5863 CAM_LOG_INFO("Enter");
5865 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5867 if (ret == CAMERA_ERROR_NONE)
5868 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5870 CAM_LOG_INFO("ret : 0x%x", ret);
5876 bool camera_attr_is_supported_anti_shake(camera_h camera)
5878 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
5882 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5884 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
5888 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5890 int ret = CAMERA_ERROR_NONE;
5891 camera_cli_s *pc = (camera_cli_s *)camera;
5892 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5894 if (!pc || !pc->cb_info || !enabled) {
5895 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5896 return CAMERA_ERROR_INVALID_PARAMETER;
5899 CAM_LOG_INFO("Enter");
5901 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5903 if (ret == CAMERA_ERROR_NONE)
5904 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
5906 CAM_LOG_INFO("ret : 0x%x", ret);
5912 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5914 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
5918 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5920 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
5924 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5926 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5930 if (!pc || !pc->cb_info || !enabled) {
5931 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5932 return CAMERA_ERROR_INVALID_PARAMETER;
5935 CAM_LOG_INFO("Enter");
5937 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5939 if (ret == CAMERA_ERROR_NONE)
5940 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
5942 CAM_LOG_INFO("ret : 0x%x", ret);
5948 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5950 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
5954 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5956 int ret = CAMERA_ERROR_NONE;
5957 camera_cli_s *pc = (camera_cli_s *)camera;
5958 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5959 camera_msg_param param;
5960 int set_disable = (int)disable;
5962 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5964 CAM_LOG_INFO("Enter");
5966 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5968 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5970 CAM_LOG_INFO("ret : 0x%x", ret);
5976 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5981 camera_msg_param param0;
5982 camera_msg_param param1;
5984 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5986 CAM_LOG_INFO("Enter");
5988 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
5989 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
5991 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
5992 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
5994 CAM_LOG_INFO("ret : 0x%x", ret);
6000 int camera_attr_get_pan(camera_h camera, int *pan_step)
6002 int ret = CAMERA_ERROR_NONE;
6003 camera_cli_s *pc = (camera_cli_s *)camera;
6004 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6006 if (!pc || !pc->cb_info || !pan_step) {
6007 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6008 return CAMERA_ERROR_INVALID_PARAMETER;
6011 CAM_LOG_INFO("Enter");
6013 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6015 if (ret == CAMERA_ERROR_NONE)
6016 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6018 CAM_LOG_INFO("ret : 0x%x", ret);
6024 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6026 int ret = CAMERA_ERROR_NONE;
6027 camera_cli_s *pc = (camera_cli_s *)camera;
6028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6030 if (!pc || !pc->cb_info || !min || !max) {
6031 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6035 CAM_LOG_INFO("Enter");
6037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6039 if (ret == CAMERA_ERROR_NONE) {
6040 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6041 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6044 CAM_LOG_INFO("ret : 0x%x", ret);
6050 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6052 int ret = CAMERA_ERROR_NONE;
6053 camera_cli_s *pc = (camera_cli_s *)camera;
6054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6055 camera_msg_param param0;
6056 camera_msg_param param1;
6058 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6060 CAM_LOG_INFO("Enter");
6062 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6063 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6065 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6066 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6068 CAM_LOG_INFO("ret : 0x%x", ret);
6074 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6076 int ret = CAMERA_ERROR_NONE;
6077 camera_cli_s *pc = (camera_cli_s *)camera;
6078 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6080 if (!pc || !pc->cb_info || !tilt_step) {
6081 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6082 return CAMERA_ERROR_INVALID_PARAMETER;
6085 CAM_LOG_INFO("Enter");
6087 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6089 if (ret == CAMERA_ERROR_NONE)
6090 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6092 CAM_LOG_INFO("ret : 0x%x", ret);
6098 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6100 int ret = CAMERA_ERROR_NONE;
6101 camera_cli_s *pc = (camera_cli_s *)camera;
6102 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6104 if (!pc || !pc->cb_info || !min || !max) {
6105 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6106 return CAMERA_ERROR_INVALID_PARAMETER;
6109 CAM_LOG_INFO("Enter");
6111 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6113 if (ret == CAMERA_ERROR_NONE) {
6114 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6115 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6118 CAM_LOG_INFO("ret : 0x%x", ret);
6124 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6126 int ret = CAMERA_ERROR_NONE;
6127 camera_cli_s *pc = (camera_cli_s *)camera;
6128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6129 camera_msg_param param;
6130 int set_ptz_type = (int)ptz_type;
6132 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6134 CAM_LOG_INFO("Enter");
6136 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6138 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6140 CAM_LOG_INFO("ret : 0x%x", ret);
6146 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6148 int ret = CAMERA_ERROR_NONE;
6149 camera_cli_s *pc = (camera_cli_s *)camera;
6150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6152 if (!pc || !pc->cb_info || !foreach_cb) {
6153 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6154 return CAMERA_ERROR_INVALID_PARAMETER;
6157 CAM_LOG_INFO("Enter");
6159 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6160 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6164 CAM_LOG_INFO("ret : 0x%x", ret);
6170 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6172 int ret = CAMERA_ERROR_NONE;
6173 camera_cli_s *pc = (camera_cli_s *)camera;
6174 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6175 int set_display_roi_area[4] = {x, y, width, height};
6179 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6181 CAM_LOG_INFO("Enter");
6183 if (pc->cb_info->is_evas_render) {
6184 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6185 if (ret != MM_ERROR_NONE) {
6186 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6187 return CAMERA_ERROR_INVALID_OPERATION;
6191 length = sizeof(set_display_roi_area) / sizeof(int) + \
6192 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6194 msg = muse_core_msg_new(api,
6195 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6198 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6204 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6206 camera_cli_s *pc = (camera_cli_s *)camera;
6207 int ret = CAMERA_ERROR_NONE;
6208 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6210 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6211 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6212 return CAMERA_ERROR_INVALID_PARAMETER;
6215 CAM_LOG_INFO("Enter");
6217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6219 if (ret == CAMERA_ERROR_NONE) {
6220 *x = pc->cb_info->get_display_roi_area[0];
6221 *y = pc->cb_info->get_display_roi_area[1];
6222 *width = pc->cb_info->get_display_roi_area[2];
6223 *height = pc->cb_info->get_display_roi_area[3];
6226 CAM_LOG_INFO("ret : 0x%x", ret);
6232 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6234 int ret = CAMERA_ERROR_NONE;
6235 int get_device_state = 0;
6238 CAM_LOG_ERROR("NULL pointer");
6239 return CAMERA_ERROR_INVALID_PARAMETER;
6242 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6243 (int)device, "get_device_state", &get_device_state);
6245 if (ret == CAMERA_ERROR_NONE) {
6246 *state = (camera_device_state_e)get_device_state;
6247 CAM_LOG_INFO("device state %d", *state);
6249 CAM_LOG_ERROR("failed 0x%x", ret);
6256 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6258 int ret = CAMERA_ERROR_NONE;
6259 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6260 camera_cb_info *info = NULL;
6262 if (!callback || !cb_id) {
6263 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6264 return CAMERA_ERROR_INVALID_PARAMETER;
6267 /* check camera support */
6268 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6269 if (ret != CAMERA_ERROR_NONE) {
6270 CAM_LOG_ERROR("get device state failed");
6274 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6276 info = g_new0(camera_cb_info, 1);
6278 CAM_LOG_ERROR("info failed");
6279 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6283 info->id = ++g_cam_dev_state_changed_cb_id;
6284 info->callback = (void *)callback;
6285 info->user_data = user_data;
6289 /* subscribe dbus signal for camera state change */
6290 if (!g_cam_dev_state_changed_cb_conn) {
6291 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6292 if (!g_cam_dev_state_changed_cb_conn) {
6293 CAM_LOG_ERROR("failed to get gdbus connection");
6294 ret = CAMERA_ERROR_INVALID_OPERATION;
6298 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6299 MM_CAMCORDER_DBUS_OBJECT,
6300 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6301 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6303 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6304 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6305 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6306 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6307 CAM_LOG_ERROR("failed to get gdbus connection");
6308 ret = CAMERA_ERROR_INVALID_OPERATION;
6312 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6315 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6317 CAM_LOG_INFO("callback id %d", info->id);
6320 if (ret != CAMERA_ERROR_NONE) {
6326 if (g_cam_dev_state_changed_cb_conn) {
6327 g_object_unref(g_cam_dev_state_changed_cb_conn);
6328 g_cam_dev_state_changed_cb_conn = NULL;
6332 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6338 int camera_remove_device_state_changed_cb(int cb_id)
6340 int ret = CAMERA_ERROR_NONE;
6341 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6342 GList *tmp_list = NULL;
6343 camera_cb_info *info = NULL;
6345 /* check camera support */
6346 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6347 if (ret != CAMERA_ERROR_NONE) {
6348 CAM_LOG_ERROR("get device state failed");
6352 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6354 if (!g_cam_dev_state_changed_cb_list) {
6355 CAM_LOG_ERROR("there is no callback info");
6356 ret = CAMERA_ERROR_INVALID_OPERATION;
6360 tmp_list = g_cam_dev_state_changed_cb_list;
6363 info = tmp_list->data;
6364 tmp_list = tmp_list->next;
6367 CAM_LOG_WARNING("NULL info");
6371 if (info->id == cb_id) {
6372 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6377 if (!g_cam_dev_state_changed_cb_list) {
6378 /* no remained callback */
6379 if (g_cam_dev_state_changed_cb_conn) {
6380 /* unsubscribe signal */
6381 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6382 g_cam_dev_state_changed_cb_subscribe_id = 0;
6384 /* unref connection */
6385 g_object_unref(g_cam_dev_state_changed_cb_conn);
6386 g_cam_dev_state_changed_cb_conn = NULL;
6390 CAM_LOG_INFO("id %d callback removed", cb_id);
6391 ret = CAMERA_ERROR_NONE;
6397 CAM_LOG_ERROR("id %d callback not found", cb_id);
6398 ret = CAMERA_ERROR_INVALID_PARAMETER;
6401 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6408 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6410 int ret = CAMERA_ERROR_NONE;
6411 camera_cli_s *pc = (camera_cli_s *)camera;
6412 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6414 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6416 g_mutex_lock(&pc->cb_info->bridge_lock);
6418 if (pc->cb_info->bridge) {
6419 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6420 ret = CAMERA_ERROR_INVALID_OPERATION;
6421 goto _SET_MEDIA_BRIDGE_DONE;
6424 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6425 if (ret != CAMERA_ERROR_NONE) {
6426 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6427 goto _SET_MEDIA_BRIDGE_DONE;
6430 pc->cb_info->bridge = bridge;
6432 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6434 _SET_MEDIA_BRIDGE_DONE:
6435 g_mutex_unlock(&pc->cb_info->bridge_lock);
6441 int camera_media_bridge_unset_bridge(camera_h camera)
6443 int ret = CAMERA_ERROR_NONE;
6444 camera_cli_s *pc = (camera_cli_s *)camera;
6445 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6447 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6449 g_mutex_lock(&pc->cb_info->bridge_lock);
6451 if (!pc->cb_info->bridge) {
6452 CAM_LOG_ERROR("no media bridge");
6453 ret = CAMERA_ERROR_INVALID_OPERATION;
6454 goto _UNSET_MEDIA_BRIDGE_DONE;
6457 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6458 if (ret != CAMERA_ERROR_NONE) {
6459 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6460 goto _UNSET_MEDIA_BRIDGE_DONE;
6463 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6465 pc->cb_info->bridge = NULL;
6467 _UNSET_MEDIA_BRIDGE_DONE:
6468 g_mutex_unlock(&pc->cb_info->bridge_lock);
6475 int camera_create_network(camera_device_e device, camera_h *camera)
6477 return _camera_create_private(device, true, camera);
6481 int camera_device_manager_initialize(camera_device_manager_h *manager)
6484 int ret = CAMERA_ERROR_NONE;
6485 void *dl_handle = NULL;
6486 camera_device_manager *new_manager = NULL;
6487 cdm_symbol_table sym_table[] = {
6488 {(void **)&new_manager->initialize, "cdm_initialize"},
6489 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6490 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6491 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6492 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6495 CAMERA_CHECK_DEVICE_MANAGER;
6497 new_manager = g_new0(camera_device_manager, 1);
6500 CAM_LOG_ERROR("NULL manager");
6501 ret = CAMERA_ERROR_INVALID_PARAMETER;
6502 goto _INITIALIZE_FAILED;
6505 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6507 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6508 ret = CAMERA_ERROR_INVALID_OPERATION;
6509 goto _INITIALIZE_FAILED;
6513 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6514 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6515 if (*sym_table[i].func_ptr == NULL) {
6516 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6517 ret = CAMERA_ERROR_INVALID_OPERATION;
6518 goto _INITIALIZE_FAILED;
6522 ret = new_manager->initialize();
6523 if (ret != CAMERA_ERROR_NONE) {
6524 CAM_LOG_ERROR("failed[0x%x]", ret);
6525 goto _INITIALIZE_FAILED;
6528 new_manager->dl_handle = dl_handle;
6529 *manager = (camera_device_manager_h)new_manager;
6531 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6532 new_manager, dl_handle);
6534 return CAMERA_ERROR_NONE;
6539 g_free(new_manager);
6545 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6547 int ret = CAMERA_ERROR_NONE;
6548 camera_device_manager *m = (camera_device_manager *)manager;
6550 CAMERA_CHECK_DEVICE_MANAGER;
6553 CAM_LOG_ERROR("NULL manager");
6554 return CAMERA_ERROR_INVALID_PARAMETER;
6557 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6559 ret = m->deinitialize();
6560 if (ret != CAMERA_ERROR_NONE) {
6561 CAM_LOG_ERROR("failed[0x%x]", ret);
6565 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6567 dlclose(m->dl_handle);
6569 memset(m, 0x0, sizeof(camera_device_manager));
6572 return CAMERA_ERROR_NONE;
6576 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6578 int ret = CAMERA_ERROR_NONE;
6580 camera_device_list_s device_list;
6581 camera_device_s *device = NULL;
6582 camera_device_manager *m = (camera_device_manager *)manager;
6584 CAMERA_CHECK_DEVICE_MANAGER;
6586 if (!m || !callback) {
6587 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6588 return CAMERA_ERROR_INVALID_PARAMETER;
6591 CAM_LOG_INFO("enter");
6593 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6595 ret = m->get_device_list(&device_list);
6596 if (ret != CAMERA_ERROR_NONE) {
6597 CAM_LOG_ERROR("failed[0x%x]", ret);
6601 CAM_LOG_INFO("device count[%d]", device_list.count);
6603 for (i = 0 ; i < device_list.count ; i++) {
6604 device = &device_list.device[i];
6606 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6607 i, device->type, device->index,
6608 device->name, device->id, device->extra_stream_num);
6610 if (!callback(device, user_data)) {
6611 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6612 i + 1, device_list.count);
6617 return CAMERA_ERROR_NONE;
6621 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6622 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6624 int ret = CAMERA_ERROR_NONE;
6625 camera_device_manager *m = (camera_device_manager *)manager;
6627 CAMERA_CHECK_DEVICE_MANAGER;
6629 if (!m || !callback || !cb_id) {
6630 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6631 return CAMERA_ERROR_INVALID_PARAMETER;
6634 CAM_LOG_INFO("enter");
6636 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6637 if (ret != CAMERA_ERROR_NONE) {
6638 CAM_LOG_ERROR("failed[0x%x]", ret);
6642 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6644 return CAMERA_ERROR_NONE;
6648 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6650 int ret = CAMERA_ERROR_NONE;
6651 camera_device_manager *m = (camera_device_manager *)manager;
6653 CAMERA_CHECK_DEVICE_MANAGER;
6656 CAM_LOG_ERROR("NULL manager");
6657 return CAMERA_ERROR_INVALID_PARAMETER;
6660 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6662 ret = m->remove_device_connection_changed_cb(cb_id);
6663 if (ret != CAMERA_ERROR_NONE) {
6664 CAM_LOG_ERROR("failed[0x%x]", ret);
6668 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6670 return CAMERA_ERROR_NONE;
6675 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6677 int ret = CAMERA_ERROR_NONE;
6678 camera_cli_s *pc = (camera_cli_s *)camera;
6679 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6681 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6683 if (!camera_is_supported_extra_preview(camera)) {
6684 CAM_LOG_ERROR("extra preview is not supported");
6685 return CAMERA_ERROR_NOT_SUPPORTED;
6689 CAM_LOG_ERROR("NULL callback");
6690 return CAMERA_ERROR_INVALID_PARAMETER;
6693 CAM_LOG_INFO("Enter");
6695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6697 if (ret == CAMERA_ERROR_NONE) {
6698 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6703 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6706 CAM_LOG_INFO("ret : 0x%x", ret);
6712 int camera_unset_extra_preview_cb(camera_h camera)
6714 int ret = CAMERA_ERROR_NONE;
6715 camera_cli_s *pc = (camera_cli_s *)camera;
6716 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6718 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6720 if (!camera_is_supported_extra_preview(camera)) {
6721 CAM_LOG_ERROR("extra preview is not supported");
6722 return CAMERA_ERROR_NOT_SUPPORTED;
6725 CAM_LOG_INFO("Enter");
6727 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6729 if (ret == CAMERA_ERROR_NONE) {
6730 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6735 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6738 CAM_LOG_INFO("ret : 0x%x", ret);
6744 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)
6746 int ret = CAMERA_ERROR_NONE;
6747 int stream_format[4] = {pixel_format, width, height, fps};
6749 camera_cli_s *pc = (camera_cli_s *)camera;
6750 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6752 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6754 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6755 stream_id, pixel_format, width, height, fps);
6757 msg = muse_core_msg_new(api,
6758 MUSE_TYPE_INT, "stream_id", stream_id,
6759 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6762 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6768 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)
6770 int ret = CAMERA_ERROR_NONE;
6771 camera_cli_s *pc = (camera_cli_s *)camera;
6772 camera_msg_param param;
6773 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6775 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6776 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6777 return CAMERA_ERROR_INVALID_PARAMETER;
6780 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6782 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6784 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6786 if (ret == CAMERA_ERROR_NONE) {
6787 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6788 *width = pc->cb_info->get_extra_preview_stream_format[1];
6789 *height = pc->cb_info->get_extra_preview_stream_format[2];
6790 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6793 CAM_LOG_INFO("ret : 0x%x", ret);
6799 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6801 int ret = CAMERA_ERROR_NONE;
6802 camera_cli_s *pc = (camera_cli_s *)camera;
6803 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6804 camera_msg_param param0;
6805 camera_msg_param param1;
6807 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6809 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6811 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6812 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6814 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6815 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6817 CAM_LOG_INFO("ret : 0x%x", ret);
6823 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6825 int ret = CAMERA_ERROR_NONE;
6826 camera_cli_s *pc = (camera_cli_s *)camera;
6827 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6828 camera_msg_param param;
6830 if (!pc || !pc->cb_info || !bitrate) {
6831 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6832 return CAMERA_ERROR_INVALID_PARAMETER;
6835 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6837 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6841 if (ret == CAMERA_ERROR_NONE) {
6842 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6843 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6845 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6852 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6854 int ret = CAMERA_ERROR_NONE;
6855 camera_cli_s *pc = (camera_cli_s *)camera;
6856 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6857 camera_msg_param param0;
6858 camera_msg_param param1;
6860 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6862 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6864 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6865 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6867 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6868 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6870 CAM_LOG_INFO("ret : 0x%x", ret);
6876 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6878 int ret = CAMERA_ERROR_NONE;
6879 camera_cli_s *pc = (camera_cli_s *)camera;
6880 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6881 camera_msg_param param;
6883 if (!pc || !pc->cb_info || !interval) {
6884 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6885 return CAMERA_ERROR_INVALID_PARAMETER;
6888 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6890 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6892 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6894 if (ret == CAMERA_ERROR_NONE) {
6895 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6896 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6898 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6905 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6907 camera_cli_s *pc = (camera_cli_s *)camera;
6909 if (!pc || !pc->cb_info || !rotation) {
6910 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6911 return CAMERA_ERROR_INVALID_PARAMETER;
6914 if (!pc->cb_info->stream_data) {
6915 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6916 return CAMERA_ERROR_INVALID_OPERATION;
6919 *rotation = pc->cb_info->stream_data->rotation;
6921 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6923 return CAMERA_ERROR_NONE;
6927 int _camera_get_log_level(void)
6929 return g_camera_log_level;