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_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
668 if (tmp_bo_handle.ptr == NULL) {
669 CAM_LOG_ERROR("map failed %p", tmp_bo);
670 tbm_bo_unref(tmp_bo);
675 tbm_bo_unmap(tmp_bo);
677 /* set bo and bo_handle */
679 *bo_handle = tmp_bo_handle;
681 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
686 static void __camera_release_imported_bo(tbm_bo *bo)
689 CAM_LOG_DEBUG("NULL bo");
698 static bool __is_supported(camera_h camera, muse_camera_api_e api)
700 int ret = CAMERA_ERROR_NONE;
701 camera_cli_s *pc = (camera_cli_s *)camera;
703 if (!pc || !pc->cb_info) {
704 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
705 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
709 CAM_LOG_INFO("Enter - api[%d]", api);
711 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
713 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
719 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
721 int ret = CAMERA_ERROR_NONE;
722 camera_cli_s *pc = (camera_cli_s *)camera;
723 camera_msg_param param;
725 if (!pc || !pc->cb_info) {
726 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
727 return CAMERA_ERROR_INVALID_PARAMETER;
730 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
732 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
734 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
736 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
742 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
744 int ret = CAMERA_ERROR_NONE;
745 camera_cli_s *pc = (camera_cli_s *)camera;
746 camera_msg_param param;
748 if (!pc || !pc->cb_info) {
749 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
750 return CAMERA_ERROR_INVALID_PARAMETER;
753 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
755 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
759 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
765 static void __send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
770 CAM_LOG_ERROR("api[%d] message failed", api);
772 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
777 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
779 if (cb_info->is_server_connected) {
780 _camera_update_api_waiting(cb_info, api, 1);
782 g_mutex_lock(&cb_info->fd_lock);
783 send_ret = muse_core_msg_send(cb_info->fd, msg);
784 g_mutex_unlock(&cb_info->fd_lock);
788 CAM_LOG_ERROR("message send failed");
790 *ret = CAMERA_ERROR_INVALID_OPERATION;
793 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
796 _camera_update_api_waiting(cb_info, api, -1);
798 muse_core_msg_free(msg);
800 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
804 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
806 int ret = CAMERA_ERROR_NONE;
809 if (!cb_info->is_server_connected) {
810 CAM_LOG_ERROR("server is disconnected");
811 return CAMERA_ERROR_SERVICE_DISCONNECTED;
814 g_mutex_lock(&(cb_info->api_mutex[api]));
816 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
818 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
820 while (!cb_info->api_activating[api]) {
821 if (time_out == CAMERA_CB_NO_TIMEOUT) {
822 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
823 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
824 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
825 CAM_LOG_ERROR("api %d TIMED OUT!", api);
826 ret = CAMERA_ERROR_INVALID_OPERATION;
830 if (!cb_info->is_server_connected) {
831 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
835 if (!cb_info->api_activating[api])
836 CAM_LOG_WARNING("invalid signal received, wait again...");
839 ret = cb_info->api_ret[api];
840 cb_info->api_activating[api] = FALSE;
843 g_mutex_unlock(&(cb_info->api_mutex[api]));
845 if (ret != CAMERA_ERROR_NONE)
846 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
852 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
853 int *ret, int timeout)
858 CAM_LOG_ERROR("NULL info - api %d", api);
861 *ret = CAMERA_ERROR_INVALID_PARAMETER;
866 msg = muse_core_msg_new(api, NULL);
868 __send_message_get_return(cb_info, api, msg, timeout, ret);
872 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
873 int *ret, camera_msg_param *param, int timeout)
878 if (!cb_info || !param) {
879 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
882 *ret = CAMERA_ERROR_INVALID_PARAMETER;
887 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
889 switch (param->type) {
891 msg = muse_core_msg_new(api,
892 param->type, param->name, param->value.value_INT,
895 case MUSE_TYPE_STRING:
896 msg = muse_core_msg_new(api,
897 param->type, param->name, param->value.value_STRING,
900 case MUSE_TYPE_ARRAY:
901 array_length = param->value_size / sizeof(int) + \
902 (param->value_size % sizeof(int) ? 1 : 0);
904 msg = muse_core_msg_new(api,
905 param->type, param->name, array_length, param->value.value_ARRAY,
909 CAM_LOG_ERROR("unknown type %d", param->type);
913 __send_message_get_return(cb_info, api, msg, timeout, ret);
917 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
918 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
922 if (!cb_info || !param0 || !param1) {
923 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
924 cb_info, param0, param1, api);
927 *ret = CAMERA_ERROR_INVALID_PARAMETER;
932 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
934 param0->name, param0->value.value_INT,
935 param1->name, param1->value.value_INT);
937 msg = muse_core_msg_new(api,
938 param0->type, param0->name, param0->value.value_INT,
939 param1->type, param1->name, param1->value.value_INT,
942 __send_message_get_return(cb_info, api, msg, timeout, ret);
946 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
948 camera_msg_param param;
951 CAM_LOG_WARNING("invalid fd %d", ret_fd);
955 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
957 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
961 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
963 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
964 in_format >= MM_PIXEL_FORMAT_NUM ||
965 out_format == NULL) {
966 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
967 return CAMERA_ERROR_INVALID_PARAMETER;
971 case MM_PIXEL_FORMAT_NV12:
972 case MM_PIXEL_FORMAT_NV12T:
973 *out_format = TBM_FORMAT_NV12;
976 case MM_PIXEL_FORMAT_NV16:
977 *out_format = TBM_FORMAT_NV16;
979 case MM_PIXEL_FORMAT_NV21:
980 *out_format = TBM_FORMAT_NV21;
982 case MM_PIXEL_FORMAT_YUYV:
983 *out_format = TBM_FORMAT_YUYV;
985 case MM_PIXEL_FORMAT_UYVY:
986 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
987 *out_format = TBM_FORMAT_UYVY;
989 case MM_PIXEL_FORMAT_422P:
990 *out_format = TBM_FORMAT_YUV422;
992 case MM_PIXEL_FORMAT_I420:
993 *out_format = TBM_FORMAT_YUV420;
995 case MM_PIXEL_FORMAT_YV12:
996 *out_format = TBM_FORMAT_YVU420;
998 case MM_PIXEL_FORMAT_RGB565:
999 *out_format = TBM_FORMAT_RGB565;
1001 case MM_PIXEL_FORMAT_RGB888:
1002 *out_format = TBM_FORMAT_RGB888;
1004 case MM_PIXEL_FORMAT_RGBA:
1005 *out_format = TBM_FORMAT_RGBA8888;
1007 case MM_PIXEL_FORMAT_ARGB:
1008 *out_format = TBM_FORMAT_ARGB8888;
1011 CAM_LOG_ERROR("invalid in_format %d", in_format);
1012 return CAMERA_ERROR_INVALID_PARAMETER;
1016 return CAMERA_ERROR_NONE;
1020 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1022 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1023 in_format >= MM_PIXEL_FORMAT_NUM ||
1025 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1026 return CAMERA_ERROR_INVALID_PARAMETER;
1029 switch (in_format) {
1030 case MM_PIXEL_FORMAT_NV12:
1031 case MM_PIXEL_FORMAT_NV12T:
1032 *mimetype = MEDIA_FORMAT_NV12;
1035 case MM_PIXEL_FORMAT_NV16:
1036 *mimetype = MEDIA_FORMAT_NV16;
1038 case MM_PIXEL_FORMAT_NV21:
1039 *mimetype = MEDIA_FORMAT_NV21;
1041 case MM_PIXEL_FORMAT_YUYV:
1042 *mimetype = MEDIA_FORMAT_YUYV;
1044 case MM_PIXEL_FORMAT_UYVY:
1045 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1046 *mimetype = MEDIA_FORMAT_UYVY;
1048 case MM_PIXEL_FORMAT_422P:
1049 *mimetype = MEDIA_FORMAT_422P;
1051 case MM_PIXEL_FORMAT_I420:
1052 *mimetype = MEDIA_FORMAT_I420;
1054 case MM_PIXEL_FORMAT_YV12:
1055 *mimetype = MEDIA_FORMAT_YV12;
1057 case MM_PIXEL_FORMAT_RGB565:
1058 *mimetype = MEDIA_FORMAT_RGB565;
1060 case MM_PIXEL_FORMAT_RGB888:
1061 *mimetype = MEDIA_FORMAT_RGB888;
1063 case MM_PIXEL_FORMAT_RGBA:
1064 *mimetype = MEDIA_FORMAT_RGBA;
1066 case MM_PIXEL_FORMAT_ARGB:
1067 *mimetype = MEDIA_FORMAT_ARGB;
1069 case MM_PIXEL_FORMAT_ENCODED_H264:
1070 /* TODO: How can we determine the profile for H.264 format? */
1071 *mimetype = MEDIA_FORMAT_H264_SP;
1073 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1074 *mimetype = MEDIA_FORMAT_MJPEG;
1076 case MM_PIXEL_FORMAT_ENCODED_VP8:
1077 *mimetype = MEDIA_FORMAT_VP8;
1079 case MM_PIXEL_FORMAT_ENCODED_VP9:
1080 *mimetype = MEDIA_FORMAT_VP9;
1083 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1084 return CAMERA_ERROR_NOT_SUPPORTED;
1088 return CAMERA_ERROR_NONE;
1092 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1093 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1096 int ret = CAMERA_ERROR_NONE;
1097 camera_media_packet_data *new_mp_data = NULL;
1099 if (!tfd || !mp_data) {
1100 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1101 return CAMERA_ERROR_INVALID_PARAMETER;
1104 new_mp_data = g_new0(camera_media_packet_data, 1);
1106 new_mp_data->ret_fd = ret_fd;
1107 new_mp_data->fd = tfd[0];
1108 new_mp_data->num_buffer_fd = num_buffer_fd;
1109 new_mp_data->bo = bo;
1111 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1115 new_mp_data->data_bo = data_bo;
1116 new_mp_data->data_fd = tfd[1];
1118 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1119 new_mp_data->data_bo, new_mp_data->data_fd);
1122 for (i = 0 ; i < num_buffer_fd ; i++) {
1123 new_mp_data->buffer_bo[i] = buffer_bo[i];
1124 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1126 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1127 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1130 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1131 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1133 new_mp_data->data_fd = CAMERA_FD_INIT;
1136 *mp_data = new_mp_data;
1138 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1143 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1147 if (!mp_data || !cb_info) {
1148 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1152 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1154 /* release imported bo and close fd */
1155 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1156 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1157 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1159 tbm_bo_unref(mp_data->buffer_bo[i]);
1161 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1162 close(mp_data->buffer_fd[i]);
1164 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1167 if (mp_data->data_bo) {
1168 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1169 mp_data->data_fd, mp_data->data_bo);
1171 tbm_bo_unref(mp_data->data_bo);
1173 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1174 close(mp_data->data_fd);
1176 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1179 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1181 tbm_bo_unref(mp_data->bo);
1183 if (CAMERA_IS_FD_VALID(mp_data->fd))
1186 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1189 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1195 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1198 int ret = CAMERA_ERROR_NONE;
1199 uint32_t tbm_format = 0;
1200 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1201 tbm_surface_info_s tsurf_info;
1203 if (!stream || !mp_data) {
1204 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1208 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1209 CAM_LOG_ERROR("No valid data");
1213 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1214 if (ret != CAMERA_ERROR_NONE)
1217 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1219 if (mp_data->num_buffer_fd > 0) {
1220 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1221 bos[i] = mp_data->buffer_bo[i];
1223 bos[0] = mp_data->data_bo;
1226 tsurf_info.width = stream->width;
1227 tsurf_info.height = stream->height;
1228 tsurf_info.format = tbm_format;
1229 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1230 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1232 switch (tbm_format) {
1233 case TBM_FORMAT_NV12: /* fall through */
1234 case TBM_FORMAT_NV21: /* fall through */
1235 case TBM_FORMAT_YUV420: /* fall through */
1236 case TBM_FORMAT_YVU420: /* fall through */
1237 case TBM_FORMAT_UYVY: /* fall through */
1238 case TBM_FORMAT_YUYV:
1239 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1240 tsurf_info.planes[i].stride = stream->stride[i];
1241 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1242 if (i != 0 && mp_data->num_buffer_fd <= 1)
1243 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1244 tsurf_info.size += tsurf_info.planes[i].size;
1246 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1247 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1251 case TBM_FORMAT_RGB565: /* fall through */
1252 case TBM_FORMAT_RGB888: /* fall through */
1253 case TBM_FORMAT_RGBA8888: /* fall through */
1254 case TBM_FORMAT_ARGB8888:
1255 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1256 tsurf_info.planes[0].offset = 0;
1257 tsurf_info.size = stream->data.rgb.length_data;
1260 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1265 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1266 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1270 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1272 int ret = CAMERA_ERROR_NONE;
1273 int pkt_fmt_width = 0;
1274 int pkt_fmt_height = 0;
1275 bool make_pkt_fmt = false;
1276 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1277 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1279 if (!cb_info || !stream) {
1280 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1281 return CAMERA_ERROR_INVALID_PARAMETER;
1284 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1285 if (ret != CAMERA_ERROR_NONE)
1288 /* check media packet format */
1289 if (cb_info->pkt_fmt) {
1290 media_format_get_video_info(cb_info->pkt_fmt,
1291 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1293 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1294 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1296 if (pkt_fmt_mimetype != mimetype ||
1297 pkt_fmt_width != stream->width ||
1298 pkt_fmt_height != stream->height) {
1299 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1300 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1302 media_format_unref(cb_info->pkt_fmt);
1303 cb_info->pkt_fmt = NULL;
1304 make_pkt_fmt = true;
1307 make_pkt_fmt = true;
1310 /* create packet format */
1312 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1313 mimetype, stream->width, stream->height);
1315 ret = media_format_create(&cb_info->pkt_fmt);
1316 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1317 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1318 return CAMERA_ERROR_INVALID_OPERATION;
1321 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1322 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1323 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1324 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1325 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1326 return CAMERA_ERROR_INVALID_OPERATION;
1330 return CAMERA_ERROR_NONE;
1334 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1335 camera_media_packet_data *mp_data, media_packet_h *packet)
1337 media_packet_h pkt = NULL;
1338 tbm_surface_h tsurf = NULL;
1339 int ret = CAMERA_ERROR_NONE;
1341 if (!cb_info || !stream || !mp_data || !packet) {
1342 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1343 cb_info, stream, mp_data, packet);
1344 return CAMERA_ERROR_INVALID_PARAMETER;
1347 ret = __camera_update_media_packet_format(cb_info, stream);
1348 if (ret != CAMERA_ERROR_NONE)
1351 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1352 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1353 stream->data.encoded.data, stream->data.encoded.length_data,
1354 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1357 tsurf = __camera_get_tbm_surface(stream, mp_data);
1359 CAM_LOG_ERROR("get tbm surface failed");
1360 ret = CAMERA_ERROR_INVALID_OPERATION;
1361 goto _PACKET_CREATE_FAILED;
1364 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1365 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1366 (void *)cb_info, &pkt);
1369 if (ret != MEDIA_PACKET_ERROR_NONE) {
1370 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1371 goto _PACKET_CREATE_FAILED;
1374 ret = media_packet_set_extra(pkt, (void *)mp_data);
1375 if (ret != MEDIA_PACKET_ERROR_NONE) {
1376 CAM_LOG_ERROR("media_packet_set_extra failed");
1377 goto _PACKET_CREATE_FAILED;
1380 /* set timestamp : msec -> nsec */
1381 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1382 CAM_LOG_WARNING("media_packet_set_pts failed");
1384 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1385 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1387 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1391 return CAMERA_ERROR_NONE;
1393 _PACKET_CREATE_FAILED:
1395 tbm_surface_destroy(tsurf);
1397 media_packet_unref(pkt);
1399 return CAMERA_ERROR_INVALID_OPERATION;
1402 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1405 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1406 camera_media_packet_data *mp_data = NULL;
1407 tbm_surface_h tsurf = NULL;
1409 if (!pkt || !cb_info) {
1410 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1414 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1415 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1416 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1420 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1422 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1423 pkt, mp_data, tsurf);
1426 tbm_surface_destroy(tsurf);
1428 g_mutex_lock(&cb_info->mp_data_mutex);
1429 __camera_release_media_packet_data(mp_data, cb_info);
1430 g_mutex_unlock(&cb_info->mp_data_mutex);
1433 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1438 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1439 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1443 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1445 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1447 if (cb_info->user_cb[event] == NULL) {
1448 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1449 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1450 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1451 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1452 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1453 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1457 /* return buffer message should be sent for some events.
1458 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1459 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1460 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1461 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1466 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1472 muse_camera_msg_get(previous, recv_msg);
1473 muse_camera_msg_get(current, recv_msg);
1474 muse_camera_msg_get(by_policy, recv_msg);
1476 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1477 previous, current, by_policy);
1479 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1480 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1483 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1487 muse_camera_msg_get(state, recv_msg);
1489 CAM_LOG_INFO("FOCUS state - %d", state);
1491 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1494 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1495 CAM_LOG_INFO("CAPTURE_COMPLETED");
1496 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1498 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1499 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1500 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1503 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1507 muse_camera_msg_get(percent, recv_msg);
1509 CAM_LOG_INFO("HDR progress - %d %%", percent);
1511 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1514 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1520 muse_camera_msg_get(policy, recv_msg);
1521 muse_camera_msg_get(previous, recv_msg);
1522 muse_camera_msg_get(current, recv_msg);
1524 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1526 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1527 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1530 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1535 muse_camera_msg_get(policy, recv_msg);
1536 muse_camera_msg_get(state, recv_msg);
1538 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1540 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1541 (camera_state_e)state, cb_info->user_data[event]);
1544 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1545 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1547 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1550 int current_state = 0;
1552 muse_camera_msg_get(error, recv_msg);
1553 muse_camera_msg_get(current_state, recv_msg);
1555 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1557 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1558 (camera_state_e)current_state, cb_info->user_data[event]);
1562 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1564 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1565 muse_camera_msg_get(param1, recv_msg);
1566 muse_camera_msg_get(param2, recv_msg);
1568 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1570 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1571 cb_info->user_cb[event] = NULL;
1572 cb_info->user_data[event] = NULL;
1573 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1576 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1578 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1582 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1584 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1603 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1605 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1606 muse_camera_msg_get(param1, recv_msg);
1608 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1610 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1611 cb_info->user_cb[event] = NULL;
1612 cb_info->user_data[event] = NULL;
1613 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1617 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1618 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1621 CAM_LOG_WARNING("unhandled event %d", event);
1625 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1628 static gboolean __camera_idle_event_callback(gpointer data)
1630 camera_cb_info_s *cb_info = NULL;
1631 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1633 if (cam_idle_event == NULL) {
1634 CAM_LOG_ERROR("cam_idle_event is NULL");
1639 g_mutex_lock(&g_cam_idle_event_lock);
1641 cb_info = cam_idle_event->cb_info;
1642 if (cb_info == NULL) {
1643 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1644 g_mutex_unlock(&g_cam_idle_event_lock);
1645 goto IDLE_EVENT_CALLBACK_DONE;
1648 /* remove event from list */
1649 if (cb_info->idle_event_list)
1650 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1652 g_mutex_unlock(&g_cam_idle_event_lock);
1655 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1657 IDLE_EVENT_CALLBACK_DONE:
1659 g_free(cam_idle_event);
1660 cam_idle_event = NULL;
1665 static gpointer __camera_msg_handler_func(gpointer data)
1669 camera_message_s *cam_msg = NULL;
1670 camera_idle_event_s *cam_idle_event = NULL;
1671 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1672 camera_cb_info_s *cb_info = NULL;
1674 if (!handler_info || !handler_info->cb_info) {
1675 CAM_LOG_ERROR("NULL handler %p", handler_info);
1679 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1680 type = handler_info->type;
1682 CAM_LOG_INFO("t:%d start[thread:%p]", type, handler_info->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, handler_info->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 if (handler_info->thread) {
2146 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2150 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2152 handler_info->type = type;
2153 handler_info->queue = g_queue_new();
2154 if (handler_info->queue == NULL) {
2155 CAM_LOG_ERROR("t:%d queue failed", type);
2159 g_mutex_init(&handler_info->mutex);
2160 g_cond_init(&handler_info->cond);
2162 handler_info->cb_info = (void *)cb_info;
2163 g_atomic_int_set(&handler_info->running, 1);
2165 handler_info->thread = g_thread_try_new(thread_name,
2166 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2167 if (handler_info->thread == NULL) {
2168 CAM_LOG_ERROR("t:%d thread failed", type);
2170 g_mutex_clear(&handler_info->mutex);
2171 g_cond_clear(&handler_info->cond);
2172 g_queue_free(handler_info->queue);
2173 handler_info->queue = NULL;
2178 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2184 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2188 if (!handler_info) {
2189 CAM_LOG_ERROR("NULL handler");
2193 if (!handler_info->thread) {
2194 CAM_LOG_WARNING("thread is not created");
2198 type = handler_info->type;
2200 CAM_LOG_INFO("t:%d thread[%p]", type, handler_info->thread);
2202 g_mutex_lock(&handler_info->mutex);
2203 g_atomic_int_set(&handler_info->running, 0);
2204 g_cond_signal(&handler_info->cond);
2205 g_mutex_unlock(&handler_info->mutex);
2207 g_thread_join(handler_info->thread);
2208 handler_info->thread = NULL;
2210 g_mutex_clear(&handler_info->mutex);
2211 g_cond_clear(&handler_info->cond);
2212 g_queue_free(handler_info->queue);
2213 handler_info->queue = NULL;
2215 CAM_LOG_INFO("t:%d done", type);
2219 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2221 camera_cb_info_s *cb_info = NULL;
2224 g_return_val_if_fail(sockfd > 0, NULL);
2226 cb_info = g_new0(camera_cb_info_s, 1);
2227 if (cb_info == NULL) {
2228 CAM_LOG_ERROR("cb_info failed");
2232 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2234 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2235 g_mutex_init(&cb_info->api_mutex[i]);
2236 g_cond_init(&cb_info->api_cond[i]);
2239 g_mutex_init(&cb_info->fd_lock);
2240 g_mutex_init(&cb_info->mp_data_mutex);
2241 g_mutex_init(&cb_info->bridge_lock);
2243 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2244 g_mutex_init(&cb_info->user_cb_mutex[i]);
2246 /* message handler thread */
2247 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2248 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2249 CAM_LOG_ERROR("msg_handler_info failed");
2253 /* message handler thread for capture callback */
2254 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2255 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2256 CAM_LOG_ERROR("capture_cb_info failed");
2260 cb_info->fd = sockfd;
2262 /* message receive thread */
2263 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2264 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2265 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2266 if (cb_info->msg_recv_thread == NULL) {
2267 CAM_LOG_ERROR("message receive thread creation failed");
2272 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2273 cb_info->fds[i] = CAMERA_FD_INIT;
2275 cb_info->is_server_connected = TRUE;
2281 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2282 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2284 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2285 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2287 g_mutex_clear(&cb_info->fd_lock);
2288 g_mutex_clear(&cb_info->mp_data_mutex);
2289 g_mutex_clear(&cb_info->bridge_lock);
2291 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2292 g_mutex_clear(&cb_info->api_mutex[i]);
2293 g_cond_clear(&cb_info->api_cond[i]);
2304 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2308 g_return_if_fail(cb_info != NULL);
2310 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2312 g_thread_join(cb_info->msg_recv_thread);
2313 cb_info->msg_recv_thread = NULL;
2315 CAM_LOG_INFO("msg_recv thread removed");
2317 /* destroy msg handler threads */
2318 if (cb_info->preview_cb_info.thread)
2319 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2320 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2321 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2323 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2324 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2326 g_mutex_clear(&cb_info->fd_lock);
2327 g_mutex_clear(&cb_info->mp_data_mutex);
2328 g_mutex_clear(&cb_info->bridge_lock);
2330 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2331 g_mutex_clear(&cb_info->api_mutex[i]);
2332 g_cond_clear(&cb_info->api_cond[i]);
2335 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2336 muse_client_close(cb_info->fd);
2337 cb_info->fd = CAMERA_FD_INIT;
2340 if (cb_info->bufmgr) {
2341 tbm_bufmgr_deinit(cb_info->bufmgr);
2342 cb_info->bufmgr = NULL;
2344 if (cb_info->pkt_fmt) {
2345 media_format_unref(cb_info->pkt_fmt);
2346 cb_info->pkt_fmt = NULL;
2349 if (cb_info->dp_interface) {
2350 mm_display_interface_deinit(cb_info->dp_interface);
2351 cb_info->dp_interface = NULL;
2358 int _camera_start_evas_rendering(camera_h camera)
2360 camera_cli_s *pc = (camera_cli_s *)camera;
2362 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2364 CAM_LOG_INFO("start");
2366 if (!pc->cb_info->is_evas_render) {
2367 CAM_LOG_ERROR("EVAS surface is not set");
2368 return CAMERA_ERROR_NONE;
2371 /* set evas render flag as RUN */
2372 pc->cb_info->run_evas_render = true;
2374 return CAMERA_ERROR_NONE;
2378 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2380 int ret = CAMERA_ERROR_NONE;
2381 camera_cli_s *pc = (camera_cli_s *)camera;
2383 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2385 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2387 if (!pc->cb_info->is_evas_render) {
2388 CAM_LOG_ERROR("EVAS surface is not set");
2389 return CAMERA_ERROR_NONE;
2392 /* set evas render flag as STOP and release buffers */
2393 pc->cb_info->run_evas_render = false;
2395 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2396 if (ret == MM_ERROR_NONE) {
2397 ret = CAMERA_ERROR_NONE;
2399 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2400 ret = CAMERA_ERROR_INVALID_OPERATION;
2407 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2409 int ret = CAMERA_ERROR_NONE;
2410 int sock_fd = CAMERA_FD_INIT;
2411 int module_index = -1;
2413 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2415 /* create muse connection */
2416 if (!key || !value) {
2417 CAM_LOG_ERROR("NULL pointer");
2418 return CAMERA_ERROR_INVALID_PARAMETER;
2421 sock_fd = muse_client_new();
2423 CAM_LOG_ERROR("muse_client_new failed");
2424 return CAMERA_ERROR_INVALID_OPERATION;
2427 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2428 CAM_LOG_ERROR("muse client get module index failed");
2429 ret = CAMERA_ERROR_INVALID_OPERATION;
2433 msg = muse_core_msg_new(api,
2434 MUSE_TYPE_INT, "module", module_index,
2435 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2438 CAM_LOG_ERROR("msg failed");
2439 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2443 ret = muse_core_msg_send(sock_fd, msg);
2445 muse_core_msg_free(msg);
2449 CAM_LOG_ERROR("send msg failed");
2450 ret = CAMERA_ERROR_INVALID_OPERATION;
2454 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2456 CAM_LOG_ERROR("recv msg failed %d", errno);
2457 ret = CAMERA_ERROR_INVALID_OPERATION;
2461 if (!muse_camera_msg_get(ret, recv_msg)) {
2462 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2463 ret = CAMERA_ERROR_INVALID_OPERATION;
2467 if (ret == CAMERA_ERROR_NONE)
2468 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2470 CAM_LOG_INFO("api %d - value %d", api, *value);
2473 if (CAMERA_IS_FD_VALID(sock_fd)) {
2474 muse_client_close(sock_fd);
2475 sock_fd = CAMERA_FD_INIT;
2482 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2484 int sock_fd = CAMERA_FD_INIT;
2485 char *send_msg = NULL;
2487 int ret = CAMERA_ERROR_NONE;
2488 camera_cli_s *pc = NULL;
2489 tbm_bufmgr bufmgr = NULL;
2491 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2492 int module_index = -1;
2493 int device_type = (int)device;
2495 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2497 sock_fd = muse_client_new();
2499 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2500 ret = CAMERA_ERROR_INVALID_OPERATION;
2504 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2505 CAM_LOG_ERROR("muse client get module index failed");
2506 ret = CAMERA_ERROR_INVALID_OPERATION;
2510 send_msg = muse_core_msg_new(api,
2511 MUSE_TYPE_INT, "module", module_index,
2512 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2513 MUSE_TYPE_INT, "is_network", (int)is_network,
2517 CAM_LOG_ERROR("NULL msg");
2518 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2522 send_ret = muse_core_msg_send(sock_fd, send_msg);
2524 muse_core_msg_free(send_msg);
2528 CAM_LOG_ERROR("send msg failed %d", errno);
2529 ret = CAMERA_ERROR_INVALID_OPERATION;
2533 pc = g_new0(camera_cli_s, 1);
2535 CAM_LOG_ERROR("camera_cli_s alloc failed");
2536 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2540 bufmgr = tbm_bufmgr_init(-1);
2541 if (bufmgr == NULL) {
2542 CAM_LOG_ERROR("get tbm bufmgr failed");
2543 ret = CAMERA_ERROR_INVALID_OPERATION;
2547 pc->cb_info = __camera_client_callback_new(sock_fd);
2548 if (pc->cb_info == NULL) {
2549 CAM_LOG_ERROR("cb_info alloc failed");
2550 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2554 sock_fd = CAMERA_FD_INIT;
2556 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2558 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2560 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2562 if (ret == CAMERA_ERROR_NONE) {
2563 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2564 int user_buffer_supported = 0;
2565 int log_level = CAMERA_LOG_LEVEL_INFO;
2566 intptr_t handle = 0;
2568 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2570 CAM_LOG_ERROR("Receiving Handle Failed!!");
2571 ret = CAMERA_ERROR_INVALID_OPERATION;
2575 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2576 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2577 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2579 pc->remote_handle = handle;
2580 pc->cb_info->bufmgr = bufmgr;
2581 pc->cb_info->preview_format = preview_format;
2582 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2583 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2584 pc->cb_info->is_network = is_network;
2585 g_camera_log_level = log_level;
2587 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2588 preview_format, user_buffer_supported, g_camera_log_level);
2591 CAM_LOG_ERROR("NULL out handle");
2592 ret= CAMERA_ERROR_INVALID_PARAMETER;
2596 *camera = (camera_h)pc;
2598 /* get display interface handle */
2599 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2600 CAM_LOG_WARNING("display interface init failed");
2609 tbm_bufmgr_deinit(bufmgr);
2613 if (CAMERA_IS_FD_VALID(sock_fd)) {
2614 muse_client_close(sock_fd);
2615 sock_fd = CAMERA_FD_INIT;
2620 int temp_fd = pc->cb_info->fd;
2622 /* pc->cb_info->fd should be closed,
2623 because g_thread_join for msg_recv_thread is not returned
2624 in __camera_client_callback_destroy. */
2625 if (CAMERA_IS_FD_VALID(temp_fd)) {
2626 pc->cb_info->fd = CAMERA_FD_INIT;
2627 muse_client_close(temp_fd);
2630 __camera_client_callback_destroy(pc->cb_info);
2637 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2644 int camera_create(camera_device_e device, camera_h *camera)
2646 return _camera_create_private(device, false, camera);
2650 int camera_change_device(camera_h camera, camera_device_e device)
2653 int ret = CAMERA_ERROR_NONE;
2654 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2655 camera_cli_s *pc = (camera_cli_s *)camera;
2656 camera_msg_param param;
2658 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2660 CAMERA_MSG_PARAM_SET(param, INT, device);
2662 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2664 if (ret == CAMERA_ERROR_NONE) {
2665 /* reset callback and user data */
2666 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2667 pc->cb_info->user_cb[i] = NULL;
2668 pc->cb_info->user_data[i] = NULL;
2676 int camera_destroy(camera_h camera)
2678 int ret = CAMERA_ERROR_NONE;
2679 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2680 camera_cli_s *pc = (camera_cli_s *)camera;
2682 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2684 CAM_LOG_INFO("Enter");
2686 if (pc->cb_info->is_server_connected)
2687 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2689 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2691 if (ret == CAMERA_ERROR_NONE) {
2692 __camera_deactivate_idle_event_all(pc->cb_info);
2693 __camera_client_callback_destroy(pc->cb_info);
2700 CAM_LOG_INFO("ret : 0x%x", ret);
2705 int camera_start_preview(camera_h camera)
2707 int ret = CAMERA_ERROR_NONE;
2709 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2710 camera_cli_s *pc = (camera_cli_s *)camera;
2711 camera_state_e current_state = CAMERA_STATE_NONE;
2713 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2715 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2716 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2718 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2719 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2720 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2721 pc->cb_info->dp_info.type);
2722 return CAMERA_ERROR_INVALID_OPERATION;
2725 ret = camera_get_state(camera, ¤t_state);
2726 if (ret != CAMERA_ERROR_NONE) {
2727 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2731 if (current_state == CAMERA_STATE_CREATED) {
2732 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2733 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2734 CAM_LOG_ERROR("preview_cb_info failed");
2735 return CAMERA_ERROR_INVALID_OPERATION;
2738 if (pc->cb_info->user_buffer_supported) {
2739 if (!__camera_allocate_preview_buffer(camera)) {
2740 ret = CAMERA_ERROR_INVALID_OPERATION;
2744 fds = pc->cb_info->fds;
2748 _camera_msg_send(api, fds, pc->cb_info, &ret,
2749 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2750 CAMERA_CB_NO_TIMEOUT);
2752 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2754 if (ret != CAMERA_ERROR_NONE)
2757 if (pc->cb_info->is_evas_render) {
2758 ret = _camera_start_evas_rendering(camera);
2759 if (ret != CAMERA_ERROR_NONE) {
2760 CAM_LOG_ERROR("stop preview because of error");
2761 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2766 CAM_LOG_INFO("done");
2768 return CAMERA_ERROR_NONE;
2771 if (current_state == CAMERA_STATE_CREATED) {
2772 if (pc->cb_info->user_buffer_supported)
2773 __camera_release_preview_buffer(camera);
2775 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2778 CAM_LOG_ERROR("failed : 0x%x", ret);
2784 int camera_stop_preview(camera_h camera)
2786 int ret = CAMERA_ERROR_NONE;
2787 camera_cli_s *pc = (camera_cli_s *)camera;
2788 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2789 camera_state_e current_state = CAMERA_STATE_NONE;
2791 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2793 CAM_LOG_INFO("Enter");
2796 if (pc->cb_info->is_evas_render) {
2797 ret = camera_get_state(camera, ¤t_state);
2798 if (ret != CAMERA_ERROR_NONE) {
2799 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2803 if (current_state == CAMERA_STATE_PREVIEW) {
2804 ret = _camera_stop_evas_rendering(camera, false);
2805 if (ret != CAMERA_ERROR_NONE)
2810 /* send stop preview message */
2811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2813 if (ret == CAMERA_ERROR_NONE) {
2814 if (pc->cb_info->user_buffer_supported)
2815 __camera_release_preview_buffer(camera);
2817 /* release remained message for preview callback */
2818 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2819 } else if (current_state == CAMERA_STATE_PREVIEW) {
2820 CAM_LOG_WARNING("restart evas rendering");
2821 _camera_start_evas_rendering(camera);
2824 CAM_LOG_INFO("ret : 0x%x", ret);
2830 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2832 int ret = CAMERA_ERROR_NONE;
2833 camera_cli_s *pc = (camera_cli_s *)camera;
2834 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2836 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2838 CAM_LOG_INFO("Enter");
2840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2846 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2848 CAM_LOG_INFO("ret : 0x%x", ret);
2854 bool camera_is_supported_continuous_capture(camera_h camera)
2856 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2860 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)
2862 int ret = CAMERA_ERROR_NONE;
2863 camera_cli_s *pc = (camera_cli_s *)camera;
2864 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2865 camera_msg_param param;
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 value = (count << 16) | interval;
2879 CAMERA_MSG_PARAM_SET(param, INT, value);
2881 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2883 CAM_LOG_INFO("ret : 0x%x", ret);
2889 int camera_stop_continuous_capture(camera_h camera)
2891 int ret = CAMERA_ERROR_NONE;
2892 camera_cli_s *pc = (camera_cli_s *)camera;
2893 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2895 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2897 CAM_LOG_INFO("Enter");
2899 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2901 CAM_LOG_INFO("ret : 0x%x", ret);
2907 bool camera_is_supported_face_detection(camera_h camera)
2909 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2913 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2915 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2919 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2921 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2925 bool camera_is_supported_extra_preview(camera_h camera)
2927 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2931 int camera_get_device_count(camera_h camera, int *device_count)
2933 int ret = CAMERA_ERROR_NONE;
2934 camera_cli_s *pc = (camera_cli_s *)camera;
2935 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2937 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2939 CAM_LOG_INFO("Enter");
2941 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2943 if (ret == CAMERA_ERROR_NONE)
2944 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2946 CAM_LOG_INFO("ret : 0x%x", ret);
2951 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2953 int ret = CAMERA_ERROR_NONE;
2954 camera_cli_s *pc = (camera_cli_s *)camera;
2955 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2957 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2959 CAM_LOG_INFO("Enter");
2961 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2963 if (ret == CAMERA_ERROR_NONE) {
2964 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2966 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2967 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2969 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2972 CAM_LOG_INFO("ret : 0x%x", ret);
2977 int camera_stop_face_detection(camera_h camera)
2979 int ret = CAMERA_ERROR_NONE;
2980 camera_cli_s *pc = (camera_cli_s *)camera;
2981 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2983 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2985 CAM_LOG_INFO("Enter");
2987 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2989 if (ret == CAMERA_ERROR_NONE) {
2990 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2995 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2998 CAM_LOG_INFO("ret : 0x%x", ret);
3003 int camera_get_state(camera_h camera, camera_state_e *state)
3005 int ret = CAMERA_ERROR_NONE;
3006 camera_cli_s *pc = (camera_cli_s *)camera;
3007 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3009 if (!pc || !pc->cb_info || !state) {
3010 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3011 return CAMERA_ERROR_INVALID_PARAMETER;
3014 CAM_LOG_INFO("Enter");
3016 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3018 if (ret == CAMERA_ERROR_NONE)
3019 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3021 CAM_LOG_INFO("ret : 0x%x", ret);
3026 int camera_start_focusing(camera_h camera, bool continuous)
3028 int ret = CAMERA_ERROR_NONE;
3029 camera_cli_s *pc = (camera_cli_s *)camera;
3030 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3031 camera_msg_param param;
3032 int is_continuous = (int)continuous;
3034 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3036 CAM_LOG_INFO("Enter");
3038 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3040 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3042 CAM_LOG_INFO("ret : 0x%x", ret);
3047 int camera_cancel_focusing(camera_h camera)
3049 int ret = CAMERA_ERROR_NONE;
3050 camera_cli_s *pc = (camera_cli_s *)camera;
3051 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3053 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3055 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3057 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3059 CAM_LOG_INFO("ret : 0x%x", ret);
3065 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3067 int mm_ret = MM_ERROR_NONE;
3068 int ret = CAMERA_ERROR_NONE;
3069 camera_cli_s *pc = (camera_cli_s *)camera;
3070 camera_cb_info_s *cb_info = NULL;
3071 camera_state_e current_state = CAMERA_STATE_NONE;
3072 camera_msg_param param;
3073 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3074 muse_camera_display_info_s *dp_info = NULL;
3076 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3078 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3079 CAM_LOG_ERROR("invalid type %d", type);
3080 return CAMERA_ERROR_INVALID_PARAMETER;
3083 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3084 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3085 return CAMERA_ERROR_INVALID_PARAMETER;
3088 cb_info = (camera_cb_info_s *)pc->cb_info;
3089 dp_info = &cb_info->dp_info;
3091 ret = camera_get_state(camera, ¤t_state);
3092 if (ret != CAMERA_ERROR_NONE) {
3093 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3097 if (current_state != CAMERA_STATE_CREATED) {
3098 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3099 return CAMERA_ERROR_INVALID_STATE;
3102 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3104 if (type != MM_DISPLAY_TYPE_NONE) {
3105 /* check display interface handle */
3106 if (!cb_info->dp_interface) {
3107 CAM_LOG_ERROR("display interface not supported");
3108 return CAMERA_ERROR_NOT_SUPPORTED;
3111 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3112 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3113 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3114 return CAMERA_ERROR_NOT_SUPPORTED;
3115 } else if (mm_ret != MM_ERROR_NONE) {
3116 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3117 return CAMERA_ERROR_INVALID_OPERATION;
3120 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3121 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3123 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3124 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3125 dp_info->window_rect.width, dp_info->window_rect.height);
3126 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3128 camera_flip_e flip = CAMERA_FLIP_NONE;
3129 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3130 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3137 camera_get_display_flip(camera, &flip);
3138 camera_get_display_mode(camera, &mode);
3139 camera_get_display_rotation(camera, &rotation);
3140 camera_is_display_visible(camera, &visible);
3142 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3143 flip, mode, rotation, visible);
3145 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3146 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3147 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3148 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3150 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3151 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3152 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3153 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3159 if (mm_ret != MM_ERROR_NONE) {
3160 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3161 return CAMERA_ERROR_INVALID_OPERATION;
3164 dp_info->type = type;
3166 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3168 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3170 if (ret == CAMERA_ERROR_NONE)
3171 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3177 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3179 CAM_LOG_INFO("type %d, display %p", type, display);
3180 return _camera_set_display(camera, (mm_display_type_e)type, display);
3184 int camera_set_preview_resolution(camera_h camera, int width, int height)
3186 int ret = CAMERA_ERROR_NONE;
3187 camera_state_e current_state = CAMERA_STATE_NONE;
3188 camera_cli_s *pc = (camera_cli_s *)camera;
3189 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3190 camera_msg_param param;
3193 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3195 if (pc->cb_info->is_evas_render) {
3196 ret = camera_get_state(camera, ¤t_state);
3197 if (ret != CAMERA_ERROR_NONE) {
3198 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3202 if (current_state == CAMERA_STATE_PREVIEW) {
3203 ret = _camera_stop_evas_rendering(camera, true);
3204 if (ret != CAMERA_ERROR_NONE)
3209 value = (width << 16) | height;
3210 CAMERA_MSG_PARAM_SET(param, INT, value);
3212 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3214 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3216 CAM_LOG_INFO("ret : 0x%x", ret);
3218 if (current_state == CAMERA_STATE_PREVIEW) {
3219 CAM_LOG_WARNING("restart evas rendering");
3220 _camera_start_evas_rendering(camera);
3227 int camera_set_capture_resolution(camera_h camera, int width, int height)
3229 int ret = CAMERA_ERROR_NONE;
3230 camera_cli_s *pc = (camera_cli_s *)camera;
3231 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3232 camera_msg_param param;
3235 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3237 CAM_LOG_INFO("Enter");
3239 value = (width << 16) | height;
3240 CAMERA_MSG_PARAM_SET(param, INT, value);
3242 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3244 CAM_LOG_INFO("ret : 0x%x", ret);
3250 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3252 int ret = CAMERA_ERROR_NONE;
3253 int set_format = (int)format;
3254 camera_cli_s *pc = (camera_cli_s *)camera;
3255 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3256 camera_msg_param param;
3258 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3260 CAM_LOG_INFO("Enter - format %d", set_format);
3262 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3264 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3266 CAM_LOG_INFO("ret : 0x%x", ret);
3272 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3274 int ret = CAMERA_ERROR_NONE;
3275 int set_format = (int)format;
3276 camera_msg_param param;
3277 camera_cli_s *pc = (camera_cli_s *)camera;
3278 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3280 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3282 CAM_LOG_INFO("Enter - format %d", set_format);
3284 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3286 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3288 if (ret == CAMERA_ERROR_NONE)
3289 pc->cb_info->preview_format = set_format;
3291 CAM_LOG_INFO("ret : 0x%x", ret);
3297 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3299 int ret = CAMERA_ERROR_NONE;
3300 camera_cli_s *pc = (camera_cli_s *)camera;
3301 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3303 if (!pc || !pc->cb_info || !width || !height) {
3304 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3305 return CAMERA_ERROR_INVALID_PARAMETER;
3308 CAM_LOG_INFO("Enter");
3310 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3312 if (ret == CAMERA_ERROR_NONE) {
3313 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3314 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3317 CAM_LOG_INFO("ret : 0x%x", ret);
3323 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3325 int ret = CAMERA_ERROR_NONE;
3326 int set_rotation = (int)rotation;
3327 camera_cli_s *pc = (camera_cli_s *)camera;
3328 camera_msg_param param;
3330 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3332 if (pc->cb_info->is_evas_render) {
3333 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3334 if (ret != MM_ERROR_NONE) {
3335 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3336 return CAMERA_ERROR_INVALID_OPERATION;
3340 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3342 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3348 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3350 int ret = CAMERA_ERROR_NONE;
3351 camera_cli_s *pc = (camera_cli_s *)camera;
3353 if (!pc || !pc->cb_info || !rotation) {
3354 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3355 return CAMERA_ERROR_INVALID_PARAMETER;
3358 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3360 if (ret == CAMERA_ERROR_NONE)
3361 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3367 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3369 int ret = CAMERA_ERROR_NONE;
3370 int set_flip = (int)flip;
3371 camera_cli_s *pc = (camera_cli_s *)camera;
3372 camera_msg_param param;
3374 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3376 if (pc->cb_info->is_evas_render) {
3377 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3378 if (ret != MM_ERROR_NONE) {
3379 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3380 return CAMERA_ERROR_INVALID_OPERATION;
3384 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3386 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3392 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3394 int ret = CAMERA_ERROR_NONE;
3395 camera_cli_s *pc = (camera_cli_s *)camera;
3397 if (!pc || !pc->cb_info || !flip) {
3398 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3399 return CAMERA_ERROR_INVALID_PARAMETER;
3402 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3404 if (ret == CAMERA_ERROR_NONE)
3405 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3411 int camera_set_display_visible(camera_h camera, bool visible)
3413 int ret = CAMERA_ERROR_NONE;
3414 int set_visible = (int)visible;
3415 camera_cli_s *pc = (camera_cli_s *)camera;
3416 camera_msg_param param;
3418 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3420 if (pc->cb_info->is_evas_render) {
3421 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3422 if (ret != MM_ERROR_NONE) {
3423 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3424 return CAMERA_ERROR_INVALID_OPERATION;
3428 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3430 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3436 int camera_is_display_visible(camera_h camera, bool *visible)
3438 int ret = CAMERA_ERROR_NONE;
3439 camera_cli_s *pc = (camera_cli_s *)camera;
3441 if (!pc || !pc->cb_info || !visible) {
3442 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3443 return CAMERA_ERROR_INVALID_PARAMETER;
3446 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3448 if (ret == CAMERA_ERROR_NONE)
3449 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3455 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3457 int ret = CAMERA_ERROR_NONE;
3458 int set_mode = (int)mode;
3459 camera_cli_s *pc = (camera_cli_s *)camera;
3460 camera_msg_param param;
3462 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3464 if (pc->cb_info->is_evas_render) {
3465 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3466 if (ret != MM_ERROR_NONE) {
3467 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3468 return CAMERA_ERROR_INVALID_OPERATION;
3472 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3474 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3480 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3482 int ret = CAMERA_ERROR_NONE;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3485 if (!pc || !pc->cb_info || !mode) {
3486 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3487 return CAMERA_ERROR_INVALID_PARAMETER;
3490 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3492 if (ret == CAMERA_ERROR_NONE)
3493 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3499 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3501 int ret = CAMERA_ERROR_NONE;
3502 int set_hint = (int)hint;
3503 camera_cli_s *pc = (camera_cli_s *)camera;
3504 camera_msg_param param;
3506 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3508 CAM_LOG_INFO("Enter - hint %d", set_hint);
3510 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3512 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3518 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3520 int ret = CAMERA_ERROR_NONE;
3521 camera_cli_s *pc = (camera_cli_s *)camera;
3522 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3524 if (!pc || !pc->cb_info || !hint) {
3525 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3526 return CAMERA_ERROR_INVALID_PARAMETER;
3529 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3531 if (ret == CAMERA_ERROR_NONE) {
3532 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3533 CAM_LOG_INFO("display reuse hint %d", *hint);
3540 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3542 int ret = CAMERA_ERROR_NONE;
3543 camera_cli_s *pc = (camera_cli_s *)camera;
3544 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3546 if (!pc || !pc->cb_info || !width || !height) {
3547 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3548 return CAMERA_ERROR_INVALID_PARAMETER;
3551 CAM_LOG_INFO("Enter");
3553 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3555 if (ret == CAMERA_ERROR_NONE) {
3556 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3557 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3560 CAM_LOG_INFO("ret : 0x%x", ret);
3566 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3568 int ret = CAMERA_ERROR_NONE;
3569 camera_cli_s *pc = (camera_cli_s *)camera;
3570 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3572 if (!pc || !pc->cb_info || !format) {
3573 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3574 return CAMERA_ERROR_INVALID_PARAMETER;
3577 CAM_LOG_INFO("Enter");
3579 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3581 if (ret == CAMERA_ERROR_NONE)
3582 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3584 CAM_LOG_INFO("ret : 0x%x", ret);
3590 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3592 int ret = CAMERA_ERROR_NONE;
3593 camera_cli_s *pc = (camera_cli_s *)camera;
3594 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3596 if (!pc || !pc->cb_info || !format) {
3597 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3598 return CAMERA_ERROR_INVALID_PARAMETER;
3601 CAM_LOG_INFO("Enter");
3603 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3605 if (ret == CAMERA_ERROR_NONE)
3606 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3608 CAM_LOG_INFO("ret : 0x%x", ret);
3614 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3616 int ret = CAMERA_ERROR_NONE;
3617 camera_cli_s *pc = (camera_cli_s *)camera;
3618 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3620 if (!pc || !pc->cb_info || !facing_direction) {
3621 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3622 return CAMERA_ERROR_INVALID_PARAMETER;
3625 CAM_LOG_INFO("Enter");
3627 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3629 if (ret == CAMERA_ERROR_NONE)
3630 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3632 CAM_LOG_INFO("ret : 0x%x", ret);
3638 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3640 int ret = CAMERA_ERROR_NONE;
3641 camera_cli_s *pc = (camera_cli_s *)camera;
3642 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3644 if (!pc || !pc->cb_info || !callback) {
3645 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3646 return CAMERA_ERROR_INVALID_PARAMETER;
3649 CAM_LOG_INFO("Enter");
3651 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3653 if (ret == CAMERA_ERROR_NONE) {
3654 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3656 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3657 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3659 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3662 CAM_LOG_INFO("ret : 0x%x", ret);
3668 int camera_unset_preview_cb(camera_h camera)
3670 int ret = CAMERA_ERROR_NONE;
3671 camera_cli_s *pc = (camera_cli_s *)camera;
3672 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3674 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3676 CAM_LOG_INFO("Enter");
3678 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3680 if (ret == CAMERA_ERROR_NONE) {
3681 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3683 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3684 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3686 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3689 CAM_LOG_INFO("ret : 0x%x", ret);
3695 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3697 int ret = CAMERA_ERROR_NONE;
3698 camera_cli_s *pc = (camera_cli_s *)camera;
3699 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3701 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3703 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3704 CAM_LOG_ERROR("NOT SUPPORTED");
3705 return CAMERA_ERROR_NOT_SUPPORTED;
3708 if (callback == NULL) {
3709 CAM_LOG_ERROR("NULL callback");
3710 return CAMERA_ERROR_INVALID_PARAMETER;
3713 CAM_LOG_INFO("Enter");
3715 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3717 if (ret == CAMERA_ERROR_NONE) {
3718 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3720 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3721 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3723 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3726 CAM_LOG_INFO("ret : 0x%x", ret);
3732 int camera_unset_media_packet_preview_cb(camera_h camera)
3734 int ret = CAMERA_ERROR_NONE;
3735 camera_cli_s *pc = (camera_cli_s *)camera;
3736 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3738 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3740 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3741 CAM_LOG_ERROR("NOT SUPPORTED");
3742 return CAMERA_ERROR_NOT_SUPPORTED;
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] = NULL;
3753 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
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_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3766 int ret = CAMERA_ERROR_NONE;
3767 camera_cli_s *pc = (camera_cli_s *)camera;
3768 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3770 if (!pc || !pc->cb_info || !callback) {
3771 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3772 return CAMERA_ERROR_INVALID_PARAMETER;
3775 CAM_LOG_INFO("Enter");
3777 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3779 if (ret == CAMERA_ERROR_NONE) {
3780 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3782 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3783 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3785 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3788 CAM_LOG_INFO("ret : 0x%x", ret);
3794 int camera_unset_state_changed_cb(camera_h camera)
3796 int ret = CAMERA_ERROR_NONE;
3797 camera_cli_s *pc = (camera_cli_s *)camera;
3798 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3800 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3802 CAM_LOG_INFO("Enter");
3804 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3806 if (ret == CAMERA_ERROR_NONE) {
3807 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3812 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3815 CAM_LOG_INFO("ret : 0x%x", ret);
3821 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3823 int ret = CAMERA_ERROR_NONE;
3824 camera_cli_s *pc = (camera_cli_s *)camera;
3825 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3827 if (!pc || !pc->cb_info || !callback) {
3828 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3829 return CAMERA_ERROR_INVALID_PARAMETER;
3832 CAM_LOG_INFO("Enter");
3834 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3836 if (ret == CAMERA_ERROR_NONE) {
3837 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3839 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3840 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3842 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3845 CAM_LOG_INFO("ret : 0x%x", ret);
3851 int camera_unset_interrupted_cb(camera_h camera)
3853 int ret = CAMERA_ERROR_NONE;
3854 camera_cli_s *pc = (camera_cli_s *)camera;
3855 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3857 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3859 CAM_LOG_INFO("Enter");
3861 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3863 if (ret == CAMERA_ERROR_NONE) {
3864 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3866 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3867 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3869 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3872 CAM_LOG_INFO("ret : 0x%x", ret);
3878 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3880 int ret = CAMERA_ERROR_NONE;
3881 camera_cli_s *pc = (camera_cli_s *)camera;
3882 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3884 if (!pc || !pc->cb_info || !callback) {
3885 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3886 return CAMERA_ERROR_INVALID_PARAMETER;
3889 CAM_LOG_INFO("Enter");
3891 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3893 if (ret == CAMERA_ERROR_NONE) {
3894 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3896 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3897 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3899 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3902 CAM_LOG_INFO("ret : 0x%x", ret);
3908 int camera_unset_interrupt_started_cb(camera_h camera)
3910 int ret = CAMERA_ERROR_NONE;
3911 camera_cli_s *pc = (camera_cli_s *)camera;
3912 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3914 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3916 CAM_LOG_INFO("Enter");
3918 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3920 if (ret == CAMERA_ERROR_NONE) {
3921 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3923 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3924 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3926 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3929 CAM_LOG_INFO("ret : 0x%x", ret);
3935 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3937 int ret = CAMERA_ERROR_NONE;
3938 camera_cli_s *pc = (camera_cli_s *)camera;
3939 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3941 if (!pc || !pc->cb_info || !callback) {
3942 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3943 return CAMERA_ERROR_INVALID_PARAMETER;
3946 CAM_LOG_INFO("Enter");
3948 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3950 if (ret == CAMERA_ERROR_NONE) {
3951 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3953 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3954 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3956 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3959 CAM_LOG_INFO("ret : 0x%x", ret);
3965 int camera_unset_focus_changed_cb(camera_h camera)
3967 int ret = CAMERA_ERROR_NONE;
3968 camera_cli_s *pc = (camera_cli_s *)camera;
3969 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3971 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3973 CAM_LOG_INFO("Enter");
3975 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3977 if (ret == CAMERA_ERROR_NONE) {
3978 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3980 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3981 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3983 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3986 CAM_LOG_INFO("ret : 0x%x", ret);
3992 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3994 int ret = CAMERA_ERROR_NONE;
3995 camera_cli_s *pc = (camera_cli_s *)camera;
3996 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3998 if (!pc || !pc->cb_info || !callback) {
3999 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4000 return CAMERA_ERROR_INVALID_PARAMETER;
4003 CAM_LOG_INFO("Enter");
4005 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4007 if (ret == CAMERA_ERROR_NONE) {
4008 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4010 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4011 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4013 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4016 CAM_LOG_INFO("ret : 0x%x", ret);
4022 int camera_unset_error_cb(camera_h camera)
4024 int ret = CAMERA_ERROR_NONE;
4025 camera_cli_s *pc = (camera_cli_s *)camera;
4026 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4028 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4030 CAM_LOG_INFO("Enter");
4032 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4034 if (ret == CAMERA_ERROR_NONE) {
4035 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4037 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4038 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4040 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4043 CAM_LOG_INFO("ret : 0x%x", ret);
4049 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4051 int ret = CAMERA_ERROR_NONE;
4052 camera_cli_s *pc = (camera_cli_s *)camera;
4053 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4055 if (!pc || !pc->cb_info || !foreach_cb) {
4056 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4057 return CAMERA_ERROR_INVALID_PARAMETER;
4060 CAM_LOG_INFO("Enter");
4062 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4063 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4065 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4067 CAM_LOG_INFO("ret : 0x%x", ret);
4073 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4075 int ret = CAMERA_ERROR_NONE;
4076 camera_cli_s *pc = (camera_cli_s *)camera;
4077 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4079 if (!pc || !pc->cb_info || !foreach_cb) {
4080 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4081 return CAMERA_ERROR_INVALID_PARAMETER;
4084 CAM_LOG_INFO("Enter");
4086 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4087 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4091 CAM_LOG_INFO("ret : 0x%x", ret);
4097 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4099 int ret = CAMERA_ERROR_NONE;
4100 camera_cli_s *pc = (camera_cli_s *)camera;
4101 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4103 if (!pc || !pc->cb_info || !foreach_cb) {
4104 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4105 return CAMERA_ERROR_INVALID_PARAMETER;
4108 CAM_LOG_INFO("Enter");
4110 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4111 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4113 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4115 CAM_LOG_INFO("ret : 0x%x", ret);
4121 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4123 int ret = CAMERA_ERROR_NONE;
4124 camera_cli_s *pc = (camera_cli_s *)camera;
4125 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4127 if (!pc || !pc->cb_info || !foreach_cb) {
4128 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4129 return CAMERA_ERROR_INVALID_PARAMETER;
4132 CAM_LOG_INFO("Enter");
4134 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4135 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4137 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4139 CAM_LOG_INFO("ret : 0x%x", ret);
4145 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4147 int ret = CAMERA_ERROR_NONE;
4148 camera_cli_s *pc = (camera_cli_s *)camera;
4149 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4151 if (!pc || !pc->cb_info || !width || !height) {
4152 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4153 return CAMERA_ERROR_INVALID_PARAMETER;
4156 CAM_LOG_INFO("Enter");
4157 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4159 if (ret == CAMERA_ERROR_NONE) {
4160 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4161 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4164 CAM_LOG_INFO("ret : 0x%x", ret);
4170 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4172 int ret = CAMERA_ERROR_NONE;
4173 camera_cli_s *pc = (camera_cli_s *)camera;
4174 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4176 if (!pc || !pc->cb_info || !angle) {
4177 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4178 return CAMERA_ERROR_INVALID_PARAMETER;
4181 CAM_LOG_INFO("Enter");
4183 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4185 if (ret == CAMERA_ERROR_NONE)
4186 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4188 CAM_LOG_INFO("ret : 0x%x", ret);
4194 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4196 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4200 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4202 int ret = CAMERA_ERROR_NONE;
4203 camera_cli_s *pc = (camera_cli_s *)camera;
4204 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4206 if (!pc || !pc->cb_info || !mode) {
4207 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4208 return CAMERA_ERROR_INVALID_PARAMETER;
4211 CAM_LOG_INFO("Enter");
4213 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4215 if (ret == CAMERA_ERROR_NONE)
4216 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4218 CAM_LOG_INFO("ret : 0x%x", ret);
4224 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4226 int ret = CAMERA_ERROR_NONE;
4227 camera_cli_s *pc = (camera_cli_s *)camera;
4228 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4230 if (!pc || !pc->cb_info || !foreach_cb) {
4231 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4232 return CAMERA_ERROR_INVALID_PARAMETER;
4235 CAM_LOG_INFO("Enter");
4237 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4238 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4240 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4242 CAM_LOG_INFO("Finish, return :%x", ret);
4248 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4250 int ret = CAMERA_ERROR_NONE;
4251 camera_cli_s *pc = (camera_cli_s *)camera;
4252 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4253 camera_msg_param param;
4254 int set_fps = (int)fps;
4256 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4258 CAM_LOG_INFO("Enter");
4260 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4262 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4264 CAM_LOG_INFO("ret : 0x%x", ret);
4270 int camera_attr_set_image_quality(camera_h camera, int quality)
4272 int ret = CAMERA_ERROR_NONE;
4273 camera_cli_s *pc = (camera_cli_s *)camera;
4274 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4275 camera_msg_param param;
4277 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4279 CAM_LOG_INFO("Enter");
4281 CAMERA_MSG_PARAM_SET(param, INT, quality);
4283 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4285 CAM_LOG_INFO("ret : 0x%x", ret);
4291 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4293 int ret = CAMERA_ERROR_NONE;
4294 camera_cli_s *pc = (camera_cli_s *)camera;
4295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4297 if (!pc || !pc->cb_info || !fps) {
4298 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4299 return CAMERA_ERROR_INVALID_PARAMETER;
4302 CAM_LOG_INFO("Enter");
4304 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4306 if (ret == CAMERA_ERROR_NONE)
4307 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4309 CAM_LOG_INFO("ret : 0x%x", ret);
4315 int camera_attr_get_image_quality(camera_h camera, int *quality)
4317 int ret = CAMERA_ERROR_NONE;
4318 camera_cli_s *pc = (camera_cli_s *)camera;
4319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4321 if (!pc || !pc->cb_info || !quality) {
4322 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4323 return CAMERA_ERROR_INVALID_PARAMETER;
4326 CAM_LOG_INFO("Enter");
4328 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4330 if (ret == CAMERA_ERROR_NONE)
4331 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4333 CAM_LOG_INFO("ret : 0x%x", ret);
4339 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4341 int ret = CAMERA_ERROR_NONE;
4342 camera_cli_s *pc = (camera_cli_s *)camera;
4343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4345 if (!pc || !pc->cb_info || !bitrate) {
4346 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4347 return CAMERA_ERROR_INVALID_PARAMETER;
4350 CAM_LOG_INFO("Enter");
4352 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4354 if (ret == CAMERA_ERROR_NONE)
4355 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4357 CAM_LOG_INFO("ret : 0x%x", ret);
4363 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4368 camera_msg_param param;
4369 int set_bitrate = bitrate;
4371 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4373 CAM_LOG_INFO("Enter");
4375 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4377 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4379 CAM_LOG_INFO("ret : 0x%x", ret);
4385 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4387 int ret = CAMERA_ERROR_NONE;
4388 camera_cli_s *pc = (camera_cli_s *)camera;
4389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4391 if (!pc || !pc->cb_info || !interval) {
4392 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4393 return CAMERA_ERROR_INVALID_PARAMETER;
4396 CAM_LOG_INFO("Enter");
4398 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4400 if (ret == CAMERA_ERROR_NONE)
4401 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4403 CAM_LOG_INFO("ret : 0x%x", ret);
4409 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4411 int ret = CAMERA_ERROR_NONE;
4412 camera_cli_s *pc = (camera_cli_s *)camera;
4413 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4414 camera_msg_param param;
4415 int set_gop_interval = interval;
4417 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4419 CAM_LOG_INFO("Enter");
4421 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4423 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4425 CAM_LOG_INFO("ret : 0x%x", ret);
4431 int camera_attr_set_zoom(camera_h camera, int zoom)
4433 int ret = CAMERA_ERROR_NONE;
4434 camera_cli_s *pc = (camera_cli_s *)camera;
4435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4436 camera_msg_param param;
4438 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4440 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4442 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4444 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4446 CAM_LOG_INFO("ret : 0x%x", ret);
4452 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4454 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4458 int camera_attr_set_af_area(camera_h camera, int x, int y)
4460 int ret = CAMERA_ERROR_NONE;
4461 camera_cli_s *pc = (camera_cli_s *)camera;
4462 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4463 camera_msg_param param;
4466 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4468 CAM_LOG_INFO("Enter - %d,%d", x, y);
4470 value = (x << 16) | y;
4471 CAMERA_MSG_PARAM_SET(param, INT, value);
4473 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4475 CAM_LOG_INFO("ret : 0x%x", ret);
4481 int camera_attr_clear_af_area(camera_h camera)
4483 int ret = CAMERA_ERROR_NONE;
4484 camera_cli_s *pc = (camera_cli_s *)camera;
4485 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4487 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4489 CAM_LOG_INFO("Enter");
4491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4493 CAM_LOG_INFO("ret : 0x%x", ret);
4499 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4501 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4505 int camera_attr_set_exposure(camera_h camera, int value)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4510 camera_msg_param param;
4512 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4514 CAM_LOG_INFO("Enter");
4516 CAMERA_MSG_PARAM_SET(param, INT, value);
4518 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4520 CAM_LOG_INFO("ret : 0x%x", ret);
4526 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4528 int ret = CAMERA_ERROR_NONE;
4529 camera_cli_s *pc = (camera_cli_s *)camera;
4530 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4531 camera_msg_param param;
4532 int set_iso = (int)iso;
4534 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4536 CAM_LOG_INFO("Enter");
4538 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4540 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4542 CAM_LOG_INFO("ret : 0x%x", ret);
4548 int camera_attr_set_brightness(camera_h camera, int level)
4550 int ret = CAMERA_ERROR_NONE;
4551 camera_cli_s *pc = (camera_cli_s *)camera;
4552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4553 camera_msg_param param;
4555 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4557 CAM_LOG_INFO("Enter");
4559 CAMERA_MSG_PARAM_SET(param, INT, level);
4561 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4563 CAM_LOG_INFO("ret : 0x%x", ret);
4569 int camera_attr_set_contrast(camera_h camera, int level)
4571 int ret = CAMERA_ERROR_NONE;
4572 camera_cli_s *pc = (camera_cli_s *)camera;
4573 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4574 camera_msg_param param;
4576 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4578 CAM_LOG_INFO("Enter");
4580 CAMERA_MSG_PARAM_SET(param, INT, level);
4582 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4584 CAM_LOG_INFO("ret : 0x%x", ret);
4590 int camera_attr_set_hue(camera_h camera, int level)
4592 int ret = CAMERA_ERROR_NONE;
4593 camera_cli_s *pc = (camera_cli_s *)camera;
4594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4595 camera_msg_param param;
4597 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4599 CAM_LOG_INFO("Enter");
4601 CAMERA_MSG_PARAM_SET(param, INT, level);
4603 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4605 CAM_LOG_INFO("ret : 0x%x", ret);
4611 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4613 int ret = CAMERA_ERROR_NONE;
4614 camera_cli_s *pc = (camera_cli_s *)camera;
4615 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4616 camera_msg_param param;
4617 int set_whitebalance = (int)wb;
4619 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4621 CAM_LOG_INFO("Enter");
4623 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4625 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4627 CAM_LOG_INFO("ret : 0x%x", ret);
4633 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4635 int ret = CAMERA_ERROR_NONE;
4636 camera_cli_s *pc = (camera_cli_s *)camera;
4637 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4638 camera_msg_param param;
4639 int set_effect = (int)effect;
4641 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4643 CAM_LOG_INFO("Enter");
4645 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4647 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4649 CAM_LOG_INFO("ret : 0x%x", ret);
4655 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4657 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4661 int camera_attr_enable_tag(camera_h camera, bool enable)
4663 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4667 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4669 int ret = CAMERA_ERROR_NONE;
4670 camera_cli_s *pc = (camera_cli_s *)camera;
4671 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4672 camera_msg_param param;
4674 if (!pc || !pc->cb_info || !description) {
4675 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4676 return CAMERA_ERROR_INVALID_PARAMETER;
4679 CAM_LOG_INFO("Enter");
4681 CAMERA_MSG_PARAM_SET(param, STRING, description);
4683 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4685 CAM_LOG_INFO("ret : 0x%x", ret);
4691 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4693 int ret = CAMERA_ERROR_NONE;
4694 camera_cli_s *pc = (camera_cli_s *)camera;
4695 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4696 camera_msg_param param;
4697 int set_orientation = (int)orientation;
4699 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4701 CAM_LOG_INFO("Enter");
4703 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4705 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4707 CAM_LOG_INFO("ret : 0x%x", ret);
4713 int camera_attr_set_tag_software(camera_h camera, const char *software)
4715 int ret = CAMERA_ERROR_NONE;
4716 camera_cli_s *pc = (camera_cli_s *)camera;
4717 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4718 camera_msg_param param;
4720 if (!pc || !pc->cb_info || !software) {
4721 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4722 return CAMERA_ERROR_INVALID_PARAMETER;
4725 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4727 CAMERA_MSG_PARAM_SET(param, STRING, software);
4729 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4731 CAM_LOG_INFO("ret : 0x%x", ret);
4737 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4739 int ret = CAMERA_ERROR_NONE;
4740 camera_cli_s *pc = (camera_cli_s *)camera;
4741 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4742 double set_geotag[3] = {latitude, longitude, altitude};
4746 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4748 CAM_LOG_INFO("Enter");
4750 length = sizeof(set_geotag) / sizeof(int) + \
4751 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4753 msg = muse_core_msg_new(api,
4754 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4757 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4763 int camera_attr_remove_geotag(camera_h camera)
4765 int ret = CAMERA_ERROR_NONE;
4766 camera_cli_s *pc = (camera_cli_s *)camera;
4767 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4769 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4771 CAM_LOG_INFO("Enter");
4773 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4775 CAM_LOG_INFO("ret : 0x%x", ret);
4781 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4783 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4787 int camera_attr_get_zoom(camera_h camera, int *zoom)
4789 int ret = CAMERA_ERROR_NONE;
4790 camera_cli_s *pc = (camera_cli_s *)camera;
4791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4793 if (!pc || !pc->cb_info || !zoom) {
4794 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4795 return CAMERA_ERROR_INVALID_PARAMETER;
4798 CAM_LOG_INFO("Enter");
4800 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4802 if (ret == CAMERA_ERROR_NONE)
4803 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4805 CAM_LOG_INFO("ret : 0x%x", ret);
4811 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4813 int ret = CAMERA_ERROR_NONE;
4814 camera_cli_s *pc = (camera_cli_s *)camera;
4815 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4817 if (!pc || !pc->cb_info || !min || !max) {
4818 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4819 return CAMERA_ERROR_INVALID_PARAMETER;
4822 CAM_LOG_INFO("Enter");
4824 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4826 if (ret == CAMERA_ERROR_NONE) {
4827 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4828 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4831 CAM_LOG_INFO("ret : 0x%x", ret);
4837 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4839 int ret = CAMERA_ERROR_NONE;
4840 camera_cli_s *pc = (camera_cli_s *)camera;
4841 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4843 if (!pc || !pc->cb_info || !mode) {
4844 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4845 return CAMERA_ERROR_INVALID_PARAMETER;
4848 CAM_LOG_INFO("Enter");
4850 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4852 if (ret == CAMERA_ERROR_NONE)
4853 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4855 CAM_LOG_INFO("ret : 0x%x", ret);
4861 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4863 int ret = CAMERA_ERROR_NONE;
4864 camera_cli_s *pc = (camera_cli_s *)camera;
4865 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4867 if (!pc || !pc->cb_info || !mode) {
4868 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4869 return CAMERA_ERROR_INVALID_PARAMETER;
4872 CAM_LOG_INFO("Enter");
4874 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4876 if (ret == CAMERA_ERROR_NONE)
4877 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4879 CAM_LOG_INFO("ret : 0x%x", ret);
4885 int camera_attr_get_exposure(camera_h camera, int *value)
4887 int ret = CAMERA_ERROR_NONE;
4888 camera_cli_s *pc = (camera_cli_s *)camera;
4889 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4891 if (!pc || !pc->cb_info || !value) {
4892 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
4893 return CAMERA_ERROR_INVALID_PARAMETER;
4896 CAM_LOG_INFO("Enter");
4898 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4900 if (ret == CAMERA_ERROR_NONE)
4901 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
4903 CAM_LOG_INFO("ret : 0x%x", ret);
4909 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4911 int ret = CAMERA_ERROR_NONE;
4912 camera_cli_s *pc = (camera_cli_s *)camera;
4913 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4915 if (!pc || !pc->cb_info || !min || !max) {
4916 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4917 return CAMERA_ERROR_INVALID_PARAMETER;
4920 CAM_LOG_INFO("Enter");
4922 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4924 if (ret == CAMERA_ERROR_NONE) {
4925 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
4926 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
4929 CAM_LOG_INFO("ret : 0x%x", ret);
4935 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4937 int ret = CAMERA_ERROR_NONE;
4938 camera_cli_s *pc = (camera_cli_s *)camera;
4939 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4941 if (!pc || !pc->cb_info || !iso) {
4942 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
4943 return CAMERA_ERROR_INVALID_PARAMETER;
4946 CAM_LOG_INFO("Enter");
4948 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4950 if (ret == CAMERA_ERROR_NONE)
4951 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
4953 CAM_LOG_INFO("ret : 0x%x", ret);
4959 int camera_attr_get_brightness(camera_h camera, int *level)
4961 int ret = CAMERA_ERROR_NONE;
4962 camera_cli_s *pc = (camera_cli_s *)camera;
4963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4965 if (!pc || !pc->cb_info || !level) {
4966 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
4967 return CAMERA_ERROR_INVALID_PARAMETER;
4970 CAM_LOG_INFO("Enter");
4972 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4974 if (ret == CAMERA_ERROR_NONE)
4975 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
4977 CAM_LOG_INFO("ret : 0x%x", ret);
4983 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4985 int ret = CAMERA_ERROR_NONE;
4986 camera_cli_s *pc = (camera_cli_s *)camera;
4987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4989 if (!pc || !pc->cb_info || !min || !max) {
4990 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4991 return CAMERA_ERROR_INVALID_PARAMETER;
4994 CAM_LOG_INFO("Enter");
4996 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4998 if (ret == CAMERA_ERROR_NONE) {
4999 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5000 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5003 CAM_LOG_INFO("ret : 0x%x", ret);
5009 int camera_attr_get_contrast(camera_h camera, int *level)
5011 int ret = CAMERA_ERROR_NONE;
5012 camera_cli_s *pc = (camera_cli_s *)camera;
5013 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5015 if (!pc || !pc->cb_info || !level) {
5016 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5017 return CAMERA_ERROR_INVALID_PARAMETER;
5020 CAM_LOG_INFO("Enter");
5022 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5024 if (ret == CAMERA_ERROR_NONE)
5025 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5027 CAM_LOG_INFO("ret : 0x%x", ret);
5033 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5035 int ret = CAMERA_ERROR_NONE;
5036 camera_cli_s *pc = (camera_cli_s *)camera;
5037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5039 if (!pc || !pc->cb_info || !min || !max) {
5040 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5041 return CAMERA_ERROR_INVALID_PARAMETER;
5044 CAM_LOG_INFO("Enter");
5046 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5048 if (ret == CAMERA_ERROR_NONE) {
5049 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5050 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5051 CAM_LOG_INFO("min %d, max %d", *min, *max);
5054 CAM_LOG_INFO("ret : 0x%x", ret);
5060 int camera_attr_get_hue(camera_h camera, int *level)
5062 int ret = CAMERA_ERROR_NONE;
5063 camera_cli_s *pc = (camera_cli_s *)camera;
5064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5066 if (!pc || !pc->cb_info || !level) {
5067 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5068 return CAMERA_ERROR_INVALID_PARAMETER;
5071 CAM_LOG_INFO("Enter");
5073 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5075 if (ret == CAMERA_ERROR_NONE)
5076 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5078 CAM_LOG_INFO("ret : 0x%x", ret);
5084 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5086 int ret = CAMERA_ERROR_NONE;
5087 camera_cli_s *pc = (camera_cli_s *)camera;
5088 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5090 if (!pc || !pc->cb_info || !min || !max) {
5091 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5092 return CAMERA_ERROR_INVALID_PARAMETER;
5095 CAM_LOG_INFO("Enter");
5097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5099 if (ret == CAMERA_ERROR_NONE) {
5100 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5101 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5102 CAM_LOG_INFO("min %d, max %d", *min, *max);
5105 CAM_LOG_INFO("ret : 0x%x", ret);
5111 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5113 int ret = CAMERA_ERROR_NONE;
5114 camera_cli_s *pc = (camera_cli_s *)camera;
5115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5117 if (!pc || !pc->cb_info || !wb) {
5118 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5119 return CAMERA_ERROR_INVALID_PARAMETER;
5122 CAM_LOG_INFO("Enter");
5124 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5126 if (ret == CAMERA_ERROR_NONE)
5127 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5129 CAM_LOG_INFO("ret : 0x%x", ret);
5135 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5137 int ret = CAMERA_ERROR_NONE;
5138 camera_cli_s *pc = (camera_cli_s *)camera;
5139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5141 if (!pc || !pc->cb_info || !effect) {
5142 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5143 return CAMERA_ERROR_INVALID_PARAMETER;
5146 CAM_LOG_INFO("Enter");
5148 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5150 if (ret == CAMERA_ERROR_NONE)
5151 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5153 CAM_LOG_INFO("ret : 0x%x", ret);
5159 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5165 if (!pc || !pc->cb_info || !mode) {
5166 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5170 CAM_LOG_INFO("Enter");
5172 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5177 CAM_LOG_INFO("ret : 0x%x", ret);
5183 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5189 if (!pc || !pc->cb_info || !enable) {
5190 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5194 CAM_LOG_INFO("Enter");
5196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE)
5199 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5201 CAM_LOG_INFO("ret : 0x%x", ret);
5207 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5209 int ret = CAMERA_ERROR_NONE;
5210 camera_cli_s *pc = (camera_cli_s *)camera;
5211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5213 if (!pc || !pc->cb_info || !description) {
5214 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5215 return CAMERA_ERROR_INVALID_PARAMETER;
5218 CAM_LOG_INFO("Enter");
5220 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5222 if (ret == CAMERA_ERROR_NONE)
5223 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5225 CAM_LOG_INFO("ret : 0x%x", ret);
5231 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5233 int ret = CAMERA_ERROR_NONE;
5234 camera_cli_s *pc = (camera_cli_s *)camera;
5235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5237 if (!pc || !pc->cb_info || !orientation) {
5238 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5239 return CAMERA_ERROR_INVALID_PARAMETER;
5242 CAM_LOG_INFO("Enter");
5244 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5246 if (ret == CAMERA_ERROR_NONE)
5247 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5249 CAM_LOG_INFO("ret : 0x%x", ret);
5255 int camera_attr_get_tag_software(camera_h camera, char **software)
5257 int ret = CAMERA_ERROR_NONE;
5258 camera_cli_s *pc = (camera_cli_s *)camera;
5259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5261 if (!pc || !pc->cb_info || !software) {
5262 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5263 return CAMERA_ERROR_INVALID_PARAMETER;
5266 CAM_LOG_INFO("Enter");
5268 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5270 if (ret == CAMERA_ERROR_NONE)
5271 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5273 CAM_LOG_INFO("ret : 0x%x", ret);
5279 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5281 int ret = CAMERA_ERROR_NONE;
5282 camera_cli_s *pc = (camera_cli_s *)camera;
5283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5285 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5286 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5287 return CAMERA_ERROR_INVALID_PARAMETER;
5290 CAM_LOG_INFO("Enter");
5292 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5294 if (ret == CAMERA_ERROR_NONE) {
5295 *latitude = pc->cb_info->get_geotag[0];
5296 *longitude = pc->cb_info->get_geotag[1];
5297 *altitude = pc->cb_info->get_geotag[2];
5300 CAM_LOG_INFO("ret : 0x%x", ret);
5306 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5308 int ret = CAMERA_ERROR_NONE;
5309 camera_cli_s *pc = (camera_cli_s *)camera;
5310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5312 if (!pc || !pc->cb_info || !mode) {
5313 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5314 return CAMERA_ERROR_INVALID_PARAMETER;
5317 CAM_LOG_INFO("Enter");
5319 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5321 if (ret == CAMERA_ERROR_NONE)
5322 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5324 CAM_LOG_INFO("ret : 0x%x", ret);
5330 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5332 int ret = CAMERA_ERROR_NONE;
5333 int get_flash_state = 0;
5336 CAM_LOG_ERROR("NULL pointer");
5337 return CAMERA_ERROR_INVALID_PARAMETER;
5340 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5341 (int)device, "get_flash_state", &get_flash_state);
5343 if (ret == CAMERA_ERROR_NONE) {
5344 *state = (camera_flash_state_e)get_flash_state;
5345 CAM_LOG_INFO("flash state %d", *state);
5347 CAM_LOG_ERROR("failed 0x%x", ret);
5354 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5356 int ret = CAMERA_ERROR_NONE;
5357 camera_cli_s *pc = (camera_cli_s *)camera;
5358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5360 if (!pc || !pc->cb_info || !foreach_cb) {
5361 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5362 return CAMERA_ERROR_INVALID_PARAMETER;
5365 CAM_LOG_INFO("Enter");
5367 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5368 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 CAM_LOG_INFO("ret : 0x%x", ret);
5378 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5380 int ret = CAMERA_ERROR_NONE;
5381 camera_cli_s *pc = (camera_cli_s *)camera;
5382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5384 if (!pc || !pc->cb_info || !foreach_cb) {
5385 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5386 return CAMERA_ERROR_INVALID_PARAMETER;
5389 CAM_LOG_INFO("Enter");
5391 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5392 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 CAM_LOG_INFO("ret : 0x%x", ret);
5402 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5404 int ret = CAMERA_ERROR_NONE;
5405 camera_cli_s *pc = (camera_cli_s *)camera;
5406 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5408 if (!pc || !pc->cb_info || !foreach_cb) {
5409 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5410 return CAMERA_ERROR_INVALID_PARAMETER;
5413 CAM_LOG_INFO("Enter");
5415 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5416 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5418 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5420 CAM_LOG_INFO("ret : 0x%x", ret);
5426 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5428 int ret = CAMERA_ERROR_NONE;
5429 camera_cli_s *pc = (camera_cli_s *)camera;
5430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5432 if (!pc || !pc->cb_info || !foreach_cb) {
5433 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5434 return CAMERA_ERROR_INVALID_PARAMETER;
5437 CAM_LOG_INFO("Enter");
5439 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5440 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5442 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5444 CAM_LOG_INFO("ret : 0x%x", ret);
5450 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5452 int ret = CAMERA_ERROR_NONE;
5453 camera_cli_s *pc = (camera_cli_s *)camera;
5454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5456 if (!pc || !pc->cb_info || !foreach_cb) {
5457 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5458 return CAMERA_ERROR_INVALID_PARAMETER;
5461 CAM_LOG_INFO("Enter");
5463 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5464 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5466 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5468 CAM_LOG_INFO("ret : 0x%x", ret);
5474 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5476 int ret = CAMERA_ERROR_NONE;
5477 camera_cli_s *pc = (camera_cli_s *)camera;
5478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5480 if (!pc || !pc->cb_info || !foreach_cb) {
5481 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5482 return CAMERA_ERROR_INVALID_PARAMETER;
5485 CAM_LOG_INFO("Enter");
5487 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5488 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5490 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5492 CAM_LOG_INFO("ret : 0x%x", ret);
5498 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5500 int ret = CAMERA_ERROR_NONE;
5501 camera_cli_s *pc = (camera_cli_s *)camera;
5502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5504 if (!pc || !pc->cb_info || !foreach_cb) {
5505 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5506 return CAMERA_ERROR_INVALID_PARAMETER;
5509 CAM_LOG_INFO("Enter");
5511 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5512 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5514 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5516 CAM_LOG_INFO("ret : 0x%x", ret);
5522 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5524 int ret = CAMERA_ERROR_NONE;
5525 camera_cli_s *pc = (camera_cli_s *)camera;
5526 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5528 if (!pc || !pc->cb_info || !foreach_cb) {
5529 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5530 return CAMERA_ERROR_INVALID_PARAMETER;
5533 CAM_LOG_INFO("Enter");
5535 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5536 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5538 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5540 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5546 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)
5548 int ret = CAMERA_ERROR_NONE;
5549 camera_cli_s *pc = (camera_cli_s *)camera;
5550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5551 camera_msg_param param;
5554 if (!pc || !pc->cb_info || !foreach_cb) {
5555 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5559 CAM_LOG_INFO("Enter");
5561 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5562 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5564 value = (width << 16) | height;
5565 CAMERA_MSG_PARAM_SET(param, INT, value);
5567 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5569 CAM_LOG_INFO("ret : 0x%x", ret);
5575 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5577 int ret = CAMERA_ERROR_NONE;
5578 camera_cli_s *pc = (camera_cli_s *)camera;
5579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5581 if (!pc || !pc->cb_info || !foreach_cb) {
5582 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5583 return CAMERA_ERROR_INVALID_PARAMETER;
5586 CAM_LOG_INFO("Enter");
5588 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5589 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5591 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5593 CAM_LOG_INFO("ret : 0x%x", ret);
5599 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5601 int ret = CAMERA_ERROR_NONE;
5602 camera_cli_s *pc = (camera_cli_s *)camera;
5603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5605 if (!pc || !pc->cb_info || !foreach_cb) {
5606 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5607 return CAMERA_ERROR_INVALID_PARAMETER;
5610 CAM_LOG_INFO("Enter");
5612 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5613 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5615 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5617 CAM_LOG_INFO("ret : 0x%x", ret);
5623 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5625 int ret = CAMERA_ERROR_NONE;
5626 camera_cli_s *pc = (camera_cli_s *)camera;
5627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5628 camera_msg_param param;
5629 int set_rotation = (int)rotation;
5631 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5633 CAM_LOG_INFO("Enter");
5635 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5637 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5639 CAM_LOG_INFO("ret : 0x%x", ret);
5645 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5647 int ret = CAMERA_ERROR_NONE;
5648 camera_cli_s *pc = (camera_cli_s *)camera;
5649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5651 if (!pc || !pc->cb_info || !rotation) {
5652 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5653 return CAMERA_ERROR_INVALID_PARAMETER;
5656 CAM_LOG_INFO("Enter");
5658 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5660 if (ret == CAMERA_ERROR_NONE)
5661 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5663 CAM_LOG_INFO("ret : 0x%x", ret);
5669 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5671 int ret = CAMERA_ERROR_NONE;
5672 camera_cli_s *pc = (camera_cli_s *)camera;
5673 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5674 camera_msg_param param;
5675 int set_flip = (int)flip;
5677 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5679 CAM_LOG_INFO("Enter");
5681 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5683 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5685 CAM_LOG_INFO("ret : 0x%x", ret);
5691 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5693 int ret = CAMERA_ERROR_NONE;
5694 camera_cli_s *pc = (camera_cli_s *)camera;
5695 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5697 if (!pc || !pc->cb_info || !flip) {
5698 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5699 return CAMERA_ERROR_INVALID_PARAMETER;
5702 CAM_LOG_INFO("Enter");
5704 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5706 if (ret == CAMERA_ERROR_NONE)
5707 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5709 CAM_LOG_INFO("ret : 0x%x", ret);
5714 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5716 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5720 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5722 int ret = CAMERA_ERROR_NONE;
5723 camera_cli_s *pc = (camera_cli_s *)camera;
5724 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5726 if (!pc || !pc->cb_info || !mode) {
5727 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5728 return CAMERA_ERROR_INVALID_PARAMETER;
5731 CAM_LOG_INFO("Enter");
5733 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5735 if (ret == CAMERA_ERROR_NONE)
5736 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5738 CAM_LOG_INFO("ret : 0x%x", ret);
5744 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5746 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5750 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5752 int ret = CAMERA_ERROR_NONE;
5753 camera_cli_s *pc = (camera_cli_s *)camera;
5754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5756 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5758 CAM_LOG_INFO("Enter");
5760 if (!camera_attr_is_supported_hdr_capture(camera)) {
5761 CAM_LOG_ERROR("HDR not supported");
5762 return CAMERA_ERROR_NOT_SUPPORTED;
5766 CAM_LOG_ERROR("NULL callback");
5767 return CAMERA_ERROR_INVALID_PARAMETER;
5770 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5772 if (ret == CAMERA_ERROR_NONE) {
5773 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5775 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5776 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5778 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5781 CAM_LOG_INFO("ret : 0x%x", ret);
5787 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5789 int ret = CAMERA_ERROR_NONE;
5790 camera_cli_s *pc = (camera_cli_s *)camera;
5791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5793 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5795 CAM_LOG_INFO("Enter");
5797 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5799 if (ret == CAMERA_ERROR_NONE) {
5800 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5802 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5803 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5805 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5808 CAM_LOG_INFO("ret : 0x%x", ret);
5814 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5816 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5820 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5822 int ret = CAMERA_ERROR_NONE;
5823 camera_cli_s *pc = (camera_cli_s *)camera;
5824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5826 if (!pc || !pc->cb_info || !enabled) {
5827 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5828 return CAMERA_ERROR_INVALID_PARAMETER;
5831 CAM_LOG_INFO("Enter");
5833 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5835 if (ret == CAMERA_ERROR_NONE)
5836 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5838 CAM_LOG_INFO("ret : 0x%x", ret);
5844 bool camera_attr_is_supported_anti_shake(camera_h camera)
5846 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
5850 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5852 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
5856 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5858 int ret = CAMERA_ERROR_NONE;
5859 camera_cli_s *pc = (camera_cli_s *)camera;
5860 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5862 if (!pc || !pc->cb_info || !enabled) {
5863 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5864 return CAMERA_ERROR_INVALID_PARAMETER;
5867 CAM_LOG_INFO("Enter");
5869 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5871 if (ret == CAMERA_ERROR_NONE)
5872 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
5874 CAM_LOG_INFO("ret : 0x%x", ret);
5880 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5882 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
5886 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5888 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
5892 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5894 int ret = CAMERA_ERROR_NONE;
5895 camera_cli_s *pc = (camera_cli_s *)camera;
5896 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5898 if (!pc || !pc->cb_info || !enabled) {
5899 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5900 return CAMERA_ERROR_INVALID_PARAMETER;
5903 CAM_LOG_INFO("Enter");
5905 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5907 if (ret == CAMERA_ERROR_NONE)
5908 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
5910 CAM_LOG_INFO("ret : 0x%x", ret);
5916 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5918 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
5922 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5924 int ret = CAMERA_ERROR_NONE;
5925 camera_cli_s *pc = (camera_cli_s *)camera;
5926 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5927 camera_msg_param param;
5928 int set_disable = (int)disable;
5930 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5932 CAM_LOG_INFO("Enter");
5934 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5936 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5938 CAM_LOG_INFO("ret : 0x%x", ret);
5944 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5946 int ret = CAMERA_ERROR_NONE;
5947 camera_cli_s *pc = (camera_cli_s *)camera;
5948 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5949 camera_msg_param param0;
5950 camera_msg_param param1;
5952 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5954 CAM_LOG_INFO("Enter");
5956 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
5957 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
5959 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
5960 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
5962 CAM_LOG_INFO("ret : 0x%x", ret);
5968 int camera_attr_get_pan(camera_h camera, int *pan_step)
5970 int ret = CAMERA_ERROR_NONE;
5971 camera_cli_s *pc = (camera_cli_s *)camera;
5972 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
5974 if (!pc || !pc->cb_info || !pan_step) {
5975 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
5976 return CAMERA_ERROR_INVALID_PARAMETER;
5979 CAM_LOG_INFO("Enter");
5981 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5983 if (ret == CAMERA_ERROR_NONE)
5984 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
5986 CAM_LOG_INFO("ret : 0x%x", ret);
5992 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
5994 int ret = CAMERA_ERROR_NONE;
5995 camera_cli_s *pc = (camera_cli_s *)camera;
5996 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
5998 if (!pc || !pc->cb_info || !min || !max) {
5999 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6000 return CAMERA_ERROR_INVALID_PARAMETER;
6003 CAM_LOG_INFO("Enter");
6005 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6007 if (ret == CAMERA_ERROR_NONE) {
6008 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6009 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6012 CAM_LOG_INFO("ret : 0x%x", ret);
6018 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6020 int ret = CAMERA_ERROR_NONE;
6021 camera_cli_s *pc = (camera_cli_s *)camera;
6022 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6023 camera_msg_param param0;
6024 camera_msg_param param1;
6026 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6028 CAM_LOG_INFO("Enter");
6030 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6031 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6033 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6034 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6036 CAM_LOG_INFO("ret : 0x%x", ret);
6042 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6044 int ret = CAMERA_ERROR_NONE;
6045 camera_cli_s *pc = (camera_cli_s *)camera;
6046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6048 if (!pc || !pc->cb_info || !tilt_step) {
6049 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6050 return CAMERA_ERROR_INVALID_PARAMETER;
6053 CAM_LOG_INFO("Enter");
6055 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6057 if (ret == CAMERA_ERROR_NONE)
6058 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6060 CAM_LOG_INFO("ret : 0x%x", ret);
6066 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6068 int ret = CAMERA_ERROR_NONE;
6069 camera_cli_s *pc = (camera_cli_s *)camera;
6070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6072 if (!pc || !pc->cb_info || !min || !max) {
6073 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6074 return CAMERA_ERROR_INVALID_PARAMETER;
6077 CAM_LOG_INFO("Enter");
6079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6081 if (ret == CAMERA_ERROR_NONE) {
6082 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6083 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6086 CAM_LOG_INFO("ret : 0x%x", ret);
6092 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6094 int ret = CAMERA_ERROR_NONE;
6095 camera_cli_s *pc = (camera_cli_s *)camera;
6096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6097 camera_msg_param param;
6098 int set_ptz_type = (int)ptz_type;
6100 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6102 CAM_LOG_INFO("Enter");
6104 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6106 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6108 CAM_LOG_INFO("ret : 0x%x", ret);
6114 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6120 if (!pc || !pc->cb_info || !foreach_cb) {
6121 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6125 CAM_LOG_INFO("Enter");
6127 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6128 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6130 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6132 CAM_LOG_INFO("ret : 0x%x", ret);
6138 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6140 int ret = CAMERA_ERROR_NONE;
6141 camera_cli_s *pc = (camera_cli_s *)camera;
6142 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6143 int set_display_roi_area[4] = {x, y, width, height};
6147 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6149 CAM_LOG_INFO("Enter");
6151 if (pc->cb_info->is_evas_render) {
6152 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6153 if (ret != MM_ERROR_NONE) {
6154 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6155 return CAMERA_ERROR_INVALID_OPERATION;
6159 length = sizeof(set_display_roi_area) / sizeof(int) + \
6160 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6162 msg = muse_core_msg_new(api,
6163 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6166 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6172 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6174 camera_cli_s *pc = (camera_cli_s *)camera;
6175 int ret = CAMERA_ERROR_NONE;
6176 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6178 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6179 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6180 return CAMERA_ERROR_INVALID_PARAMETER;
6183 CAM_LOG_INFO("Enter");
6185 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6187 if (ret == CAMERA_ERROR_NONE) {
6188 *x = pc->cb_info->get_display_roi_area[0];
6189 *y = pc->cb_info->get_display_roi_area[1];
6190 *width = pc->cb_info->get_display_roi_area[2];
6191 *height = pc->cb_info->get_display_roi_area[3];
6194 CAM_LOG_INFO("ret : 0x%x", ret);
6200 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6202 int ret = CAMERA_ERROR_NONE;
6203 int get_device_state = 0;
6206 CAM_LOG_ERROR("NULL pointer");
6207 return CAMERA_ERROR_INVALID_PARAMETER;
6210 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6211 (int)device, "get_device_state", &get_device_state);
6213 if (ret == CAMERA_ERROR_NONE) {
6214 *state = (camera_device_state_e)get_device_state;
6215 CAM_LOG_INFO("device state %d", *state);
6217 CAM_LOG_ERROR("failed 0x%x", ret);
6224 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6226 int ret = CAMERA_ERROR_NONE;
6227 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6228 camera_cb_info *info = NULL;
6230 if (!callback || !cb_id) {
6231 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6232 return CAMERA_ERROR_INVALID_PARAMETER;
6235 /* check camera support */
6236 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6237 if (ret != CAMERA_ERROR_NONE) {
6238 CAM_LOG_ERROR("get device state failed");
6242 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6244 info = g_new0(camera_cb_info, 1);
6246 CAM_LOG_ERROR("info failed");
6247 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6251 info->id = ++g_cam_dev_state_changed_cb_id;
6252 info->callback = (void *)callback;
6253 info->user_data = user_data;
6257 /* subscribe dbus signal for camera state change */
6258 if (!g_cam_dev_state_changed_cb_conn) {
6259 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6260 if (!g_cam_dev_state_changed_cb_conn) {
6261 CAM_LOG_ERROR("failed to get gdbus connection");
6262 ret = CAMERA_ERROR_INVALID_OPERATION;
6266 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6267 MM_CAMCORDER_DBUS_OBJECT,
6268 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6269 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6271 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6272 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6273 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6274 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6275 CAM_LOG_ERROR("failed to get gdbus connection");
6276 ret = CAMERA_ERROR_INVALID_OPERATION;
6280 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6283 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6285 CAM_LOG_INFO("callback id %d", info->id);
6288 if (ret != CAMERA_ERROR_NONE) {
6294 if (g_cam_dev_state_changed_cb_conn) {
6295 g_object_unref(g_cam_dev_state_changed_cb_conn);
6296 g_cam_dev_state_changed_cb_conn = NULL;
6300 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6306 int camera_remove_device_state_changed_cb(int cb_id)
6308 int ret = CAMERA_ERROR_NONE;
6309 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6310 GList *tmp_list = NULL;
6311 camera_cb_info *info = NULL;
6313 /* check camera support */
6314 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6315 if (ret != CAMERA_ERROR_NONE) {
6316 CAM_LOG_ERROR("get device state failed");
6320 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6322 if (!g_cam_dev_state_changed_cb_list) {
6323 CAM_LOG_ERROR("there is no callback info");
6324 ret = CAMERA_ERROR_INVALID_OPERATION;
6328 tmp_list = g_cam_dev_state_changed_cb_list;
6331 info = tmp_list->data;
6332 tmp_list = tmp_list->next;
6335 CAM_LOG_WARNING("NULL info");
6339 if (info->id == cb_id) {
6340 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6345 if (!g_cam_dev_state_changed_cb_list) {
6346 /* no remained callback */
6347 if (g_cam_dev_state_changed_cb_conn) {
6348 /* unsubscribe signal */
6349 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6350 g_cam_dev_state_changed_cb_subscribe_id = 0;
6352 /* unref connection */
6353 g_object_unref(g_cam_dev_state_changed_cb_conn);
6354 g_cam_dev_state_changed_cb_conn = NULL;
6358 CAM_LOG_INFO("id %d callback removed", cb_id);
6359 ret = CAMERA_ERROR_NONE;
6365 CAM_LOG_ERROR("id %d callback not found", cb_id);
6366 ret = CAMERA_ERROR_INVALID_PARAMETER;
6369 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6376 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6378 int ret = CAMERA_ERROR_NONE;
6379 camera_cli_s *pc = (camera_cli_s *)camera;
6380 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6382 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6384 g_mutex_lock(&pc->cb_info->bridge_lock);
6386 if (pc->cb_info->bridge) {
6387 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6388 ret = CAMERA_ERROR_INVALID_OPERATION;
6389 goto _SET_MEDIA_BRIDGE_DONE;
6392 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6393 if (ret != CAMERA_ERROR_NONE) {
6394 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6395 goto _SET_MEDIA_BRIDGE_DONE;
6398 pc->cb_info->bridge = bridge;
6400 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6402 _SET_MEDIA_BRIDGE_DONE:
6403 g_mutex_unlock(&pc->cb_info->bridge_lock);
6409 int camera_media_bridge_unset_bridge(camera_h camera)
6411 int ret = CAMERA_ERROR_NONE;
6412 camera_cli_s *pc = (camera_cli_s *)camera;
6413 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6415 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6417 g_mutex_lock(&pc->cb_info->bridge_lock);
6419 if (!pc->cb_info->bridge) {
6420 CAM_LOG_ERROR("no media bridge");
6421 ret = CAMERA_ERROR_INVALID_OPERATION;
6422 goto _UNSET_MEDIA_BRIDGE_DONE;
6425 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6426 if (ret != CAMERA_ERROR_NONE) {
6427 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6428 goto _UNSET_MEDIA_BRIDGE_DONE;
6431 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6433 pc->cb_info->bridge = NULL;
6435 _UNSET_MEDIA_BRIDGE_DONE:
6436 g_mutex_unlock(&pc->cb_info->bridge_lock);
6443 int camera_create_network(camera_device_e device, camera_h *camera)
6445 return _camera_create_private(device, true, camera);
6449 int camera_device_manager_initialize(camera_device_manager_h *manager)
6452 int ret = CAMERA_ERROR_NONE;
6453 void *dl_handle = NULL;
6454 camera_device_manager *new_manager = NULL;
6455 cdm_symbol_table sym_table[] = {
6456 {(void **)&new_manager->initialize, "cdm_initialize"},
6457 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6458 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6459 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6460 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6463 CAMERA_CHECK_DEVICE_MANAGER;
6465 new_manager = g_new0(camera_device_manager, 1);
6468 CAM_LOG_ERROR("NULL manager");
6469 ret = CAMERA_ERROR_INVALID_PARAMETER;
6470 goto _INITIALIZE_FAILED;
6473 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6475 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6476 ret = CAMERA_ERROR_INVALID_OPERATION;
6477 goto _INITIALIZE_FAILED;
6481 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6482 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6483 if (*sym_table[i].func_ptr == NULL) {
6484 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6485 ret = CAMERA_ERROR_INVALID_OPERATION;
6486 goto _INITIALIZE_FAILED;
6490 ret = new_manager->initialize();
6491 if (ret != CAMERA_ERROR_NONE) {
6492 CAM_LOG_ERROR("failed[0x%x]", ret);
6493 goto _INITIALIZE_FAILED;
6496 new_manager->dl_handle = dl_handle;
6497 *manager = (camera_device_manager_h)new_manager;
6499 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6500 new_manager, dl_handle);
6502 return CAMERA_ERROR_NONE;
6507 g_free(new_manager);
6513 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6515 int ret = CAMERA_ERROR_NONE;
6516 camera_device_manager *m = (camera_device_manager *)manager;
6518 CAMERA_CHECK_DEVICE_MANAGER;
6521 CAM_LOG_ERROR("NULL manager");
6522 return CAMERA_ERROR_INVALID_PARAMETER;
6525 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6527 ret = m->deinitialize();
6528 if (ret != CAMERA_ERROR_NONE) {
6529 CAM_LOG_ERROR("failed[0x%x]", ret);
6533 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6535 dlclose(m->dl_handle);
6537 memset(m, 0x0, sizeof(camera_device_manager));
6540 return CAMERA_ERROR_NONE;
6544 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6546 int ret = CAMERA_ERROR_NONE;
6548 camera_device_list_s device_list;
6549 camera_device_s *device = NULL;
6550 camera_device_manager *m = (camera_device_manager *)manager;
6552 CAMERA_CHECK_DEVICE_MANAGER;
6554 if (!m || !callback) {
6555 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6556 return CAMERA_ERROR_INVALID_PARAMETER;
6559 CAM_LOG_INFO("enter");
6561 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6563 ret = m->get_device_list(&device_list);
6564 if (ret != CAMERA_ERROR_NONE) {
6565 CAM_LOG_ERROR("failed[0x%x]", ret);
6569 CAM_LOG_INFO("device count[%d]", device_list.count);
6571 for (i = 0 ; i < device_list.count ; i++) {
6572 device = &device_list.device[i];
6574 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6575 i, device->type, device->index,
6576 device->name, device->id, device->extra_stream_num);
6578 if (!callback(device, user_data)) {
6579 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6580 i + 1, device_list.count);
6585 return CAMERA_ERROR_NONE;
6589 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6590 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6592 int ret = CAMERA_ERROR_NONE;
6593 camera_device_manager *m = (camera_device_manager *)manager;
6595 CAMERA_CHECK_DEVICE_MANAGER;
6597 if (!m || !callback || !cb_id) {
6598 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6599 return CAMERA_ERROR_INVALID_PARAMETER;
6602 CAM_LOG_INFO("enter");
6604 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6605 if (ret != CAMERA_ERROR_NONE) {
6606 CAM_LOG_ERROR("failed[0x%x]", ret);
6610 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6612 return CAMERA_ERROR_NONE;
6616 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6618 int ret = CAMERA_ERROR_NONE;
6619 camera_device_manager *m = (camera_device_manager *)manager;
6621 CAMERA_CHECK_DEVICE_MANAGER;
6624 CAM_LOG_ERROR("NULL manager");
6625 return CAMERA_ERROR_INVALID_PARAMETER;
6628 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6630 ret = m->remove_device_connection_changed_cb(cb_id);
6631 if (ret != CAMERA_ERROR_NONE) {
6632 CAM_LOG_ERROR("failed[0x%x]", ret);
6636 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6638 return CAMERA_ERROR_NONE;
6643 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6645 int ret = CAMERA_ERROR_NONE;
6646 camera_cli_s *pc = (camera_cli_s *)camera;
6647 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6649 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6651 if (!camera_is_supported_extra_preview(camera)) {
6652 CAM_LOG_ERROR("extra preview is not supported");
6653 return CAMERA_ERROR_NOT_SUPPORTED;
6657 CAM_LOG_ERROR("NULL callback");
6658 return CAMERA_ERROR_INVALID_PARAMETER;
6661 CAM_LOG_INFO("Enter");
6663 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6665 if (ret == CAMERA_ERROR_NONE) {
6666 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6668 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6669 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6671 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6674 CAM_LOG_INFO("ret : 0x%x", ret);
6680 int camera_unset_extra_preview_cb(camera_h camera)
6682 int ret = CAMERA_ERROR_NONE;
6683 camera_cli_s *pc = (camera_cli_s *)camera;
6684 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6686 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6688 if (!camera_is_supported_extra_preview(camera)) {
6689 CAM_LOG_ERROR("extra preview is not supported");
6690 return CAMERA_ERROR_NOT_SUPPORTED;
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] = NULL;
6701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
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_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
6714 int ret = CAMERA_ERROR_NONE;
6715 int stream_format[4] = {pixel_format, width, height, fps};
6717 camera_cli_s *pc = (camera_cli_s *)camera;
6718 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6720 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6722 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6723 stream_id, pixel_format, width, height, fps);
6725 msg = muse_core_msg_new(api,
6726 MUSE_TYPE_INT, "stream_id", stream_id,
6727 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6730 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6736 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)
6738 int ret = CAMERA_ERROR_NONE;
6739 camera_cli_s *pc = (camera_cli_s *)camera;
6740 camera_msg_param param;
6741 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6743 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6744 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6745 return CAMERA_ERROR_INVALID_PARAMETER;
6748 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6750 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6752 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6754 if (ret == CAMERA_ERROR_NONE) {
6755 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6756 *width = pc->cb_info->get_extra_preview_stream_format[1];
6757 *height = pc->cb_info->get_extra_preview_stream_format[2];
6758 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6761 CAM_LOG_INFO("ret : 0x%x", ret);
6767 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6769 int ret = CAMERA_ERROR_NONE;
6770 camera_cli_s *pc = (camera_cli_s *)camera;
6771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6772 camera_msg_param param0;
6773 camera_msg_param param1;
6775 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6777 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6779 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6780 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6782 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6783 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6785 CAM_LOG_INFO("ret : 0x%x", ret);
6791 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6793 int ret = CAMERA_ERROR_NONE;
6794 camera_cli_s *pc = (camera_cli_s *)camera;
6795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6796 camera_msg_param param;
6798 if (!pc || !pc->cb_info || !bitrate) {
6799 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6800 return CAMERA_ERROR_INVALID_PARAMETER;
6803 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6805 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6807 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6809 if (ret == CAMERA_ERROR_NONE) {
6810 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6811 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6813 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6820 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6822 int ret = CAMERA_ERROR_NONE;
6823 camera_cli_s *pc = (camera_cli_s *)camera;
6824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6825 camera_msg_param param0;
6826 camera_msg_param param1;
6828 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6830 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6832 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6833 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6835 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6836 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6838 CAM_LOG_INFO("ret : 0x%x", ret);
6844 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6846 int ret = CAMERA_ERROR_NONE;
6847 camera_cli_s *pc = (camera_cli_s *)camera;
6848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6849 camera_msg_param param;
6851 if (!pc || !pc->cb_info || !interval) {
6852 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6853 return CAMERA_ERROR_INVALID_PARAMETER;
6856 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6858 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6860 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6862 if (ret == CAMERA_ERROR_NONE) {
6863 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6864 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6866 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6873 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6875 camera_cli_s *pc = (camera_cli_s *)camera;
6877 if (!pc || !pc->cb_info || !rotation) {
6878 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6879 return CAMERA_ERROR_INVALID_PARAMETER;
6882 if (!pc->cb_info->stream_data) {
6883 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6884 return CAMERA_ERROR_INVALID_OPERATION;
6887 *rotation = pc->cb_info->stream_data->rotation;
6889 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6891 return CAMERA_ERROR_NONE;
6895 int _camera_get_log_level(void)
6897 return g_camera_log_level;