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;\
46 /* for camera device manager */
47 typedef struct _cdm_symbol_table {
49 const char *func_name;
52 /* for device changed callback */
53 static GMutex g_cam_dev_state_changed_cb_lock;
54 static GList *g_cam_dev_state_changed_cb_list;
55 static int g_cam_dev_state_changed_cb_id;
56 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
57 static guint g_cam_dev_state_changed_cb_subscribe_id;
58 static GMutex g_cam_idle_event_lock;
61 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
63 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
64 static void __camera_release_imported_bo(tbm_bo *bo);
66 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
67 camera_media_packet_data *mp_data, media_packet_h *packet);
68 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
69 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
70 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
72 static gboolean __camera_allocate_preview_buffer(camera_h camera);
73 static void __camera_release_preview_buffer(camera_h camera);
74 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
76 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
77 int type, const char *thread_name, camera_cb_info_s *cb_info);
78 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
82 static gboolean __camera_allocate_preview_buffer(camera_h camera)
85 int ret = CAMERA_ERROR_NONE;
86 int format = CAMERA_PIXEL_FORMAT_INVALID;
90 camera_cli_s *pc = (camera_cli_s *)camera;
91 camera_cb_info_s *cb_info = NULL;
93 if (!pc || !pc->cb_info) {
94 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
98 cb_info = pc->cb_info;
100 CAM_LOG_INFO("Enter");
102 /* get preview info and calculate size */
103 ret = camera_get_preview_format(camera, &format);
104 if (ret != CAMERA_ERROR_NONE) {
105 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
109 ret = camera_get_preview_resolution(camera, &width, &height);
110 if (ret != CAMERA_ERROR_NONE) {
111 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
115 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
118 case CAMERA_PIXEL_FORMAT_INVZ:
119 buffer_size = width * height;
121 case CAMERA_PIXEL_FORMAT_NV12:
122 case CAMERA_PIXEL_FORMAT_I420:
123 buffer_size = (width * height * 3) >> 1;
125 case CAMERA_PIXEL_FORMAT_YUYV:
126 case CAMERA_PIXEL_FORMAT_UYVY:
127 buffer_size = width * height * 2;
130 CAM_LOG_ERROR("unhandled format %d", format);
131 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
134 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
136 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
137 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
138 if (!cb_info->bos[i]) {
139 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
140 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
143 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
144 if (cb_info->fds[i] < 0) {
145 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
146 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
149 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
152 CAM_LOG_INFO("Done");
156 _ALLOCATE_PREVIEW_BUFFER_FAILED:
157 __camera_release_preview_buffer(camera);
162 static void __camera_release_preview_buffer(camera_h camera)
165 camera_cli_s *pc = (camera_cli_s *)camera;
166 camera_cb_info_s *cb_info = NULL;
168 if (!pc || !pc->cb_info) {
169 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
173 CAM_LOG_INFO("Enter");
175 cb_info = pc->cb_info;
177 /* close exported fd and bos */
178 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
179 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
181 if (cb_info->bos[i]) {
182 tbm_bo_unref(cb_info->bos[i]);
183 cb_info->bos[i] = NULL;
188 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
189 close(cb_info->fds[i]);
190 cb_info->fds[i] = CAMERA_FD_INIT;
194 CAM_LOG_INFO("Done");
198 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
203 CAM_LOG_WARNING("NULL tfd");
207 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
208 if (!CAMERA_IS_FD_VALID(tfd[i]))
212 tfd[i] = CAMERA_FD_INIT;
217 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
220 api < 0 || api >= MUSE_CAMERA_API_MAX) {
221 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
225 g_mutex_lock(&(cb_info->api_mutex[api]));
226 cb_info->api_waiting[api] += value;
227 g_mutex_unlock(&(cb_info->api_mutex[api]));
229 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
230 api, value, cb_info->api_waiting[api]);
234 static void __camera_device_state_changed_cb(GDBusConnection *connection,
235 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
236 const gchar *signal_name, GVariant *param, gpointer user_data)
239 camera_device_e device = CAMERA_DEVICE_CAMERA0;
240 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
241 GList *tmp_list = NULL;
242 camera_cb_info *info = NULL;
244 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
246 if (!g_cam_dev_state_changed_cb_list || !param) {
247 CAM_LOG_WARNING("no callback or NULL param %p", param);
251 /* get device and state */
252 g_variant_get(param, "(i)", &value);
254 device = value >> 16;
255 state = 0x0000ffff & value;
257 CAM_LOG_INFO("device %d, state %d", device, state);
259 tmp_list = g_cam_dev_state_changed_cb_list;
262 info = (camera_cb_info *)tmp_list->data;
265 if (info->callback) {
266 CAM_LOG_INFO("start id[%d] callback", info->id);
267 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
268 CAM_LOG_INFO("returned id[%d] callback", info->id);
270 CAM_LOG_WARNING("NULL callback for id %d", info->id);
274 tmp_list = tmp_list->next;
278 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
282 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
286 int ret_fd = CAMERA_FD_INIT;
287 int preview_fd = CAMERA_FD_INIT;
288 int num_buffer_fd = 0;
289 unsigned char *buf_pos = NULL;
292 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
293 tbm_bo_handle bo_handle = {.ptr = NULL};
294 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
295 tbm_bo data_bo = NULL;
296 tbm_bo_handle data_bo_handle = {.ptr = NULL};
298 camera_msg_param param;
299 camera_preview_data_s frame;
300 MMCamcorderVideoStreamDataType *stream = NULL;
301 camera_media_packet_data *mp_data = NULL;
302 media_packet_h pkt = NULL;
304 /* tfd[0]: MMCamcorderVideoStreamDataType
305 tfd[1]: data_bo or zero copy bo[0]
306 tfd[2]: zero copy bo[1]
307 tfd[3]: zero copy bo[2] */
309 if (!cb_info || !recv_msg || !tfd) {
310 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
314 muse_camera_msg_get(preview_fd, recv_msg);
315 muse_camera_msg_get(num_buffer_fd, recv_msg);
317 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
319 memset(&frame, 0x0, sizeof(camera_preview_data_s));
322 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
327 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
329 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
330 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
331 goto _PREVIEW_CB_HANDLER_DONE;
334 /* import tbm bo and get virtual address */
335 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
336 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
337 goto _PREVIEW_CB_HANDLER_DONE;
340 buf_pos = (unsigned char *)bo_handle.ptr;
342 /* get stream info */
343 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
345 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
346 /* import tbm data_bo and get virtual address */
347 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
348 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
349 goto _PREVIEW_CB_HANDLER_DONE;
352 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
353 stream->data.encoded.data = data_bo_handle.ptr;
355 for (i = 0 ; i < num_buffer_fd ; i++) {
356 /* import buffer bo and get virtual address */
357 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
358 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
359 goto _PREVIEW_CB_HANDLER_DONE;
363 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
364 stream->data.encoded.data = buffer_bo_handle[0].ptr;
367 /* preview callback */
368 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
369 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
370 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
372 /* set stream data for camera_get_preview_frame_rotation() */
373 cb_info->stream_data = stream;
375 if (stream->extra_stream_id < 0) {
376 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
377 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
378 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
380 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
381 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
382 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
385 cb_info->stream_data = NULL;
388 if (stream->extra_stream_id >= 0)
389 goto _PREVIEW_CB_HANDLER_DONE;
391 /* make media packet with below cases.
392 * 1. media_packet_preview_cb is set
393 * 2. EVAS display rendering
394 * 3. media bridge is set
396 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
397 cb_info->is_evas_render ||
399 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
400 if (ret != CAMERA_ERROR_NONE) {
401 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
402 goto _PREVIEW_CB_HANDLER_DONE;
405 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
406 if (ret != CAMERA_ERROR_NONE) {
407 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
408 __camera_release_media_packet_data(mp_data, cb_info);
410 goto _PREVIEW_CB_HANDLER_DONE;
414 /* 1. media packet preview callback */
415 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
416 media_packet_ref(pkt);
417 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
418 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
421 /* 2. call evas renderer */
422 if (cb_info->is_evas_render) {
423 if (cb_info->run_evas_render) {
424 media_packet_ref(pkt);
425 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
426 if (ret != MM_ERROR_NONE) {
427 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
428 media_packet_unref(pkt);
431 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
436 /* 3. media bridge */
437 g_mutex_lock(&cb_info->bridge_lock);
439 if (cb_info->bridge) {
440 media_packet_ref(pkt);
441 ret = media_bridge_push_packet(cb_info->bridge, pkt);
442 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
443 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
444 media_packet_unref(pkt);
449 g_mutex_unlock(&cb_info->bridge_lock);
451 _PREVIEW_CB_HANDLER_DONE:
452 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
453 and preview callback(normal or media packet) is set. */
454 if (num_buffer_fd > 0 &&
455 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
456 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
457 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
460 media_packet_unref(pkt);
465 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
467 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
469 /* release imported bo and fd */
470 __camera_release_imported_bo(&data_bo);
471 __camera_release_imported_bo(&bo);
473 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
474 __camera_release_imported_bo(&buffer_bo[i]);
476 __camera_release_tfd(tfd);
480 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
483 int capture_fd_main = 0;
484 int capture_fd_post = 0;
485 int capture_fd_thumb = 0;
486 unsigned char *buf_pos = NULL;
488 camera_image_data_s *rImage = NULL;
489 camera_image_data_s *rPostview = NULL;
490 camera_image_data_s *rThumbnail = NULL;
492 tbm_bo bo_main = NULL;
493 tbm_bo bo_post = NULL;
494 tbm_bo bo_thumb = NULL;
495 tbm_bo_handle bo_main_handle = {.ptr = NULL};
496 tbm_bo_handle bo_post_handle = {.ptr = NULL};
497 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
499 if (!cb_info || !recv_msg || !tfd) {
500 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
504 muse_camera_msg_get(capture_fd_main, recv_msg);
505 muse_camera_msg_get(capture_fd_post, recv_msg);
506 muse_camera_msg_get(capture_fd_thumb, recv_msg);
508 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
509 capture_fd_main, capture_fd_post, capture_fd_thumb,
510 tfd[0], tfd[1], tfd[2]);
512 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
513 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
514 goto _CAPTURE_CB_HANDLER_DONE;
517 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
518 CAM_LOG_WARNING("NULL callback");
519 goto _CAPTURE_CB_HANDLER_DONE;
522 /* import tbm bo and get virtual address */
523 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
524 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
525 goto _CAPTURE_CB_HANDLER_DONE;
528 buf_pos = (unsigned char *)bo_main_handle.ptr;
529 rImage = (camera_image_data_s *)buf_pos;
530 rImage->data = buf_pos + sizeof(camera_image_data_s);
531 if (rImage->exif && rImage->exif_size > 0) {
532 rImage->exif = rImage->data + rImage->size;
535 rImage->exif_size = 0;
538 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
539 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
542 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
543 /* import tbm bo and get virtual address */
545 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
546 buf_pos = (unsigned char *)bo_post_handle.ptr;
547 rPostview = (camera_image_data_s *)buf_pos;
548 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
549 rPostview->data = buf_pos + sizeof(camera_image_data_s);
551 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
555 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
556 /* import tbm bo and get virtual address */
558 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
559 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
560 rThumbnail = (camera_image_data_s *)buf_pos;
561 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
562 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
564 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
569 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
570 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
572 _CAPTURE_CB_HANDLER_DONE:
574 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
575 __camera_release_imported_bo(&bo_main);
576 _camera_msg_return_buffer(capture_fd_main, cb_info);
579 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
580 __camera_release_imported_bo(&bo_post);
581 _camera_msg_return_buffer(capture_fd_post, cb_info);
584 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
585 __camera_release_imported_bo(&bo_thumb);
586 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
589 __camera_release_tfd(tfd);
591 CAM_LOG_INFO("return buffer done");
596 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
599 int face_fd = CAMERA_FD_INIT;
600 camera_detected_face_s *faces = NULL;
603 tbm_bo_handle bo_handle = {.ptr = NULL};
605 if (!cb_info || !recv_msg || !tfd) {
606 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
610 muse_camera_msg_get(count, recv_msg);
611 muse_camera_msg_get(face_fd, recv_msg);
613 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
614 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
616 if (CAMERA_IS_FD_VALID(tfd[0])) {
617 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
619 faces = bo_handle.ptr;
623 tfd[0] = CAMERA_FD_INIT;
626 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
627 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
630 __camera_release_imported_bo(&bo);
632 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
633 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
637 _camera_msg_return_buffer(face_fd, cb_info);
642 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
644 tbm_bo tmp_bo = NULL;
645 tbm_bo_handle tmp_bo_handle = {NULL, };
647 if (!bufmgr || !bo || !bo_handle || fd < 0) {
648 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
649 bufmgr, bo, bo_handle, fd);
653 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
654 if (tmp_bo == NULL) {
655 CAM_LOG_ERROR("import failed - fd %d", fd);
659 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
660 if (tmp_bo_handle.ptr == NULL) {
661 CAM_LOG_ERROR("map failed %p", tmp_bo);
662 tbm_bo_unref(tmp_bo);
667 tbm_bo_unmap(tmp_bo);
669 /* set bo and bo_handle */
671 *bo_handle = tmp_bo_handle;
673 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
678 static void __camera_release_imported_bo(tbm_bo *bo)
681 CAM_LOG_DEBUG("NULL bo");
690 static bool __is_supported_common(camera_h camera, muse_camera_api_e api)
692 int ret = CAMERA_ERROR_NONE;
693 camera_cli_s *pc = (camera_cli_s *)camera;
695 if (!pc || !pc->cb_info) {
696 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
697 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
701 CAM_LOG_INFO("Enter - api[%d]", api);
703 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
705 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
711 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
713 int ret = CAMERA_ERROR_NONE;
716 if (!cb_info->is_server_connected) {
717 CAM_LOG_ERROR("server is disconnected");
718 return CAMERA_ERROR_SERVICE_DISCONNECTED;
721 g_mutex_lock(&(cb_info->api_mutex[api]));
723 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
725 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
727 while (!cb_info->api_activating[api]) {
728 if (time_out == CAMERA_CB_NO_TIMEOUT) {
729 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
730 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
731 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
732 CAM_LOG_ERROR("api %d TIMED OUT!", api);
733 ret = CAMERA_ERROR_INVALID_OPERATION;
737 if (!cb_info->is_server_connected) {
738 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
742 if (!cb_info->api_activating[api])
743 CAM_LOG_WARNING("invalid signal received, wait again...");
746 ret = cb_info->api_ret[api];
747 cb_info->api_activating[api] = FALSE;
750 g_mutex_unlock(&(cb_info->api_mutex[api]));
752 if (ret != CAMERA_ERROR_NONE)
753 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
759 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
760 int *ret, int timeout)
766 CAM_LOG_ERROR("NULL info - api %d", api);
769 *ret = CAMERA_ERROR_INVALID_PARAMETER;
774 msg = muse_core_msg_new(api, NULL);
776 CAM_LOG_ERROR("msg failed: api %d", api);
779 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
784 CAM_LOG_DEBUG("send msg[%s]", msg);
786 if (cb_info->is_server_connected) {
787 _camera_update_api_waiting(cb_info, api, 1);
789 g_mutex_lock(&cb_info->fd_lock);
790 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
791 g_mutex_unlock(&cb_info->fd_lock);
795 CAM_LOG_ERROR("msg send failed");
797 *ret = CAMERA_ERROR_INVALID_OPERATION;
800 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
803 _camera_update_api_waiting(cb_info, api, -1);
805 muse_core_msg_free(msg);
809 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
810 int *ret, camera_msg_param *param, int timeout)
816 if (!cb_info || !param) {
817 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
820 *ret = CAMERA_ERROR_INVALID_PARAMETER;
825 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
827 switch (param->type) {
829 msg = muse_core_msg_new(api,
830 param->type, param->name, param->value.value_INT,
833 case MUSE_TYPE_STRING:
834 msg = muse_core_msg_new(api,
835 param->type, param->name, param->value.value_STRING,
838 case MUSE_TYPE_ARRAY:
839 array_length = param->value_size / sizeof(int) + \
840 (param->value_size % sizeof(int) ? 1 : 0);
842 msg = muse_core_msg_new(api,
843 param->type, param->name, array_length, param->value.value_ARRAY,
847 CAM_LOG_ERROR("unknown type %d", param->type);
852 CAM_LOG_ERROR("msg failed: api %d", api);
855 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
860 CAM_LOG_DEBUG("send msg[%s]", msg);
862 if (cb_info->is_server_connected) {
863 _camera_update_api_waiting(cb_info, api, 1);
865 g_mutex_lock(&cb_info->fd_lock);
866 send_ret = muse_core_msg_send(cb_info->fd, msg);
867 g_mutex_unlock(&cb_info->fd_lock);
871 CAM_LOG_ERROR("msg send failed");
874 *ret = CAMERA_ERROR_INVALID_OPERATION;
877 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
880 _camera_update_api_waiting(cb_info, api, -1);
882 muse_core_msg_free(msg);
886 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
887 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
889 int func_ret = CAMERA_ERROR_NONE;
893 if (!cb_info || !param0 || !param1) {
894 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
895 cb_info, param0, param1, api);
896 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
897 goto _SEND_PARAM2_INT_DONE;
900 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
902 param0->name, param0->value.value_INT,
903 param1->name, param1->value.value_INT);
905 msg = muse_core_msg_new(api,
906 param0->type, param0->name, param0->value.value_INT,
907 param1->type, param1->name, param1->value.value_INT,
910 CAM_LOG_ERROR("msg failed: api %d", api);
911 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
912 goto _SEND_PARAM2_INT_DONE;
915 CAM_LOG_DEBUG("send msg[%s]", msg);
917 if (cb_info->is_server_connected) {
918 _camera_update_api_waiting(cb_info, api, 1);
920 g_mutex_lock(&cb_info->fd_lock);
921 send_ret = muse_core_msg_send(cb_info->fd, msg);
922 g_mutex_unlock(&cb_info->fd_lock);
926 CAM_LOG_ERROR("msg send failed");
928 func_ret = CAMERA_ERROR_INVALID_OPERATION;
930 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
933 _camera_update_api_waiting(cb_info, api, -1);
935 muse_core_msg_free(msg);
937 _SEND_PARAM2_INT_DONE:
943 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
945 camera_msg_param param;
948 CAM_LOG_WARNING("invalid fd %d", ret_fd);
952 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
954 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
958 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
960 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
961 in_format >= MM_PIXEL_FORMAT_NUM ||
962 out_format == NULL) {
963 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
964 return CAMERA_ERROR_INVALID_PARAMETER;
968 case MM_PIXEL_FORMAT_NV12:
969 case MM_PIXEL_FORMAT_NV12T:
970 *out_format = TBM_FORMAT_NV12;
973 case MM_PIXEL_FORMAT_NV16:
974 *out_format = TBM_FORMAT_NV16;
976 case MM_PIXEL_FORMAT_NV21:
977 *out_format = TBM_FORMAT_NV21;
979 case MM_PIXEL_FORMAT_YUYV:
980 *out_format = TBM_FORMAT_YUYV;
982 case MM_PIXEL_FORMAT_UYVY:
983 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
984 *out_format = TBM_FORMAT_UYVY;
986 case MM_PIXEL_FORMAT_422P:
987 *out_format = TBM_FORMAT_YUV422;
989 case MM_PIXEL_FORMAT_I420:
990 *out_format = TBM_FORMAT_YUV420;
992 case MM_PIXEL_FORMAT_YV12:
993 *out_format = TBM_FORMAT_YVU420;
995 case MM_PIXEL_FORMAT_RGB565:
996 *out_format = TBM_FORMAT_RGB565;
998 case MM_PIXEL_FORMAT_RGB888:
999 *out_format = TBM_FORMAT_RGB888;
1001 case MM_PIXEL_FORMAT_RGBA:
1002 *out_format = TBM_FORMAT_RGBA8888;
1004 case MM_PIXEL_FORMAT_ARGB:
1005 *out_format = TBM_FORMAT_ARGB8888;
1008 CAM_LOG_ERROR("invalid in_format %d", in_format);
1009 return CAMERA_ERROR_INVALID_PARAMETER;
1013 return CAMERA_ERROR_NONE;
1017 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1019 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1020 in_format >= MM_PIXEL_FORMAT_NUM ||
1022 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1023 return CAMERA_ERROR_INVALID_PARAMETER;
1026 switch (in_format) {
1027 case MM_PIXEL_FORMAT_NV12:
1028 case MM_PIXEL_FORMAT_NV12T:
1029 *mimetype = MEDIA_FORMAT_NV12;
1032 case MM_PIXEL_FORMAT_NV16:
1033 *mimetype = MEDIA_FORMAT_NV16;
1035 case MM_PIXEL_FORMAT_NV21:
1036 *mimetype = MEDIA_FORMAT_NV21;
1038 case MM_PIXEL_FORMAT_YUYV:
1039 *mimetype = MEDIA_FORMAT_YUYV;
1041 case MM_PIXEL_FORMAT_UYVY:
1042 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1043 *mimetype = MEDIA_FORMAT_UYVY;
1045 case MM_PIXEL_FORMAT_422P:
1046 *mimetype = MEDIA_FORMAT_422P;
1048 case MM_PIXEL_FORMAT_I420:
1049 *mimetype = MEDIA_FORMAT_I420;
1051 case MM_PIXEL_FORMAT_YV12:
1052 *mimetype = MEDIA_FORMAT_YV12;
1054 case MM_PIXEL_FORMAT_RGB565:
1055 *mimetype = MEDIA_FORMAT_RGB565;
1057 case MM_PIXEL_FORMAT_RGB888:
1058 *mimetype = MEDIA_FORMAT_RGB888;
1060 case MM_PIXEL_FORMAT_RGBA:
1061 *mimetype = MEDIA_FORMAT_RGBA;
1063 case MM_PIXEL_FORMAT_ARGB:
1064 *mimetype = MEDIA_FORMAT_ARGB;
1066 case MM_PIXEL_FORMAT_ENCODED_H264:
1067 /* TODO: How can we determine the profile for H.264 format? */
1068 *mimetype = MEDIA_FORMAT_H264_SP;
1070 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1071 *mimetype = MEDIA_FORMAT_MJPEG;
1073 case MM_PIXEL_FORMAT_ENCODED_VP8:
1074 *mimetype = MEDIA_FORMAT_VP8;
1076 case MM_PIXEL_FORMAT_ENCODED_VP9:
1077 *mimetype = MEDIA_FORMAT_VP9;
1080 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1081 return CAMERA_ERROR_NOT_SUPPORTED;
1085 return CAMERA_ERROR_NONE;
1089 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1090 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1093 int ret = CAMERA_ERROR_NONE;
1094 camera_media_packet_data *new_mp_data = NULL;
1096 if (!tfd || !mp_data) {
1097 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1098 return CAMERA_ERROR_INVALID_PARAMETER;
1101 new_mp_data = g_new0(camera_media_packet_data, 1);
1103 new_mp_data->ret_fd = ret_fd;
1104 new_mp_data->fd = tfd[0];
1105 new_mp_data->num_buffer_fd = num_buffer_fd;
1106 new_mp_data->bo = bo;
1108 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1112 new_mp_data->data_bo = data_bo;
1113 new_mp_data->data_fd = tfd[1];
1115 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1116 new_mp_data->data_bo, new_mp_data->data_fd);
1119 for (i = 0 ; i < num_buffer_fd ; i++) {
1120 new_mp_data->buffer_bo[i] = buffer_bo[i];
1121 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1123 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1124 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1127 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1128 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1130 new_mp_data->data_fd = CAMERA_FD_INIT;
1133 *mp_data = new_mp_data;
1135 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1140 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1144 if (!mp_data || !cb_info) {
1145 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1149 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1151 /* release imported bo and close fd */
1152 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1153 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1154 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1156 tbm_bo_unref(mp_data->buffer_bo[i]);
1158 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1159 close(mp_data->buffer_fd[i]);
1161 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1164 if (mp_data->data_bo) {
1165 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1166 mp_data->data_fd, mp_data->data_bo);
1168 tbm_bo_unref(mp_data->data_bo);
1170 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1171 close(mp_data->data_fd);
1173 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1176 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1178 tbm_bo_unref(mp_data->bo);
1180 if (CAMERA_IS_FD_VALID(mp_data->fd))
1183 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1186 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1192 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1195 int ret = CAMERA_ERROR_NONE;
1196 uint32_t tbm_format = 0;
1197 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1198 tbm_surface_info_s tsurf_info;
1200 if (!stream || !mp_data) {
1201 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1205 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1206 CAM_LOG_ERROR("No valid data");
1210 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1211 if (ret != CAMERA_ERROR_NONE)
1214 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1216 if (mp_data->num_buffer_fd > 0) {
1217 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1218 bos[i] = mp_data->buffer_bo[i];
1220 bos[0] = mp_data->data_bo;
1223 tsurf_info.width = stream->width;
1224 tsurf_info.height = stream->height;
1225 tsurf_info.format = tbm_format;
1226 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1227 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1229 switch (tbm_format) {
1230 case TBM_FORMAT_NV12: /* fall through */
1231 case TBM_FORMAT_NV21: /* fall through */
1232 case TBM_FORMAT_YUV420: /* fall through */
1233 case TBM_FORMAT_YVU420: /* fall through */
1234 case TBM_FORMAT_UYVY: /* fall through */
1235 case TBM_FORMAT_YUYV:
1236 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1237 tsurf_info.planes[i].stride = stream->stride[i];
1238 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1239 if (i != 0 && mp_data->num_buffer_fd <= 1)
1240 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1241 tsurf_info.size += tsurf_info.planes[i].size;
1243 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1244 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1248 case TBM_FORMAT_RGB565: /* fall through */
1249 case TBM_FORMAT_RGB888: /* fall through */
1250 case TBM_FORMAT_RGBA8888: /* fall through */
1251 case TBM_FORMAT_ARGB8888:
1252 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1253 tsurf_info.planes[0].offset = 0;
1254 tsurf_info.size = stream->data.rgb.length_data;
1257 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1262 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1263 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1267 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1269 int ret = CAMERA_ERROR_NONE;
1270 int pkt_fmt_width = 0;
1271 int pkt_fmt_height = 0;
1272 bool make_pkt_fmt = false;
1273 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1274 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1276 if (!cb_info || !stream) {
1277 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1278 return CAMERA_ERROR_INVALID_PARAMETER;
1281 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1282 if (ret != CAMERA_ERROR_NONE)
1285 /* check media packet format */
1286 if (cb_info->pkt_fmt) {
1287 media_format_get_video_info(cb_info->pkt_fmt,
1288 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1290 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
1291 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1293 if (pkt_fmt_mimetype != mimetype ||
1294 pkt_fmt_width != stream->width ||
1295 pkt_fmt_height != stream->height) {
1296 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1297 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1299 media_format_unref(cb_info->pkt_fmt);
1300 cb_info->pkt_fmt = NULL;
1301 make_pkt_fmt = true;
1304 make_pkt_fmt = true;
1307 /* create packet format */
1309 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1310 mimetype, stream->width, stream->height);
1312 ret = media_format_create(&cb_info->pkt_fmt);
1313 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1314 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1315 return CAMERA_ERROR_INVALID_OPERATION;
1318 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1319 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1320 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1321 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1322 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1323 return CAMERA_ERROR_INVALID_OPERATION;
1327 return CAMERA_ERROR_NONE;
1331 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1332 camera_media_packet_data *mp_data, media_packet_h *packet)
1334 media_packet_h pkt = NULL;
1335 tbm_surface_h tsurf = NULL;
1336 int ret = CAMERA_ERROR_NONE;
1338 if (!cb_info || !stream || !mp_data || !packet) {
1339 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1340 cb_info, stream, mp_data, packet);
1341 return CAMERA_ERROR_INVALID_PARAMETER;
1344 ret = __camera_update_media_packet_format(cb_info, stream);
1345 if (ret != CAMERA_ERROR_NONE)
1348 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1349 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1350 stream->data.encoded.data, stream->data.encoded.length_data,
1351 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1354 tsurf = __camera_get_tbm_surface(stream, mp_data);
1356 CAM_LOG_ERROR("get tbm surface failed");
1357 ret = CAMERA_ERROR_INVALID_OPERATION;
1358 goto _PACKET_CREATE_FAILED;
1361 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1362 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1363 (void *)cb_info, &pkt);
1366 if (ret != MEDIA_PACKET_ERROR_NONE) {
1367 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1368 goto _PACKET_CREATE_FAILED;
1371 ret = media_packet_set_extra(pkt, (void *)mp_data);
1372 if (ret != MEDIA_PACKET_ERROR_NONE) {
1373 CAM_LOG_ERROR("media_packet_set_extra failed");
1374 goto _PACKET_CREATE_FAILED;
1377 /* set timestamp : msec -> nsec */
1378 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1379 CAM_LOG_WARNING("media_packet_set_pts failed");
1381 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1382 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1384 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1388 return CAMERA_ERROR_NONE;
1390 _PACKET_CREATE_FAILED:
1392 tbm_surface_destroy(tsurf);
1394 media_packet_unref(pkt);
1396 return CAMERA_ERROR_INVALID_OPERATION;
1399 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1402 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1403 camera_media_packet_data *mp_data = NULL;
1404 tbm_surface_h tsurf = NULL;
1406 if (!pkt || !cb_info) {
1407 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1411 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1412 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1413 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1417 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1419 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1420 pkt, mp_data, tsurf);
1423 tbm_surface_destroy(tsurf);
1425 g_mutex_lock(&cb_info->mp_data_mutex);
1426 __camera_release_media_packet_data(mp_data, cb_info);
1427 g_mutex_unlock(&cb_info->mp_data_mutex);
1430 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1435 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1436 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1440 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1442 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1444 if (cb_info->user_cb[event] == NULL) {
1445 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1446 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1447 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1448 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1449 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1450 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1454 /* return buffer message should be sent for some events.
1455 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1456 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1457 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1458 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1463 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1469 muse_camera_msg_get(previous, recv_msg);
1470 muse_camera_msg_get(current, recv_msg);
1471 muse_camera_msg_get(by_policy, recv_msg);
1473 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1474 previous, current, by_policy);
1476 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1477 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1480 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1484 muse_camera_msg_get(state, recv_msg);
1486 CAM_LOG_INFO("FOCUS state - %d", state);
1488 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1491 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1492 CAM_LOG_INFO("CAPTURE_COMPLETED");
1493 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1495 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1496 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1497 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1500 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1504 muse_camera_msg_get(percent, recv_msg);
1506 CAM_LOG_INFO("HDR progress - %d %%", percent);
1508 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1511 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1517 muse_camera_msg_get(policy, recv_msg);
1518 muse_camera_msg_get(previous, recv_msg);
1519 muse_camera_msg_get(current, recv_msg);
1521 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1523 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1524 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1527 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1532 muse_camera_msg_get(policy, recv_msg);
1533 muse_camera_msg_get(state, recv_msg);
1535 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1537 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1538 (camera_state_e)state, cb_info->user_data[event]);
1541 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1542 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1544 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1547 int current_state = 0;
1549 muse_camera_msg_get(error, recv_msg);
1550 muse_camera_msg_get(current_state, recv_msg);
1552 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1554 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1555 (camera_state_e)current_state, cb_info->user_data[event]);
1559 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1561 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1562 muse_camera_msg_get(param1, recv_msg);
1563 muse_camera_msg_get(param2, recv_msg);
1565 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1567 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1568 cb_info->user_cb[event] = NULL;
1569 cb_info->user_data[event] = NULL;
1570 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1573 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1575 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1577 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1579 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1581 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1583 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1585 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1587 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1589 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1591 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1593 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1595 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1597 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1603 muse_camera_msg_get(param1, recv_msg);
1605 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1607 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1608 cb_info->user_cb[event] = NULL;
1609 cb_info->user_data[event] = NULL;
1610 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1614 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1615 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1618 CAM_LOG_WARNING("unhandled event %d", event);
1622 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1625 static gboolean __camera_idle_event_callback(gpointer data)
1627 camera_cb_info_s *cb_info = NULL;
1628 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1630 if (cam_idle_event == NULL) {
1631 CAM_LOG_ERROR("cam_idle_event is NULL");
1636 g_mutex_lock(&g_cam_idle_event_lock);
1638 cb_info = cam_idle_event->cb_info;
1639 if (cb_info == NULL) {
1640 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1641 g_mutex_unlock(&g_cam_idle_event_lock);
1642 goto IDLE_EVENT_CALLBACK_DONE;
1645 /* remove event from list */
1646 if (cb_info->idle_event_list)
1647 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1649 g_mutex_unlock(&g_cam_idle_event_lock);
1652 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1654 IDLE_EVENT_CALLBACK_DONE:
1656 g_free(cam_idle_event);
1657 cam_idle_event = NULL;
1662 static gpointer __camera_msg_handler_func(gpointer data)
1666 camera_message_s *cam_msg = NULL;
1667 camera_idle_event_s *cam_idle_event = NULL;
1668 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1669 camera_cb_info_s *cb_info = NULL;
1671 if (!handler_info || !handler_info->cb_info) {
1672 CAM_LOG_ERROR("NULL handler %p", handler_info);
1676 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1677 type = handler_info->type;
1679 CAM_LOG_INFO("t:%d start[thread:%p]", type, handler_info->thread);
1681 g_mutex_lock(&handler_info->mutex);
1683 while (g_atomic_int_get(&handler_info->running)) {
1684 if (g_queue_is_empty(handler_info->queue)) {
1685 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1686 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1687 CAM_LOG_VERBOSE("t[%d] signal received", type);
1689 if (g_atomic_int_get(&handler_info->running) == 0) {
1690 CAM_LOG_INFO("t:%d stop event thread", type);
1695 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1697 g_mutex_unlock(&handler_info->mutex);
1699 if (cam_msg == NULL) {
1700 CAM_LOG_ERROR("t:%d NULL message", type);
1701 g_mutex_lock(&handler_info->mutex);
1707 if (api < MUSE_CAMERA_API_MAX) {
1710 g_mutex_lock(&cb_info->api_mutex[api]);
1712 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1713 if (cb_info->api_waiting[api] > 0) {
1714 cb_info->api_ret[api] = ret;
1715 cb_info->api_activating[api] = TRUE;
1717 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1719 g_cond_broadcast(&cb_info->api_cond[api]);
1721 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1724 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1727 g_mutex_unlock(&cb_info->api_mutex[api]);
1728 } else if (api == MUSE_CAMERA_CB_EVENT) {
1729 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1730 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1731 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1734 switch (cam_msg->event_class) {
1735 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1736 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1738 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1739 cam_idle_event = g_new0(camera_idle_event_s, 1);
1740 if (cam_idle_event == NULL) {
1741 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1745 cam_idle_event->event = cam_msg->event;
1746 cam_idle_event->cb_info = cb_info;
1748 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1749 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1751 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1752 type, cam_msg->event, cam_idle_event);
1754 g_mutex_lock(&g_cam_idle_event_lock);
1755 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1756 g_mutex_unlock(&g_cam_idle_event_lock);
1758 g_idle_add_full(G_PRIORITY_DEFAULT,
1759 (GSourceFunc)__camera_idle_event_callback,
1760 (gpointer)cam_idle_event,
1764 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1768 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1774 g_mutex_lock(&handler_info->mutex);
1777 /* remove remained event */
1778 while (!g_queue_is_empty(handler_info->queue)) {
1779 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1781 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1782 __camera_release_tfd(cam_msg->tfd);
1785 CAM_LOG_WARNING("t:%d NULL message", type);
1789 g_mutex_unlock(&handler_info->mutex);
1791 CAM_LOG_INFO("t:%d return[thread:%p]", type, handler_info->thread);
1797 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1799 camera_idle_event_s *cam_idle_event = NULL;
1802 if (cb_info == NULL) {
1803 CAM_LOG_ERROR("cb_info is NULL");
1807 g_mutex_lock(&g_cam_idle_event_lock);
1809 if (cb_info->idle_event_list == NULL) {
1810 CAM_LOG_INFO("No remained idle event");
1811 g_mutex_unlock(&g_cam_idle_event_lock);
1815 list = cb_info->idle_event_list;
1818 cam_idle_event = list->data;
1819 list = g_list_next(list);
1821 if (!cam_idle_event) {
1822 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1826 if (g_idle_remove_by_data(cam_idle_event)) {
1827 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1829 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1831 g_free(cam_idle_event);
1832 cam_idle_event = NULL;
1837 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1838 cam_idle_event, cam_idle_event->event);
1840 cam_idle_event->cb_info = NULL;
1842 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1845 g_list_free(cb_info->idle_event_list);
1846 cb_info->idle_event_list = NULL;
1848 g_mutex_unlock(&g_cam_idle_event_lock);
1852 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1854 camera_message_s *cam_msg = NULL;
1856 if (!cb_info || !msg) {
1857 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1861 cam_msg = g_new0(camera_message_s, 1);
1863 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1868 cam_msg->event = event;
1869 cam_msg->event_class = event_class;
1872 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1874 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1876 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1877 api, event, event_class);
1879 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1880 if (!cb_info->preview_cb_info.thread) {
1881 LOGI("The thread for preview cb is not created yet, create it now");
1882 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1883 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1884 CAM_LOG_ERROR("failed to create thread for preview cb");
1890 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1891 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1892 g_cond_signal(&cb_info->preview_cb_info.cond);
1893 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1894 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1895 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1896 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1897 g_cond_signal(&cb_info->capture_cb_info.cond);
1898 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1900 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1901 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1902 g_cond_signal(&cb_info->msg_handler_info.cond);
1903 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1910 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1912 int ret = CAMERA_ERROR_NONE;
1916 int event_class = -1;
1920 if (!cb_info || !msg) {
1921 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1925 CAM_LOG_DEBUG("msg[%s]", msg);
1927 if (!muse_camera_msg_get(api, msg)) {
1928 CAM_LOG_ERROR("failed to get camera api");
1932 if (api == MUSE_CAMERA_CB_EVENT) {
1933 if (!muse_camera_msg_get(event, msg) ||
1934 !muse_camera_msg_get(event_class, msg)) {
1935 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1939 if (!muse_camera_msg_get(api_class, msg)) {
1940 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1945 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1946 if (api >= MUSE_CAMERA_API_MAX) {
1947 CAM_LOG_ERROR("invalid api %d", api);
1951 if (!muse_camera_msg_get(ret, msg)) {
1952 CAM_LOG_ERROR("failed to get camera ret");
1956 g_mutex_lock(&cb_info->api_mutex[api]);
1959 case MUSE_CAMERA_API_CREATE:
1960 if (ret != CAMERA_ERROR_NONE) {
1961 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1962 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1965 case MUSE_CAMERA_API_DESTROY:
1966 if (ret == CAMERA_ERROR_NONE) {
1967 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1968 CAM_LOG_INFO("camera destroy done. close client cb handler");
1972 muse_camera_msg_get(get_type, msg);
1973 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1974 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1975 muse_camera_msg_get(get_index, msg);
1978 case MUSE_CAMERA_GET_TYPE_INT:
1979 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1981 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1982 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1983 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1985 case MUSE_CAMERA_GET_TYPE_ARRAY:
1987 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
1988 muse_core_msg_deserialize("get_value",
1989 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1990 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
1991 cb_info->get_display_roi_area[0],
1992 cb_info->get_display_roi_area[1],
1993 cb_info->get_display_roi_area[2],
1994 cb_info->get_display_roi_area[3]);
1996 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
1997 muse_core_msg_deserialize("get_value",
1998 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1999 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2000 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2002 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2003 muse_core_msg_deserialize("get_value",
2004 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2005 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2006 cb_info->get_extra_preview_stream_format[0],
2007 cb_info->get_extra_preview_stream_format[1],
2008 cb_info->get_extra_preview_stream_format[2],
2009 cb_info->get_extra_preview_stream_format[3]);
2012 CAM_LOG_WARNING("unknown api[%d]", api);
2016 case MUSE_CAMERA_GET_TYPE_STRING:
2017 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2020 CAM_LOG_WARNING("unknown type %d", get_type);
2027 if (cb_info->api_waiting[api] > 0) {
2028 cb_info->api_ret[api] = ret;
2029 cb_info->api_activating[api] = TRUE;
2031 g_cond_broadcast(&cb_info->api_cond[api]);
2033 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2036 g_mutex_unlock(&cb_info->api_mutex[api]);
2037 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2038 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2040 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2045 static gpointer __camera_msg_recv_func(gpointer data)
2048 int recv_length = 0;
2049 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2050 char *recv_msg = NULL;
2051 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2054 CAM_LOG_ERROR("cb_info NULL");
2058 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2060 recv_msg = cb_info->recv_msg;
2062 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2063 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2064 tfd[i] = CAMERA_FD_INIT;
2066 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2067 if (recv_length <= 0) {
2068 cb_info->is_server_connected = FALSE;
2069 CAM_LOG_ERROR("receive msg failed - server disconnected");
2073 if (CAMERA_IS_FD_VALID(tfd[0]))
2074 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2076 recv_msg[recv_length] = '\0';
2078 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2080 __camera_process_msg(cb_info, recv_msg, tfd);
2083 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2086 if (!cb_info->is_server_connected) {
2087 char *error_msg = NULL;
2089 if (cb_info->bufmgr == NULL) {
2090 CAM_LOG_ERROR("No need to send error(handle is not created)");
2094 if (cb_info->fd < 0) {
2095 CAM_LOG_ERROR("fd is closed in client side");
2099 /* send error msg for server disconnection */
2100 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2101 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2102 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2106 CAM_LOG_ERROR("error_msg failed");
2110 __camera_add_msg_to_queue(cb_info,
2111 MUSE_CAMERA_CB_EVENT,
2112 MUSE_CAMERA_EVENT_TYPE_ERROR,
2113 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2117 muse_core_msg_free(error_msg);
2120 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2121 if (cb_info->api_waiting[i])
2122 g_cond_broadcast(&cb_info->api_cond[i]);
2125 CAM_LOG_ERROR("add error msg for service disconnection done");
2133 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2134 int type, const char *thread_name, camera_cb_info_s *cb_info)
2136 if (!handler_info || !thread_name || !cb_info) {
2137 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2138 type, handler_info, thread_name, cb_info);
2142 if (handler_info->thread) {
2143 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2147 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2149 handler_info->type = type;
2150 handler_info->queue = g_queue_new();
2151 if (handler_info->queue == NULL) {
2152 CAM_LOG_ERROR("t:%d queue failed", type);
2156 g_mutex_init(&handler_info->mutex);
2157 g_cond_init(&handler_info->cond);
2159 handler_info->cb_info = (void *)cb_info;
2160 g_atomic_int_set(&handler_info->running, 1);
2162 handler_info->thread = g_thread_try_new(thread_name,
2163 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2164 if (handler_info->thread == NULL) {
2165 CAM_LOG_ERROR("t:%d thread failed", type);
2167 g_mutex_clear(&handler_info->mutex);
2168 g_cond_clear(&handler_info->cond);
2169 g_queue_free(handler_info->queue);
2170 handler_info->queue = NULL;
2175 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2181 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2185 if (!handler_info) {
2186 CAM_LOG_ERROR("NULL handler");
2190 if (!handler_info->thread) {
2191 CAM_LOG_WARNING("thread is not created");
2195 type = handler_info->type;
2197 CAM_LOG_INFO("t:%d thread[%p]", type, handler_info->thread);
2199 g_mutex_lock(&handler_info->mutex);
2200 g_atomic_int_set(&handler_info->running, 0);
2201 g_cond_signal(&handler_info->cond);
2202 g_mutex_unlock(&handler_info->mutex);
2204 g_thread_join(handler_info->thread);
2205 handler_info->thread = NULL;
2207 g_mutex_clear(&handler_info->mutex);
2208 g_cond_clear(&handler_info->cond);
2209 g_queue_free(handler_info->queue);
2210 handler_info->queue = NULL;
2212 CAM_LOG_INFO("t:%d done", type);
2216 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2218 camera_cb_info_s *cb_info = NULL;
2221 g_return_val_if_fail(sockfd > 0, NULL);
2223 cb_info = g_new0(camera_cb_info_s, 1);
2224 if (cb_info == NULL) {
2225 CAM_LOG_ERROR("cb_info failed");
2229 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2231 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2232 g_mutex_init(&cb_info->api_mutex[i]);
2233 g_cond_init(&cb_info->api_cond[i]);
2236 g_mutex_init(&cb_info->fd_lock);
2237 g_mutex_init(&cb_info->mp_data_mutex);
2238 g_mutex_init(&cb_info->bridge_lock);
2240 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2241 g_mutex_init(&cb_info->user_cb_mutex[i]);
2243 /* message handler thread */
2244 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2245 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2246 CAM_LOG_ERROR("msg_handler_info failed");
2250 /* message handler thread for capture callback */
2251 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2252 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2253 CAM_LOG_ERROR("capture_cb_info failed");
2257 cb_info->fd = sockfd;
2259 /* message receive thread */
2260 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2261 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2262 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2263 if (cb_info->msg_recv_thread == NULL) {
2264 CAM_LOG_ERROR("message receive thread creation failed");
2269 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2270 cb_info->fds[i] = CAMERA_FD_INIT;
2272 cb_info->is_server_connected = TRUE;
2278 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2279 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2281 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2282 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2284 g_mutex_clear(&cb_info->fd_lock);
2285 g_mutex_clear(&cb_info->mp_data_mutex);
2286 g_mutex_clear(&cb_info->bridge_lock);
2288 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2289 g_mutex_clear(&cb_info->api_mutex[i]);
2290 g_cond_clear(&cb_info->api_cond[i]);
2301 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2305 g_return_if_fail(cb_info != NULL);
2307 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2309 g_thread_join(cb_info->msg_recv_thread);
2310 cb_info->msg_recv_thread = NULL;
2312 CAM_LOG_INFO("msg_recv thread removed");
2314 /* destroy msg handler threads */
2315 if (cb_info->preview_cb_info.thread)
2316 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2317 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2318 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2320 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2321 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2323 g_mutex_clear(&cb_info->fd_lock);
2324 g_mutex_clear(&cb_info->mp_data_mutex);
2325 g_mutex_clear(&cb_info->bridge_lock);
2327 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2328 g_mutex_clear(&cb_info->api_mutex[i]);
2329 g_cond_clear(&cb_info->api_cond[i]);
2332 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2333 muse_client_close(cb_info->fd);
2334 cb_info->fd = CAMERA_FD_INIT;
2337 if (cb_info->bufmgr) {
2338 tbm_bufmgr_deinit(cb_info->bufmgr);
2339 cb_info->bufmgr = NULL;
2341 if (cb_info->pkt_fmt) {
2342 media_format_unref(cb_info->pkt_fmt);
2343 cb_info->pkt_fmt = NULL;
2346 if (cb_info->dp_interface) {
2347 mm_display_interface_deinit(cb_info->dp_interface);
2348 cb_info->dp_interface = NULL;
2355 int _camera_start_evas_rendering(camera_h camera)
2357 camera_cli_s *pc = (camera_cli_s *)camera;
2359 if (!pc || !pc->cb_info) {
2360 CAM_LOG_ERROR("NULL handle[%p]", pc);
2361 return CAMERA_ERROR_INVALID_PARAMETER;
2364 CAM_LOG_INFO("start");
2366 if (!pc->cb_info->is_evas_render) {
2367 CAM_LOG_ERROR("EVAS surface is not set");
2368 return CAMERA_ERROR_NONE;
2371 /* set evas render flag as RUN */
2372 pc->cb_info->run_evas_render = true;
2374 return CAMERA_ERROR_NONE;
2378 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2380 int ret = CAMERA_ERROR_NONE;
2381 camera_cli_s *pc = (camera_cli_s *)camera;
2383 if (!pc || !pc->cb_info) {
2384 CAM_LOG_ERROR("NULL handle[%p]", pc);
2385 return CAMERA_ERROR_INVALID_PARAMETER;
2388 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2390 if (!pc->cb_info->is_evas_render) {
2391 CAM_LOG_ERROR("EVAS surface is not set");
2392 return CAMERA_ERROR_NONE;
2395 /* set evas render flag as STOP and release buffers */
2396 pc->cb_info->run_evas_render = false;
2398 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2399 if (ret == MM_ERROR_NONE) {
2400 ret = CAMERA_ERROR_NONE;
2402 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2403 ret = CAMERA_ERROR_INVALID_OPERATION;
2410 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2412 int ret = CAMERA_ERROR_NONE;
2413 int sock_fd = CAMERA_FD_INIT;
2414 int module_index = -1;
2416 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2418 /* create muse connection */
2419 if (!key || !value) {
2420 CAM_LOG_ERROR("NULL pointer");
2421 return CAMERA_ERROR_INVALID_PARAMETER;
2424 sock_fd = muse_client_new();
2426 CAM_LOG_ERROR("muse_client_new failed");
2427 return CAMERA_ERROR_INVALID_OPERATION;
2430 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2431 CAM_LOG_ERROR("muse client get module index failed");
2432 ret = CAMERA_ERROR_INVALID_OPERATION;
2436 msg = muse_core_msg_new(api,
2437 MUSE_TYPE_INT, "module", module_index,
2438 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2441 CAM_LOG_ERROR("msg failed");
2442 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2446 ret = muse_core_msg_send(sock_fd, msg);
2448 muse_core_msg_free(msg);
2452 CAM_LOG_ERROR("send msg failed");
2453 ret = CAMERA_ERROR_INVALID_OPERATION;
2457 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2459 CAM_LOG_ERROR("recv msg failed %d", errno);
2460 ret = CAMERA_ERROR_INVALID_OPERATION;
2464 if (!muse_camera_msg_get(ret, recv_msg)) {
2465 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2466 ret = CAMERA_ERROR_INVALID_OPERATION;
2470 if (ret == CAMERA_ERROR_NONE)
2471 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2473 CAM_LOG_INFO("api %d - value %d", api, *value);
2476 if (CAMERA_IS_FD_VALID(sock_fd)) {
2477 muse_client_close(sock_fd);
2478 sock_fd = CAMERA_FD_INIT;
2485 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2487 int sock_fd = CAMERA_FD_INIT;
2488 char *send_msg = NULL;
2490 int ret = CAMERA_ERROR_NONE;
2491 camera_cli_s *pc = NULL;
2492 tbm_bufmgr bufmgr = NULL;
2494 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2495 int module_index = -1;
2496 int device_type = (int)device;
2499 CAM_LOG_ERROR("NULL pointer");
2500 return CAMERA_ERROR_INVALID_PARAMETER;
2503 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2505 sock_fd = muse_client_new();
2507 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2508 ret = CAMERA_ERROR_INVALID_OPERATION;
2512 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2513 CAM_LOG_ERROR("muse client get module index failed");
2514 ret = CAMERA_ERROR_INVALID_OPERATION;
2518 send_msg = muse_core_msg_new(api,
2519 MUSE_TYPE_INT, "module", module_index,
2520 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2521 MUSE_TYPE_INT, "is_network", (int)is_network,
2525 CAM_LOG_ERROR("NULL msg");
2526 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2530 send_ret = muse_core_msg_send(sock_fd, send_msg);
2532 muse_core_msg_free(send_msg);
2536 CAM_LOG_ERROR("send msg failed %d", errno);
2537 ret = CAMERA_ERROR_INVALID_OPERATION;
2541 pc = g_new0(camera_cli_s, 1);
2543 CAM_LOG_ERROR("camera_cli_s alloc failed");
2544 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2548 bufmgr = tbm_bufmgr_init(-1);
2549 if (bufmgr == NULL) {
2550 CAM_LOG_ERROR("get tbm bufmgr failed");
2551 ret = CAMERA_ERROR_INVALID_OPERATION;
2555 pc->cb_info = __camera_client_callback_new(sock_fd);
2556 if (pc->cb_info == NULL) {
2557 CAM_LOG_ERROR("cb_info alloc failed");
2558 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2562 sock_fd = CAMERA_FD_INIT;
2564 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2566 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2568 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2570 if (ret == CAMERA_ERROR_NONE) {
2571 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2572 int user_buffer_supported = 0;
2573 int log_level = CAMERA_LOG_LEVEL_INFO;
2574 intptr_t handle = 0;
2576 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2578 CAM_LOG_ERROR("Receiving Handle Failed!!");
2579 ret = CAMERA_ERROR_INVALID_OPERATION;
2583 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2584 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2585 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2587 pc->remote_handle = handle;
2588 pc->cb_info->bufmgr = bufmgr;
2589 pc->cb_info->preview_format = preview_format;
2590 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2591 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2592 pc->cb_info->is_network = is_network;
2593 g_camera_log_level = log_level;
2595 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2596 preview_format, user_buffer_supported, g_camera_log_level);
2598 *camera = (camera_h)pc;
2600 /* get display interface handle */
2601 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2602 CAM_LOG_WARNING("display interface init failed");
2611 tbm_bufmgr_deinit(bufmgr);
2615 if (CAMERA_IS_FD_VALID(sock_fd)) {
2616 muse_client_close(sock_fd);
2617 sock_fd = CAMERA_FD_INIT;
2622 int temp_fd = pc->cb_info->fd;
2624 /* pc->cb_info->fd should be closed,
2625 because g_thread_join for msg_recv_thread is not returned
2626 in __camera_client_callback_destroy. */
2627 if (CAMERA_IS_FD_VALID(temp_fd)) {
2628 pc->cb_info->fd = CAMERA_FD_INIT;
2629 muse_client_close(temp_fd);
2632 __camera_client_callback_destroy(pc->cb_info);
2639 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2646 int camera_create(camera_device_e device, camera_h *camera)
2648 return _camera_create_private(device, false, camera);
2652 int camera_change_device(camera_h camera, camera_device_e device)
2655 int ret = CAMERA_ERROR_NONE;
2656 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2657 camera_cli_s *pc = (camera_cli_s *)camera;
2658 camera_msg_param param;
2660 if (!pc || !pc->cb_info) {
2661 CAM_LOG_ERROR("NULL handle[%p]", pc);
2662 return CAMERA_ERROR_INVALID_PARAMETER;
2665 CAMERA_MSG_PARAM_SET(param, INT, device);
2667 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2669 if (ret == CAMERA_ERROR_NONE) {
2670 /* reset callback and user data */
2671 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2672 pc->cb_info->user_cb[i] = NULL;
2673 pc->cb_info->user_data[i] = NULL;
2681 int camera_destroy(camera_h camera)
2683 int ret = CAMERA_ERROR_NONE;
2684 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2685 camera_cli_s *pc = (camera_cli_s *)camera;
2687 if (!pc || !pc->cb_info) {
2688 CAM_LOG_ERROR("NULL handle[%p]", pc);
2689 return CAMERA_ERROR_INVALID_PARAMETER;
2692 CAM_LOG_INFO("Enter");
2694 if (pc->cb_info->is_server_connected)
2695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2697 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2699 if (ret == CAMERA_ERROR_NONE) {
2700 __camera_deactivate_idle_event_all(pc->cb_info);
2701 __camera_client_callback_destroy(pc->cb_info);
2708 CAM_LOG_INFO("ret : 0x%x", ret);
2713 int camera_start_preview(camera_h camera)
2715 int ret = CAMERA_ERROR_NONE;
2717 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2718 camera_cli_s *pc = (camera_cli_s *)camera;
2719 camera_state_e current_state = CAMERA_STATE_NONE;
2721 if (!pc || !pc->cb_info) {
2722 CAM_LOG_ERROR("NULL handle[%p]", pc);
2723 return CAMERA_ERROR_INVALID_PARAMETER;
2726 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2727 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2729 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2730 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2731 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2732 pc->cb_info->dp_info.type);
2733 return CAMERA_ERROR_INVALID_OPERATION;
2736 ret = camera_get_state(camera, ¤t_state);
2737 if (ret != CAMERA_ERROR_NONE) {
2738 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2742 if (current_state == CAMERA_STATE_CREATED) {
2743 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2744 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2745 CAM_LOG_ERROR("preview_cb_info failed");
2746 return CAMERA_ERROR_INVALID_OPERATION;
2749 if (pc->cb_info->user_buffer_supported) {
2750 if (!__camera_allocate_preview_buffer(camera)) {
2751 ret = CAMERA_ERROR_INVALID_OPERATION;
2755 fds = pc->cb_info->fds;
2759 _camera_msg_send(api, fds, pc->cb_info, &ret,
2760 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2761 CAMERA_CB_NO_TIMEOUT);
2763 (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
2765 if (ret != CAMERA_ERROR_NONE)
2768 if (pc->cb_info->is_evas_render) {
2769 ret = _camera_start_evas_rendering(camera);
2770 if (ret != CAMERA_ERROR_NONE) {
2771 CAM_LOG_ERROR("stop preview because of error");
2772 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2777 CAM_LOG_INFO("done");
2779 return CAMERA_ERROR_NONE;
2782 if (current_state == CAMERA_STATE_CREATED) {
2783 if (pc->cb_info->user_buffer_supported)
2784 __camera_release_preview_buffer(camera);
2786 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2789 CAM_LOG_ERROR("failed : 0x%x", ret);
2795 int camera_stop_preview(camera_h camera)
2797 int ret = CAMERA_ERROR_NONE;
2798 camera_cli_s *pc = (camera_cli_s *)camera;
2799 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2800 camera_state_e current_state = CAMERA_STATE_NONE;
2802 if (!pc || !pc->cb_info) {
2803 CAM_LOG_ERROR("NULL handle[%p]", pc);
2804 return CAMERA_ERROR_INVALID_PARAMETER;
2807 CAM_LOG_INFO("Enter");
2810 if (pc->cb_info->is_evas_render) {
2811 ret = camera_get_state(camera, ¤t_state);
2812 if (ret != CAMERA_ERROR_NONE) {
2813 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2817 if (current_state == CAMERA_STATE_PREVIEW) {
2818 ret = _camera_stop_evas_rendering(camera, false);
2819 if (ret != CAMERA_ERROR_NONE)
2824 /* send stop preview message */
2825 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2827 if (ret == CAMERA_ERROR_NONE) {
2828 if (pc->cb_info->user_buffer_supported)
2829 __camera_release_preview_buffer(camera);
2831 /* release remained message for preview callback */
2832 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2833 } else if (current_state == CAMERA_STATE_PREVIEW) {
2834 CAM_LOG_WARNING("restart evas rendering");
2835 _camera_start_evas_rendering(camera);
2838 CAM_LOG_INFO("ret : 0x%x", ret);
2844 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2846 int ret = CAMERA_ERROR_NONE;
2847 camera_cli_s *pc = (camera_cli_s *)camera;
2848 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2850 if (!pc || !pc->cb_info) {
2851 CAM_LOG_ERROR("NULL handle[%p]", pc);
2852 return CAMERA_ERROR_INVALID_PARAMETER;
2855 CAM_LOG_INFO("Enter");
2857 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2858 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2860 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2861 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2863 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2865 CAM_LOG_INFO("ret : 0x%x", ret);
2871 bool camera_is_supported_continuous_capture(camera_h camera)
2873 return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
2877 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)
2879 int ret = CAMERA_ERROR_NONE;
2880 camera_cli_s *pc = (camera_cli_s *)camera;
2881 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2882 camera_msg_param param;
2885 if (!pc || !pc->cb_info) {
2886 CAM_LOG_ERROR("NULL handle[%p]", pc);
2887 return CAMERA_ERROR_INVALID_PARAMETER;
2890 CAM_LOG_INFO("Enter");
2892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2895 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2896 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2898 value = (count << 16) | interval;
2899 CAMERA_MSG_PARAM_SET(param, INT, value);
2901 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2903 CAM_LOG_INFO("ret : 0x%x", ret);
2909 int camera_stop_continuous_capture(camera_h camera)
2911 int ret = CAMERA_ERROR_NONE;
2912 camera_cli_s *pc = (camera_cli_s *)camera;
2913 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2915 if (!pc || !pc->cb_info) {
2916 CAM_LOG_ERROR("NULL handle[%p]", pc);
2917 return CAMERA_ERROR_INVALID_PARAMETER;
2920 CAM_LOG_INFO("Enter");
2922 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2924 CAM_LOG_INFO("ret : 0x%x", ret);
2930 bool camera_is_supported_face_detection(camera_h camera)
2932 return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
2936 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2938 return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
2942 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2944 return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
2948 bool camera_is_supported_extra_preview(camera_h camera)
2950 return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
2954 int camera_get_device_count(camera_h camera, int *device_count)
2956 int ret = CAMERA_ERROR_NONE;
2957 camera_cli_s *pc = (camera_cli_s *)camera;
2958 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2960 if (!pc || !pc->cb_info) {
2961 CAM_LOG_ERROR("NULL handle[%p]", pc);
2962 return CAMERA_ERROR_INVALID_PARAMETER;
2965 CAM_LOG_INFO("Enter");
2967 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2969 if (ret == CAMERA_ERROR_NONE)
2970 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2972 CAM_LOG_INFO("ret : 0x%x", ret);
2977 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2979 int ret = CAMERA_ERROR_NONE;
2980 camera_cli_s *pc = (camera_cli_s *)camera;
2981 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2983 if (!pc || !pc->cb_info) {
2984 CAM_LOG_ERROR("NULL handle[%p]", pc);
2985 return CAMERA_ERROR_INVALID_PARAMETER;
2988 CAM_LOG_INFO("Enter");
2990 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2992 if (ret == CAMERA_ERROR_NONE) {
2993 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2995 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2996 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2998 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3001 CAM_LOG_INFO("ret : 0x%x", ret);
3006 int camera_stop_face_detection(camera_h camera)
3008 int ret = CAMERA_ERROR_NONE;
3009 camera_cli_s *pc = (camera_cli_s *)camera;
3010 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3012 if (!pc || !pc->cb_info) {
3013 CAM_LOG_ERROR("NULL handle[%p]", pc);
3014 return CAMERA_ERROR_INVALID_PARAMETER;
3017 CAM_LOG_INFO("Enter");
3019 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3021 if (ret == CAMERA_ERROR_NONE) {
3022 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3027 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3030 CAM_LOG_INFO("ret : 0x%x", ret);
3035 int camera_get_state(camera_h camera, camera_state_e *state)
3037 int ret = CAMERA_ERROR_NONE;
3038 camera_cli_s *pc = (camera_cli_s *)camera;
3039 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3041 if (!pc || !pc->cb_info || !state) {
3042 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3043 return CAMERA_ERROR_INVALID_PARAMETER;
3046 CAM_LOG_INFO("Enter");
3048 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3050 if (ret == CAMERA_ERROR_NONE)
3051 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3053 CAM_LOG_INFO("ret : 0x%x", ret);
3058 int camera_start_focusing(camera_h camera, bool continuous)
3060 int ret = CAMERA_ERROR_NONE;
3061 camera_cli_s *pc = (camera_cli_s *)camera;
3062 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3063 camera_msg_param param;
3064 int is_continuous = (int)continuous;
3066 if (!pc || !pc->cb_info) {
3067 CAM_LOG_ERROR("NULL handle[%p]", pc);
3068 return CAMERA_ERROR_INVALID_PARAMETER;
3071 CAM_LOG_INFO("Enter");
3073 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3075 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3077 CAM_LOG_INFO("ret : 0x%x", ret);
3082 int camera_cancel_focusing(camera_h camera)
3084 int ret = CAMERA_ERROR_NONE;
3085 camera_cli_s *pc = (camera_cli_s *)camera;
3086 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3088 if (!pc || !pc->cb_info) {
3089 CAM_LOG_ERROR("NULL handle[%p]", pc);
3090 return CAMERA_ERROR_INVALID_PARAMETER;
3093 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3095 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3097 CAM_LOG_INFO("ret : 0x%x", ret);
3103 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3105 int mm_ret = MM_ERROR_NONE;
3106 int ret = CAMERA_ERROR_NONE;
3107 camera_cli_s *pc = (camera_cli_s *)camera;
3108 camera_cb_info_s *cb_info = NULL;
3109 camera_state_e current_state = CAMERA_STATE_NONE;
3110 camera_msg_param param;
3111 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3112 muse_camera_display_info_s *dp_info = NULL;
3114 if (!pc || !pc->cb_info) {
3115 CAM_LOG_ERROR("NULL handle[%p]", pc);
3116 return CAMERA_ERROR_INVALID_PARAMETER;
3119 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3120 CAM_LOG_ERROR("invalid type %d", type);
3121 return CAMERA_ERROR_INVALID_PARAMETER;
3124 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3125 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3126 return CAMERA_ERROR_INVALID_PARAMETER;
3129 cb_info = (camera_cb_info_s *)pc->cb_info;
3130 dp_info = &cb_info->dp_info;
3132 ret = camera_get_state(camera, ¤t_state);
3133 if (ret != CAMERA_ERROR_NONE) {
3134 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3138 if (current_state != CAMERA_STATE_CREATED) {
3139 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3140 return CAMERA_ERROR_INVALID_STATE;
3143 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3145 if (type != MM_DISPLAY_TYPE_NONE) {
3146 /* check display interface handle */
3147 if (!cb_info->dp_interface) {
3148 CAM_LOG_ERROR("display interface not supported");
3149 return CAMERA_ERROR_NOT_SUPPORTED;
3152 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3153 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3154 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3155 return CAMERA_ERROR_NOT_SUPPORTED;
3156 } else if (mm_ret != MM_ERROR_NONE) {
3157 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3158 return CAMERA_ERROR_INVALID_OPERATION;
3161 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3162 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3164 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3165 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3166 dp_info->window_rect.width, dp_info->window_rect.height);
3167 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3169 camera_flip_e flip = CAMERA_FLIP_NONE;
3170 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3171 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3178 camera_get_display_flip(camera, &flip);
3179 camera_get_display_mode(camera, &mode);
3180 camera_get_display_rotation(camera, &rotation);
3181 camera_is_display_visible(camera, &visible);
3183 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3184 flip, mode, rotation, visible);
3186 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3187 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3188 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3189 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3191 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3192 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3193 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3194 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3200 if (mm_ret != MM_ERROR_NONE) {
3201 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3202 return CAMERA_ERROR_INVALID_OPERATION;
3205 dp_info->type = type;
3207 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3209 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3211 if (ret == CAMERA_ERROR_NONE)
3212 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3218 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3220 CAM_LOG_INFO("type %d, display %p", type, display);
3221 return _camera_set_display(camera, (mm_display_type_e)type, display);
3225 int camera_set_preview_resolution(camera_h camera, int width, int height)
3227 int ret = CAMERA_ERROR_NONE;
3228 camera_state_e current_state = CAMERA_STATE_NONE;
3229 camera_cli_s *pc = (camera_cli_s *)camera;
3230 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3231 camera_msg_param param;
3234 if (!pc || !pc->cb_info) {
3235 CAM_LOG_ERROR("NULL handle[%p]", pc);
3236 return CAMERA_ERROR_INVALID_PARAMETER;
3239 if (pc->cb_info->is_evas_render) {
3240 ret = camera_get_state(camera, ¤t_state);
3241 if (ret != CAMERA_ERROR_NONE) {
3242 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3246 if (current_state == CAMERA_STATE_PREVIEW) {
3247 ret = _camera_stop_evas_rendering(camera, true);
3248 if (ret != CAMERA_ERROR_NONE)
3253 value = (width << 16) | height;
3254 CAMERA_MSG_PARAM_SET(param, INT, value);
3256 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3258 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3260 CAM_LOG_INFO("ret : 0x%x", ret);
3262 if (current_state == CAMERA_STATE_PREVIEW) {
3263 CAM_LOG_WARNING("restart evas rendering");
3264 _camera_start_evas_rendering(camera);
3271 int camera_set_capture_resolution(camera_h camera, int width, int height)
3273 int ret = CAMERA_ERROR_NONE;
3274 camera_cli_s *pc = (camera_cli_s *)camera;
3275 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3276 camera_msg_param param;
3279 if (!pc || !pc->cb_info) {
3280 CAM_LOG_ERROR("NULL handle[%p]", pc);
3281 return CAMERA_ERROR_INVALID_PARAMETER;
3284 CAM_LOG_INFO("Enter");
3286 value = (width << 16) | height;
3287 CAMERA_MSG_PARAM_SET(param, INT, value);
3289 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3291 CAM_LOG_INFO("ret : 0x%x", ret);
3297 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3299 int ret = CAMERA_ERROR_NONE;
3300 int set_format = (int)format;
3301 camera_cli_s *pc = (camera_cli_s *)camera;
3302 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3303 camera_msg_param param;
3305 if (!pc || !pc->cb_info) {
3306 CAM_LOG_ERROR("NULL handle[%p]", pc);
3307 return CAMERA_ERROR_INVALID_PARAMETER;
3310 CAM_LOG_INFO("Enter - format %d", set_format);
3312 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3314 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3316 CAM_LOG_INFO("ret : 0x%x", ret);
3322 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3324 int ret = CAMERA_ERROR_NONE;
3325 int set_format = (int)format;
3326 camera_msg_param param;
3327 camera_cli_s *pc = (camera_cli_s *)camera;
3328 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3330 if (!pc || !pc->cb_info) {
3331 CAM_LOG_ERROR("NULL handle[%p]", pc);
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3335 CAM_LOG_INFO("Enter - format %d", set_format);
3337 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3339 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3341 if (ret == CAMERA_ERROR_NONE)
3342 pc->cb_info->preview_format = set_format;
3344 CAM_LOG_INFO("ret : 0x%x", ret);
3350 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3352 int ret = CAMERA_ERROR_NONE;
3353 camera_cli_s *pc = (camera_cli_s *)camera;
3354 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3356 if (!pc || !pc->cb_info || !width || !height) {
3357 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3358 return CAMERA_ERROR_INVALID_PARAMETER;
3361 CAM_LOG_INFO("Enter");
3363 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3365 if (ret == CAMERA_ERROR_NONE) {
3366 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3367 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3370 CAM_LOG_INFO("ret : 0x%x", ret);
3376 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3378 int ret = CAMERA_ERROR_NONE;
3379 int set_rotation = (int)rotation;
3380 camera_cli_s *pc = (camera_cli_s *)camera;
3381 camera_msg_param param;
3383 if (!pc || !pc->cb_info) {
3384 CAM_LOG_ERROR("NULL handle[%p]", pc);
3385 return CAMERA_ERROR_INVALID_PARAMETER;
3388 if (pc->cb_info->is_evas_render) {
3389 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3390 if (ret != MM_ERROR_NONE) {
3391 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3392 return CAMERA_ERROR_INVALID_OPERATION;
3396 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3398 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3404 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3406 int ret = CAMERA_ERROR_NONE;
3407 camera_cli_s *pc = (camera_cli_s *)camera;
3409 if (!pc || !pc->cb_info || !rotation) {
3410 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3411 return CAMERA_ERROR_INVALID_PARAMETER;
3414 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3416 if (ret == CAMERA_ERROR_NONE)
3417 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3423 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3425 int ret = CAMERA_ERROR_NONE;
3426 int set_flip = (int)flip;
3427 camera_cli_s *pc = (camera_cli_s *)camera;
3428 camera_msg_param param;
3430 if (!pc || !pc->cb_info) {
3431 CAM_LOG_ERROR("NULL handle[%p]", pc);
3432 return CAMERA_ERROR_INVALID_PARAMETER;
3435 if (pc->cb_info->is_evas_render) {
3436 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3437 if (ret != MM_ERROR_NONE) {
3438 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3439 return CAMERA_ERROR_INVALID_OPERATION;
3443 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3445 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3451 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3453 int ret = CAMERA_ERROR_NONE;
3454 camera_cli_s *pc = (camera_cli_s *)camera;
3456 if (!pc || !pc->cb_info || !flip) {
3457 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3458 return CAMERA_ERROR_INVALID_PARAMETER;
3461 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3463 if (ret == CAMERA_ERROR_NONE)
3464 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3470 int camera_set_display_visible(camera_h camera, bool visible)
3472 int ret = CAMERA_ERROR_NONE;
3473 int set_visible = (int)visible;
3474 camera_cli_s *pc = (camera_cli_s *)camera;
3475 camera_msg_param param;
3477 if (!pc || !pc->cb_info) {
3478 CAM_LOG_ERROR("NULL handle[%p]", pc);
3479 return CAMERA_ERROR_INVALID_PARAMETER;
3482 if (pc->cb_info->is_evas_render) {
3483 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3484 if (ret != MM_ERROR_NONE) {
3485 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3486 return CAMERA_ERROR_INVALID_OPERATION;
3490 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3492 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3498 int camera_is_display_visible(camera_h camera, bool *visible)
3500 int ret = CAMERA_ERROR_NONE;
3501 camera_cli_s *pc = (camera_cli_s *)camera;
3503 if (!pc || !pc->cb_info || !visible) {
3504 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3505 return CAMERA_ERROR_INVALID_PARAMETER;
3508 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3510 if (ret == CAMERA_ERROR_NONE)
3511 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3517 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3519 int ret = CAMERA_ERROR_NONE;
3520 int set_mode = (int)mode;
3521 camera_cli_s *pc = (camera_cli_s *)camera;
3522 camera_msg_param param;
3524 if (!pc || !pc->cb_info) {
3525 CAM_LOG_ERROR("NULL handle[%p]", pc);
3526 return CAMERA_ERROR_INVALID_PARAMETER;
3529 if (pc->cb_info->is_evas_render) {
3530 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3531 if (ret != MM_ERROR_NONE) {
3532 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3533 return CAMERA_ERROR_INVALID_OPERATION;
3537 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3539 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3545 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3547 int ret = CAMERA_ERROR_NONE;
3548 camera_cli_s *pc = (camera_cli_s *)camera;
3550 if (!pc || !pc->cb_info || !mode) {
3551 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3552 return CAMERA_ERROR_INVALID_PARAMETER;
3555 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3557 if (ret == CAMERA_ERROR_NONE)
3558 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3564 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3566 int ret = CAMERA_ERROR_NONE;
3567 int set_hint = (int)hint;
3568 camera_cli_s *pc = (camera_cli_s *)camera;
3569 camera_msg_param param;
3571 if (!pc || !pc->cb_info) {
3572 CAM_LOG_ERROR("NULL handle[%p]", pc);
3573 return CAMERA_ERROR_INVALID_PARAMETER;
3576 CAM_LOG_INFO("Enter - hint %d", set_hint);
3578 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3580 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3586 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3588 int ret = CAMERA_ERROR_NONE;
3589 camera_cli_s *pc = (camera_cli_s *)camera;
3590 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3592 if (!pc || !pc->cb_info || !hint) {
3593 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3597 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3599 if (ret == CAMERA_ERROR_NONE) {
3600 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3601 CAM_LOG_INFO("display reuse hint %d", *hint);
3608 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3610 int ret = CAMERA_ERROR_NONE;
3611 camera_cli_s *pc = (camera_cli_s *)camera;
3612 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3614 if (!pc || !pc->cb_info || !width || !height) {
3615 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3616 return CAMERA_ERROR_INVALID_PARAMETER;
3619 CAM_LOG_INFO("Enter");
3621 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3623 if (ret == CAMERA_ERROR_NONE) {
3624 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3625 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3628 CAM_LOG_INFO("ret : 0x%x", ret);
3634 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3636 int ret = CAMERA_ERROR_NONE;
3637 camera_cli_s *pc = (camera_cli_s *)camera;
3638 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3640 if (!pc || !pc->cb_info || !format) {
3641 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3642 return CAMERA_ERROR_INVALID_PARAMETER;
3645 CAM_LOG_INFO("Enter");
3647 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3649 if (ret == CAMERA_ERROR_NONE)
3650 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3652 CAM_LOG_INFO("ret : 0x%x", ret);
3658 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3660 int ret = CAMERA_ERROR_NONE;
3661 camera_cli_s *pc = (camera_cli_s *)camera;
3662 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3664 if (!pc || !pc->cb_info || !format) {
3665 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3669 CAM_LOG_INFO("Enter");
3671 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3673 if (ret == CAMERA_ERROR_NONE)
3674 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3676 CAM_LOG_INFO("ret : 0x%x", ret);
3682 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3684 int ret = CAMERA_ERROR_NONE;
3685 camera_cli_s *pc = (camera_cli_s *)camera;
3686 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3688 if (!pc || !pc->cb_info || !facing_direction) {
3689 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3693 CAM_LOG_INFO("Enter");
3695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3697 if (ret == CAMERA_ERROR_NONE)
3698 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3700 CAM_LOG_INFO("ret : 0x%x", ret);
3706 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3708 int ret = CAMERA_ERROR_NONE;
3709 camera_cli_s *pc = (camera_cli_s *)camera;
3710 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3712 if (!pc || !pc->cb_info || !callback) {
3713 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3714 return CAMERA_ERROR_INVALID_PARAMETER;
3717 CAM_LOG_INFO("Enter");
3719 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3721 if (ret == CAMERA_ERROR_NONE) {
3722 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3724 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3725 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3727 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3730 CAM_LOG_INFO("ret : 0x%x", ret);
3736 int camera_unset_preview_cb(camera_h camera)
3738 int ret = CAMERA_ERROR_NONE;
3739 camera_cli_s *pc = (camera_cli_s *)camera;
3740 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3742 if (!pc || !pc->cb_info) {
3743 CAM_LOG_ERROR("NULL handle[%p]", pc);
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_PREVIEW]);
3754 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3755 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3757 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3760 CAM_LOG_INFO("ret : 0x%x", ret);
3766 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3768 int ret = CAMERA_ERROR_NONE;
3769 camera_cli_s *pc = (camera_cli_s *)camera;
3770 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3772 if (!pc || !pc->cb_info) {
3773 CAM_LOG_ERROR("NULL handle[%p]", pc);
3774 return CAMERA_ERROR_INVALID_PARAMETER;
3777 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3778 CAM_LOG_ERROR("NOT SUPPORTED");
3779 return CAMERA_ERROR_NOT_SUPPORTED;
3782 if (callback == NULL) {
3783 CAM_LOG_ERROR("NULL callback");
3784 return CAMERA_ERROR_INVALID_PARAMETER;
3787 CAM_LOG_INFO("Enter");
3789 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3791 if (ret == CAMERA_ERROR_NONE) {
3792 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3797 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3800 CAM_LOG_INFO("ret : 0x%x", ret);
3806 int camera_unset_media_packet_preview_cb(camera_h camera)
3808 int ret = CAMERA_ERROR_NONE;
3809 camera_cli_s *pc = (camera_cli_s *)camera;
3810 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3812 if (!pc || !pc->cb_info) {
3813 CAM_LOG_ERROR("NULL handle[%p]", pc);
3814 return CAMERA_ERROR_INVALID_PARAMETER;
3817 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3818 CAM_LOG_ERROR("NOT SUPPORTED");
3819 return CAMERA_ERROR_NOT_SUPPORTED;
3822 CAM_LOG_INFO("Enter");
3824 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3826 if (ret == CAMERA_ERROR_NONE) {
3827 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3829 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3830 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3832 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3835 CAM_LOG_INFO("ret : 0x%x", ret);
3841 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3843 int ret = CAMERA_ERROR_NONE;
3844 camera_cli_s *pc = (camera_cli_s *)camera;
3845 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3847 if (!pc || !pc->cb_info || !callback) {
3848 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3849 return CAMERA_ERROR_INVALID_PARAMETER;
3852 CAM_LOG_INFO("Enter");
3854 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3856 if (ret == CAMERA_ERROR_NONE) {
3857 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3859 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3860 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3862 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3865 CAM_LOG_INFO("ret : 0x%x", ret);
3871 int camera_unset_state_changed_cb(camera_h camera)
3873 int ret = CAMERA_ERROR_NONE;
3874 camera_cli_s *pc = (camera_cli_s *)camera;
3875 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3877 if (!pc || !pc->cb_info) {
3878 CAM_LOG_ERROR("NULL handle[%p]", pc);
3879 return CAMERA_ERROR_INVALID_PARAMETER;
3882 CAM_LOG_INFO("Enter");
3884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3886 if (ret == CAMERA_ERROR_NONE) {
3887 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3889 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3890 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3892 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3895 CAM_LOG_INFO("ret : 0x%x", ret);
3901 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3903 int ret = CAMERA_ERROR_NONE;
3904 camera_cli_s *pc = (camera_cli_s *)camera;
3905 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3907 if (!pc || !pc->cb_info || !callback) {
3908 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3909 return CAMERA_ERROR_INVALID_PARAMETER;
3912 CAM_LOG_INFO("Enter");
3914 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3916 if (ret == CAMERA_ERROR_NONE) {
3917 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3919 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3920 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3922 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3925 CAM_LOG_INFO("ret : 0x%x", ret);
3931 int camera_unset_interrupted_cb(camera_h camera)
3933 int ret = CAMERA_ERROR_NONE;
3934 camera_cli_s *pc = (camera_cli_s *)camera;
3935 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3937 if (!pc || !pc->cb_info) {
3938 CAM_LOG_ERROR("NULL handle[%p]", pc);
3939 return CAMERA_ERROR_INVALID_PARAMETER;
3942 CAM_LOG_INFO("Enter");
3944 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3946 if (ret == CAMERA_ERROR_NONE) {
3947 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3949 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3950 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3952 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3955 CAM_LOG_INFO("ret : 0x%x", ret);
3961 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3963 int ret = CAMERA_ERROR_NONE;
3964 camera_cli_s *pc = (camera_cli_s *)camera;
3965 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3967 if (!pc || !pc->cb_info || !callback) {
3968 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3969 return CAMERA_ERROR_INVALID_PARAMETER;
3972 CAM_LOG_INFO("Enter");
3974 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3976 if (ret == CAMERA_ERROR_NONE) {
3977 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3979 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3980 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3982 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3985 CAM_LOG_INFO("ret : 0x%x", ret);
3991 int camera_unset_interrupt_started_cb(camera_h camera)
3993 int ret = CAMERA_ERROR_NONE;
3994 camera_cli_s *pc = (camera_cli_s *)camera;
3995 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3997 if (!pc || !pc->cb_info) {
3998 CAM_LOG_ERROR("NULL handle[%p]", pc);
3999 return CAMERA_ERROR_INVALID_PARAMETER;
4002 CAM_LOG_INFO("Enter");
4004 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4006 if (ret == CAMERA_ERROR_NONE) {
4007 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4009 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4010 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4012 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4015 CAM_LOG_INFO("ret : 0x%x", ret);
4021 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4023 int ret = CAMERA_ERROR_NONE;
4024 camera_cli_s *pc = (camera_cli_s *)camera;
4025 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4027 if (!pc || !pc->cb_info || !callback) {
4028 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4029 return CAMERA_ERROR_INVALID_PARAMETER;
4032 CAM_LOG_INFO("Enter");
4034 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4036 if (ret == CAMERA_ERROR_NONE) {
4037 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4039 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4040 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4042 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4045 CAM_LOG_INFO("ret : 0x%x", ret);
4051 int camera_unset_focus_changed_cb(camera_h camera)
4053 int ret = CAMERA_ERROR_NONE;
4054 camera_cli_s *pc = (camera_cli_s *)camera;
4055 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4057 if (!pc || !pc->cb_info) {
4058 CAM_LOG_ERROR("NULL handle[%p]", pc);
4059 return CAMERA_ERROR_INVALID_PARAMETER;
4062 CAM_LOG_INFO("Enter");
4064 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4066 if (ret == CAMERA_ERROR_NONE) {
4067 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4069 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4070 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4072 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4075 CAM_LOG_INFO("ret : 0x%x", ret);
4081 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4083 int ret = CAMERA_ERROR_NONE;
4084 camera_cli_s *pc = (camera_cli_s *)camera;
4085 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4087 if (!pc || !pc->cb_info || !callback) {
4088 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4089 return CAMERA_ERROR_INVALID_PARAMETER;
4092 CAM_LOG_INFO("Enter");
4094 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4096 if (ret == CAMERA_ERROR_NONE) {
4097 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4099 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4100 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4102 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4105 CAM_LOG_INFO("ret : 0x%x", ret);
4111 int camera_unset_error_cb(camera_h camera)
4113 int ret = CAMERA_ERROR_NONE;
4114 camera_cli_s *pc = (camera_cli_s *)camera;
4115 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4117 if (!pc || !pc->cb_info) {
4118 CAM_LOG_ERROR("NULL handle[%p]", pc);
4119 return CAMERA_ERROR_INVALID_PARAMETER;
4122 CAM_LOG_INFO("Enter");
4124 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4126 if (ret == CAMERA_ERROR_NONE) {
4127 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4129 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4130 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4132 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4135 CAM_LOG_INFO("ret : 0x%x", ret);
4141 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4143 int ret = CAMERA_ERROR_NONE;
4144 camera_cli_s *pc = (camera_cli_s *)camera;
4145 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4147 if (!pc || !pc->cb_info || !foreach_cb) {
4148 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4152 CAM_LOG_INFO("Enter");
4154 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4155 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4157 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4159 CAM_LOG_INFO("ret : 0x%x", ret);
4165 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4167 int ret = CAMERA_ERROR_NONE;
4168 camera_cli_s *pc = (camera_cli_s *)camera;
4169 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4171 if (!pc || !pc->cb_info || !foreach_cb) {
4172 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4173 return CAMERA_ERROR_INVALID_PARAMETER;
4176 CAM_LOG_INFO("Enter");
4178 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4179 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4181 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4183 CAM_LOG_INFO("ret : 0x%x", ret);
4189 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4191 int ret = CAMERA_ERROR_NONE;
4192 camera_cli_s *pc = (camera_cli_s *)camera;
4193 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4195 if (!pc || !pc->cb_info || !foreach_cb) {
4196 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4197 return CAMERA_ERROR_INVALID_PARAMETER;
4200 CAM_LOG_INFO("Enter");
4202 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4203 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4205 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4207 CAM_LOG_INFO("ret : 0x%x", ret);
4213 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4215 int ret = CAMERA_ERROR_NONE;
4216 camera_cli_s *pc = (camera_cli_s *)camera;
4217 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4219 if (!pc || !pc->cb_info || !foreach_cb) {
4220 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4221 return CAMERA_ERROR_INVALID_PARAMETER;
4224 CAM_LOG_INFO("Enter");
4226 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4227 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4229 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4231 CAM_LOG_INFO("ret : 0x%x", ret);
4237 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4239 int ret = CAMERA_ERROR_NONE;
4240 camera_cli_s *pc = (camera_cli_s *)camera;
4241 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4243 if (!pc || !pc->cb_info || !width || !height) {
4244 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4245 return CAMERA_ERROR_INVALID_PARAMETER;
4248 CAM_LOG_INFO("Enter");
4249 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4251 if (ret == CAMERA_ERROR_NONE) {
4252 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4253 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4256 CAM_LOG_INFO("ret : 0x%x", ret);
4262 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4264 int ret = CAMERA_ERROR_NONE;
4265 camera_cli_s *pc = (camera_cli_s *)camera;
4266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4268 if (!pc || !pc->cb_info || !angle) {
4269 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4273 CAM_LOG_INFO("Enter");
4275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4277 if (ret == CAMERA_ERROR_NONE)
4278 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4280 CAM_LOG_INFO("ret : 0x%x", ret);
4286 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4288 int ret = CAMERA_ERROR_NONE;
4289 camera_cli_s *pc = (camera_cli_s *)camera;
4290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4291 camera_msg_param param;
4292 int set_mode = (int)mode;
4294 if (!pc || !pc->cb_info) {
4295 CAM_LOG_ERROR("NULL handle[%p]", pc);
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4299 CAM_LOG_INFO("Enter");
4301 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4303 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4305 CAM_LOG_INFO("ret : 0x%x", ret);
4311 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4313 int ret = CAMERA_ERROR_NONE;
4314 camera_cli_s *pc = (camera_cli_s *)camera;
4315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4317 if (!pc || !pc->cb_info || !mode) {
4318 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4322 CAM_LOG_INFO("Enter");
4324 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4326 if (ret == CAMERA_ERROR_NONE)
4327 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4329 CAM_LOG_INFO("ret : 0x%x", ret);
4335 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4337 int ret = CAMERA_ERROR_NONE;
4338 camera_cli_s *pc = (camera_cli_s *)camera;
4339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4341 if (!pc || !pc->cb_info || !foreach_cb) {
4342 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4343 return CAMERA_ERROR_INVALID_PARAMETER;
4346 CAM_LOG_INFO("Enter");
4348 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4349 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4351 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4353 CAM_LOG_INFO("Finish, return :%x", ret);
4359 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4361 int ret = CAMERA_ERROR_NONE;
4362 camera_cli_s *pc = (camera_cli_s *)camera;
4363 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4364 camera_msg_param param;
4365 int set_fps = (int)fps;
4367 if (!pc || !pc->cb_info) {
4368 CAM_LOG_ERROR("NULL handle[%p]", pc);
4369 return CAMERA_ERROR_INVALID_PARAMETER;
4372 CAM_LOG_INFO("Enter");
4374 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4376 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4378 CAM_LOG_INFO("ret : 0x%x", ret);
4384 int camera_attr_set_image_quality(camera_h camera, int quality)
4386 int ret = CAMERA_ERROR_NONE;
4387 camera_cli_s *pc = (camera_cli_s *)camera;
4388 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4389 camera_msg_param param;
4391 if (!pc || !pc->cb_info) {
4392 CAM_LOG_ERROR("NULL handle[%p]", pc);
4393 return CAMERA_ERROR_INVALID_PARAMETER;
4396 CAM_LOG_INFO("Enter");
4398 CAMERA_MSG_PARAM_SET(param, INT, quality);
4400 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4402 CAM_LOG_INFO("ret : 0x%x", ret);
4408 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4410 int ret = CAMERA_ERROR_NONE;
4411 camera_cli_s *pc = (camera_cli_s *)camera;
4412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4414 if (!pc || !pc->cb_info || !fps) {
4415 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4416 return CAMERA_ERROR_INVALID_PARAMETER;
4419 CAM_LOG_INFO("Enter");
4421 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4423 if (ret == CAMERA_ERROR_NONE)
4424 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4426 CAM_LOG_INFO("ret : 0x%x", ret);
4432 int camera_attr_get_image_quality(camera_h camera, int *quality)
4434 int ret = CAMERA_ERROR_NONE;
4435 camera_cli_s *pc = (camera_cli_s *)camera;
4436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4438 if (!pc || !pc->cb_info || !quality) {
4439 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4440 return CAMERA_ERROR_INVALID_PARAMETER;
4443 CAM_LOG_INFO("Enter");
4445 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4447 if (ret == CAMERA_ERROR_NONE)
4448 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4450 CAM_LOG_INFO("ret : 0x%x", ret);
4456 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4458 int ret = CAMERA_ERROR_NONE;
4459 camera_cli_s *pc = (camera_cli_s *)camera;
4460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4462 if (!pc || !pc->cb_info || !bitrate) {
4463 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4464 return CAMERA_ERROR_INVALID_PARAMETER;
4467 CAM_LOG_INFO("Enter");
4469 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4471 if (ret == CAMERA_ERROR_NONE)
4472 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4474 CAM_LOG_INFO("ret : 0x%x", ret);
4480 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4482 int ret = CAMERA_ERROR_NONE;
4483 camera_cli_s *pc = (camera_cli_s *)camera;
4484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4485 camera_msg_param param;
4486 int set_bitrate = bitrate;
4488 if (!pc || !pc->cb_info) {
4489 CAM_LOG_ERROR("NULL handle[%p]", pc);
4490 return CAMERA_ERROR_INVALID_PARAMETER;
4493 CAM_LOG_INFO("Enter");
4495 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4497 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4499 CAM_LOG_INFO("ret : 0x%x", ret);
4505 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4511 if (!pc || !pc->cb_info || !interval) {
4512 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4513 return CAMERA_ERROR_INVALID_PARAMETER;
4516 CAM_LOG_INFO("Enter");
4518 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4520 if (ret == CAMERA_ERROR_NONE)
4521 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4523 CAM_LOG_INFO("ret : 0x%x", ret);
4529 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4534 camera_msg_param param;
4535 int set_gop_interval = interval;
4537 if (!pc || !pc->cb_info) {
4538 CAM_LOG_ERROR("NULL handle[%p]", pc);
4539 return CAMERA_ERROR_INVALID_PARAMETER;
4542 CAM_LOG_INFO("Enter");
4544 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4546 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4548 CAM_LOG_INFO("ret : 0x%x", ret);
4554 int camera_attr_set_zoom(camera_h camera, int zoom)
4556 int ret = CAMERA_ERROR_NONE;
4557 camera_cli_s *pc = (camera_cli_s *)camera;
4558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4559 camera_msg_param param;
4561 if (!pc || !pc->cb_info) {
4562 CAM_LOG_ERROR("NULL handle[%p]", pc);
4563 return CAMERA_ERROR_INVALID_PARAMETER;
4566 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4568 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4570 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4572 CAM_LOG_INFO("ret : 0x%x", ret);
4578 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4580 int ret = CAMERA_ERROR_NONE;
4581 camera_cli_s *pc = (camera_cli_s *)camera;
4582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4583 camera_msg_param param;
4584 int set_mode = (int)mode;
4586 if (!pc || !pc->cb_info) {
4587 CAM_LOG_ERROR("NULL handle[%p]", pc);
4588 return CAMERA_ERROR_INVALID_PARAMETER;
4591 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4593 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4601 int camera_attr_set_af_area(camera_h camera, int x, int y)
4603 int ret = CAMERA_ERROR_NONE;
4604 camera_cli_s *pc = (camera_cli_s *)camera;
4605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4606 camera_msg_param param;
4609 if (!pc || !pc->cb_info) {
4610 CAM_LOG_ERROR("NULL handle[%p]", pc);
4611 return CAMERA_ERROR_INVALID_PARAMETER;
4614 CAM_LOG_INFO("Enter - %d,%d", x, y);
4616 value = (x << 16) | y;
4617 CAMERA_MSG_PARAM_SET(param, INT, value);
4619 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4621 CAM_LOG_INFO("ret : 0x%x", ret);
4627 int camera_attr_clear_af_area(camera_h camera)
4629 int ret = CAMERA_ERROR_NONE;
4630 camera_cli_s *pc = (camera_cli_s *)camera;
4631 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4633 if (!pc || !pc->cb_info) {
4634 CAM_LOG_ERROR("NULL handle[%p]", pc);
4635 return CAMERA_ERROR_INVALID_PARAMETER;
4638 CAM_LOG_INFO("Enter");
4640 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4642 CAM_LOG_INFO("ret : 0x%x", ret);
4648 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4653 camera_msg_param param;
4654 int set_mode = (int)mode;
4656 if (!pc || !pc->cb_info) {
4657 CAM_LOG_ERROR("NULL handle[%p]", pc);
4658 return CAMERA_ERROR_INVALID_PARAMETER;
4661 CAM_LOG_INFO("Enter");
4663 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4665 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4667 CAM_LOG_INFO("ret : 0x%x", ret);
4673 int camera_attr_set_exposure(camera_h camera, int value)
4675 int ret = CAMERA_ERROR_NONE;
4676 camera_cli_s *pc = (camera_cli_s *)camera;
4677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4678 camera_msg_param param;
4680 if (!pc || !pc->cb_info) {
4681 CAM_LOG_ERROR("NULL handle[%p]", pc);
4682 return CAMERA_ERROR_INVALID_PARAMETER;
4685 CAM_LOG_INFO("Enter");
4687 CAMERA_MSG_PARAM_SET(param, INT, value);
4689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4691 CAM_LOG_INFO("ret : 0x%x", ret);
4697 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4699 int ret = CAMERA_ERROR_NONE;
4700 camera_cli_s *pc = (camera_cli_s *)camera;
4701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4702 camera_msg_param param;
4703 int set_iso = (int)iso;
4705 if (!pc || !pc->cb_info) {
4706 CAM_LOG_ERROR("NULL handle[%p]", pc);
4707 return CAMERA_ERROR_INVALID_PARAMETER;
4710 CAM_LOG_INFO("Enter");
4712 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4714 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4716 CAM_LOG_INFO("ret : 0x%x", ret);
4722 int camera_attr_set_brightness(camera_h camera, int level)
4724 int ret = CAMERA_ERROR_NONE;
4725 camera_cli_s *pc = (camera_cli_s *)camera;
4726 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4727 camera_msg_param param;
4729 if (!pc || !pc->cb_info) {
4730 CAM_LOG_ERROR("NULL handle[%p]", pc);
4731 return CAMERA_ERROR_INVALID_PARAMETER;
4734 CAM_LOG_INFO("Enter");
4736 CAMERA_MSG_PARAM_SET(param, INT, level);
4738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4740 CAM_LOG_INFO("ret : 0x%x", ret);
4746 int camera_attr_set_contrast(camera_h camera, int level)
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4751 camera_msg_param param;
4753 if (!pc || !pc->cb_info) {
4754 CAM_LOG_ERROR("NULL handle[%p]", pc);
4755 return CAMERA_ERROR_INVALID_PARAMETER;
4758 CAM_LOG_INFO("Enter");
4760 CAMERA_MSG_PARAM_SET(param, INT, level);
4762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4764 CAM_LOG_INFO("ret : 0x%x", ret);
4770 int camera_attr_set_hue(camera_h camera, int level)
4772 int ret = CAMERA_ERROR_NONE;
4773 camera_cli_s *pc = (camera_cli_s *)camera;
4774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4775 camera_msg_param param;
4777 if (!pc || !pc->cb_info) {
4778 CAM_LOG_ERROR("NULL handle[%p]", pc);
4779 return CAMERA_ERROR_INVALID_PARAMETER;
4782 CAM_LOG_INFO("Enter");
4784 CAMERA_MSG_PARAM_SET(param, INT, level);
4786 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4788 CAM_LOG_INFO("ret : 0x%x", ret);
4794 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4796 int ret = CAMERA_ERROR_NONE;
4797 camera_cli_s *pc = (camera_cli_s *)camera;
4798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4799 camera_msg_param param;
4800 int set_whitebalance = (int)wb;
4802 if (!pc || !pc->cb_info) {
4803 CAM_LOG_ERROR("NULL handle[%p]", pc);
4804 return CAMERA_ERROR_INVALID_PARAMETER;
4807 CAM_LOG_INFO("Enter");
4809 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4813 CAM_LOG_INFO("ret : 0x%x", ret);
4819 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4821 int ret = CAMERA_ERROR_NONE;
4822 camera_cli_s *pc = (camera_cli_s *)camera;
4823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4824 camera_msg_param param;
4825 int set_effect = (int)effect;
4827 if (!pc || !pc->cb_info) {
4828 CAM_LOG_ERROR("NULL handle[%p]", pc);
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4832 CAM_LOG_INFO("Enter");
4834 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4838 CAM_LOG_INFO("ret : 0x%x", ret);
4844 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4846 int ret = CAMERA_ERROR_NONE;
4847 camera_cli_s *pc = (camera_cli_s *)camera;
4848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4849 camera_msg_param param;
4850 int set_mode = (int)mode;
4852 if (!pc || !pc->cb_info) {
4853 CAM_LOG_ERROR("NULL handle[%p]", pc);
4854 return CAMERA_ERROR_INVALID_PARAMETER;
4857 CAM_LOG_INFO("Enter");
4859 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4863 CAM_LOG_INFO("ret : 0x%x", ret);
4869 int camera_attr_enable_tag(camera_h camera, bool enable)
4871 int ret = CAMERA_ERROR_NONE;
4872 camera_cli_s *pc = (camera_cli_s *)camera;
4873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4874 camera_msg_param param;
4875 int set_enable = (int)enable;
4877 if (!pc || !pc->cb_info) {
4878 CAM_LOG_ERROR("NULL handle[%p]", pc);
4879 return CAMERA_ERROR_INVALID_PARAMETER;
4882 CAM_LOG_INFO("Enter");
4884 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4886 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4888 CAM_LOG_INFO("ret : 0x%x", ret);
4894 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4896 int ret = CAMERA_ERROR_NONE;
4897 camera_cli_s *pc = (camera_cli_s *)camera;
4898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4899 camera_msg_param param;
4901 if (!pc || !pc->cb_info || !description) {
4902 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4903 return CAMERA_ERROR_INVALID_PARAMETER;
4906 CAM_LOG_INFO("Enter");
4908 CAMERA_MSG_PARAM_SET(param, STRING, description);
4910 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4912 CAM_LOG_INFO("ret : 0x%x", ret);
4918 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4920 int ret = CAMERA_ERROR_NONE;
4921 camera_cli_s *pc = (camera_cli_s *)camera;
4922 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4923 camera_msg_param param;
4924 int set_orientation = (int)orientation;
4926 if (!pc || !pc->cb_info) {
4927 CAM_LOG_ERROR("NULL handle[%p]", pc);
4928 return CAMERA_ERROR_INVALID_PARAMETER;
4931 CAM_LOG_INFO("Enter");
4933 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4935 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4937 CAM_LOG_INFO("ret : 0x%x", ret);
4943 int camera_attr_set_tag_software(camera_h camera, const char *software)
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_SET_TAG_SOFTWARE;
4948 camera_msg_param param;
4950 if (!pc || !pc->cb_info || !software) {
4951 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4952 return CAMERA_ERROR_INVALID_PARAMETER;
4955 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4957 CAMERA_MSG_PARAM_SET(param, STRING, software);
4959 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4961 CAM_LOG_INFO("ret : 0x%x", ret);
4967 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4969 int ret = CAMERA_ERROR_NONE;
4970 camera_cli_s *pc = (camera_cli_s *)camera;
4971 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4972 double set_geotag[3] = {latitude, longitude, altitude};
4977 if (!pc || !pc->cb_info) {
4978 CAM_LOG_ERROR("NULL handle[%p]", pc);
4979 return CAMERA_ERROR_INVALID_PARAMETER;
4982 CAM_LOG_INFO("Enter");
4984 length = sizeof(set_geotag) / sizeof(int) + \
4985 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4987 msg = muse_core_msg_new(api,
4988 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4991 CAM_LOG_ERROR("msg creation failed: api %d", api);
4992 return CAMERA_ERROR_OUT_OF_MEMORY;
4995 if (pc->cb_info->is_server_connected) {
4996 _camera_update_api_waiting(pc->cb_info, api, 1);
4998 g_mutex_lock(&pc->cb_info->fd_lock);
4999 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5000 g_mutex_unlock(&pc->cb_info->fd_lock);
5004 CAM_LOG_ERROR("message send failed");
5005 ret = CAMERA_ERROR_INVALID_OPERATION;
5007 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5010 _camera_update_api_waiting(pc->cb_info, api, -1);
5012 muse_core_msg_free(msg);
5014 CAM_LOG_INFO("ret : 0x%x", ret);
5020 int camera_attr_remove_geotag(camera_h camera)
5022 int ret = CAMERA_ERROR_NONE;
5023 camera_cli_s *pc = (camera_cli_s *)camera;
5024 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5026 if (!pc || !pc->cb_info) {
5027 CAM_LOG_ERROR("NULL handle[%p]", pc);
5028 return CAMERA_ERROR_INVALID_PARAMETER;
5031 CAM_LOG_INFO("Enter");
5033 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5035 CAM_LOG_INFO("ret : 0x%x", ret);
5041 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5043 int ret = CAMERA_ERROR_NONE;
5044 camera_cli_s *pc = (camera_cli_s *)camera;
5045 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5046 camera_msg_param param;
5047 int set_mode = (int)mode;
5049 if (!pc || !pc->cb_info) {
5050 CAM_LOG_ERROR("NULL handle[%p]", pc);
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5054 CAM_LOG_INFO("Enter");
5056 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5058 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5060 CAM_LOG_INFO("ret : 0x%x", ret);
5066 int camera_attr_get_zoom(camera_h camera, int *zoom)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5072 if (!pc || !pc->cb_info || !zoom) {
5073 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
5074 return CAMERA_ERROR_INVALID_PARAMETER;
5077 CAM_LOG_INFO("Enter");
5079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5081 if (ret == CAMERA_ERROR_NONE)
5082 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5084 CAM_LOG_INFO("ret : 0x%x", ret);
5090 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5096 if (!pc || !pc->cb_info || !min || !max) {
5097 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5098 return CAMERA_ERROR_INVALID_PARAMETER;
5101 CAM_LOG_INFO("Enter");
5103 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5105 if (ret == CAMERA_ERROR_NONE) {
5106 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5107 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5110 CAM_LOG_INFO("ret : 0x%x", ret);
5116 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5118 int ret = CAMERA_ERROR_NONE;
5119 camera_cli_s *pc = (camera_cli_s *)camera;
5120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5122 if (!pc || !pc->cb_info || !mode) {
5123 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5124 return CAMERA_ERROR_INVALID_PARAMETER;
5127 CAM_LOG_INFO("Enter");
5129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5131 if (ret == CAMERA_ERROR_NONE)
5132 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5134 CAM_LOG_INFO("ret : 0x%x", ret);
5140 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5142 int ret = CAMERA_ERROR_NONE;
5143 camera_cli_s *pc = (camera_cli_s *)camera;
5144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5146 if (!pc || !pc->cb_info || !mode) {
5147 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5148 return CAMERA_ERROR_INVALID_PARAMETER;
5151 CAM_LOG_INFO("Enter");
5153 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5155 if (ret == CAMERA_ERROR_NONE)
5156 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5158 CAM_LOG_INFO("ret : 0x%x", ret);
5164 int camera_attr_get_exposure(camera_h camera, int *value)
5166 int ret = CAMERA_ERROR_NONE;
5167 camera_cli_s *pc = (camera_cli_s *)camera;
5168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5170 if (!pc || !pc->cb_info || !value) {
5171 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5172 return CAMERA_ERROR_INVALID_PARAMETER;
5175 CAM_LOG_INFO("Enter");
5177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5179 if (ret == CAMERA_ERROR_NONE)
5180 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5182 CAM_LOG_INFO("ret : 0x%x", ret);
5188 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5190 int ret = CAMERA_ERROR_NONE;
5191 camera_cli_s *pc = (camera_cli_s *)camera;
5192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5194 if (!pc || !pc->cb_info || !min || !max) {
5195 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5196 return CAMERA_ERROR_INVALID_PARAMETER;
5199 CAM_LOG_INFO("Enter");
5201 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5203 if (ret == CAMERA_ERROR_NONE) {
5204 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5205 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5208 CAM_LOG_INFO("ret : 0x%x", ret);
5214 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5216 int ret = CAMERA_ERROR_NONE;
5217 camera_cli_s *pc = (camera_cli_s *)camera;
5218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5220 if (!pc || !pc->cb_info || !iso) {
5221 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5222 return CAMERA_ERROR_INVALID_PARAMETER;
5225 CAM_LOG_INFO("Enter");
5227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5229 if (ret == CAMERA_ERROR_NONE)
5230 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5232 CAM_LOG_INFO("ret : 0x%x", ret);
5238 int camera_attr_get_brightness(camera_h camera, int *level)
5240 int ret = CAMERA_ERROR_NONE;
5241 camera_cli_s *pc = (camera_cli_s *)camera;
5242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5244 if (!pc || !pc->cb_info || !level) {
5245 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5246 return CAMERA_ERROR_INVALID_PARAMETER;
5249 CAM_LOG_INFO("Enter");
5251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5253 if (ret == CAMERA_ERROR_NONE)
5254 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5256 CAM_LOG_INFO("ret : 0x%x", ret);
5262 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5264 int ret = CAMERA_ERROR_NONE;
5265 camera_cli_s *pc = (camera_cli_s *)camera;
5266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5268 if (!pc || !pc->cb_info || !min || !max) {
5269 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5270 return CAMERA_ERROR_INVALID_PARAMETER;
5273 CAM_LOG_INFO("Enter");
5275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5277 if (ret == CAMERA_ERROR_NONE) {
5278 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5279 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5282 CAM_LOG_INFO("ret : 0x%x", ret);
5288 int camera_attr_get_contrast(camera_h camera, int *level)
5290 int ret = CAMERA_ERROR_NONE;
5291 camera_cli_s *pc = (camera_cli_s *)camera;
5292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5294 if (!pc || !pc->cb_info || !level) {
5295 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5296 return CAMERA_ERROR_INVALID_PARAMETER;
5299 CAM_LOG_INFO("Enter");
5301 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5303 if (ret == CAMERA_ERROR_NONE)
5304 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5306 CAM_LOG_INFO("ret : 0x%x", ret);
5312 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5314 int ret = CAMERA_ERROR_NONE;
5315 camera_cli_s *pc = (camera_cli_s *)camera;
5316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5318 if (!pc || !pc->cb_info || !min || !max) {
5319 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5320 return CAMERA_ERROR_INVALID_PARAMETER;
5323 CAM_LOG_INFO("Enter");
5325 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5327 if (ret == CAMERA_ERROR_NONE) {
5328 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5329 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5330 CAM_LOG_INFO("min %d, max %d", *min, *max);
5333 CAM_LOG_INFO("ret : 0x%x", ret);
5339 int camera_attr_get_hue(camera_h camera, int *level)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5345 if (!pc || !pc->cb_info || !level) {
5346 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5350 CAM_LOG_INFO("Enter");
5352 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE)
5355 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5357 CAM_LOG_INFO("ret : 0x%x", ret);
5363 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5365 int ret = CAMERA_ERROR_NONE;
5366 camera_cli_s *pc = (camera_cli_s *)camera;
5367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5369 if (!pc || !pc->cb_info || !min || !max) {
5370 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5374 CAM_LOG_INFO("Enter");
5376 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5378 if (ret == CAMERA_ERROR_NONE) {
5379 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5380 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5381 CAM_LOG_INFO("min %d, max %d", *min, *max);
5384 CAM_LOG_INFO("ret : 0x%x", ret);
5390 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5392 int ret = CAMERA_ERROR_NONE;
5393 camera_cli_s *pc = (camera_cli_s *)camera;
5394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5396 if (!pc || !pc->cb_info || !wb) {
5397 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5398 return CAMERA_ERROR_INVALID_PARAMETER;
5401 CAM_LOG_INFO("Enter");
5403 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5405 if (ret == CAMERA_ERROR_NONE)
5406 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5408 CAM_LOG_INFO("ret : 0x%x", ret);
5414 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5416 int ret = CAMERA_ERROR_NONE;
5417 camera_cli_s *pc = (camera_cli_s *)camera;
5418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5420 if (!pc || !pc->cb_info || !effect) {
5421 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5422 return CAMERA_ERROR_INVALID_PARAMETER;
5425 CAM_LOG_INFO("Enter");
5427 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5429 if (ret == CAMERA_ERROR_NONE)
5430 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5432 CAM_LOG_INFO("ret : 0x%x", ret);
5438 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5440 int ret = CAMERA_ERROR_NONE;
5441 camera_cli_s *pc = (camera_cli_s *)camera;
5442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5444 if (!pc || !pc->cb_info || !mode) {
5445 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5446 return CAMERA_ERROR_INVALID_PARAMETER;
5449 CAM_LOG_INFO("Enter");
5451 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5453 if (ret == CAMERA_ERROR_NONE)
5454 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5456 CAM_LOG_INFO("ret : 0x%x", ret);
5462 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5464 int ret = CAMERA_ERROR_NONE;
5465 camera_cli_s *pc = (camera_cli_s *)camera;
5466 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5468 if (!pc || !pc->cb_info || !enable) {
5469 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5470 return CAMERA_ERROR_INVALID_PARAMETER;
5473 CAM_LOG_INFO("Enter");
5475 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5477 if (ret == CAMERA_ERROR_NONE)
5478 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5480 CAM_LOG_INFO("ret : 0x%x", ret);
5486 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5488 int ret = CAMERA_ERROR_NONE;
5489 camera_cli_s *pc = (camera_cli_s *)camera;
5490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5492 if (!pc || !pc->cb_info || !description) {
5493 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5494 return CAMERA_ERROR_INVALID_PARAMETER;
5497 CAM_LOG_INFO("Enter");
5499 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5501 if (ret == CAMERA_ERROR_NONE)
5502 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5504 CAM_LOG_INFO("ret : 0x%x", ret);
5510 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5512 int ret = CAMERA_ERROR_NONE;
5513 camera_cli_s *pc = (camera_cli_s *)camera;
5514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5516 if (!pc || !pc->cb_info || !orientation) {
5517 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5518 return CAMERA_ERROR_INVALID_PARAMETER;
5521 CAM_LOG_INFO("Enter");
5523 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5525 if (ret == CAMERA_ERROR_NONE)
5526 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5528 CAM_LOG_INFO("ret : 0x%x", ret);
5534 int camera_attr_get_tag_software(camera_h camera, char **software)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5540 if (!pc || !pc->cb_info || !software) {
5541 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5545 CAM_LOG_INFO("Enter");
5547 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5549 if (ret == CAMERA_ERROR_NONE)
5550 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5552 CAM_LOG_INFO("ret : 0x%x", ret);
5558 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5560 int ret = CAMERA_ERROR_NONE;
5561 camera_cli_s *pc = (camera_cli_s *)camera;
5562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5564 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5565 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5566 return CAMERA_ERROR_INVALID_PARAMETER;
5569 CAM_LOG_INFO("Enter");
5571 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5573 if (ret == CAMERA_ERROR_NONE) {
5574 *latitude = pc->cb_info->get_geotag[0];
5575 *longitude = pc->cb_info->get_geotag[1];
5576 *altitude = pc->cb_info->get_geotag[2];
5579 CAM_LOG_INFO("ret : 0x%x", ret);
5585 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5587 int ret = CAMERA_ERROR_NONE;
5588 camera_cli_s *pc = (camera_cli_s *)camera;
5589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5591 if (!pc || !pc->cb_info || !mode) {
5592 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5596 CAM_LOG_INFO("Enter");
5598 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 if (ret == CAMERA_ERROR_NONE)
5601 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5603 CAM_LOG_INFO("ret : 0x%x", ret);
5609 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5611 int ret = CAMERA_ERROR_NONE;
5612 int get_flash_state = 0;
5615 CAM_LOG_ERROR("NULL pointer");
5616 return CAMERA_ERROR_INVALID_PARAMETER;
5619 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5620 (int)device, "get_flash_state", &get_flash_state);
5622 if (ret == CAMERA_ERROR_NONE) {
5623 *state = (camera_flash_state_e)get_flash_state;
5624 CAM_LOG_INFO("flash state %d", *state);
5626 CAM_LOG_ERROR("failed 0x%x", ret);
5633 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_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_AF_MODE;
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_AF_MODE] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = 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_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_EXPOSURE_MODE;
5663 if (!pc || !pc->cb_info || !foreach_cb) {
5664 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5665 return CAMERA_ERROR_INVALID_PARAMETER;
5668 CAM_LOG_INFO("Enter");
5670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5673 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5675 CAM_LOG_INFO("ret : 0x%x", ret);
5681 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5683 int ret = CAMERA_ERROR_NONE;
5684 camera_cli_s *pc = (camera_cli_s *)camera;
5685 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5687 if (!pc || !pc->cb_info || !foreach_cb) {
5688 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5689 return CAMERA_ERROR_INVALID_PARAMETER;
5692 CAM_LOG_INFO("Enter");
5694 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5697 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5699 CAM_LOG_INFO("ret : 0x%x", ret);
5705 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5707 int ret = CAMERA_ERROR_NONE;
5708 camera_cli_s *pc = (camera_cli_s *)camera;
5709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5711 if (!pc || !pc->cb_info || !foreach_cb) {
5712 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5713 return CAMERA_ERROR_INVALID_PARAMETER;
5716 CAM_LOG_INFO("Enter");
5718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5721 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5723 CAM_LOG_INFO("ret : 0x%x", ret);
5729 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5735 if (!pc || !pc->cb_info || !foreach_cb) {
5736 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5737 return CAMERA_ERROR_INVALID_PARAMETER;
5740 CAM_LOG_INFO("Enter");
5742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5745 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5747 CAM_LOG_INFO("ret : 0x%x", ret);
5753 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5755 int ret = CAMERA_ERROR_NONE;
5756 camera_cli_s *pc = (camera_cli_s *)camera;
5757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5759 if (!pc || !pc->cb_info || !foreach_cb) {
5760 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5761 return CAMERA_ERROR_INVALID_PARAMETER;
5764 CAM_LOG_INFO("Enter");
5766 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5769 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5771 CAM_LOG_INFO("ret : 0x%x", ret);
5777 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5779 int ret = CAMERA_ERROR_NONE;
5780 camera_cli_s *pc = (camera_cli_s *)camera;
5781 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5783 if (!pc || !pc->cb_info || !foreach_cb) {
5784 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5785 return CAMERA_ERROR_INVALID_PARAMETER;
5788 CAM_LOG_INFO("Enter");
5790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5793 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5795 CAM_LOG_INFO("ret : 0x%x", ret);
5801 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5803 int ret = CAMERA_ERROR_NONE;
5804 camera_cli_s *pc = (camera_cli_s *)camera;
5805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5807 if (!pc || !pc->cb_info || !foreach_cb) {
5808 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5809 return CAMERA_ERROR_INVALID_PARAMETER;
5812 CAM_LOG_INFO("Enter");
5814 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5815 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5817 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5819 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5825 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)
5827 int ret = CAMERA_ERROR_NONE;
5828 camera_cli_s *pc = (camera_cli_s *)camera;
5829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5830 camera_msg_param param;
5833 if (!pc || !pc->cb_info || !foreach_cb) {
5834 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5835 return CAMERA_ERROR_INVALID_PARAMETER;
5838 CAM_LOG_INFO("Enter");
5840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5843 value = (width << 16) | height;
5844 CAMERA_MSG_PARAM_SET(param, INT, value);
5846 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5848 CAM_LOG_INFO("ret : 0x%x", ret);
5854 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_STREAM_FLIP;
5860 if (!pc || !pc->cb_info || !foreach_cb) {
5861 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5865 CAM_LOG_INFO("Enter");
5867 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5868 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5870 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5872 CAM_LOG_INFO("ret : 0x%x", ret);
5878 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5880 int ret = CAMERA_ERROR_NONE;
5881 camera_cli_s *pc = (camera_cli_s *)camera;
5882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5884 if (!pc || !pc->cb_info || !foreach_cb) {
5885 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5886 return CAMERA_ERROR_INVALID_PARAMETER;
5889 CAM_LOG_INFO("Enter");
5891 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5892 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5894 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5896 CAM_LOG_INFO("ret : 0x%x", ret);
5902 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5904 int ret = CAMERA_ERROR_NONE;
5905 camera_cli_s *pc = (camera_cli_s *)camera;
5906 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5907 camera_msg_param param;
5908 int set_rotation = (int)rotation;
5910 if (!pc || !pc->cb_info) {
5911 CAM_LOG_ERROR("NULL handle[%p]", pc);
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5915 CAM_LOG_INFO("Enter");
5917 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5919 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5921 CAM_LOG_INFO("ret : 0x%x", ret);
5927 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5933 if (!pc || !pc->cb_info || !rotation) {
5934 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5935 return CAMERA_ERROR_INVALID_PARAMETER;
5938 CAM_LOG_INFO("Enter");
5940 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5942 if (ret == CAMERA_ERROR_NONE)
5943 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5945 CAM_LOG_INFO("ret : 0x%x", ret);
5951 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5953 int ret = CAMERA_ERROR_NONE;
5954 camera_cli_s *pc = (camera_cli_s *)camera;
5955 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5956 camera_msg_param param;
5957 int set_flip = (int)flip;
5959 if (!pc || !pc->cb_info) {
5960 CAM_LOG_ERROR("NULL handle[%p]", pc);
5961 return CAMERA_ERROR_INVALID_PARAMETER;
5964 CAM_LOG_INFO("Enter");
5966 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5968 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5970 CAM_LOG_INFO("ret : 0x%x", ret);
5976 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5982 if (!pc || !pc->cb_info || !flip) {
5983 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5987 CAM_LOG_INFO("Enter");
5989 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5991 if (ret == CAMERA_ERROR_NONE)
5992 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5994 CAM_LOG_INFO("ret : 0x%x", ret);
5999 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6001 int ret = CAMERA_ERROR_NONE;
6002 camera_cli_s *pc = (camera_cli_s *)camera;
6003 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6004 camera_msg_param param;
6005 int set_mode = (int)mode;
6007 if (!pc || !pc->cb_info) {
6008 CAM_LOG_ERROR("NULL handle[%p]", pc);
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6012 CAM_LOG_INFO("Enter");
6014 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6016 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6018 CAM_LOG_INFO("ret : 0x%x", ret);
6024 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6026 int ret = CAMERA_ERROR_NONE;
6027 camera_cli_s *pc = (camera_cli_s *)camera;
6028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6030 if (!pc || !pc->cb_info || !mode) {
6031 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6035 CAM_LOG_INFO("Enter");
6037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6039 if (ret == CAMERA_ERROR_NONE)
6040 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6042 CAM_LOG_INFO("ret : 0x%x", ret);
6048 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6050 return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
6054 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6056 int ret = CAMERA_ERROR_NONE;
6057 camera_cli_s *pc = (camera_cli_s *)camera;
6058 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6060 if (!pc || !pc->cb_info) {
6061 CAM_LOG_ERROR("NULL handle[%p]", pc);
6062 return CAMERA_ERROR_INVALID_PARAMETER;
6065 CAM_LOG_INFO("Enter");
6067 if (!camera_attr_is_supported_hdr_capture(camera)) {
6068 CAM_LOG_ERROR("HDR not supported");
6069 return CAMERA_ERROR_NOT_SUPPORTED;
6073 CAM_LOG_ERROR("NULL callback");
6074 return CAMERA_ERROR_INVALID_PARAMETER;
6077 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6079 if (ret == CAMERA_ERROR_NONE) {
6080 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6082 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6083 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6085 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6088 CAM_LOG_INFO("ret : 0x%x", ret);
6094 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6096 int ret = CAMERA_ERROR_NONE;
6097 camera_cli_s *pc = (camera_cli_s *)camera;
6098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6100 if (!pc || !pc->cb_info) {
6101 CAM_LOG_ERROR("NULL handle[%p]", pc);
6102 return CAMERA_ERROR_INVALID_PARAMETER;
6105 CAM_LOG_INFO("Enter");
6107 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6109 if (ret == CAMERA_ERROR_NONE) {
6110 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6112 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6113 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6115 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6118 CAM_LOG_INFO("ret : 0x%x", ret);
6124 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6126 int ret = CAMERA_ERROR_NONE;
6127 camera_cli_s *pc = (camera_cli_s *)camera;
6128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6129 camera_msg_param param;
6130 int set_enable = (int)enable;
6132 if (!pc || !pc->cb_info) {
6133 CAM_LOG_ERROR("NULL handle[%p]", pc);
6134 return CAMERA_ERROR_INVALID_PARAMETER;
6137 CAM_LOG_INFO("Enter");
6139 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6141 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6143 CAM_LOG_INFO("ret : 0x%x", ret);
6149 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6151 int ret = CAMERA_ERROR_NONE;
6152 camera_cli_s *pc = (camera_cli_s *)camera;
6153 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6155 if (!pc || !pc->cb_info || !enabled) {
6156 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6157 return CAMERA_ERROR_INVALID_PARAMETER;
6160 CAM_LOG_INFO("Enter");
6162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6164 if (ret == CAMERA_ERROR_NONE)
6165 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6167 CAM_LOG_INFO("ret : 0x%x", ret);
6173 bool camera_attr_is_supported_anti_shake(camera_h camera)
6175 return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6179 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6181 int ret = CAMERA_ERROR_NONE;
6182 camera_cli_s *pc = (camera_cli_s *)camera;
6183 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6184 camera_msg_param param;
6185 int set_enable = (int)enable;
6187 if (!pc || !pc->cb_info) {
6188 CAM_LOG_ERROR("NULL handle[%p]", pc);
6189 return CAMERA_ERROR_INVALID_PARAMETER;
6192 CAM_LOG_INFO("Enter");
6194 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6196 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6198 CAM_LOG_INFO("ret : 0x%x", ret);
6204 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6206 int ret = CAMERA_ERROR_NONE;
6207 camera_cli_s *pc = (camera_cli_s *)camera;
6208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6210 if (!pc || !pc->cb_info || !enabled) {
6211 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6212 return CAMERA_ERROR_INVALID_PARAMETER;
6215 CAM_LOG_INFO("Enter");
6217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6219 if (ret == CAMERA_ERROR_NONE)
6220 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6222 CAM_LOG_INFO("ret : 0x%x", ret);
6228 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6230 return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6234 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6236 int ret = CAMERA_ERROR_NONE;
6237 camera_cli_s *pc = (camera_cli_s *)camera;
6238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6239 camera_msg_param param;
6240 int set_enable = (int)enable;
6242 if (!pc || !pc->cb_info) {
6243 CAM_LOG_ERROR("NULL handle[%p]", pc);
6244 return CAMERA_ERROR_INVALID_PARAMETER;
6247 CAM_LOG_INFO("Enter");
6249 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6251 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6253 CAM_LOG_INFO("ret : 0x%x", ret);
6259 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6261 int ret = CAMERA_ERROR_NONE;
6262 camera_cli_s *pc = (camera_cli_s *)camera;
6263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6265 if (!pc || !pc->cb_info || !enabled) {
6266 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6267 return CAMERA_ERROR_INVALID_PARAMETER;
6270 CAM_LOG_INFO("Enter");
6272 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6274 if (ret == CAMERA_ERROR_NONE)
6275 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6277 CAM_LOG_INFO("ret : 0x%x", ret);
6283 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6285 return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6289 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6291 int ret = CAMERA_ERROR_NONE;
6292 camera_cli_s *pc = (camera_cli_s *)camera;
6293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6294 camera_msg_param param;
6295 int set_disable = (int)disable;
6297 if (!pc || !pc->cb_info) {
6298 CAM_LOG_ERROR("NULL handle[%p]", pc);
6299 return CAMERA_ERROR_INVALID_PARAMETER;
6302 CAM_LOG_INFO("Enter");
6304 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6306 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6308 CAM_LOG_INFO("ret : 0x%x", ret);
6314 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6316 int ret = CAMERA_ERROR_NONE;
6317 camera_cli_s *pc = (camera_cli_s *)camera;
6318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6319 camera_msg_param param0;
6320 camera_msg_param param1;
6322 if (!pc || !pc->cb_info) {
6323 CAM_LOG_ERROR("NULL handle[%p]", pc);
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6327 CAM_LOG_INFO("Enter");
6329 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6330 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6332 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6333 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6335 CAM_LOG_INFO("ret : 0x%x", ret);
6341 int camera_attr_get_pan(camera_h camera, int *pan_step)
6343 int ret = CAMERA_ERROR_NONE;
6344 camera_cli_s *pc = (camera_cli_s *)camera;
6345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6347 if (!pc || !pc->cb_info || !pan_step) {
6348 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6349 return CAMERA_ERROR_INVALID_PARAMETER;
6352 CAM_LOG_INFO("Enter");
6354 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6356 if (ret == CAMERA_ERROR_NONE)
6357 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6359 CAM_LOG_INFO("ret : 0x%x", ret);
6365 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6367 int ret = CAMERA_ERROR_NONE;
6368 camera_cli_s *pc = (camera_cli_s *)camera;
6369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6371 if (!pc || !pc->cb_info || !min || !max) {
6372 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6376 CAM_LOG_INFO("Enter");
6378 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6380 if (ret == CAMERA_ERROR_NONE) {
6381 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6382 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6385 CAM_LOG_INFO("ret : 0x%x", ret);
6391 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6393 int ret = CAMERA_ERROR_NONE;
6394 camera_cli_s *pc = (camera_cli_s *)camera;
6395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6396 camera_msg_param param0;
6397 camera_msg_param param1;
6399 if (!pc || !pc->cb_info) {
6400 CAM_LOG_ERROR("NULL handle[%p]", pc);
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6404 CAM_LOG_INFO("Enter");
6406 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6407 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6409 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6410 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6412 CAM_LOG_INFO("ret : 0x%x", ret);
6418 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6420 int ret = CAMERA_ERROR_NONE;
6421 camera_cli_s *pc = (camera_cli_s *)camera;
6422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6424 if (!pc || !pc->cb_info || !tilt_step) {
6425 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6429 CAM_LOG_INFO("Enter");
6431 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6433 if (ret == CAMERA_ERROR_NONE)
6434 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6436 CAM_LOG_INFO("ret : 0x%x", ret);
6442 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6444 int ret = CAMERA_ERROR_NONE;
6445 camera_cli_s *pc = (camera_cli_s *)camera;
6446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6448 if (!pc || !pc->cb_info || !min || !max) {
6449 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6453 CAM_LOG_INFO("Enter");
6455 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6457 if (ret == CAMERA_ERROR_NONE) {
6458 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6459 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6462 CAM_LOG_INFO("ret : 0x%x", ret);
6468 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6470 int ret = CAMERA_ERROR_NONE;
6471 camera_cli_s *pc = (camera_cli_s *)camera;
6472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6473 camera_msg_param param;
6474 int set_ptz_type = (int)ptz_type;
6476 if (!pc || !pc->cb_info) {
6477 CAM_LOG_ERROR("NULL handle[%p]", pc);
6478 return CAMERA_ERROR_INVALID_PARAMETER;
6481 CAM_LOG_INFO("Enter");
6483 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6485 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6487 CAM_LOG_INFO("ret : 0x%x", ret);
6493 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6495 int ret = CAMERA_ERROR_NONE;
6496 camera_cli_s *pc = (camera_cli_s *)camera;
6497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6499 if (!pc || !pc->cb_info || !foreach_cb) {
6500 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6501 return CAMERA_ERROR_INVALID_PARAMETER;
6504 CAM_LOG_INFO("Enter");
6506 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6507 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6509 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6511 CAM_LOG_INFO("ret : 0x%x", ret);
6517 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6519 int ret = CAMERA_ERROR_NONE;
6520 camera_cli_s *pc = (camera_cli_s *)camera;
6521 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6522 int set_display_roi_area[4] = {x, y, width, height};
6527 if (!pc || !pc->cb_info) {
6528 CAM_LOG_ERROR("NULL handle[%p]", pc);
6529 return CAMERA_ERROR_INVALID_PARAMETER;
6532 CAM_LOG_INFO("Enter");
6534 if (pc->cb_info->is_evas_render) {
6535 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6536 if (ret != MM_ERROR_NONE) {
6537 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6538 return CAMERA_ERROR_INVALID_OPERATION;
6542 length = sizeof(set_display_roi_area) / sizeof(int) + \
6543 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6545 msg = muse_core_msg_new(api,
6546 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6549 CAM_LOG_ERROR("msg creation failed: api %d", api);
6550 return CAMERA_ERROR_OUT_OF_MEMORY;
6553 if (pc->cb_info->is_server_connected) {
6554 _camera_update_api_waiting(pc->cb_info, api, 1);
6556 g_mutex_lock(&pc->cb_info->fd_lock);
6557 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6558 g_mutex_unlock(&pc->cb_info->fd_lock);
6562 CAM_LOG_ERROR("message send failed");
6563 ret = CAMERA_ERROR_INVALID_OPERATION;
6565 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6568 _camera_update_api_waiting(pc->cb_info, api, -1);
6570 muse_core_msg_free(msg);
6572 CAM_LOG_INFO("ret : 0x%x", ret);
6578 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6580 camera_cli_s *pc = (camera_cli_s *)camera;
6581 int ret = CAMERA_ERROR_NONE;
6582 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6584 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6585 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6586 return CAMERA_ERROR_INVALID_PARAMETER;
6589 CAM_LOG_INFO("Enter");
6591 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6593 if (ret == CAMERA_ERROR_NONE) {
6594 *x = pc->cb_info->get_display_roi_area[0];
6595 *y = pc->cb_info->get_display_roi_area[1];
6596 *width = pc->cb_info->get_display_roi_area[2];
6597 *height = pc->cb_info->get_display_roi_area[3];
6600 CAM_LOG_INFO("ret : 0x%x", ret);
6606 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6608 int ret = CAMERA_ERROR_NONE;
6609 int get_device_state = 0;
6612 CAM_LOG_ERROR("NULL pointer");
6613 return CAMERA_ERROR_INVALID_PARAMETER;
6616 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6617 (int)device, "get_device_state", &get_device_state);
6619 if (ret == CAMERA_ERROR_NONE) {
6620 *state = (camera_device_state_e)get_device_state;
6621 CAM_LOG_INFO("device state %d", *state);
6623 CAM_LOG_ERROR("failed 0x%x", ret);
6630 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6632 int ret = CAMERA_ERROR_NONE;
6633 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6634 camera_cb_info *info = NULL;
6636 if (!callback || !cb_id) {
6637 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6638 return CAMERA_ERROR_INVALID_PARAMETER;
6641 /* check camera support */
6642 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6643 if (ret != CAMERA_ERROR_NONE) {
6644 CAM_LOG_ERROR("get device state failed");
6648 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6650 info = g_new0(camera_cb_info, 1);
6652 CAM_LOG_ERROR("info failed");
6653 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6657 info->id = ++g_cam_dev_state_changed_cb_id;
6658 info->callback = (void *)callback;
6659 info->user_data = user_data;
6663 /* subscribe dbus signal for camera state change */
6664 if (!g_cam_dev_state_changed_cb_conn) {
6665 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6666 if (!g_cam_dev_state_changed_cb_conn) {
6667 CAM_LOG_ERROR("failed to get gdbus connection");
6668 ret = CAMERA_ERROR_INVALID_OPERATION;
6672 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6673 MM_CAMCORDER_DBUS_OBJECT,
6674 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6675 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6677 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6678 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6679 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6680 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6681 CAM_LOG_ERROR("failed to get gdbus connection");
6682 ret = CAMERA_ERROR_INVALID_OPERATION;
6686 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6689 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6691 CAM_LOG_INFO("callback id %d", info->id);
6694 if (ret != CAMERA_ERROR_NONE) {
6700 if (g_cam_dev_state_changed_cb_conn) {
6701 g_object_unref(g_cam_dev_state_changed_cb_conn);
6702 g_cam_dev_state_changed_cb_conn = NULL;
6706 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6712 int camera_remove_device_state_changed_cb(int cb_id)
6714 int ret = CAMERA_ERROR_NONE;
6715 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6716 GList *tmp_list = NULL;
6717 camera_cb_info *info = NULL;
6719 /* check camera support */
6720 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6721 if (ret != CAMERA_ERROR_NONE) {
6722 CAM_LOG_ERROR("get device state failed");
6726 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6728 if (!g_cam_dev_state_changed_cb_list) {
6729 CAM_LOG_ERROR("there is no callback info");
6730 ret = CAMERA_ERROR_INVALID_OPERATION;
6734 tmp_list = g_cam_dev_state_changed_cb_list;
6737 info = tmp_list->data;
6738 tmp_list = tmp_list->next;
6741 CAM_LOG_WARNING("NULL info");
6745 if (info->id == cb_id) {
6746 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6751 if (!g_cam_dev_state_changed_cb_list) {
6752 /* no remained callback */
6753 if (g_cam_dev_state_changed_cb_conn) {
6754 /* unsubscribe signal */
6755 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6756 g_cam_dev_state_changed_cb_subscribe_id = 0;
6758 /* unref connection */
6759 g_object_unref(g_cam_dev_state_changed_cb_conn);
6760 g_cam_dev_state_changed_cb_conn = NULL;
6764 CAM_LOG_INFO("id %d callback removed", cb_id);
6765 ret = CAMERA_ERROR_NONE;
6771 CAM_LOG_ERROR("id %d callback not found", cb_id);
6772 ret = CAMERA_ERROR_INVALID_PARAMETER;
6775 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6782 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6784 int ret = CAMERA_ERROR_NONE;
6785 camera_cli_s *pc = (camera_cli_s *)camera;
6786 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6788 if (!pc || !pc->cb_info) {
6789 CAM_LOG_ERROR("NULL handle[%p]", pc);
6790 return CAMERA_ERROR_INVALID_PARAMETER;
6793 g_mutex_lock(&pc->cb_info->bridge_lock);
6795 if (pc->cb_info->bridge) {
6796 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6797 ret = CAMERA_ERROR_INVALID_OPERATION;
6798 goto _SET_MEDIA_BRIDGE_DONE;
6801 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6802 if (ret != CAMERA_ERROR_NONE) {
6803 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6804 goto _SET_MEDIA_BRIDGE_DONE;
6807 pc->cb_info->bridge = bridge;
6809 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6811 _SET_MEDIA_BRIDGE_DONE:
6812 g_mutex_unlock(&pc->cb_info->bridge_lock);
6818 int camera_media_bridge_unset_bridge(camera_h camera)
6820 int ret = CAMERA_ERROR_NONE;
6821 camera_cli_s *pc = (camera_cli_s *)camera;
6822 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6824 if (!pc || !pc->cb_info) {
6825 CAM_LOG_ERROR("NULL handle[%p]", pc);
6826 return CAMERA_ERROR_INVALID_PARAMETER;
6829 g_mutex_lock(&pc->cb_info->bridge_lock);
6831 if (!pc->cb_info->bridge) {
6832 CAM_LOG_ERROR("no media bridge");
6833 ret = CAMERA_ERROR_INVALID_OPERATION;
6834 goto _UNSET_MEDIA_BRIDGE_DONE;
6837 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6838 if (ret != CAMERA_ERROR_NONE) {
6839 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6840 goto _UNSET_MEDIA_BRIDGE_DONE;
6843 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6845 pc->cb_info->bridge = NULL;
6847 _UNSET_MEDIA_BRIDGE_DONE:
6848 g_mutex_unlock(&pc->cb_info->bridge_lock);
6855 int camera_create_network(camera_device_e device, camera_h *camera)
6857 return _camera_create_private(device, true, camera);
6861 int camera_device_manager_initialize(camera_device_manager_h *manager)
6864 int ret = CAMERA_ERROR_NONE;
6865 void *dl_handle = NULL;
6866 camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
6867 cdm_symbol_table sym_table[] = {
6868 {(void **)&new_manager->initialize, "cdm_initialize"},
6869 {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
6870 {(void **)&new_manager->get_device_list, "cdm_get_device_list"},
6871 {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"},
6872 {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"},
6875 CAMERA_CHECK_DEVICE_MANAGER;
6878 CAM_LOG_ERROR("NULL manager");
6879 ret = CAMERA_ERROR_INVALID_PARAMETER;
6880 goto _INITIALIZE_FAILED;
6883 dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
6885 CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
6886 ret = CAMERA_ERROR_INVALID_OPERATION;
6887 goto _INITIALIZE_FAILED;
6891 for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
6892 *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
6893 if (*sym_table[i].func_ptr == NULL) {
6894 CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
6895 ret = CAMERA_ERROR_INVALID_OPERATION;
6896 goto _INITIALIZE_FAILED;
6900 ret = new_manager->initialize();
6901 if (ret != CAMERA_ERROR_NONE) {
6902 CAM_LOG_ERROR("failed[0x%x]", ret);
6903 goto _INITIALIZE_FAILED;
6906 new_manager->dl_handle = dl_handle;
6907 *manager = (camera_device_manager_h)new_manager;
6909 CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
6910 new_manager, dl_handle);
6912 return CAMERA_ERROR_NONE;
6917 g_free(new_manager);
6923 int camera_device_manager_deinitialize(camera_device_manager_h manager)
6925 int ret = CAMERA_ERROR_NONE;
6926 camera_device_manager *m = (camera_device_manager *)manager;
6928 CAMERA_CHECK_DEVICE_MANAGER;
6931 CAM_LOG_ERROR("NULL manager");
6932 return CAMERA_ERROR_INVALID_PARAMETER;
6935 CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
6937 ret = m->deinitialize();
6938 if (ret != CAMERA_ERROR_NONE) {
6939 CAM_LOG_ERROR("failed[0x%x]", ret);
6943 CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
6945 dlclose(m->dl_handle);
6947 memset(m, 0x0, sizeof(camera_device_manager));
6950 return CAMERA_ERROR_NONE;
6954 int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
6956 int ret = CAMERA_ERROR_NONE;
6958 camera_device_list_s device_list;
6959 camera_device_s *device = NULL;
6960 camera_device_manager *m = (camera_device_manager *)manager;
6962 CAMERA_CHECK_DEVICE_MANAGER;
6964 if (!m || !callback) {
6965 CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
6966 return CAMERA_ERROR_INVALID_PARAMETER;
6969 CAM_LOG_INFO("enter");
6971 memset(&device_list, 0x0, sizeof(camera_device_list_s));
6973 ret = m->get_device_list(&device_list);
6974 if (ret != CAMERA_ERROR_NONE) {
6975 CAM_LOG_ERROR("failed[0x%x]", ret);
6979 CAM_LOG_INFO("device count[%d]", device_list.count);
6981 for (i = 0 ; i < device_list.count ; i++) {
6982 device = &device_list.device[i];
6984 CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
6985 i, device->type, device->index,
6986 device->name, device->id, device->extra_stream_num);
6988 if (!callback(device->type, device->index, device->name,
6989 device->id, device->extra_stream_num, user_data)) {
6990 CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
6991 i + 1, device_list.count);
6996 return CAMERA_ERROR_NONE;
7000 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
7001 camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
7003 int ret = CAMERA_ERROR_NONE;
7004 camera_device_manager *m = (camera_device_manager *)manager;
7006 CAMERA_CHECK_DEVICE_MANAGER;
7008 if (!m || !callback || !cb_id) {
7009 CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
7010 return CAMERA_ERROR_INVALID_PARAMETER;
7013 CAM_LOG_INFO("enter");
7015 ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
7016 if (ret != CAMERA_ERROR_NONE) {
7017 CAM_LOG_ERROR("failed[0x%x]", ret);
7021 CAM_LOG_INFO("cb_id[%d] added", *cb_id);
7023 return CAMERA_ERROR_NONE;
7027 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
7029 int ret = CAMERA_ERROR_NONE;
7030 camera_device_manager *m = (camera_device_manager *)manager;
7032 CAMERA_CHECK_DEVICE_MANAGER;
7035 CAM_LOG_ERROR("NULL manager");
7036 return CAMERA_ERROR_INVALID_PARAMETER;
7039 CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
7041 ret = m->remove_device_connection_changed_cb(cb_id);
7042 if (ret != CAMERA_ERROR_NONE) {
7043 CAM_LOG_ERROR("failed[0x%x]", ret);
7047 CAM_LOG_INFO("cb_id[%d] removed", cb_id);
7049 return CAMERA_ERROR_NONE;
7054 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
7056 int ret = CAMERA_ERROR_NONE;
7057 camera_cli_s *pc = (camera_cli_s *)camera;
7058 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
7060 if (!pc || !pc->cb_info || !callback) {
7061 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
7062 return CAMERA_ERROR_INVALID_PARAMETER;
7065 CAM_LOG_INFO("Enter");
7067 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7069 if (ret == CAMERA_ERROR_NONE) {
7070 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7072 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
7073 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
7075 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7078 CAM_LOG_INFO("ret : 0x%x", ret);
7084 int camera_unset_extra_preview_cb(camera_h camera)
7086 int ret = CAMERA_ERROR_NONE;
7087 camera_cli_s *pc = (camera_cli_s *)camera;
7088 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
7090 if (!pc || !pc->cb_info) {
7091 CAM_LOG_ERROR("NULL handle[%p]", pc);
7092 return CAMERA_ERROR_INVALID_PARAMETER;
7095 CAM_LOG_INFO("Enter");
7097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
7099 if (ret == CAMERA_ERROR_NONE) {
7100 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7102 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7103 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
7105 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
7108 CAM_LOG_INFO("ret : 0x%x", ret);
7114 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)
7116 int ret = CAMERA_ERROR_NONE;
7118 int stream_format[4] = {pixel_format, width, height, fps};
7120 camera_cli_s *pc = (camera_cli_s *)camera;
7121 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
7123 if (!pc || !pc->cb_info) {
7124 CAM_LOG_ERROR("NULL handle[%p]", pc);
7125 return CAMERA_ERROR_INVALID_PARAMETER;
7128 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
7129 stream_id, pixel_format, width, height, fps);
7131 msg = muse_core_msg_new(api,
7132 MUSE_TYPE_INT, "stream_id", stream_id,
7133 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
7136 CAM_LOG_ERROR("msg creation failed: api %d", api);
7137 return CAMERA_ERROR_OUT_OF_MEMORY;
7140 if (pc->cb_info->is_server_connected) {
7141 _camera_update_api_waiting(pc->cb_info, api, 1);
7143 g_mutex_lock(&pc->cb_info->fd_lock);
7144 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
7145 g_mutex_unlock(&pc->cb_info->fd_lock);
7149 CAM_LOG_ERROR("message send failed");
7150 ret = CAMERA_ERROR_INVALID_OPERATION;
7152 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
7155 _camera_update_api_waiting(pc->cb_info, api, -1);
7157 muse_core_msg_free(msg);
7159 CAM_LOG_INFO("ret : 0x%x", ret);
7165 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)
7167 int ret = CAMERA_ERROR_NONE;
7168 camera_cli_s *pc = (camera_cli_s *)camera;
7169 camera_msg_param param;
7170 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
7172 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
7173 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
7174 return CAMERA_ERROR_INVALID_PARAMETER;
7177 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7179 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7181 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7183 if (ret == CAMERA_ERROR_NONE) {
7184 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
7185 *width = pc->cb_info->get_extra_preview_stream_format[1];
7186 *height = pc->cb_info->get_extra_preview_stream_format[2];
7187 *fps = pc->cb_info->get_extra_preview_stream_format[3];
7190 CAM_LOG_INFO("ret : 0x%x", ret);
7196 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
7198 int ret = CAMERA_ERROR_NONE;
7199 camera_cli_s *pc = (camera_cli_s *)camera;
7200 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
7201 camera_msg_param param0;
7202 camera_msg_param param1;
7204 if (!pc || !pc->cb_info) {
7205 CAM_LOG_ERROR("NULL handle[%p]", pc);
7206 return CAMERA_ERROR_INVALID_PARAMETER;
7209 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
7211 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7212 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
7214 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7215 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7217 CAM_LOG_INFO("ret : 0x%x", ret);
7223 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
7225 int ret = CAMERA_ERROR_NONE;
7226 camera_cli_s *pc = (camera_cli_s *)camera;
7227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
7228 camera_msg_param param;
7230 if (!pc || !pc->cb_info || !bitrate) {
7231 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
7232 return CAMERA_ERROR_INVALID_PARAMETER;
7235 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7237 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7239 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7241 if (ret == CAMERA_ERROR_NONE) {
7242 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
7243 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
7245 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
7252 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
7254 int ret = CAMERA_ERROR_NONE;
7255 camera_cli_s *pc = (camera_cli_s *)camera;
7256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
7257 camera_msg_param param0;
7258 camera_msg_param param1;
7260 if (!pc || !pc->cb_info) {
7261 CAM_LOG_ERROR("NULL handle[%p]", pc);
7262 return CAMERA_ERROR_INVALID_PARAMETER;
7265 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
7267 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
7268 CAMERA_MSG_PARAM_SET(param1, INT, interval);
7270 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
7271 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
7273 CAM_LOG_INFO("ret : 0x%x", ret);
7279 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
7281 int ret = CAMERA_ERROR_NONE;
7282 camera_cli_s *pc = (camera_cli_s *)camera;
7283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
7284 camera_msg_param param;
7286 if (!pc || !pc->cb_info || !interval) {
7287 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
7288 return CAMERA_ERROR_INVALID_PARAMETER;
7291 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
7293 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
7295 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
7297 if (ret == CAMERA_ERROR_NONE) {
7298 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
7299 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
7301 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
7308 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
7310 camera_cli_s *pc = (camera_cli_s *)camera;
7312 if (!pc || !pc->cb_info || !rotation) {
7313 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
7314 return CAMERA_ERROR_INVALID_PARAMETER;
7317 if (!pc->cb_info->stream_data) {
7318 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
7319 return CAMERA_ERROR_INVALID_OPERATION;
7322 *rotation = pc->cb_info->stream_data->rotation;
7324 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
7326 return CAMERA_ERROR_NONE;
7330 int _camera_get_log_level(void)
7332 return g_camera_log_level;