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;
1673 GThread *thread = NULL;
1675 if (!handler_info || !handler_info->cb_info) {
1676 CAM_LOG_ERROR("NULL handler %p", handler_info);
1680 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1681 type = handler_info->type;
1682 thread = handler_info->thread;
1684 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1686 g_mutex_lock(&handler_info->mutex);
1688 while (g_atomic_int_get(&handler_info->running)) {
1689 if (g_queue_is_empty(handler_info->queue)) {
1690 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1691 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1692 CAM_LOG_VERBOSE("t[%d] signal received", type);
1694 if (g_atomic_int_get(&handler_info->running) == 0) {
1695 CAM_LOG_INFO("t:%d stop event thread", type);
1700 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1702 g_mutex_unlock(&handler_info->mutex);
1704 if (cam_msg == NULL) {
1705 CAM_LOG_ERROR("t:%d NULL message", type);
1706 g_mutex_lock(&handler_info->mutex);
1712 if (api < MUSE_CAMERA_API_MAX) {
1715 g_mutex_lock(&cb_info->api_mutex[api]);
1717 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1718 if (cb_info->api_waiting[api] > 0) {
1719 cb_info->api_ret[api] = ret;
1720 cb_info->api_activating[api] = TRUE;
1722 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1724 g_cond_broadcast(&cb_info->api_cond[api]);
1726 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1729 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1732 g_mutex_unlock(&cb_info->api_mutex[api]);
1733 } else if (api == MUSE_CAMERA_CB_EVENT) {
1734 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1735 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1736 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1739 switch (cam_msg->event_class) {
1740 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1741 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1743 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1744 cam_idle_event = g_new0(camera_idle_event_s, 1);
1745 if (cam_idle_event == NULL) {
1746 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1750 cam_idle_event->event = cam_msg->event;
1751 cam_idle_event->cb_info = cb_info;
1753 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1754 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1756 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1757 type, cam_msg->event, cam_idle_event);
1759 g_mutex_lock(&g_cam_idle_event_lock);
1760 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1761 g_mutex_unlock(&g_cam_idle_event_lock);
1763 g_idle_add_full(G_PRIORITY_DEFAULT,
1764 (GSourceFunc)__camera_idle_event_callback,
1765 (gpointer)cam_idle_event,
1769 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1773 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1779 g_mutex_lock(&handler_info->mutex);
1782 /* remove remained event */
1783 while (!g_queue_is_empty(handler_info->queue)) {
1784 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1786 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1787 __camera_release_tfd(cam_msg->tfd);
1790 CAM_LOG_WARNING("t:%d NULL message", type);
1794 g_mutex_unlock(&handler_info->mutex);
1796 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1802 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1804 camera_idle_event_s *cam_idle_event = NULL;
1807 if (cb_info == NULL) {
1808 CAM_LOG_ERROR("cb_info is NULL");
1812 g_mutex_lock(&g_cam_idle_event_lock);
1814 if (cb_info->idle_event_list == NULL) {
1815 CAM_LOG_INFO("No remained idle event");
1816 g_mutex_unlock(&g_cam_idle_event_lock);
1820 list = cb_info->idle_event_list;
1823 cam_idle_event = list->data;
1824 list = g_list_next(list);
1826 if (!cam_idle_event) {
1827 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1831 if (g_idle_remove_by_data(cam_idle_event)) {
1832 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1834 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1836 g_free(cam_idle_event);
1837 cam_idle_event = NULL;
1842 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1843 cam_idle_event, cam_idle_event->event);
1845 cam_idle_event->cb_info = NULL;
1847 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1850 g_list_free(cb_info->idle_event_list);
1851 cb_info->idle_event_list = NULL;
1853 g_mutex_unlock(&g_cam_idle_event_lock);
1857 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1859 camera_message_s *cam_msg = NULL;
1861 if (!cb_info || !msg) {
1862 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1866 cam_msg = g_new0(camera_message_s, 1);
1868 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1873 cam_msg->event = event;
1874 cam_msg->event_class = event_class;
1877 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1879 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1881 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1882 api, event, event_class);
1884 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1885 if (!cb_info->preview_cb_info.thread) {
1886 LOGI("The thread for preview cb is not created yet, create it now");
1887 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1888 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1889 CAM_LOG_ERROR("failed to create thread for preview cb");
1895 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1896 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1897 g_cond_signal(&cb_info->preview_cb_info.cond);
1898 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1899 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1900 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1901 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1902 g_cond_signal(&cb_info->capture_cb_info.cond);
1903 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1905 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1906 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1907 g_cond_signal(&cb_info->msg_handler_info.cond);
1908 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1915 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1917 int ret = CAMERA_ERROR_NONE;
1921 int event_class = -1;
1925 if (!cb_info || !msg) {
1926 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1930 CAM_LOG_DEBUG("msg[%s]", msg);
1932 if (!muse_camera_msg_get(api, msg)) {
1933 CAM_LOG_ERROR("failed to get camera api");
1937 if (api == MUSE_CAMERA_CB_EVENT) {
1938 if (!muse_camera_msg_get(event, msg) ||
1939 !muse_camera_msg_get(event_class, msg)) {
1940 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1944 if (!muse_camera_msg_get(api_class, msg)) {
1945 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1950 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1951 if (api >= MUSE_CAMERA_API_MAX) {
1952 CAM_LOG_ERROR("invalid api %d", api);
1956 if (!muse_camera_msg_get(ret, msg)) {
1957 CAM_LOG_ERROR("failed to get camera ret");
1961 g_mutex_lock(&cb_info->api_mutex[api]);
1964 case MUSE_CAMERA_API_CREATE:
1965 if (ret != CAMERA_ERROR_NONE) {
1966 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1967 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1970 case MUSE_CAMERA_API_DESTROY:
1971 if (ret == CAMERA_ERROR_NONE) {
1972 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1973 CAM_LOG_INFO("camera destroy done. close client cb handler");
1977 muse_camera_msg_get(get_type, msg);
1978 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1979 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1980 muse_camera_msg_get(get_index, msg);
1983 case MUSE_CAMERA_GET_TYPE_INT:
1984 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1986 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1987 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1988 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1990 case MUSE_CAMERA_GET_TYPE_ARRAY:
1992 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
1993 muse_core_msg_deserialize("get_value",
1994 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1995 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1996 cb_info->get_display_roi_area[0],
1997 cb_info->get_display_roi_area[1],
1998 cb_info->get_display_roi_area[2],
1999 cb_info->get_display_roi_area[3]);
2001 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2002 muse_core_msg_deserialize("get_value",
2003 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2004 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2005 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2007 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2008 muse_core_msg_deserialize("get_value",
2009 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2010 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2011 cb_info->get_extra_preview_stream_format[0],
2012 cb_info->get_extra_preview_stream_format[1],
2013 cb_info->get_extra_preview_stream_format[2],
2014 cb_info->get_extra_preview_stream_format[3]);
2017 CAM_LOG_WARNING("unknown api[%d]", api);
2021 case MUSE_CAMERA_GET_TYPE_STRING:
2022 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2025 CAM_LOG_WARNING("unknown type %d", get_type);
2032 if (cb_info->api_waiting[api] > 0) {
2033 cb_info->api_ret[api] = ret;
2034 cb_info->api_activating[api] = TRUE;
2036 g_cond_broadcast(&cb_info->api_cond[api]);
2038 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2041 g_mutex_unlock(&cb_info->api_mutex[api]);
2042 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2043 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2045 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2050 static gpointer __camera_msg_recv_func(gpointer data)
2053 int recv_length = 0;
2054 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2055 char *recv_msg = NULL;
2056 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2059 CAM_LOG_ERROR("cb_info NULL");
2063 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2065 recv_msg = cb_info->recv_msg;
2067 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2068 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2069 tfd[i] = CAMERA_FD_INIT;
2071 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2072 if (recv_length <= 0) {
2073 cb_info->is_server_connected = FALSE;
2074 CAM_LOG_ERROR("receive msg failed - server disconnected");
2078 if (CAMERA_IS_FD_VALID(tfd[0]))
2079 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2081 recv_msg[recv_length] = '\0';
2083 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2085 __camera_process_msg(cb_info, recv_msg, tfd);
2088 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2091 if (!cb_info->is_server_connected) {
2092 char *error_msg = NULL;
2094 if (cb_info->bufmgr == NULL) {
2095 CAM_LOG_ERROR("No need to send error(handle is not created)");
2099 if (cb_info->fd < 0) {
2100 CAM_LOG_ERROR("fd is closed in client side");
2104 /* send error msg for server disconnection */
2105 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2106 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2107 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2111 CAM_LOG_ERROR("error_msg failed");
2115 __camera_add_msg_to_queue(cb_info,
2116 MUSE_CAMERA_CB_EVENT,
2117 MUSE_CAMERA_EVENT_TYPE_ERROR,
2118 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2122 muse_core_msg_free(error_msg);
2125 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2126 if (cb_info->api_waiting[i])
2127 g_cond_broadcast(&cb_info->api_cond[i]);
2130 CAM_LOG_ERROR("add error msg for service disconnection done");
2138 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2139 int type, const char *thread_name, camera_cb_info_s *cb_info)
2141 if (!handler_info || !thread_name || !cb_info) {
2142 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2143 type, handler_info, thread_name, cb_info);
2147 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2149 if (handler_info->thread) {
2150 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2154 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2156 handler_info->type = type;
2157 handler_info->queue = g_queue_new();
2158 if (handler_info->queue == NULL) {
2159 CAM_LOG_ERROR("t:%d queue failed", type);
2163 handler_info->cb_info = (void *)cb_info;
2164 g_atomic_int_set(&handler_info->running, 1);
2166 handler_info->thread = g_thread_try_new(thread_name,
2167 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2168 if (handler_info->thread == NULL) {
2169 CAM_LOG_ERROR("t:%d thread failed", type);
2171 g_queue_free(handler_info->queue);
2172 handler_info->queue = NULL;
2177 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2183 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2185 GThread *thread = NULL;
2187 if (!handler_info) {
2188 CAM_LOG_ERROR("NULL handler");
2192 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2194 if (!handler_info->thread) {
2195 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2199 thread = handler_info->thread;
2200 handler_info->thread = NULL;
2202 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2204 g_atomic_int_set(&handler_info->running, 0);
2205 g_cond_signal(&handler_info->cond);
2207 g_clear_pointer(&locker, g_mutex_locker_free);
2209 g_thread_join(thread);
2211 g_queue_free(handler_info->queue);
2212 handler_info->queue = NULL;
2214 CAM_LOG_INFO("t:%d done", handler_info->type);
2218 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2223 CAM_LOG_ERROR("NULL cb_info");
2227 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2228 g_mutex_init(&cb_info->api_mutex[i]);
2229 g_cond_init(&cb_info->api_cond[i]);
2232 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2233 g_mutex_init(&cb_info->user_cb_mutex[i]);
2235 g_mutex_init(&cb_info->fd_lock);
2236 g_mutex_init(&cb_info->mp_data_mutex);
2237 g_mutex_init(&cb_info->bridge_lock);
2239 g_mutex_init(&cb_info->msg_handler_info.mutex);
2240 g_mutex_init(&cb_info->preview_cb_info.mutex);
2241 g_mutex_init(&cb_info->capture_cb_info.mutex);
2242 g_cond_init(&cb_info->msg_handler_info.cond);
2243 g_cond_init(&cb_info->preview_cb_info.cond);
2244 g_cond_init(&cb_info->capture_cb_info.cond);
2246 CAM_LOG_INFO("done");
2250 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2255 CAM_LOG_ERROR("NULL cb_info");
2259 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2260 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2261 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2262 g_cond_clear(&cb_info->msg_handler_info.cond);
2263 g_cond_clear(&cb_info->preview_cb_info.cond);
2264 g_cond_clear(&cb_info->capture_cb_info.cond);
2266 g_mutex_clear(&cb_info->fd_lock);
2267 g_mutex_clear(&cb_info->mp_data_mutex);
2268 g_mutex_clear(&cb_info->bridge_lock);
2270 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2271 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2273 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2274 g_mutex_clear(&cb_info->api_mutex[i]);
2275 g_cond_clear(&cb_info->api_cond[i]);
2278 CAM_LOG_INFO("done");
2282 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2284 camera_cb_info_s *cb_info = NULL;
2287 g_return_val_if_fail(sockfd > 0, NULL);
2289 cb_info = g_new0(camera_cb_info_s, 1);
2291 CAM_LOG_ERROR("cb_info failed");
2295 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2297 __camera_mutex_cond_init(cb_info);
2299 /* message handler thread */
2300 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2301 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2302 CAM_LOG_ERROR("msg_handler_info failed");
2306 /* message handler thread for capture callback */
2307 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2308 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2309 CAM_LOG_ERROR("capture_cb_info failed");
2313 cb_info->fd = sockfd;
2315 /* message receive thread */
2316 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2317 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2318 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2319 if (cb_info->msg_recv_thread == NULL) {
2320 CAM_LOG_ERROR("message receive thread creation failed");
2325 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2326 cb_info->fds[i] = CAMERA_FD_INIT;
2328 cb_info->is_server_connected = TRUE;
2334 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2335 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2337 __camera_mutex_cond_clear(cb_info);
2348 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2351 CAM_LOG_ERROR("NULL cb_info");
2355 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2357 g_thread_join(cb_info->msg_recv_thread);
2358 cb_info->msg_recv_thread = NULL;
2360 CAM_LOG_INFO("msg_recv thread removed");
2362 /* destroy msg handler threads */
2363 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2364 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2365 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2367 __camera_mutex_cond_clear(cb_info);
2369 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2370 muse_client_close(cb_info->fd);
2371 cb_info->fd = CAMERA_FD_INIT;
2374 if (cb_info->bufmgr) {
2375 tbm_bufmgr_deinit(cb_info->bufmgr);
2376 cb_info->bufmgr = NULL;
2378 if (cb_info->pkt_fmt) {
2379 media_format_unref(cb_info->pkt_fmt);
2380 cb_info->pkt_fmt = NULL;
2383 if (cb_info->dp_interface) {
2384 mm_display_interface_deinit(cb_info->dp_interface);
2385 cb_info->dp_interface = NULL;
2392 int _camera_start_evas_rendering(camera_h camera)
2394 camera_cli_s *pc = (camera_cli_s *)camera;
2396 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2398 CAM_LOG_INFO("start");
2400 if (!pc->cb_info->is_evas_render) {
2401 CAM_LOG_ERROR("EVAS surface is not set");
2402 return CAMERA_ERROR_NONE;
2405 /* set evas render flag as RUN */
2406 pc->cb_info->run_evas_render = true;
2408 return CAMERA_ERROR_NONE;
2412 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2414 int ret = CAMERA_ERROR_NONE;
2415 camera_cli_s *pc = (camera_cli_s *)camera;
2417 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2419 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2421 if (!pc->cb_info->is_evas_render) {
2422 CAM_LOG_ERROR("EVAS surface is not set");
2423 return CAMERA_ERROR_NONE;
2426 /* set evas render flag as STOP and release buffers */
2427 pc->cb_info->run_evas_render = false;
2429 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2430 if (ret == MM_ERROR_NONE) {
2431 ret = CAMERA_ERROR_NONE;
2433 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2434 ret = CAMERA_ERROR_INVALID_OPERATION;
2441 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2443 int ret = CAMERA_ERROR_NONE;
2444 int sock_fd = CAMERA_FD_INIT;
2445 int module_index = -1;
2447 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2449 /* create muse connection */
2450 if (!key || !value) {
2451 CAM_LOG_ERROR("NULL pointer");
2452 return CAMERA_ERROR_INVALID_PARAMETER;
2455 sock_fd = muse_client_new();
2457 CAM_LOG_ERROR("muse_client_new failed");
2458 return CAMERA_ERROR_INVALID_OPERATION;
2461 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2462 CAM_LOG_ERROR("muse client get module index failed");
2463 ret = CAMERA_ERROR_INVALID_OPERATION;
2467 msg = muse_core_msg_new(api,
2468 MUSE_TYPE_INT, "module", module_index,
2469 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2472 CAM_LOG_ERROR("msg failed");
2473 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2477 ret = muse_core_msg_send(sock_fd, msg);
2479 muse_core_msg_free(msg);
2483 CAM_LOG_ERROR("send msg failed");
2484 ret = CAMERA_ERROR_INVALID_OPERATION;
2488 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2490 CAM_LOG_ERROR("recv msg failed %d", errno);
2491 ret = CAMERA_ERROR_INVALID_OPERATION;
2495 if (!muse_camera_msg_get(ret, recv_msg)) {
2496 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2497 ret = CAMERA_ERROR_INVALID_OPERATION;
2501 if (ret == CAMERA_ERROR_NONE)
2502 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2504 CAM_LOG_INFO("api %d - value %d", api, *value);
2507 if (CAMERA_IS_FD_VALID(sock_fd)) {
2508 muse_client_close(sock_fd);
2509 sock_fd = CAMERA_FD_INIT;
2516 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2518 int sock_fd = CAMERA_FD_INIT;
2519 char *send_msg = NULL;
2521 int ret = CAMERA_ERROR_NONE;
2522 camera_cli_s *pc = NULL;
2523 tbm_bufmgr bufmgr = NULL;
2525 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2526 int module_index = -1;
2527 int device_type = (int)device;
2529 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2531 sock_fd = muse_client_new();
2533 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2534 ret = CAMERA_ERROR_INVALID_OPERATION;
2538 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2539 CAM_LOG_ERROR("muse client get module index failed");
2540 ret = CAMERA_ERROR_INVALID_OPERATION;
2544 send_msg = muse_core_msg_new(api,
2545 MUSE_TYPE_INT, "module", module_index,
2546 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2547 MUSE_TYPE_INT, "is_network", (int)is_network,
2551 CAM_LOG_ERROR("NULL msg");
2552 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2556 send_ret = muse_core_msg_send(sock_fd, send_msg);
2558 muse_core_msg_free(send_msg);
2562 CAM_LOG_ERROR("send msg failed %d", errno);
2563 ret = CAMERA_ERROR_INVALID_OPERATION;
2567 pc = g_new0(camera_cli_s, 1);
2569 CAM_LOG_ERROR("camera_cli_s alloc failed");
2570 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2574 bufmgr = tbm_bufmgr_init(-1);
2575 if (bufmgr == NULL) {
2576 CAM_LOG_ERROR("get tbm bufmgr failed");
2577 ret = CAMERA_ERROR_INVALID_OPERATION;
2581 pc->cb_info = __camera_client_callback_new(sock_fd);
2582 if (pc->cb_info == NULL) {
2583 CAM_LOG_ERROR("cb_info alloc failed");
2584 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2588 sock_fd = CAMERA_FD_INIT;
2590 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2592 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2594 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2596 if (ret == CAMERA_ERROR_NONE) {
2597 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2598 int user_buffer_supported = 0;
2599 int log_level = CAMERA_LOG_LEVEL_INFO;
2600 intptr_t handle = 0;
2602 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2604 CAM_LOG_ERROR("Receiving Handle Failed!!");
2605 ret = CAMERA_ERROR_INVALID_OPERATION;
2609 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2610 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2611 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2613 pc->remote_handle = handle;
2614 pc->cb_info->bufmgr = bufmgr;
2615 pc->cb_info->preview_format = preview_format;
2616 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2617 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2618 pc->cb_info->is_network = is_network;
2619 g_camera_log_level = log_level;
2621 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2622 preview_format, user_buffer_supported, g_camera_log_level);
2625 CAM_LOG_ERROR("NULL out handle");
2626 ret= CAMERA_ERROR_INVALID_PARAMETER;
2630 *camera = (camera_h)pc;
2632 /* get display interface handle */
2633 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2634 CAM_LOG_WARNING("display interface init failed");
2643 tbm_bufmgr_deinit(bufmgr);
2647 if (CAMERA_IS_FD_VALID(sock_fd)) {
2648 muse_client_close(sock_fd);
2649 sock_fd = CAMERA_FD_INIT;
2654 int temp_fd = pc->cb_info->fd;
2656 /* pc->cb_info->fd should be closed,
2657 because g_thread_join for msg_recv_thread is not returned
2658 in __camera_client_callback_destroy. */
2659 if (CAMERA_IS_FD_VALID(temp_fd)) {
2660 pc->cb_info->fd = CAMERA_FD_INIT;
2661 muse_client_close(temp_fd);
2664 __camera_client_callback_destroy(pc->cb_info);
2671 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2678 int camera_create(camera_device_e device, camera_h *camera)
2680 return _camera_create_private(device, false, camera);
2684 int camera_change_device(camera_h camera, camera_device_e device)
2687 int ret = CAMERA_ERROR_NONE;
2688 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2689 camera_cli_s *pc = (camera_cli_s *)camera;
2690 camera_msg_param param;
2692 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2694 CAMERA_MSG_PARAM_SET(param, INT, device);
2696 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2698 if (ret == CAMERA_ERROR_NONE) {
2699 /* reset callback and user data */
2700 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2701 pc->cb_info->user_cb[i] = NULL;
2702 pc->cb_info->user_data[i] = NULL;
2710 int camera_destroy(camera_h camera)
2712 int ret = CAMERA_ERROR_NONE;
2713 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2714 camera_cli_s *pc = (camera_cli_s *)camera;
2716 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2718 CAM_LOG_INFO("Enter");
2720 if (pc->cb_info->is_server_connected)
2721 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2723 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2725 if (ret == CAMERA_ERROR_NONE) {
2726 __camera_deactivate_idle_event_all(pc->cb_info);
2727 __camera_client_callback_destroy(pc->cb_info);
2734 CAM_LOG_INFO("ret : 0x%x", ret);
2739 int camera_start_preview(camera_h camera)
2741 int ret = CAMERA_ERROR_NONE;
2743 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2744 camera_cli_s *pc = (camera_cli_s *)camera;
2745 camera_state_e current_state = CAMERA_STATE_NONE;
2747 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2749 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2750 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2752 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2753 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2754 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2755 pc->cb_info->dp_info.type);
2756 return CAMERA_ERROR_INVALID_OPERATION;
2759 ret = camera_get_state(camera, ¤t_state);
2760 if (ret != CAMERA_ERROR_NONE) {
2761 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2765 if (current_state == CAMERA_STATE_CREATED) {
2766 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2767 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2768 CAM_LOG_ERROR("preview_cb_info failed");
2769 return CAMERA_ERROR_INVALID_OPERATION;
2772 if (pc->cb_info->user_buffer_supported) {
2773 if (!__camera_allocate_preview_buffer(camera)) {
2774 ret = CAMERA_ERROR_INVALID_OPERATION;
2778 fds = pc->cb_info->fds;
2782 _camera_msg_send(api, fds, pc->cb_info, &ret,
2783 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2784 CAMERA_CB_NO_TIMEOUT);
2786 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2788 if (ret != CAMERA_ERROR_NONE)
2791 if (pc->cb_info->is_evas_render) {
2792 ret = _camera_start_evas_rendering(camera);
2793 if (ret != CAMERA_ERROR_NONE) {
2794 CAM_LOG_ERROR("stop preview because of error");
2795 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2800 CAM_LOG_INFO("done");
2802 return CAMERA_ERROR_NONE;
2805 if (current_state == CAMERA_STATE_CREATED) {
2806 if (pc->cb_info->user_buffer_supported)
2807 __camera_release_preview_buffer(camera);
2809 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2812 CAM_LOG_ERROR("failed : 0x%x", ret);
2818 int camera_stop_preview(camera_h camera)
2820 int ret = CAMERA_ERROR_NONE;
2821 camera_cli_s *pc = (camera_cli_s *)camera;
2822 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2823 camera_state_e current_state = CAMERA_STATE_NONE;
2825 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2827 CAM_LOG_INFO("Enter");
2830 if (pc->cb_info->is_evas_render) {
2831 ret = camera_get_state(camera, ¤t_state);
2832 if (ret != CAMERA_ERROR_NONE) {
2833 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2837 if (current_state == CAMERA_STATE_PREVIEW) {
2838 ret = _camera_stop_evas_rendering(camera, false);
2839 if (ret != CAMERA_ERROR_NONE)
2844 /* send stop preview message */
2845 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2847 if (ret == CAMERA_ERROR_NONE) {
2848 if (pc->cb_info->user_buffer_supported)
2849 __camera_release_preview_buffer(camera);
2851 /* release remained message for preview callback */
2852 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2853 } else if (current_state == CAMERA_STATE_PREVIEW) {
2854 CAM_LOG_WARNING("restart evas rendering");
2855 _camera_start_evas_rendering(camera);
2858 CAM_LOG_INFO("ret : 0x%x", ret);
2864 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2866 int ret = CAMERA_ERROR_NONE;
2867 camera_cli_s *pc = (camera_cli_s *)camera;
2868 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2870 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2872 CAM_LOG_INFO("Enter");
2874 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2875 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2877 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2878 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2880 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2882 CAM_LOG_INFO("ret : 0x%x", ret);
2888 bool camera_is_supported_continuous_capture(camera_h camera)
2890 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2894 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)
2896 int ret = CAMERA_ERROR_NONE;
2897 camera_cli_s *pc = (camera_cli_s *)camera;
2898 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2899 camera_msg_param param;
2902 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2904 CAM_LOG_INFO("Enter");
2906 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2907 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2909 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2910 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2912 value = (count << 16) | interval;
2913 CAMERA_MSG_PARAM_SET(param, INT, value);
2915 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2917 CAM_LOG_INFO("ret : 0x%x", ret);
2923 int camera_stop_continuous_capture(camera_h camera)
2925 int ret = CAMERA_ERROR_NONE;
2926 camera_cli_s *pc = (camera_cli_s *)camera;
2927 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2929 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2931 CAM_LOG_INFO("Enter");
2933 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2935 CAM_LOG_INFO("ret : 0x%x", ret);
2941 bool camera_is_supported_face_detection(camera_h camera)
2943 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2947 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2949 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2953 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2955 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2959 bool camera_is_supported_extra_preview(camera_h camera)
2961 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2965 int camera_get_device_count(camera_h camera, int *device_count)
2967 int ret = CAMERA_ERROR_NONE;
2968 camera_cli_s *pc = (camera_cli_s *)camera;
2969 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2971 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2973 CAM_LOG_INFO("Enter");
2975 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2977 if (ret == CAMERA_ERROR_NONE)
2978 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2980 CAM_LOG_INFO("ret : 0x%x", ret);
2985 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2987 int ret = CAMERA_ERROR_NONE;
2988 camera_cli_s *pc = (camera_cli_s *)camera;
2989 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2991 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2993 CAM_LOG_INFO("Enter");
2995 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2997 if (ret == CAMERA_ERROR_NONE) {
2998 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3003 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3006 CAM_LOG_INFO("ret : 0x%x", ret);
3011 int camera_stop_face_detection(camera_h camera)
3013 int ret = CAMERA_ERROR_NONE;
3014 camera_cli_s *pc = (camera_cli_s *)camera;
3015 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3017 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3019 CAM_LOG_INFO("Enter");
3021 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3023 if (ret == CAMERA_ERROR_NONE) {
3024 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3029 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3032 CAM_LOG_INFO("ret : 0x%x", ret);
3037 int camera_get_state(camera_h camera, camera_state_e *state)
3039 int ret = CAMERA_ERROR_NONE;
3040 camera_cli_s *pc = (camera_cli_s *)camera;
3041 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3043 if (!pc || !pc->cb_info || !state) {
3044 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3045 return CAMERA_ERROR_INVALID_PARAMETER;
3048 CAM_LOG_INFO("Enter");
3050 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3052 if (ret == CAMERA_ERROR_NONE)
3053 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3055 CAM_LOG_INFO("ret : 0x%x", ret);
3060 int camera_start_focusing(camera_h camera, bool continuous)
3062 int ret = CAMERA_ERROR_NONE;
3063 camera_cli_s *pc = (camera_cli_s *)camera;
3064 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3065 camera_msg_param param;
3066 int is_continuous = (int)continuous;
3068 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3070 CAM_LOG_INFO("Enter");
3072 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3074 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3076 CAM_LOG_INFO("ret : 0x%x", ret);
3081 int camera_cancel_focusing(camera_h camera)
3083 int ret = CAMERA_ERROR_NONE;
3084 camera_cli_s *pc = (camera_cli_s *)camera;
3085 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3087 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3089 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3091 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3093 CAM_LOG_INFO("ret : 0x%x", ret);
3099 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3101 int mm_ret = MM_ERROR_NONE;
3102 int ret = CAMERA_ERROR_NONE;
3103 camera_cli_s *pc = (camera_cli_s *)camera;
3104 camera_cb_info_s *cb_info = NULL;
3105 camera_state_e current_state = CAMERA_STATE_NONE;
3106 camera_msg_param param;
3107 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3108 muse_camera_display_info_s *dp_info = NULL;
3110 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3112 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3113 CAM_LOG_ERROR("invalid type %d", type);
3114 return CAMERA_ERROR_INVALID_PARAMETER;
3117 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3118 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3119 return CAMERA_ERROR_INVALID_PARAMETER;
3122 cb_info = (camera_cb_info_s *)pc->cb_info;
3123 dp_info = &cb_info->dp_info;
3125 ret = camera_get_state(camera, ¤t_state);
3126 if (ret != CAMERA_ERROR_NONE) {
3127 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3131 if (current_state != CAMERA_STATE_CREATED) {
3132 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3133 return CAMERA_ERROR_INVALID_STATE;
3136 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3138 if (type != MM_DISPLAY_TYPE_NONE) {
3139 /* check display interface handle */
3140 if (!cb_info->dp_interface) {
3141 CAM_LOG_ERROR("display interface not supported");
3142 return CAMERA_ERROR_NOT_SUPPORTED;
3145 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3146 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3147 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3148 return CAMERA_ERROR_NOT_SUPPORTED;
3149 } else if (mm_ret != MM_ERROR_NONE) {
3150 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3151 return CAMERA_ERROR_INVALID_OPERATION;
3154 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3155 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3157 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3158 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3159 dp_info->window_rect.width, dp_info->window_rect.height);
3160 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3162 camera_flip_e flip = CAMERA_FLIP_NONE;
3163 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3164 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3171 camera_get_display_flip(camera, &flip);
3172 camera_get_display_mode(camera, &mode);
3173 camera_get_display_rotation(camera, &rotation);
3174 camera_is_display_visible(camera, &visible);
3176 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3177 flip, mode, rotation, visible);
3179 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3180 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3181 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3182 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3184 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3185 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3186 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3187 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3193 if (mm_ret != MM_ERROR_NONE) {
3194 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3195 return CAMERA_ERROR_INVALID_OPERATION;
3198 dp_info->type = type;
3200 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3202 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3204 if (ret == CAMERA_ERROR_NONE)
3205 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3211 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3213 CAM_LOG_INFO("type %d, display %p", type, display);
3214 return _camera_set_display(camera, (mm_display_type_e)type, display);
3218 int camera_set_preview_resolution(camera_h camera, int width, int height)
3220 int ret = CAMERA_ERROR_NONE;
3221 camera_state_e current_state = CAMERA_STATE_NONE;
3222 camera_cli_s *pc = (camera_cli_s *)camera;
3223 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3224 camera_msg_param param;
3227 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3229 if (pc->cb_info->is_evas_render) {
3230 ret = camera_get_state(camera, ¤t_state);
3231 if (ret != CAMERA_ERROR_NONE) {
3232 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3236 if (current_state == CAMERA_STATE_PREVIEW) {
3237 ret = _camera_stop_evas_rendering(camera, true);
3238 if (ret != CAMERA_ERROR_NONE)
3243 value = (width << 16) | height;
3244 CAMERA_MSG_PARAM_SET(param, INT, value);
3246 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3248 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3250 CAM_LOG_INFO("ret : 0x%x", ret);
3252 if (current_state == CAMERA_STATE_PREVIEW) {
3253 CAM_LOG_WARNING("restart evas rendering");
3254 _camera_start_evas_rendering(camera);
3261 int camera_set_capture_resolution(camera_h camera, int width, int height)
3263 int ret = CAMERA_ERROR_NONE;
3264 camera_cli_s *pc = (camera_cli_s *)camera;
3265 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3266 camera_msg_param param;
3269 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3271 CAM_LOG_INFO("Enter");
3273 value = (width << 16) | height;
3274 CAMERA_MSG_PARAM_SET(param, INT, value);
3276 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3278 CAM_LOG_INFO("ret : 0x%x", ret);
3284 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3286 int ret = CAMERA_ERROR_NONE;
3287 int set_format = (int)format;
3288 camera_cli_s *pc = (camera_cli_s *)camera;
3289 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3290 camera_msg_param param;
3292 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3294 CAM_LOG_INFO("Enter - format %d", set_format);
3296 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3298 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3300 CAM_LOG_INFO("ret : 0x%x", ret);
3306 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3308 int ret = CAMERA_ERROR_NONE;
3309 int set_format = (int)format;
3310 camera_msg_param param;
3311 camera_cli_s *pc = (camera_cli_s *)camera;
3312 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3314 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3316 CAM_LOG_INFO("Enter - format %d", set_format);
3318 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3320 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3322 if (ret == CAMERA_ERROR_NONE)
3323 pc->cb_info->preview_format = set_format;
3325 CAM_LOG_INFO("ret : 0x%x", ret);
3331 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3333 int ret = CAMERA_ERROR_NONE;
3334 camera_cli_s *pc = (camera_cli_s *)camera;
3335 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3337 if (!pc || !pc->cb_info || !width || !height) {
3338 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3339 return CAMERA_ERROR_INVALID_PARAMETER;
3342 CAM_LOG_INFO("Enter");
3344 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3346 if (ret == CAMERA_ERROR_NONE) {
3347 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3348 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3351 CAM_LOG_INFO("ret : 0x%x", ret);
3357 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3359 int ret = CAMERA_ERROR_NONE;
3360 int set_rotation = (int)rotation;
3361 camera_cli_s *pc = (camera_cli_s *)camera;
3362 camera_msg_param param;
3364 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3366 if (pc->cb_info->is_evas_render) {
3367 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3368 if (ret != MM_ERROR_NONE) {
3369 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3370 return CAMERA_ERROR_INVALID_OPERATION;
3374 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3376 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3382 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3384 int ret = CAMERA_ERROR_NONE;
3385 camera_cli_s *pc = (camera_cli_s *)camera;
3387 if (!pc || !pc->cb_info || !rotation) {
3388 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3389 return CAMERA_ERROR_INVALID_PARAMETER;
3392 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3394 if (ret == CAMERA_ERROR_NONE)
3395 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3401 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3403 int ret = CAMERA_ERROR_NONE;
3404 int set_flip = (int)flip;
3405 camera_cli_s *pc = (camera_cli_s *)camera;
3406 camera_msg_param param;
3408 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3410 if (pc->cb_info->is_evas_render) {
3411 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3412 if (ret != MM_ERROR_NONE) {
3413 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3414 return CAMERA_ERROR_INVALID_OPERATION;
3418 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3420 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3426 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3428 int ret = CAMERA_ERROR_NONE;
3429 camera_cli_s *pc = (camera_cli_s *)camera;
3431 if (!pc || !pc->cb_info || !flip) {
3432 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3433 return CAMERA_ERROR_INVALID_PARAMETER;
3436 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3438 if (ret == CAMERA_ERROR_NONE)
3439 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3445 int camera_set_display_visible(camera_h camera, bool visible)
3447 int ret = CAMERA_ERROR_NONE;
3448 int set_visible = (int)visible;
3449 camera_cli_s *pc = (camera_cli_s *)camera;
3450 camera_msg_param param;
3452 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3454 if (pc->cb_info->is_evas_render) {
3455 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3456 if (ret != MM_ERROR_NONE) {
3457 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3458 return CAMERA_ERROR_INVALID_OPERATION;
3462 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3464 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3470 int camera_is_display_visible(camera_h camera, bool *visible)
3472 int ret = CAMERA_ERROR_NONE;
3473 camera_cli_s *pc = (camera_cli_s *)camera;
3475 if (!pc || !pc->cb_info || !visible) {
3476 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3477 return CAMERA_ERROR_INVALID_PARAMETER;
3480 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3482 if (ret == CAMERA_ERROR_NONE)
3483 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3489 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3491 int ret = CAMERA_ERROR_NONE;
3492 int set_mode = (int)mode;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3494 camera_msg_param param;
3496 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3498 if (pc->cb_info->is_evas_render) {
3499 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3500 if (ret != MM_ERROR_NONE) {
3501 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3502 return CAMERA_ERROR_INVALID_OPERATION;
3506 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3508 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3514 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3516 int ret = CAMERA_ERROR_NONE;
3517 camera_cli_s *pc = (camera_cli_s *)camera;
3519 if (!pc || !pc->cb_info || !mode) {
3520 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3521 return CAMERA_ERROR_INVALID_PARAMETER;
3524 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3526 if (ret == CAMERA_ERROR_NONE)
3527 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3533 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3535 int ret = CAMERA_ERROR_NONE;
3536 int set_hint = (int)hint;
3537 camera_cli_s *pc = (camera_cli_s *)camera;
3538 camera_msg_param param;
3540 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3542 CAM_LOG_INFO("Enter - hint %d", set_hint);
3544 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3546 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3552 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3554 int ret = CAMERA_ERROR_NONE;
3555 camera_cli_s *pc = (camera_cli_s *)camera;
3556 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3558 if (!pc || !pc->cb_info || !hint) {
3559 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3560 return CAMERA_ERROR_INVALID_PARAMETER;
3563 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3565 if (ret == CAMERA_ERROR_NONE) {
3566 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3567 CAM_LOG_INFO("display reuse hint %d", *hint);
3574 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3576 int ret = CAMERA_ERROR_NONE;
3577 camera_cli_s *pc = (camera_cli_s *)camera;
3578 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3580 if (!pc || !pc->cb_info || !width || !height) {
3581 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3582 return CAMERA_ERROR_INVALID_PARAMETER;
3585 CAM_LOG_INFO("Enter");
3587 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3589 if (ret == CAMERA_ERROR_NONE) {
3590 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3591 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3594 CAM_LOG_INFO("ret : 0x%x", ret);
3600 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3602 int ret = CAMERA_ERROR_NONE;
3603 camera_cli_s *pc = (camera_cli_s *)camera;
3604 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3606 if (!pc || !pc->cb_info || !format) {
3607 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3608 return CAMERA_ERROR_INVALID_PARAMETER;
3611 CAM_LOG_INFO("Enter");
3613 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3615 if (ret == CAMERA_ERROR_NONE)
3616 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3618 CAM_LOG_INFO("ret : 0x%x", ret);
3624 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3626 int ret = CAMERA_ERROR_NONE;
3627 camera_cli_s *pc = (camera_cli_s *)camera;
3628 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3630 if (!pc || !pc->cb_info || !format) {
3631 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3632 return CAMERA_ERROR_INVALID_PARAMETER;
3635 CAM_LOG_INFO("Enter");
3637 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3639 if (ret == CAMERA_ERROR_NONE)
3640 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3642 CAM_LOG_INFO("ret : 0x%x", ret);
3648 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3650 int ret = CAMERA_ERROR_NONE;
3651 camera_cli_s *pc = (camera_cli_s *)camera;
3652 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3654 if (!pc || !pc->cb_info || !facing_direction) {
3655 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3656 return CAMERA_ERROR_INVALID_PARAMETER;
3659 CAM_LOG_INFO("Enter");
3661 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3663 if (ret == CAMERA_ERROR_NONE)
3664 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3666 CAM_LOG_INFO("ret : 0x%x", ret);
3672 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3674 int ret = CAMERA_ERROR_NONE;
3675 camera_cli_s *pc = (camera_cli_s *)camera;
3676 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3678 if (!pc || !pc->cb_info || !callback) {
3679 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3680 return CAMERA_ERROR_INVALID_PARAMETER;
3683 CAM_LOG_INFO("Enter");
3685 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3687 if (ret == CAMERA_ERROR_NONE) {
3688 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3690 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3691 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3693 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3696 CAM_LOG_INFO("ret : 0x%x", ret);
3702 int camera_unset_preview_cb(camera_h camera)
3704 int ret = CAMERA_ERROR_NONE;
3705 camera_cli_s *pc = (camera_cli_s *)camera;
3706 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3708 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3710 CAM_LOG_INFO("Enter");
3712 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3714 if (ret == CAMERA_ERROR_NONE) {
3715 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3717 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3718 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3720 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3723 CAM_LOG_INFO("ret : 0x%x", ret);
3729 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3731 int ret = CAMERA_ERROR_NONE;
3732 camera_cli_s *pc = (camera_cli_s *)camera;
3733 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3735 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3737 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3738 CAM_LOG_ERROR("NOT SUPPORTED");
3739 return CAMERA_ERROR_NOT_SUPPORTED;
3742 if (callback == NULL) {
3743 CAM_LOG_ERROR("NULL callback");
3744 return CAMERA_ERROR_INVALID_PARAMETER;
3747 CAM_LOG_INFO("Enter");
3749 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3751 if (ret == CAMERA_ERROR_NONE) {
3752 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3754 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3755 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3757 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3760 CAM_LOG_INFO("ret : 0x%x", ret);
3766 int camera_unset_media_packet_preview_cb(camera_h camera)
3768 int ret = CAMERA_ERROR_NONE;
3769 camera_cli_s *pc = (camera_cli_s *)camera;
3770 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3772 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3774 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3775 CAM_LOG_ERROR("NOT SUPPORTED");
3776 return CAMERA_ERROR_NOT_SUPPORTED;
3779 CAM_LOG_INFO("Enter");
3781 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3783 if (ret == CAMERA_ERROR_NONE) {
3784 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3786 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3787 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3789 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3792 CAM_LOG_INFO("ret : 0x%x", ret);
3798 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3800 int ret = CAMERA_ERROR_NONE;
3801 camera_cli_s *pc = (camera_cli_s *)camera;
3802 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3804 if (!pc || !pc->cb_info || !callback) {
3805 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3806 return CAMERA_ERROR_INVALID_PARAMETER;
3809 CAM_LOG_INFO("Enter");
3811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3813 if (ret == CAMERA_ERROR_NONE) {
3814 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3816 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3817 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3819 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3822 CAM_LOG_INFO("ret : 0x%x", ret);
3828 int camera_unset_state_changed_cb(camera_h camera)
3830 int ret = CAMERA_ERROR_NONE;
3831 camera_cli_s *pc = (camera_cli_s *)camera;
3832 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3834 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3836 CAM_LOG_INFO("Enter");
3838 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3840 if (ret == CAMERA_ERROR_NONE) {
3841 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3846 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3849 CAM_LOG_INFO("ret : 0x%x", ret);
3855 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3857 int ret = CAMERA_ERROR_NONE;
3858 camera_cli_s *pc = (camera_cli_s *)camera;
3859 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3861 if (!pc || !pc->cb_info || !callback) {
3862 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3863 return CAMERA_ERROR_INVALID_PARAMETER;
3866 CAM_LOG_INFO("Enter");
3868 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3876 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3879 CAM_LOG_INFO("ret : 0x%x", ret);
3885 int camera_unset_interrupted_cb(camera_h camera)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3891 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3893 CAM_LOG_INFO("Enter");
3895 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3897 if (ret == CAMERA_ERROR_NONE) {
3898 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3900 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3901 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3903 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3906 CAM_LOG_INFO("ret : 0x%x", ret);
3912 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3914 int ret = CAMERA_ERROR_NONE;
3915 camera_cli_s *pc = (camera_cli_s *)camera;
3916 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3918 if (!pc || !pc->cb_info || !callback) {
3919 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3920 return CAMERA_ERROR_INVALID_PARAMETER;
3923 CAM_LOG_INFO("Enter");
3925 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3927 if (ret == CAMERA_ERROR_NONE) {
3928 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3930 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3931 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3933 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3936 CAM_LOG_INFO("ret : 0x%x", ret);
3942 int camera_unset_interrupt_started_cb(camera_h camera)
3944 int ret = CAMERA_ERROR_NONE;
3945 camera_cli_s *pc = (camera_cli_s *)camera;
3946 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3948 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3950 CAM_LOG_INFO("Enter");
3952 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3954 if (ret == CAMERA_ERROR_NONE) {
3955 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3957 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3958 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3960 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3963 CAM_LOG_INFO("ret : 0x%x", ret);
3969 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3971 int ret = CAMERA_ERROR_NONE;
3972 camera_cli_s *pc = (camera_cli_s *)camera;
3973 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3975 if (!pc || !pc->cb_info || !callback) {
3976 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3977 return CAMERA_ERROR_INVALID_PARAMETER;
3980 CAM_LOG_INFO("Enter");
3982 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3984 if (ret == CAMERA_ERROR_NONE) {
3985 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3987 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3988 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3990 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3993 CAM_LOG_INFO("ret : 0x%x", ret);
3999 int camera_unset_focus_changed_cb(camera_h camera)
4001 int ret = CAMERA_ERROR_NONE;
4002 camera_cli_s *pc = (camera_cli_s *)camera;
4003 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4005 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4007 CAM_LOG_INFO("Enter");
4009 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4011 if (ret == CAMERA_ERROR_NONE) {
4012 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4014 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4015 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4017 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4020 CAM_LOG_INFO("ret : 0x%x", ret);
4026 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4028 int ret = CAMERA_ERROR_NONE;
4029 camera_cli_s *pc = (camera_cli_s *)camera;
4030 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4032 if (!pc || !pc->cb_info || !callback) {
4033 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4034 return CAMERA_ERROR_INVALID_PARAMETER;
4037 CAM_LOG_INFO("Enter");
4039 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4041 if (ret == CAMERA_ERROR_NONE) {
4042 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4044 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4045 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4047 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4050 CAM_LOG_INFO("ret : 0x%x", ret);
4056 int camera_unset_error_cb(camera_h camera)
4058 int ret = CAMERA_ERROR_NONE;
4059 camera_cli_s *pc = (camera_cli_s *)camera;
4060 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4062 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4064 CAM_LOG_INFO("Enter");
4066 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4068 if (ret == CAMERA_ERROR_NONE) {
4069 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4071 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4072 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4074 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4077 CAM_LOG_INFO("ret : 0x%x", ret);
4083 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4085 int ret = CAMERA_ERROR_NONE;
4086 camera_cli_s *pc = (camera_cli_s *)camera;
4087 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4089 if (!pc || !pc->cb_info || !foreach_cb) {
4090 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4091 return CAMERA_ERROR_INVALID_PARAMETER;
4094 CAM_LOG_INFO("Enter");
4096 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4097 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4099 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4101 CAM_LOG_INFO("ret : 0x%x", ret);
4107 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4109 int ret = CAMERA_ERROR_NONE;
4110 camera_cli_s *pc = (camera_cli_s *)camera;
4111 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4113 if (!pc || !pc->cb_info || !foreach_cb) {
4114 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4115 return CAMERA_ERROR_INVALID_PARAMETER;
4118 CAM_LOG_INFO("Enter");
4120 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4121 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4123 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4125 CAM_LOG_INFO("ret : 0x%x", ret);
4131 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4133 int ret = CAMERA_ERROR_NONE;
4134 camera_cli_s *pc = (camera_cli_s *)camera;
4135 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4137 if (!pc || !pc->cb_info || !foreach_cb) {
4138 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4139 return CAMERA_ERROR_INVALID_PARAMETER;
4142 CAM_LOG_INFO("Enter");
4144 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4145 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4147 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4149 CAM_LOG_INFO("ret : 0x%x", ret);
4155 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4161 if (!pc || !pc->cb_info || !foreach_cb) {
4162 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4163 return CAMERA_ERROR_INVALID_PARAMETER;
4166 CAM_LOG_INFO("Enter");
4168 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4169 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4171 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4173 CAM_LOG_INFO("ret : 0x%x", ret);
4179 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4181 int ret = CAMERA_ERROR_NONE;
4182 camera_cli_s *pc = (camera_cli_s *)camera;
4183 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4185 if (!pc || !pc->cb_info || !width || !height) {
4186 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4187 return CAMERA_ERROR_INVALID_PARAMETER;
4190 CAM_LOG_INFO("Enter");
4191 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4193 if (ret == CAMERA_ERROR_NONE) {
4194 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4195 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4198 CAM_LOG_INFO("ret : 0x%x", ret);
4204 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4206 int ret = CAMERA_ERROR_NONE;
4207 camera_cli_s *pc = (camera_cli_s *)camera;
4208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4210 if (!pc || !pc->cb_info || !angle) {
4211 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4212 return CAMERA_ERROR_INVALID_PARAMETER;
4215 CAM_LOG_INFO("Enter");
4217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4219 if (ret == CAMERA_ERROR_NONE)
4220 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4222 CAM_LOG_INFO("ret : 0x%x", ret);
4228 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4230 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4234 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4236 int ret = CAMERA_ERROR_NONE;
4237 camera_cli_s *pc = (camera_cli_s *)camera;
4238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4240 if (!pc || !pc->cb_info || !mode) {
4241 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4242 return CAMERA_ERROR_INVALID_PARAMETER;
4245 CAM_LOG_INFO("Enter");
4247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4249 if (ret == CAMERA_ERROR_NONE)
4250 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4252 CAM_LOG_INFO("ret : 0x%x", ret);
4258 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4260 int ret = CAMERA_ERROR_NONE;
4261 camera_cli_s *pc = (camera_cli_s *)camera;
4262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4264 if (!pc || !pc->cb_info || !foreach_cb) {
4265 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4266 return CAMERA_ERROR_INVALID_PARAMETER;
4269 CAM_LOG_INFO("Enter");
4271 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4272 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4274 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4276 CAM_LOG_INFO("Finish, return :%x", ret);
4282 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4284 int ret = CAMERA_ERROR_NONE;
4285 camera_cli_s *pc = (camera_cli_s *)camera;
4286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4287 camera_msg_param param;
4288 int set_fps = (int)fps;
4290 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4292 CAM_LOG_INFO("Enter");
4294 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4296 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4298 CAM_LOG_INFO("ret : 0x%x", ret);
4304 int camera_attr_set_image_quality(camera_h camera, int quality)
4306 int ret = CAMERA_ERROR_NONE;
4307 camera_cli_s *pc = (camera_cli_s *)camera;
4308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4309 camera_msg_param param;
4311 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4313 CAM_LOG_INFO("Enter");
4315 CAMERA_MSG_PARAM_SET(param, INT, quality);
4317 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4319 CAM_LOG_INFO("ret : 0x%x", ret);
4325 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4331 if (!pc || !pc->cb_info || !fps) {
4332 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4336 CAM_LOG_INFO("Enter");
4338 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4340 if (ret == CAMERA_ERROR_NONE)
4341 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4343 CAM_LOG_INFO("ret : 0x%x", ret);
4349 int camera_attr_get_image_quality(camera_h camera, int *quality)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4355 if (!pc || !pc->cb_info || !quality) {
4356 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4357 return CAMERA_ERROR_INVALID_PARAMETER;
4360 CAM_LOG_INFO("Enter");
4362 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4364 if (ret == CAMERA_ERROR_NONE)
4365 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4367 CAM_LOG_INFO("ret : 0x%x", ret);
4373 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4375 int ret = CAMERA_ERROR_NONE;
4376 camera_cli_s *pc = (camera_cli_s *)camera;
4377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4379 if (!pc || !pc->cb_info || !bitrate) {
4380 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4381 return CAMERA_ERROR_INVALID_PARAMETER;
4384 CAM_LOG_INFO("Enter");
4386 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4388 if (ret == CAMERA_ERROR_NONE)
4389 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4391 CAM_LOG_INFO("ret : 0x%x", ret);
4397 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4399 int ret = CAMERA_ERROR_NONE;
4400 camera_cli_s *pc = (camera_cli_s *)camera;
4401 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4402 camera_msg_param param;
4403 int set_bitrate = bitrate;
4405 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4407 CAM_LOG_INFO("Enter");
4409 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4411 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4413 CAM_LOG_INFO("ret : 0x%x", ret);
4419 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4421 int ret = CAMERA_ERROR_NONE;
4422 camera_cli_s *pc = (camera_cli_s *)camera;
4423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4425 if (!pc || !pc->cb_info || !interval) {
4426 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4427 return CAMERA_ERROR_INVALID_PARAMETER;
4430 CAM_LOG_INFO("Enter");
4432 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4434 if (ret == CAMERA_ERROR_NONE)
4435 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4437 CAM_LOG_INFO("ret : 0x%x", ret);
4443 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4445 int ret = CAMERA_ERROR_NONE;
4446 camera_cli_s *pc = (camera_cli_s *)camera;
4447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4448 camera_msg_param param;
4449 int set_gop_interval = interval;
4451 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4453 CAM_LOG_INFO("Enter");
4455 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4457 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4459 CAM_LOG_INFO("ret : 0x%x", ret);
4465 int camera_attr_set_zoom(camera_h camera, int zoom)
4467 int ret = CAMERA_ERROR_NONE;
4468 camera_cli_s *pc = (camera_cli_s *)camera;
4469 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4470 camera_msg_param param;
4472 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4474 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4476 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4478 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4480 CAM_LOG_INFO("ret : 0x%x", ret);
4486 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4488 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4492 int camera_attr_set_af_area(camera_h camera, int x, int y)
4494 int ret = CAMERA_ERROR_NONE;
4495 camera_cli_s *pc = (camera_cli_s *)camera;
4496 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4497 camera_msg_param param;
4500 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4502 CAM_LOG_INFO("Enter - %d,%d", x, y);
4504 value = (x << 16) | y;
4505 CAMERA_MSG_PARAM_SET(param, INT, value);
4507 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4509 CAM_LOG_INFO("ret : 0x%x", ret);
4515 int camera_attr_clear_af_area(camera_h camera)
4517 int ret = CAMERA_ERROR_NONE;
4518 camera_cli_s *pc = (camera_cli_s *)camera;
4519 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4521 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4523 CAM_LOG_INFO("Enter");
4525 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4527 CAM_LOG_INFO("ret : 0x%x", ret);
4533 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4535 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4539 int camera_attr_set_exposure(camera_h camera, int value)
4541 int ret = CAMERA_ERROR_NONE;
4542 camera_cli_s *pc = (camera_cli_s *)camera;
4543 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4544 camera_msg_param param;
4546 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4548 CAM_LOG_INFO("Enter");
4550 CAMERA_MSG_PARAM_SET(param, INT, value);
4552 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4554 CAM_LOG_INFO("ret : 0x%x", ret);
4560 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4562 int ret = CAMERA_ERROR_NONE;
4563 camera_cli_s *pc = (camera_cli_s *)camera;
4564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4565 camera_msg_param param;
4566 int set_iso = (int)iso;
4568 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4570 CAM_LOG_INFO("Enter");
4572 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4574 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4576 CAM_LOG_INFO("ret : 0x%x", ret);
4582 int camera_attr_set_brightness(camera_h camera, int level)
4584 int ret = CAMERA_ERROR_NONE;
4585 camera_cli_s *pc = (camera_cli_s *)camera;
4586 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4587 camera_msg_param param;
4589 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4591 CAM_LOG_INFO("Enter");
4593 CAMERA_MSG_PARAM_SET(param, INT, level);
4595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4597 CAM_LOG_INFO("ret : 0x%x", ret);
4603 int camera_attr_set_contrast(camera_h camera, int level)
4605 int ret = CAMERA_ERROR_NONE;
4606 camera_cli_s *pc = (camera_cli_s *)camera;
4607 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4608 camera_msg_param param;
4610 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4612 CAM_LOG_INFO("Enter");
4614 CAMERA_MSG_PARAM_SET(param, INT, level);
4616 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4618 CAM_LOG_INFO("ret : 0x%x", ret);
4624 int camera_attr_set_hue(camera_h camera, int level)
4626 int ret = CAMERA_ERROR_NONE;
4627 camera_cli_s *pc = (camera_cli_s *)camera;
4628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4629 camera_msg_param param;
4631 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4633 CAM_LOG_INFO("Enter");
4635 CAMERA_MSG_PARAM_SET(param, INT, level);
4637 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4639 CAM_LOG_INFO("ret : 0x%x", ret);
4645 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4647 int ret = CAMERA_ERROR_NONE;
4648 camera_cli_s *pc = (camera_cli_s *)camera;
4649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4650 camera_msg_param param;
4651 int set_whitebalance = (int)wb;
4653 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4655 CAM_LOG_INFO("Enter");
4657 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4659 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4661 CAM_LOG_INFO("ret : 0x%x", ret);
4667 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
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_EFFECT;
4672 camera_msg_param param;
4673 int set_effect = (int)effect;
4675 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4677 CAM_LOG_INFO("Enter");
4679 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4683 CAM_LOG_INFO("ret : 0x%x", ret);
4689 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4691 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4695 int camera_attr_enable_tag(camera_h camera, bool enable)
4697 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4701 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4703 int ret = CAMERA_ERROR_NONE;
4704 camera_cli_s *pc = (camera_cli_s *)camera;
4705 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4706 camera_msg_param param;
4708 if (!pc || !pc->cb_info || !description) {
4709 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4710 return CAMERA_ERROR_INVALID_PARAMETER;
4713 CAM_LOG_INFO("Enter");
4715 CAMERA_MSG_PARAM_SET(param, STRING, description);
4717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4719 CAM_LOG_INFO("ret : 0x%x", ret);
4725 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4727 int ret = CAMERA_ERROR_NONE;
4728 camera_cli_s *pc = (camera_cli_s *)camera;
4729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4730 camera_msg_param param;
4731 int set_orientation = (int)orientation;
4733 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4735 CAM_LOG_INFO("Enter");
4737 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4739 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4741 CAM_LOG_INFO("ret : 0x%x", ret);
4747 int camera_attr_set_tag_software(camera_h camera, const char *software)
4749 int ret = CAMERA_ERROR_NONE;
4750 camera_cli_s *pc = (camera_cli_s *)camera;
4751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4752 camera_msg_param param;
4754 if (!pc || !pc->cb_info || !software) {
4755 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4756 return CAMERA_ERROR_INVALID_PARAMETER;
4759 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4761 CAMERA_MSG_PARAM_SET(param, STRING, software);
4763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4765 CAM_LOG_INFO("ret : 0x%x", ret);
4771 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4773 int ret = CAMERA_ERROR_NONE;
4774 camera_cli_s *pc = (camera_cli_s *)camera;
4775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4776 double set_geotag[3] = {latitude, longitude, altitude};
4780 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4782 CAM_LOG_INFO("Enter");
4784 length = sizeof(set_geotag) / sizeof(int) + \
4785 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4787 msg = muse_core_msg_new(api,
4788 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4791 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4797 int camera_attr_remove_geotag(camera_h camera)
4799 int ret = CAMERA_ERROR_NONE;
4800 camera_cli_s *pc = (camera_cli_s *)camera;
4801 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4803 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4805 CAM_LOG_INFO("Enter");
4807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4809 CAM_LOG_INFO("ret : 0x%x", ret);
4815 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4817 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4821 int camera_attr_get_zoom(camera_h camera, int *zoom)
4823 int ret = CAMERA_ERROR_NONE;
4824 camera_cli_s *pc = (camera_cli_s *)camera;
4825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4827 if (!pc || !pc->cb_info || !zoom) {
4828 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4832 CAM_LOG_INFO("Enter");
4834 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4836 if (ret == CAMERA_ERROR_NONE)
4837 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4839 CAM_LOG_INFO("ret : 0x%x", ret);
4845 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4847 int ret = CAMERA_ERROR_NONE;
4848 camera_cli_s *pc = (camera_cli_s *)camera;
4849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4851 if (!pc || !pc->cb_info || !min || !max) {
4852 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4853 return CAMERA_ERROR_INVALID_PARAMETER;
4856 CAM_LOG_INFO("Enter");
4858 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4860 if (ret == CAMERA_ERROR_NONE) {
4861 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4862 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4865 CAM_LOG_INFO("ret : 0x%x", ret);
4871 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4877 if (!pc || !pc->cb_info || !mode) {
4878 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4879 return CAMERA_ERROR_INVALID_PARAMETER;
4882 CAM_LOG_INFO("Enter");
4884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4886 if (ret == CAMERA_ERROR_NONE)
4887 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4889 CAM_LOG_INFO("ret : 0x%x", ret);
4895 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4897 int ret = CAMERA_ERROR_NONE;
4898 camera_cli_s *pc = (camera_cli_s *)camera;
4899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4901 if (!pc || !pc->cb_info || !mode) {
4902 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4903 return CAMERA_ERROR_INVALID_PARAMETER;
4906 CAM_LOG_INFO("Enter");
4908 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4910 if (ret == CAMERA_ERROR_NONE)
4911 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4913 CAM_LOG_INFO("ret : 0x%x", ret);
4919 int camera_attr_get_exposure(camera_h camera, int *value)
4921 int ret = CAMERA_ERROR_NONE;
4922 camera_cli_s *pc = (camera_cli_s *)camera;
4923 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4925 if (!pc || !pc->cb_info || !value) {
4926 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
4927 return CAMERA_ERROR_INVALID_PARAMETER;
4930 CAM_LOG_INFO("Enter");
4932 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4934 if (ret == CAMERA_ERROR_NONE)
4935 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
4937 CAM_LOG_INFO("ret : 0x%x", ret);
4943 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4945 int ret = CAMERA_ERROR_NONE;
4946 camera_cli_s *pc = (camera_cli_s *)camera;
4947 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4949 if (!pc || !pc->cb_info || !min || !max) {
4950 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
4951 return CAMERA_ERROR_INVALID_PARAMETER;
4954 CAM_LOG_INFO("Enter");
4956 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4958 if (ret == CAMERA_ERROR_NONE) {
4959 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
4960 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
4963 CAM_LOG_INFO("ret : 0x%x", ret);
4969 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4971 int ret = CAMERA_ERROR_NONE;
4972 camera_cli_s *pc = (camera_cli_s *)camera;
4973 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4975 if (!pc || !pc->cb_info || !iso) {
4976 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
4977 return CAMERA_ERROR_INVALID_PARAMETER;
4980 CAM_LOG_INFO("Enter");
4982 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4984 if (ret == CAMERA_ERROR_NONE)
4985 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
4987 CAM_LOG_INFO("ret : 0x%x", ret);
4993 int camera_attr_get_brightness(camera_h camera, int *level)
4995 int ret = CAMERA_ERROR_NONE;
4996 camera_cli_s *pc = (camera_cli_s *)camera;
4997 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4999 if (!pc || !pc->cb_info || !level) {
5000 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5001 return CAMERA_ERROR_INVALID_PARAMETER;
5004 CAM_LOG_INFO("Enter");
5006 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5008 if (ret == CAMERA_ERROR_NONE)
5009 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5011 CAM_LOG_INFO("ret : 0x%x", ret);
5017 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5019 int ret = CAMERA_ERROR_NONE;
5020 camera_cli_s *pc = (camera_cli_s *)camera;
5021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5023 if (!pc || !pc->cb_info || !min || !max) {
5024 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5025 return CAMERA_ERROR_INVALID_PARAMETER;
5028 CAM_LOG_INFO("Enter");
5030 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5032 if (ret == CAMERA_ERROR_NONE) {
5033 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5034 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5037 CAM_LOG_INFO("ret : 0x%x", ret);
5043 int camera_attr_get_contrast(camera_h camera, int *level)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5049 if (!pc || !pc->cb_info || !level) {
5050 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5054 CAM_LOG_INFO("Enter");
5056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5058 if (ret == CAMERA_ERROR_NONE)
5059 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5061 CAM_LOG_INFO("ret : 0x%x", ret);
5067 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5069 int ret = CAMERA_ERROR_NONE;
5070 camera_cli_s *pc = (camera_cli_s *)camera;
5071 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5073 if (!pc || !pc->cb_info || !min || !max) {
5074 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5075 return CAMERA_ERROR_INVALID_PARAMETER;
5078 CAM_LOG_INFO("Enter");
5080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5082 if (ret == CAMERA_ERROR_NONE) {
5083 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5084 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5085 CAM_LOG_INFO("min %d, max %d", *min, *max);
5088 CAM_LOG_INFO("ret : 0x%x", ret);
5094 int camera_attr_get_hue(camera_h camera, int *level)
5096 int ret = CAMERA_ERROR_NONE;
5097 camera_cli_s *pc = (camera_cli_s *)camera;
5098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5100 if (!pc || !pc->cb_info || !level) {
5101 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5105 CAM_LOG_INFO("Enter");
5107 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE)
5110 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5112 CAM_LOG_INFO("ret : 0x%x", ret);
5118 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5120 int ret = CAMERA_ERROR_NONE;
5121 camera_cli_s *pc = (camera_cli_s *)camera;
5122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5124 if (!pc || !pc->cb_info || !min || !max) {
5125 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5126 return CAMERA_ERROR_INVALID_PARAMETER;
5129 CAM_LOG_INFO("Enter");
5131 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5133 if (ret == CAMERA_ERROR_NONE) {
5134 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5135 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5136 CAM_LOG_INFO("min %d, max %d", *min, *max);
5139 CAM_LOG_INFO("ret : 0x%x", ret);
5145 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5147 int ret = CAMERA_ERROR_NONE;
5148 camera_cli_s *pc = (camera_cli_s *)camera;
5149 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5151 if (!pc || !pc->cb_info || !wb) {
5152 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5153 return CAMERA_ERROR_INVALID_PARAMETER;
5156 CAM_LOG_INFO("Enter");
5158 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5160 if (ret == CAMERA_ERROR_NONE)
5161 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5163 CAM_LOG_INFO("ret : 0x%x", ret);
5169 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5171 int ret = CAMERA_ERROR_NONE;
5172 camera_cli_s *pc = (camera_cli_s *)camera;
5173 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5175 if (!pc || !pc->cb_info || !effect) {
5176 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5177 return CAMERA_ERROR_INVALID_PARAMETER;
5180 CAM_LOG_INFO("Enter");
5182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5184 if (ret == CAMERA_ERROR_NONE)
5185 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5187 CAM_LOG_INFO("ret : 0x%x", ret);
5193 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5195 int ret = CAMERA_ERROR_NONE;
5196 camera_cli_s *pc = (camera_cli_s *)camera;
5197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5199 if (!pc || !pc->cb_info || !mode) {
5200 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5201 return CAMERA_ERROR_INVALID_PARAMETER;
5204 CAM_LOG_INFO("Enter");
5206 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5208 if (ret == CAMERA_ERROR_NONE)
5209 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5211 CAM_LOG_INFO("ret : 0x%x", ret);
5217 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5219 int ret = CAMERA_ERROR_NONE;
5220 camera_cli_s *pc = (camera_cli_s *)camera;
5221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5223 if (!pc || !pc->cb_info || !enable) {
5224 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5225 return CAMERA_ERROR_INVALID_PARAMETER;
5228 CAM_LOG_INFO("Enter");
5230 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5232 if (ret == CAMERA_ERROR_NONE)
5233 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5235 CAM_LOG_INFO("ret : 0x%x", ret);
5241 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5243 int ret = CAMERA_ERROR_NONE;
5244 camera_cli_s *pc = (camera_cli_s *)camera;
5245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5247 if (!pc || !pc->cb_info || !description) {
5248 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5249 return CAMERA_ERROR_INVALID_PARAMETER;
5252 CAM_LOG_INFO("Enter");
5254 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5256 if (ret == CAMERA_ERROR_NONE)
5257 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5259 CAM_LOG_INFO("ret : 0x%x", ret);
5265 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5267 int ret = CAMERA_ERROR_NONE;
5268 camera_cli_s *pc = (camera_cli_s *)camera;
5269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5271 if (!pc || !pc->cb_info || !orientation) {
5272 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5273 return CAMERA_ERROR_INVALID_PARAMETER;
5276 CAM_LOG_INFO("Enter");
5278 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 if (ret == CAMERA_ERROR_NONE)
5281 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5283 CAM_LOG_INFO("ret : 0x%x", ret);
5289 int camera_attr_get_tag_software(camera_h camera, char **software)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5295 if (!pc || !pc->cb_info || !software) {
5296 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5300 CAM_LOG_INFO("Enter");
5302 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE)
5305 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5307 CAM_LOG_INFO("ret : 0x%x", ret);
5313 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5315 int ret = CAMERA_ERROR_NONE;
5316 camera_cli_s *pc = (camera_cli_s *)camera;
5317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5319 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5320 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5321 return CAMERA_ERROR_INVALID_PARAMETER;
5324 CAM_LOG_INFO("Enter");
5326 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5328 if (ret == CAMERA_ERROR_NONE) {
5329 *latitude = pc->cb_info->get_geotag[0];
5330 *longitude = pc->cb_info->get_geotag[1];
5331 *altitude = pc->cb_info->get_geotag[2];
5334 CAM_LOG_INFO("ret : 0x%x", ret);
5340 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5342 int ret = CAMERA_ERROR_NONE;
5343 camera_cli_s *pc = (camera_cli_s *)camera;
5344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5346 if (!pc || !pc->cb_info || !mode) {
5347 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5348 return CAMERA_ERROR_INVALID_PARAMETER;
5351 CAM_LOG_INFO("Enter");
5353 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5355 if (ret == CAMERA_ERROR_NONE)
5356 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5358 CAM_LOG_INFO("ret : 0x%x", ret);
5364 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5366 int ret = CAMERA_ERROR_NONE;
5367 int get_flash_state = 0;
5370 CAM_LOG_ERROR("NULL pointer");
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5374 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5375 (int)device, "get_flash_state", &get_flash_state);
5377 if (ret == CAMERA_ERROR_NONE) {
5378 *state = (camera_flash_state_e)get_flash_state;
5379 CAM_LOG_INFO("flash state %d", *state);
5381 CAM_LOG_ERROR("failed 0x%x", ret);
5388 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5390 int ret = CAMERA_ERROR_NONE;
5391 camera_cli_s *pc = (camera_cli_s *)camera;
5392 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5394 if (!pc || !pc->cb_info || !foreach_cb) {
5395 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5396 return CAMERA_ERROR_INVALID_PARAMETER;
5399 CAM_LOG_INFO("Enter");
5401 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5402 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5404 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5406 CAM_LOG_INFO("ret : 0x%x", ret);
5412 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5414 int ret = CAMERA_ERROR_NONE;
5415 camera_cli_s *pc = (camera_cli_s *)camera;
5416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5418 if (!pc || !pc->cb_info || !foreach_cb) {
5419 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5420 return CAMERA_ERROR_INVALID_PARAMETER;
5423 CAM_LOG_INFO("Enter");
5425 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5426 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5428 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5430 CAM_LOG_INFO("ret : 0x%x", ret);
5436 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5438 int ret = CAMERA_ERROR_NONE;
5439 camera_cli_s *pc = (camera_cli_s *)camera;
5440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5442 if (!pc || !pc->cb_info || !foreach_cb) {
5443 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5444 return CAMERA_ERROR_INVALID_PARAMETER;
5447 CAM_LOG_INFO("Enter");
5449 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5450 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5452 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5454 CAM_LOG_INFO("ret : 0x%x", ret);
5460 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5462 int ret = CAMERA_ERROR_NONE;
5463 camera_cli_s *pc = (camera_cli_s *)camera;
5464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5466 if (!pc || !pc->cb_info || !foreach_cb) {
5467 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5468 return CAMERA_ERROR_INVALID_PARAMETER;
5471 CAM_LOG_INFO("Enter");
5473 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5474 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5476 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5478 CAM_LOG_INFO("ret : 0x%x", ret);
5484 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5486 int ret = CAMERA_ERROR_NONE;
5487 camera_cli_s *pc = (camera_cli_s *)camera;
5488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5490 if (!pc || !pc->cb_info || !foreach_cb) {
5491 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5492 return CAMERA_ERROR_INVALID_PARAMETER;
5495 CAM_LOG_INFO("Enter");
5497 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5498 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5500 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5502 CAM_LOG_INFO("ret : 0x%x", ret);
5508 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5510 int ret = CAMERA_ERROR_NONE;
5511 camera_cli_s *pc = (camera_cli_s *)camera;
5512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5514 if (!pc || !pc->cb_info || !foreach_cb) {
5515 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5516 return CAMERA_ERROR_INVALID_PARAMETER;
5519 CAM_LOG_INFO("Enter");
5521 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5522 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5524 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5526 CAM_LOG_INFO("ret : 0x%x", ret);
5532 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5534 int ret = CAMERA_ERROR_NONE;
5535 camera_cli_s *pc = (camera_cli_s *)camera;
5536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5538 if (!pc || !pc->cb_info || !foreach_cb) {
5539 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5540 return CAMERA_ERROR_INVALID_PARAMETER;
5543 CAM_LOG_INFO("Enter");
5545 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5546 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5548 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5550 CAM_LOG_INFO("ret : 0x%x", ret);
5556 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5558 int ret = CAMERA_ERROR_NONE;
5559 camera_cli_s *pc = (camera_cli_s *)camera;
5560 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5562 if (!pc || !pc->cb_info || !foreach_cb) {
5563 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5564 return CAMERA_ERROR_INVALID_PARAMETER;
5567 CAM_LOG_INFO("Enter");
5569 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5570 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5572 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5574 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5580 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)
5582 int ret = CAMERA_ERROR_NONE;
5583 camera_cli_s *pc = (camera_cli_s *)camera;
5584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5585 camera_msg_param param;
5588 if (!pc || !pc->cb_info || !foreach_cb) {
5589 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5590 return CAMERA_ERROR_INVALID_PARAMETER;
5593 CAM_LOG_INFO("Enter");
5595 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5596 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5598 value = (width << 16) | height;
5599 CAMERA_MSG_PARAM_SET(param, INT, value);
5601 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5603 CAM_LOG_INFO("ret : 0x%x", ret);
5609 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5611 int ret = CAMERA_ERROR_NONE;
5612 camera_cli_s *pc = (camera_cli_s *)camera;
5613 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5615 if (!pc || !pc->cb_info || !foreach_cb) {
5616 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5617 return CAMERA_ERROR_INVALID_PARAMETER;
5620 CAM_LOG_INFO("Enter");
5622 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5623 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5625 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5627 CAM_LOG_INFO("ret : 0x%x", ret);
5633 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5635 int ret = CAMERA_ERROR_NONE;
5636 camera_cli_s *pc = (camera_cli_s *)camera;
5637 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5639 if (!pc || !pc->cb_info || !foreach_cb) {
5640 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5641 return CAMERA_ERROR_INVALID_PARAMETER;
5644 CAM_LOG_INFO("Enter");
5646 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5649 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5651 CAM_LOG_INFO("ret : 0x%x", ret);
5657 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5659 int ret = CAMERA_ERROR_NONE;
5660 camera_cli_s *pc = (camera_cli_s *)camera;
5661 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5662 camera_msg_param param;
5663 int set_rotation = (int)rotation;
5665 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5667 CAM_LOG_INFO("Enter");
5669 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5671 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5673 CAM_LOG_INFO("ret : 0x%x", ret);
5679 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5681 int ret = CAMERA_ERROR_NONE;
5682 camera_cli_s *pc = (camera_cli_s *)camera;
5683 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5685 if (!pc || !pc->cb_info || !rotation) {
5686 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5687 return CAMERA_ERROR_INVALID_PARAMETER;
5690 CAM_LOG_INFO("Enter");
5692 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5694 if (ret == CAMERA_ERROR_NONE)
5695 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5697 CAM_LOG_INFO("ret : 0x%x", ret);
5703 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5705 int ret = CAMERA_ERROR_NONE;
5706 camera_cli_s *pc = (camera_cli_s *)camera;
5707 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5708 camera_msg_param param;
5709 int set_flip = (int)flip;
5711 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5713 CAM_LOG_INFO("Enter");
5715 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5719 CAM_LOG_INFO("ret : 0x%x", ret);
5725 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5727 int ret = CAMERA_ERROR_NONE;
5728 camera_cli_s *pc = (camera_cli_s *)camera;
5729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5731 if (!pc || !pc->cb_info || !flip) {
5732 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5733 return CAMERA_ERROR_INVALID_PARAMETER;
5736 CAM_LOG_INFO("Enter");
5738 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5740 if (ret == CAMERA_ERROR_NONE)
5741 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5743 CAM_LOG_INFO("ret : 0x%x", ret);
5748 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5750 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5754 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5760 if (!pc || !pc->cb_info || !mode) {
5761 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5762 return CAMERA_ERROR_INVALID_PARAMETER;
5765 CAM_LOG_INFO("Enter");
5767 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5769 if (ret == CAMERA_ERROR_NONE)
5770 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5772 CAM_LOG_INFO("ret : 0x%x", ret);
5778 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5780 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5784 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5786 int ret = CAMERA_ERROR_NONE;
5787 camera_cli_s *pc = (camera_cli_s *)camera;
5788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5790 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5792 CAM_LOG_INFO("Enter");
5794 if (!camera_attr_is_supported_hdr_capture(camera)) {
5795 CAM_LOG_ERROR("HDR not supported");
5796 return CAMERA_ERROR_NOT_SUPPORTED;
5800 CAM_LOG_ERROR("NULL callback");
5801 return CAMERA_ERROR_INVALID_PARAMETER;
5804 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5806 if (ret == CAMERA_ERROR_NONE) {
5807 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5812 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5815 CAM_LOG_INFO("ret : 0x%x", ret);
5821 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5823 int ret = CAMERA_ERROR_NONE;
5824 camera_cli_s *pc = (camera_cli_s *)camera;
5825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5827 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5829 CAM_LOG_INFO("Enter");
5831 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5833 if (ret == CAMERA_ERROR_NONE) {
5834 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5839 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5842 CAM_LOG_INFO("ret : 0x%x", ret);
5848 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5850 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5854 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5856 int ret = CAMERA_ERROR_NONE;
5857 camera_cli_s *pc = (camera_cli_s *)camera;
5858 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5860 if (!pc || !pc->cb_info || !enabled) {
5861 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5865 CAM_LOG_INFO("Enter");
5867 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5869 if (ret == CAMERA_ERROR_NONE)
5870 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5872 CAM_LOG_INFO("ret : 0x%x", ret);
5878 bool camera_attr_is_supported_anti_shake(camera_h camera)
5880 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
5884 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5886 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
5890 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5892 int ret = CAMERA_ERROR_NONE;
5893 camera_cli_s *pc = (camera_cli_s *)camera;
5894 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5896 if (!pc || !pc->cb_info || !enabled) {
5897 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5898 return CAMERA_ERROR_INVALID_PARAMETER;
5901 CAM_LOG_INFO("Enter");
5903 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5905 if (ret == CAMERA_ERROR_NONE)
5906 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
5908 CAM_LOG_INFO("ret : 0x%x", ret);
5914 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5916 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
5920 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5922 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
5926 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5928 int ret = CAMERA_ERROR_NONE;
5929 camera_cli_s *pc = (camera_cli_s *)camera;
5930 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5932 if (!pc || !pc->cb_info || !enabled) {
5933 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
5934 return CAMERA_ERROR_INVALID_PARAMETER;
5937 CAM_LOG_INFO("Enter");
5939 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5941 if (ret == CAMERA_ERROR_NONE)
5942 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
5944 CAM_LOG_INFO("ret : 0x%x", ret);
5950 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5952 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
5956 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5958 int ret = CAMERA_ERROR_NONE;
5959 camera_cli_s *pc = (camera_cli_s *)camera;
5960 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5961 camera_msg_param param;
5962 int set_disable = (int)disable;
5964 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5966 CAM_LOG_INFO("Enter");
5968 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5970 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5972 CAM_LOG_INFO("ret : 0x%x", ret);
5978 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5980 int ret = CAMERA_ERROR_NONE;
5981 camera_cli_s *pc = (camera_cli_s *)camera;
5982 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5983 camera_msg_param param0;
5984 camera_msg_param param1;
5986 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5988 CAM_LOG_INFO("Enter");
5990 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
5991 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
5993 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
5994 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
5996 CAM_LOG_INFO("ret : 0x%x", ret);
6002 int camera_attr_get_pan(camera_h camera, int *pan_step)
6004 int ret = CAMERA_ERROR_NONE;
6005 camera_cli_s *pc = (camera_cli_s *)camera;
6006 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6008 if (!pc || !pc->cb_info || !pan_step) {
6009 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6010 return CAMERA_ERROR_INVALID_PARAMETER;
6013 CAM_LOG_INFO("Enter");
6015 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6017 if (ret == CAMERA_ERROR_NONE)
6018 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6020 CAM_LOG_INFO("ret : 0x%x", ret);
6026 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6028 int ret = CAMERA_ERROR_NONE;
6029 camera_cli_s *pc = (camera_cli_s *)camera;
6030 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6032 if (!pc || !pc->cb_info || !min || !max) {
6033 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6034 return CAMERA_ERROR_INVALID_PARAMETER;
6037 CAM_LOG_INFO("Enter");
6039 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6041 if (ret == CAMERA_ERROR_NONE) {
6042 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6043 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6046 CAM_LOG_INFO("ret : 0x%x", ret);
6052 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6054 int ret = CAMERA_ERROR_NONE;
6055 camera_cli_s *pc = (camera_cli_s *)camera;
6056 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6057 camera_msg_param param0;
6058 camera_msg_param param1;
6060 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6062 CAM_LOG_INFO("Enter");
6064 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6065 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6067 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6068 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6070 CAM_LOG_INFO("ret : 0x%x", ret);
6076 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6078 int ret = CAMERA_ERROR_NONE;
6079 camera_cli_s *pc = (camera_cli_s *)camera;
6080 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6082 if (!pc || !pc->cb_info || !tilt_step) {
6083 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6084 return CAMERA_ERROR_INVALID_PARAMETER;
6087 CAM_LOG_INFO("Enter");
6089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6091 if (ret == CAMERA_ERROR_NONE)
6092 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6094 CAM_LOG_INFO("ret : 0x%x", ret);
6100 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6102 int ret = CAMERA_ERROR_NONE;
6103 camera_cli_s *pc = (camera_cli_s *)camera;
6104 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6106 if (!pc || !pc->cb_info || !min || !max) {
6107 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6108 return CAMERA_ERROR_INVALID_PARAMETER;
6111 CAM_LOG_INFO("Enter");
6113 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 if (ret == CAMERA_ERROR_NONE) {
6116 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6117 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6120 CAM_LOG_INFO("ret : 0x%x", ret);
6126 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6128 int ret = CAMERA_ERROR_NONE;
6129 camera_cli_s *pc = (camera_cli_s *)camera;
6130 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6131 camera_msg_param param;
6132 int set_ptz_type = (int)ptz_type;
6134 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6136 CAM_LOG_INFO("Enter");
6138 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6140 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6142 CAM_LOG_INFO("ret : 0x%x", ret);
6148 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6150 int ret = CAMERA_ERROR_NONE;
6151 camera_cli_s *pc = (camera_cli_s *)camera;
6152 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6154 if (!pc || !pc->cb_info || !foreach_cb) {
6155 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6156 return CAMERA_ERROR_INVALID_PARAMETER;
6159 CAM_LOG_INFO("Enter");
6161 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6162 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6164 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6166 CAM_LOG_INFO("ret : 0x%x", ret);
6172 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6174 int ret = CAMERA_ERROR_NONE;
6175 camera_cli_s *pc = (camera_cli_s *)camera;
6176 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6177 int set_display_roi_area[4] = {x, y, width, height};
6181 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6183 CAM_LOG_INFO("Enter");
6185 if (pc->cb_info->is_evas_render) {
6186 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6187 if (ret != MM_ERROR_NONE) {
6188 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6189 return CAMERA_ERROR_INVALID_OPERATION;
6193 length = sizeof(set_display_roi_area) / sizeof(int) + \
6194 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6196 msg = muse_core_msg_new(api,
6197 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6200 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6206 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6208 camera_cli_s *pc = (camera_cli_s *)camera;
6209 int ret = CAMERA_ERROR_NONE;
6210 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6212 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6213 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6214 return CAMERA_ERROR_INVALID_PARAMETER;
6217 CAM_LOG_INFO("Enter");
6219 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6221 if (ret == CAMERA_ERROR_NONE) {
6222 *x = pc->cb_info->get_display_roi_area[0];
6223 *y = pc->cb_info->get_display_roi_area[1];
6224 *width = pc->cb_info->get_display_roi_area[2];
6225 *height = pc->cb_info->get_display_roi_area[3];
6228 CAM_LOG_INFO("ret : 0x%x", ret);
6234 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6236 int ret = CAMERA_ERROR_NONE;
6237 int get_device_state = 0;
6240 CAM_LOG_ERROR("NULL pointer");
6241 return CAMERA_ERROR_INVALID_PARAMETER;
6244 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6245 (int)device, "get_device_state", &get_device_state);
6247 if (ret == CAMERA_ERROR_NONE) {
6248 *state = (camera_device_state_e)get_device_state;
6249 CAM_LOG_INFO("device state %d", *state);
6251 CAM_LOG_ERROR("failed 0x%x", ret);
6258 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6260 int ret = CAMERA_ERROR_NONE;
6261 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6262 camera_cb_info *info = NULL;
6264 if (!callback || !cb_id) {
6265 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6266 return CAMERA_ERROR_INVALID_PARAMETER;
6269 /* check camera support */
6270 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6271 if (ret != CAMERA_ERROR_NONE) {
6272 CAM_LOG_ERROR("get device state failed");
6276 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6278 info = g_new0(camera_cb_info, 1);
6280 CAM_LOG_ERROR("info failed");
6281 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6285 info->id = ++g_cam_dev_state_changed_cb_id;
6286 info->callback = (void *)callback;
6287 info->user_data = user_data;
6291 /* subscribe dbus signal for camera state change */
6292 if (!g_cam_dev_state_changed_cb_conn) {
6293 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6294 if (!g_cam_dev_state_changed_cb_conn) {
6295 CAM_LOG_ERROR("failed to get gdbus connection");
6296 ret = CAMERA_ERROR_INVALID_OPERATION;
6300 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6301 MM_CAMCORDER_DBUS_OBJECT,
6302 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6303 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6305 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6306 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6307 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6308 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6309 CAM_LOG_ERROR("failed to get gdbus connection");
6310 ret = CAMERA_ERROR_INVALID_OPERATION;
6314 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6317 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6319 CAM_LOG_INFO("callback id %d", info->id);
6322 if (ret != CAMERA_ERROR_NONE) {
6328 if (g_cam_dev_state_changed_cb_conn) {
6329 g_object_unref(g_cam_dev_state_changed_cb_conn);
6330 g_cam_dev_state_changed_cb_conn = NULL;
6334 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6340 int camera_remove_device_state_changed_cb(int cb_id)
6342 int ret = CAMERA_ERROR_NONE;
6343 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6344 GList *tmp_list = NULL;
6345 camera_cb_info *info = NULL;
6347 /* check camera support */
6348 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6349 if (ret != CAMERA_ERROR_NONE) {
6350 CAM_LOG_ERROR("get device state failed");
6354 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6356 if (!g_cam_dev_state_changed_cb_list) {
6357 CAM_LOG_ERROR("there is no callback info");
6358 ret = CAMERA_ERROR_INVALID_OPERATION;
6362 tmp_list = g_cam_dev_state_changed_cb_list;
6365 info = tmp_list->data;
6366 tmp_list = tmp_list->next;
6369 CAM_LOG_WARNING("NULL info");
6373 if (info->id == cb_id) {
6374 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6379 if (!g_cam_dev_state_changed_cb_list) {
6380 /* no remained callback */
6381 if (g_cam_dev_state_changed_cb_conn) {
6382 /* unsubscribe signal */
6383 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6384 g_cam_dev_state_changed_cb_subscribe_id = 0;
6386 /* unref connection */
6387 g_object_unref(g_cam_dev_state_changed_cb_conn);
6388 g_cam_dev_state_changed_cb_conn = NULL;
6392 CAM_LOG_INFO("id %d callback removed", cb_id);
6393 ret = CAMERA_ERROR_NONE;
6399 CAM_LOG_ERROR("id %d callback not found", cb_id);
6400 ret = CAMERA_ERROR_INVALID_PARAMETER;
6403 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6410 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6412 int ret = CAMERA_ERROR_NONE;
6413 camera_cli_s *pc = (camera_cli_s *)camera;
6414 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6416 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6418 g_mutex_lock(&pc->cb_info->bridge_lock);
6420 if (pc->cb_info->bridge) {
6421 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6422 ret = CAMERA_ERROR_INVALID_OPERATION;
6423 goto _SET_MEDIA_BRIDGE_DONE;
6426 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6427 if (ret != CAMERA_ERROR_NONE) {
6428 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6429 goto _SET_MEDIA_BRIDGE_DONE;
6432 pc->cb_info->bridge = bridge;
6434 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6436 _SET_MEDIA_BRIDGE_DONE:
6437 g_mutex_unlock(&pc->cb_info->bridge_lock);
6443 int camera_media_bridge_unset_bridge(camera_h camera)
6445 int ret = CAMERA_ERROR_NONE;
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6449 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6451 g_mutex_lock(&pc->cb_info->bridge_lock);
6453 if (!pc->cb_info->bridge) {
6454 CAM_LOG_ERROR("no media bridge");
6455 ret = CAMERA_ERROR_INVALID_OPERATION;
6456 goto _UNSET_MEDIA_BRIDGE_DONE;
6459 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6460 if (ret != CAMERA_ERROR_NONE) {
6461 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6462 goto _UNSET_MEDIA_BRIDGE_DONE;
6465 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6467 pc->cb_info->bridge = NULL;
6469 _UNSET_MEDIA_BRIDGE_DONE:
6470 g_mutex_unlock(&pc->cb_info->bridge_lock);
6477 int camera_create_network(camera_device_e device, camera_h *camera)
6479 return _camera_create_private(device, true, camera);
6483 int camera_device_manager_initialize(camera_device_manager_h *manager)
6486 int ret = CAMERA_ERROR_NONE;
6487 void *dl_handle = NULL;
6488 camera_device_manager *new_manager = NULL;
6489 cdm_symbol_table sym_table[] = {
6490 {(void **)&new_manager->initialize, "cdm_initialize"},
6491 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6492 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6493 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6494 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6497 CAMERA_CHECK_DEVICE_MANAGER;
6499 new_manager = g_new0(camera_device_manager, 1);
6502 CAM_LOG_ERROR("NULL manager");
6503 ret = CAMERA_ERROR_INVALID_PARAMETER;
6504 goto _INITIALIZE_FAILED;
6507 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6509 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6510 ret = CAMERA_ERROR_INVALID_OPERATION;
6511 goto _INITIALIZE_FAILED;
6515 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6516 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6517 if (*sym_table[i].func_ptr == NULL) {
6518 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6519 ret = CAMERA_ERROR_INVALID_OPERATION;
6520 goto _INITIALIZE_FAILED;
6524 ret = new_manager->initialize();
6525 if (ret != CAMERA_ERROR_NONE) {
6526 CAM_LOG_ERROR("failed[0x%x]", ret);
6527 goto _INITIALIZE_FAILED;
6530 new_manager->dl_handle = dl_handle;
6531 *manager = (camera_device_manager_h)new_manager;
6533 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6534 new_manager, dl_handle);
6536 return CAMERA_ERROR_NONE;
6541 g_free(new_manager);
6547 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6549 int ret = CAMERA_ERROR_NONE;
6550 camera_device_manager *m = (camera_device_manager *)manager;
6552 CAMERA_CHECK_DEVICE_MANAGER;
6555 CAM_LOG_ERROR("NULL manager");
6556 return CAMERA_ERROR_INVALID_PARAMETER;
6559 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6561 ret = m->deinitialize();
6562 if (ret != CAMERA_ERROR_NONE) {
6563 CAM_LOG_ERROR("failed[0x%x]", ret);
6567 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6569 dlclose(m->dl_handle);
6571 memset(m, 0x0, sizeof(camera_device_manager));
6574 return CAMERA_ERROR_NONE;
6578 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6580 int ret = CAMERA_ERROR_NONE;
6582 camera_device_list_s device_list;
6583 camera_device_s *device = NULL;
6584 camera_device_manager *m = (camera_device_manager *)manager;
6586 CAMERA_CHECK_DEVICE_MANAGER;
6588 if (!m || !callback) {
6589 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6590 return CAMERA_ERROR_INVALID_PARAMETER;
6593 CAM_LOG_INFO("enter");
6595 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6597 ret = m->get_device_list(&device_list);
6598 if (ret != CAMERA_ERROR_NONE) {
6599 CAM_LOG_ERROR("failed[0x%x]", ret);
6603 CAM_LOG_INFO("device count[%d]", device_list.count);
6605 for (i = 0 ; i < device_list.count ; i++) {
6606 device = &device_list.device[i];
6608 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6609 i, device->type, device->index,
6610 device->name, device->id, device->extra_stream_num);
6612 if (!callback(device, user_data)) {
6613 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6614 i + 1, device_list.count);
6619 return CAMERA_ERROR_NONE;
6623 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
6624 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
6626 int ret = CAMERA_ERROR_NONE;
6627 camera_device_manager *m = (camera_device_manager *)manager;
6629 CAMERA_CHECK_DEVICE_MANAGER;
6631 if (!m || !callback || !cb_id) {
6632 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
6633 return CAMERA_ERROR_INVALID_PARAMETER;
6636 CAM_LOG_INFO("enter");
6638 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
6639 if (ret != CAMERA_ERROR_NONE) {
6640 CAM_LOG_ERROR("failed[0x%x]", ret);
6644 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
6646 return CAMERA_ERROR_NONE;
6650 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
6652 int ret = CAMERA_ERROR_NONE;
6653 camera_device_manager *m = (camera_device_manager *)manager;
6655 CAMERA_CHECK_DEVICE_MANAGER;
6658 CAM_LOG_ERROR("NULL manager");
6659 return CAMERA_ERROR_INVALID_PARAMETER;
6662 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
6664 ret = m->remove_device_connection_changed_cb(cb_id);
6665 if (ret != CAMERA_ERROR_NONE) {
6666 CAM_LOG_ERROR("failed[0x%x]", ret);
6670 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
6672 return CAMERA_ERROR_NONE;
6677 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6679 int ret = CAMERA_ERROR_NONE;
6680 camera_cli_s *pc = (camera_cli_s *)camera;
6681 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6683 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6685 if (!camera_is_supported_extra_preview(camera)) {
6686 CAM_LOG_ERROR("extra preview is not supported");
6687 return CAMERA_ERROR_NOT_SUPPORTED;
6691 CAM_LOG_ERROR("NULL callback");
6692 return CAMERA_ERROR_INVALID_PARAMETER;
6695 CAM_LOG_INFO("Enter");
6697 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6699 if (ret == CAMERA_ERROR_NONE) {
6700 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6705 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6708 CAM_LOG_INFO("ret : 0x%x", ret);
6714 int camera_unset_extra_preview_cb(camera_h camera)
6716 int ret = CAMERA_ERROR_NONE;
6717 camera_cli_s *pc = (camera_cli_s *)camera;
6718 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6720 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6722 if (!camera_is_supported_extra_preview(camera)) {
6723 CAM_LOG_ERROR("extra preview is not supported");
6724 return CAMERA_ERROR_NOT_SUPPORTED;
6727 CAM_LOG_INFO("Enter");
6729 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6731 if (ret == CAMERA_ERROR_NONE) {
6732 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6737 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6740 CAM_LOG_INFO("ret : 0x%x", ret);
6746 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)
6748 int ret = CAMERA_ERROR_NONE;
6749 int stream_format[4] = {pixel_format, width, height, fps};
6751 camera_cli_s *pc = (camera_cli_s *)camera;
6752 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6754 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6756 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6757 stream_id, pixel_format, width, height, fps);
6759 msg = muse_core_msg_new(api,
6760 MUSE_TYPE_INT, "stream_id", stream_id,
6761 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6764 __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6770 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)
6772 int ret = CAMERA_ERROR_NONE;
6773 camera_cli_s *pc = (camera_cli_s *)camera;
6774 camera_msg_param param;
6775 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6777 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6778 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6779 return CAMERA_ERROR_INVALID_PARAMETER;
6782 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6784 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6786 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6788 if (ret == CAMERA_ERROR_NONE) {
6789 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6790 *width = pc->cb_info->get_extra_preview_stream_format[1];
6791 *height = pc->cb_info->get_extra_preview_stream_format[2];
6792 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6795 CAM_LOG_INFO("ret : 0x%x", ret);
6801 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6803 int ret = CAMERA_ERROR_NONE;
6804 camera_cli_s *pc = (camera_cli_s *)camera;
6805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6806 camera_msg_param param0;
6807 camera_msg_param param1;
6809 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6811 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6813 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6814 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6816 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6817 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6819 CAM_LOG_INFO("ret : 0x%x", ret);
6825 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6827 int ret = CAMERA_ERROR_NONE;
6828 camera_cli_s *pc = (camera_cli_s *)camera;
6829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6830 camera_msg_param param;
6832 if (!pc || !pc->cb_info || !bitrate) {
6833 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6834 return CAMERA_ERROR_INVALID_PARAMETER;
6837 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6839 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6841 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6843 if (ret == CAMERA_ERROR_NONE) {
6844 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6845 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6847 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6854 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6856 int ret = CAMERA_ERROR_NONE;
6857 camera_cli_s *pc = (camera_cli_s *)camera;
6858 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6859 camera_msg_param param0;
6860 camera_msg_param param1;
6862 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6864 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6866 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6867 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6869 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6870 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6872 CAM_LOG_INFO("ret : 0x%x", ret);
6878 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6880 int ret = CAMERA_ERROR_NONE;
6881 camera_cli_s *pc = (camera_cli_s *)camera;
6882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6883 camera_msg_param param;
6885 if (!pc || !pc->cb_info || !interval) {
6886 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6887 return CAMERA_ERROR_INVALID_PARAMETER;
6890 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6892 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6894 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6896 if (ret == CAMERA_ERROR_NONE) {
6897 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6898 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6900 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6907 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6909 camera_cli_s *pc = (camera_cli_s *)camera;
6911 if (!pc || !pc->cb_info || !rotation) {
6912 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6913 return CAMERA_ERROR_INVALID_PARAMETER;
6916 if (!pc->cb_info->stream_data) {
6917 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6918 return CAMERA_ERROR_INVALID_OPERATION;
6921 *rotation = pc->cb_info->stream_data->rotation;
6923 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6925 return CAMERA_ERROR_NONE;
6929 int _camera_get_log_level(void)
6931 return g_camera_log_level;