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.
23 #include <muse_camera_msg.h>
24 #include <camera_private.h>
25 #include <muse_client.h>
32 #define LOG_TAG "TIZEN_N_CAMERA"
33 #define MODULE_NAME "camera"
35 /* for device changed callback */
36 static GMutex g_cam_dev_state_changed_cb_lock;
37 static GList *g_cam_dev_state_changed_cb_list;
38 static int g_cam_dev_state_changed_cb_id;
39 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
40 static guint g_cam_dev_state_changed_cb_subscribe_id;
41 static GMutex g_cam_idle_event_lock;
44 int g_mmcam_log_level;
46 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
47 int *ret, int timeout);
48 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
49 int *ret, camera_msg_param *param, int timeout);
50 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
51 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
52 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
53 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
54 static void _camera_release_imported_bo(tbm_bo *bo);
55 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
56 camera_media_packet_data *mp_data, media_packet_h *packet);
57 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
58 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
59 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
60 static gboolean _camera_allocate_preview_buffer(camera_h camera);
61 static void _camera_release_preview_buffer(camera_h camera);
64 static gboolean _camera_allocate_preview_buffer(camera_h camera)
67 int ret = CAMERA_ERROR_NONE;
68 int format = CAMERA_PIXEL_FORMAT_INVALID;
72 camera_cli_s *pc = (camera_cli_s *)camera;
73 camera_cb_info_s *cb_info = NULL;
75 if (!pc || !pc->cb_info) {
76 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
80 cb_info = pc->cb_info;
82 CAM_LOG_INFO("Enter");
84 /* get preview info and calculate size */
85 ret = camera_get_preview_format(camera, &format);
86 if (ret != CAMERA_ERROR_NONE) {
87 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
91 ret = camera_get_preview_resolution(camera, &width, &height);
92 if (ret != CAMERA_ERROR_NONE) {
93 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
97 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
100 case CAMERA_PIXEL_FORMAT_INVZ:
101 buffer_size = width * height;
103 case CAMERA_PIXEL_FORMAT_NV12:
104 case CAMERA_PIXEL_FORMAT_I420:
105 buffer_size = (width * height * 3) >> 1;
107 case CAMERA_PIXEL_FORMAT_YUYV:
108 case CAMERA_PIXEL_FORMAT_UYVY:
109 buffer_size = width * height * 2;
112 CAM_LOG_ERROR("unhandled format %d", format);
113 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
116 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
118 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
119 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
120 if (!cb_info->bos[i]) {
121 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
122 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
125 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
126 if (cb_info->fds[i] < 0) {
127 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
128 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
131 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
134 CAM_LOG_INFO("Done");
138 _ALLOCATE_PREVIEW_BUFFER_FAILED:
139 _camera_release_preview_buffer(camera);
144 static void _camera_release_preview_buffer(camera_h camera)
147 camera_cli_s *pc = (camera_cli_s *)camera;
148 camera_cb_info_s *cb_info = NULL;
150 if (!pc || !pc->cb_info) {
151 CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
155 CAM_LOG_INFO("Enter");
157 cb_info = pc->cb_info;
159 /* close exported fd and bos */
160 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
161 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
163 if (cb_info->bos[i]) {
164 tbm_bo_unref(cb_info->bos[i]);
165 cb_info->bos[i] = NULL;
170 if (cb_info->fds[i] >= 0) {
171 close(cb_info->fds[i]);
172 cb_info->fds[i] = -1;
176 CAM_LOG_INFO("Done");
182 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
185 api < 0 || api >= MUSE_CAMERA_API_MAX) {
186 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
190 g_mutex_lock(&(cb_info->api_mutex[api]));
191 cb_info->api_waiting[api] += value;
192 g_mutex_unlock(&(cb_info->api_mutex[api]));
194 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
195 api, value, cb_info->api_waiting[api]);
201 static void __camera_device_state_changed_cb(GDBusConnection *connection,
202 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
203 const gchar *signal_name, GVariant *param, gpointer user_data)
206 camera_device_e device = CAMERA_DEVICE_CAMERA0;
207 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
208 GList *tmp_list = NULL;
209 camera_cb_info *info = NULL;
211 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
213 if (!g_cam_dev_state_changed_cb_list || !param) {
214 CAM_LOG_WARNING("no callback or NULL param %p", param);
218 /* get device and state */
219 g_variant_get(param, "(i)", &value);
221 device = value >> 16;
222 state = 0x0000ffff & value;
224 CAM_LOG_INFO("device %d, state %d", device, state);
226 tmp_list = g_cam_dev_state_changed_cb_list;
229 info = (camera_cb_info *)tmp_list->data;
232 if (info->callback) {
233 CAM_LOG_INFO("start id[%d] callback", info->id);
234 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
235 CAM_LOG_INFO("returned id[%d] callback", info->id);
237 CAM_LOG_WARNING("NULL callback for id %d", info->id);
241 tmp_list = tmp_list->next;
245 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
251 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
257 int num_buffer_fd = 0;
258 unsigned char *buf_pos = NULL;
261 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
262 tbm_bo_handle bo_handle = {.ptr = NULL};
263 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
264 tbm_bo data_bo = NULL;
265 tbm_bo_handle data_bo_handle = {.ptr = NULL};
267 camera_msg_param param;
268 camera_preview_data_s frame;
269 camera_stream_data_s *stream = NULL;
270 camera_media_packet_data *mp_data = NULL;
271 media_packet_h pkt = NULL;
272 media_packet_h pkt_evas = NULL;
274 /* tfd[0]: MMCamcorderVideoStreamDataType
275 tfd[1]: data_bo or zero copy bo[0]
276 tfd[2]: zero copy bo[1]
277 tfd[3]: zero copy bo[2] */
279 if (!cb_info || !recv_msg || !tfd) {
280 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
284 muse_camera_msg_get(preview_fd, recv_msg);
285 muse_camera_msg_get(num_buffer_fd, recv_msg);
287 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
289 memset(&frame, 0x0, sizeof(camera_preview_data_s));
292 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
297 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
299 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
300 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
301 goto _PREVIEW_CB_HANDLER_DONE;
304 if (num_buffer_fd == 0 && tfd[1] >= 0) {
305 /* import tbm data_bo and get virtual address */
306 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
307 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
308 goto _PREVIEW_CB_HANDLER_DONE;
312 /* import tbm bo and get virtual address */
313 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
314 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
315 goto _PREVIEW_CB_HANDLER_DONE;
318 buf_pos = (unsigned char *)bo_handle.ptr;
320 /* get stream info */
321 stream = (camera_stream_data_s *)buf_pos;
323 for (i = 0 ; i < num_buffer_fd ; i++) {
324 /* import buffer bo and get virtual address */
325 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
326 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
327 goto _PREVIEW_CB_HANDLER_DONE;
331 /* call preview callback */
332 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
333 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
335 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
336 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
339 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
340 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
342 if (ret == CAMERA_ERROR_NONE) {
343 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
344 if (ret != CAMERA_ERROR_NONE) {
345 CAM_LOG_ERROR("create pkt for evas failed");
346 _camera_media_packet_data_release(mp_data, cb_info);
352 /* call media packet callback */
353 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
354 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
356 if (ret == CAMERA_ERROR_NONE) {
357 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
359 if (ret == CAMERA_ERROR_NONE) {
360 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
361 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
363 _camera_media_packet_data_release(mp_data, cb_info);
369 /* call evas renderer */
371 if (cb_info->run_evas_render) {
372 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
374 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
375 media_packet_destroy(pkt_evas);
380 /* send message for preview callback return */
381 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
382 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
384 _PREVIEW_CB_HANDLER_DONE:
385 if (mp_data == NULL) {
386 /* release imported bo */
387 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
388 _camera_release_imported_bo(&buffer_bo[i]);
390 /* unmap and unref tbm bo */
391 _camera_release_imported_bo(&data_bo);
392 _camera_release_imported_bo(&bo);
394 /* close imported fd */
395 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
405 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
407 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
414 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
418 int capture_fd_main = 0;
419 int capture_fd_post = 0;
420 int capture_fd_thumb = 0;
421 unsigned char *buf_pos = NULL;
423 camera_image_data_s *rImage = NULL;
424 camera_image_data_s *rPostview = NULL;
425 camera_image_data_s *rThumbnail = NULL;
427 tbm_bo bo_main = NULL;
428 tbm_bo bo_post = NULL;
429 tbm_bo bo_thumb = NULL;
430 tbm_bo_handle bo_main_handle = {.ptr = NULL};
431 tbm_bo_handle bo_post_handle = {.ptr = NULL};
432 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
434 if (!cb_info || !recv_msg || !tfd) {
435 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
439 muse_camera_msg_get(capture_fd_main, recv_msg);
440 muse_camera_msg_get(capture_fd_post, recv_msg);
441 muse_camera_msg_get(capture_fd_thumb, recv_msg);
443 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
444 capture_fd_main, capture_fd_post, capture_fd_thumb,
445 tfd[0], tfd[1], tfd[2]);
447 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
448 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
449 goto _CAPTURE_CB_HANDLER_DONE;
452 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
453 CAM_LOG_WARNING("NULL callback");
454 goto _CAPTURE_CB_HANDLER_DONE;
457 /* import tbm bo and get virtual address */
458 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
459 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
460 goto _CAPTURE_CB_HANDLER_DONE;
463 buf_pos = (unsigned char *)bo_main_handle.ptr;
464 rImage = (camera_image_data_s *)buf_pos;
465 rImage->data = buf_pos + sizeof(camera_image_data_s);
466 if (rImage->exif && rImage->exif_size > 0) {
467 rImage->exif = rImage->data + rImage->size;
470 rImage->exif_size = 0;
473 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
474 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
476 if (capture_fd_post >= 0) {
477 /* import tbm bo and get virtual address */
479 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
480 buf_pos = (unsigned char *)bo_post_handle.ptr;
481 rPostview = (camera_image_data_s *)buf_pos;
482 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
483 rPostview->data = buf_pos + sizeof(camera_image_data_s);
485 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
489 if (capture_fd_thumb >= 0) {
490 /* import tbm bo and get virtual address */
492 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
493 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
494 rThumbnail = (camera_image_data_s *)buf_pos;
495 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
496 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
498 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
502 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
503 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
505 _CAPTURE_CB_HANDLER_DONE:
507 if (capture_fd_main >= 0) {
508 _camera_release_imported_bo(&bo_main);
509 _camera_msg_return_buffer(capture_fd_main, cb_info);
512 if (capture_fd_post >= 0) {
513 _camera_release_imported_bo(&bo_post);
514 _camera_msg_return_buffer(capture_fd_post, cb_info);
517 if (capture_fd_thumb >= 0) {
518 _camera_release_imported_bo(&bo_thumb);
519 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
522 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
524 CAM_LOG_INFO("close %d", tfd[i]);
532 CAM_LOG_INFO("return buffer done");
538 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
542 camera_detected_face_s *faces = NULL;
545 tbm_bo_handle bo_handle = {.ptr = NULL};
547 if (!cb_info || !recv_msg || !tfd) {
548 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
552 muse_camera_msg_get(count, recv_msg);
553 muse_camera_msg_get(face_fd, recv_msg);
555 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
556 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
559 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
561 faces = bo_handle.ptr;
568 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
569 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
572 _camera_release_imported_bo(&bo);
574 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
575 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
579 _camera_msg_return_buffer(face_fd, cb_info);
585 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
587 tbm_bo tmp_bo = NULL;
588 tbm_bo_handle tmp_bo_handle = {NULL, };
590 if (!bufmgr || !bo || !bo_handle || fd < 0) {
591 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
592 bufmgr, bo, bo_handle, fd);
596 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
597 if (tmp_bo == NULL) {
598 CAM_LOG_ERROR("import failed - fd %d", fd);
602 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
603 if (tmp_bo_handle.ptr == NULL) {
604 CAM_LOG_ERROR("map failed %p", tmp_bo);
605 tbm_bo_unref(tmp_bo);
610 tbm_bo_unmap(tmp_bo);
612 /* set bo and bo_handle */
614 *bo_handle = tmp_bo_handle;
616 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
621 static void _camera_release_imported_bo(tbm_bo *bo)
624 CAM_LOG_DEBUG("NULL bo");
634 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
636 int ret = CAMERA_ERROR_NONE;
639 if (!cb_info->is_server_connected) {
640 CAM_LOG_ERROR("server is disconnected");
641 return CAMERA_ERROR_SERVICE_DISCONNECTED;
644 g_mutex_lock(&(cb_info->api_mutex[api]));
646 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
648 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
650 while (!cb_info->api_activating[api]) {
651 if (time_out == CAMERA_CB_NO_TIMEOUT) {
652 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
653 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
654 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
655 CAM_LOG_ERROR("api %d TIMED OUT!", api);
656 ret = CAMERA_ERROR_INVALID_OPERATION;
660 if (!cb_info->api_activating[api])
661 CAM_LOG_WARNING("invalid signal received, wait again...");
664 ret = cb_info->api_ret[api];
665 cb_info->api_activating[api] = FALSE;
668 g_mutex_unlock(&(cb_info->api_mutex[api]));
670 if (ret != CAMERA_ERROR_NONE)
671 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
677 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
678 int *ret, int timeout)
684 CAM_LOG_ERROR("NULL info - api %d", api);
687 *ret = CAMERA_ERROR_INVALID_PARAMETER;
692 msg = muse_core_msg_new(api, NULL);
694 CAM_LOG_ERROR("msg failed: api %d", api);
697 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
702 CAM_LOG_DEBUG("send msg[%s]", msg);
704 if (cb_info->is_server_connected) {
705 __camera_update_api_waiting(cb_info, api, 1);
707 g_mutex_lock(&cb_info->fd_lock);
708 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
709 g_mutex_unlock(&cb_info->fd_lock);
713 CAM_LOG_ERROR("msg send failed");
715 *ret = CAMERA_ERROR_INVALID_OPERATION;
718 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
721 __camera_update_api_waiting(cb_info, api, -1);
723 muse_core_msg_free(msg);
729 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
730 int *ret, camera_msg_param *param, int timeout)
736 if (!cb_info || !param) {
737 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
740 *ret = CAMERA_ERROR_INVALID_PARAMETER;
745 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
747 switch (param->type) {
749 msg = muse_core_msg_new(api,
750 param->type, param->name, param->value.value_INT,
753 case MUSE_TYPE_STRING:
754 msg = muse_core_msg_new(api,
755 param->type, param->name, param->value.value_STRING,
758 case MUSE_TYPE_ARRAY:
759 array_length = param->value_size / sizeof(int) + \
760 (param->value_size % sizeof(int) ? 1 : 0);
762 msg = muse_core_msg_new(api,
763 param->type, param->name, array_length, param->value.value_ARRAY,
767 CAM_LOG_ERROR("unknown type %d", param->type);
772 CAM_LOG_ERROR("msg failed: api %d", api);
775 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
780 CAM_LOG_DEBUG("send msg[%s]", msg);
782 if (cb_info->is_server_connected) {
783 __camera_update_api_waiting(cb_info, api, 1);
785 g_mutex_lock(&cb_info->fd_lock);
786 send_ret = muse_core_msg_send(cb_info->fd, msg);
787 g_mutex_unlock(&cb_info->fd_lock);
791 CAM_LOG_ERROR("msg send failed");
794 *ret = CAMERA_ERROR_INVALID_OPERATION;
797 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
800 __camera_update_api_waiting(cb_info, api, -1);
802 muse_core_msg_free(msg);
808 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
809 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
811 int func_ret = CAMERA_ERROR_NONE;
815 if (!cb_info || !param0 || !param1) {
816 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
817 cb_info, param0, param1, api);
818 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
819 goto _SEND_PARAM2_INT_DONE;
822 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
824 param0->name, param0->value.value_INT,
825 param1->name, param1->value.value_INT);
827 msg = muse_core_msg_new(api,
828 param0->type, param0->name, param0->value.value_INT,
829 param1->type, param1->name, param1->value.value_INT,
832 CAM_LOG_ERROR("msg failed: api %d", api);
833 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
834 goto _SEND_PARAM2_INT_DONE;
837 CAM_LOG_DEBUG("send msg[%s]", msg);
839 if (cb_info->is_server_connected) {
840 __camera_update_api_waiting(cb_info, api, 1);
842 g_mutex_lock(&cb_info->fd_lock);
843 send_ret = muse_core_msg_send(cb_info->fd, msg);
844 g_mutex_unlock(&cb_info->fd_lock);
848 CAM_LOG_ERROR("msg send failed");
850 func_ret = CAMERA_ERROR_INVALID_OPERATION;
852 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
855 __camera_update_api_waiting(cb_info, api, -1);
857 muse_core_msg_free(msg);
859 _SEND_PARAM2_INT_DONE:
867 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
869 camera_msg_param param;
872 CAM_LOG_WARNING("invalid fd %d", ret_fd);
876 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
878 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
884 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
886 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
887 in_format >= MM_PIXEL_FORMAT_NUM ||
888 out_format == NULL) {
889 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
890 return CAMERA_ERROR_INVALID_PARAMETER;
894 case MM_PIXEL_FORMAT_NV12:
895 case MM_PIXEL_FORMAT_NV12T:
896 *out_format = TBM_FORMAT_NV12;
899 case MM_PIXEL_FORMAT_NV16:
900 *out_format = TBM_FORMAT_NV16;
902 case MM_PIXEL_FORMAT_NV21:
903 *out_format = TBM_FORMAT_NV21;
905 case MM_PIXEL_FORMAT_YUYV:
906 *out_format = TBM_FORMAT_YUYV;
908 case MM_PIXEL_FORMAT_UYVY:
909 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
910 *out_format = TBM_FORMAT_UYVY;
912 case MM_PIXEL_FORMAT_422P:
913 *out_format = TBM_FORMAT_YUV422;
915 case MM_PIXEL_FORMAT_I420:
916 *out_format = TBM_FORMAT_YUV420;
918 case MM_PIXEL_FORMAT_YV12:
919 *out_format = TBM_FORMAT_YVU420;
921 case MM_PIXEL_FORMAT_RGB565:
922 *out_format = TBM_FORMAT_RGB565;
924 case MM_PIXEL_FORMAT_RGB888:
925 *out_format = TBM_FORMAT_RGB888;
927 case MM_PIXEL_FORMAT_RGBA:
928 *out_format = TBM_FORMAT_RGBA8888;
930 case MM_PIXEL_FORMAT_ARGB:
931 *out_format = TBM_FORMAT_ARGB8888;
934 CAM_LOG_ERROR("invalid in_format %d", in_format);
935 return CAMERA_ERROR_INVALID_PARAMETER;
939 return CAMERA_ERROR_NONE;
943 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
945 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
946 in_format >= MM_PIXEL_FORMAT_NUM ||
948 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
949 return CAMERA_ERROR_INVALID_PARAMETER;
953 case MM_PIXEL_FORMAT_NV12:
954 case MM_PIXEL_FORMAT_NV12T:
955 *mimetype = MEDIA_FORMAT_NV12;
958 case MM_PIXEL_FORMAT_NV16:
959 *mimetype = MEDIA_FORMAT_NV16;
961 case MM_PIXEL_FORMAT_NV21:
962 *mimetype = MEDIA_FORMAT_NV21;
964 case MM_PIXEL_FORMAT_YUYV:
965 *mimetype = MEDIA_FORMAT_YUYV;
967 case MM_PIXEL_FORMAT_UYVY:
968 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
969 *mimetype = MEDIA_FORMAT_UYVY;
971 case MM_PIXEL_FORMAT_422P:
972 *mimetype = MEDIA_FORMAT_422P;
974 case MM_PIXEL_FORMAT_I420:
975 *mimetype = MEDIA_FORMAT_I420;
977 case MM_PIXEL_FORMAT_YV12:
978 *mimetype = MEDIA_FORMAT_YV12;
980 case MM_PIXEL_FORMAT_RGB565:
981 *mimetype = MEDIA_FORMAT_RGB565;
983 case MM_PIXEL_FORMAT_RGB888:
984 *mimetype = MEDIA_FORMAT_RGB888;
986 case MM_PIXEL_FORMAT_RGBA:
987 *mimetype = MEDIA_FORMAT_RGBA;
989 case MM_PIXEL_FORMAT_ARGB:
990 *mimetype = MEDIA_FORMAT_ARGB;
993 CAM_LOG_ERROR("invalid in_format %d", in_format);
994 return CAMERA_ERROR_INVALID_PARAMETER;
998 return CAMERA_ERROR_NONE;
1001 void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
1002 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1005 unsigned char *buf_pos = NULL;
1007 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1008 CAM_LOG_ERROR("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1012 /* set frame info */
1013 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1014 frame->format = MM_PIXEL_FORMAT_UYVY;
1016 frame->format = stream->format;
1018 frame->width = stream->width;
1019 frame->height = stream->height;
1020 frame->timestamp = stream->timestamp;
1021 frame->num_of_planes = stream->num_planes;
1023 if (num_buffer_fd == 0) {
1026 if (!data_bo_handle || !data_bo_handle->ptr) {
1027 CAM_LOG_ERROR("NULL pointer");
1031 buf_pos = data_bo_handle->ptr;
1033 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1034 frame->data.encoded_plane.data = buf_pos;
1035 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1036 frame->data.encoded_plane.is_delta_frame = (bool)stream->data.encoded.is_delta_frame;
1037 total_size = stream->data.encoded.length_data;
1038 } else if (stream->format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
1039 frame->data.encoded_plane.data = buf_pos;
1040 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1041 total_size = stream->data.encoded.length_data;
1042 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1043 frame->data.depth_plane.data = buf_pos;
1044 frame->data.depth_plane.size = stream->data.depth.length_data;
1045 total_size = stream->data.depth.length_data;
1046 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1047 stream->format == MM_PIXEL_FORMAT_ARGB) {
1048 frame->data.rgb_plane.data = buf_pos;
1049 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1050 total_size = stream->data.rgb.length_data;
1052 switch (stream->num_planes) {
1054 frame->data.single_plane.yuv = buf_pos;
1055 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1056 total_size = stream->data.yuv420.length_yuv;
1059 frame->data.double_plane.y = buf_pos;
1060 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1061 buf_pos += stream->data.yuv420sp.length_y;
1062 frame->data.double_plane.uv = buf_pos;
1063 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1064 total_size = stream->data.yuv420sp.length_y + \
1065 stream->data.yuv420sp.length_uv;
1068 frame->data.triple_plane.y = buf_pos;
1069 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1070 buf_pos += stream->data.yuv420p.length_y;
1071 frame->data.triple_plane.u = buf_pos;
1072 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1073 buf_pos += stream->data.yuv420p.length_u;
1074 frame->data.triple_plane.v = buf_pos;
1075 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1076 total_size = stream->data.yuv420p.length_y + \
1077 stream->data.yuv420p.length_u + \
1078 stream->data.yuv420p.length_v;
1087 switch (stream->num_planes) {
1090 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1091 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1092 total_size = stream->data.yuv420.length_yuv;
1096 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1097 if (stream->num_planes == (unsigned int)num_buffer_fd)
1098 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1100 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1101 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1102 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1103 total_size = stream->data.yuv420sp.length_y + \
1104 stream->data.yuv420sp.length_uv;
1108 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1109 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1110 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1111 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1113 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1114 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1116 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1117 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1118 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1119 total_size = stream->data.yuv420p.length_y + \
1120 stream->data.yuv420p.length_u + \
1121 stream->data.yuv420p.length_v;
1129 CAM_LOG_DEBUG("format[%d], res[%dx%d], size[%d], plane num[%d]",
1130 frame->format, frame->width, frame->height, total_size, frame->num_of_planes);
1135 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1136 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1139 int ret = CAMERA_ERROR_NONE;
1140 camera_media_packet_data *tmp_mp_data = NULL;
1143 CAM_LOG_ERROR("NULL tfd");
1144 return CAMERA_ERROR_INVALID_PARAMETER;
1147 if (*mp_data == NULL) {
1148 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1150 tmp_mp_data->ret_fd = ret_fd;
1151 tmp_mp_data->fd = tfd[0];
1152 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1153 tmp_mp_data->bo = bo;
1155 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", tmp_mp_data->fd, tmp_mp_data->ret_fd);
1159 tmp_mp_data->data_bo = data_bo;
1160 tmp_mp_data->data_fd = tfd[1];
1162 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1163 tmp_mp_data->data_bo, tmp_mp_data->data_fd);
1166 for (i = 0 ; i < num_buffer_fd ; i++) {
1167 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1168 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1170 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1171 i, tmp_mp_data->buffer_bo[i], tmp_mp_data->buffer_fd[i]);
1175 tmp_mp_data->ref_cnt++;
1177 *mp_data = tmp_mp_data;
1179 CAM_LOG_DEBUG("mp_data %p", tmp_mp_data);
1181 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1182 CAM_LOG_ERROR("failed to alloc media packet data");
1185 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1191 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1195 if (!mp_data || !cb_info) {
1196 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1200 if (mp_data->ref_cnt > 1) {
1202 CAM_LOG_INFO("ref count %d", mp_data->ref_cnt);
1204 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1206 /* release imported bo and close imported fd */
1207 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1208 tbm_bo_unref(mp_data->buffer_bo[i]);
1209 mp_data->buffer_bo[i] = NULL;
1211 close(mp_data->buffer_fd[i]);
1212 mp_data->buffer_fd[i] = -1;
1215 /* unref tbm bo and close imported fd */
1219 _camera_release_imported_bo(&mp_data->bo);
1221 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1222 close(mp_data->data_fd);
1223 mp_data->data_fd = -1;
1225 _camera_release_imported_bo(&mp_data->data_bo);
1228 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1236 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1237 camera_media_packet_data *mp_data, media_packet_h *packet)
1239 media_packet_h pkt = NULL;
1240 bool make_pkt_fmt = false;
1241 tbm_surface_h tsurf = NULL;
1242 tbm_surface_info_s tsurf_info;
1243 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1244 uint32_t bo_format = 0;
1247 int num_buffer_fd = 0;
1248 tbm_bo *buffer_bo = NULL;
1250 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1251 CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1252 cb_info, stream, mp_data, packet);
1253 return CAMERA_ERROR_INVALID_PARAMETER;
1256 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1257 buffer_bo = mp_data->buffer_bo;
1258 num_buffer_fd = mp_data->num_buffer_fd;
1260 /* create tbm surface */
1261 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1262 tsurf_info.planes[i].stride = stream->stride[i];
1264 /* get tbm surface format */
1265 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1266 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1268 if (ret == CAMERA_ERROR_NONE) {
1269 tsurf_info.width = stream->width;
1270 tsurf_info.height = stream->height;
1271 tsurf_info.format = bo_format;
1272 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1273 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1275 if (num_buffer_fd > 0) {
1276 switch (bo_format) {
1277 case TBM_FORMAT_NV12:
1278 case TBM_FORMAT_NV21:
1279 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1280 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1281 tsurf_info.planes[0].offset = 0;
1282 if (num_buffer_fd == 1)
1283 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1284 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1287 case TBM_FORMAT_YUV420:
1288 case TBM_FORMAT_YVU420:
1289 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1290 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1291 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1292 tsurf_info.planes[0].offset = 0;
1293 if (num_buffer_fd == 1) {
1294 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1295 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1297 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1299 case TBM_FORMAT_UYVY:
1300 case TBM_FORMAT_YUYV:
1301 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1302 tsurf_info.planes[0].offset = 0;
1303 tsurf_info.size = tsurf_info.planes[0].size;
1310 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1311 } else if (mp_data->data_bo) {
1313 switch (bo_format) {
1314 case TBM_FORMAT_NV12:
1315 case TBM_FORMAT_NV21:
1316 tsurf_info.planes[0].size = stream->width * stream->height;
1317 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1318 tsurf_info.planes[0].offset = 0;
1319 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1320 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1322 case TBM_FORMAT_YUV420:
1323 case TBM_FORMAT_YVU420:
1324 tsurf_info.planes[0].size = stream->width * stream->height;
1325 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1326 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1327 tsurf_info.planes[0].offset = 0;
1328 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1329 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1330 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1332 case TBM_FORMAT_UYVY:
1333 case TBM_FORMAT_YUYV:
1334 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1335 tsurf_info.planes[0].offset = 0;
1336 tsurf_info.size = tsurf_info.planes[0].size;
1342 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1348 /* check media packet format */
1349 if (cb_info->pkt_fmt) {
1350 int pkt_fmt_width = 0;
1351 int pkt_fmt_height = 0;
1352 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1354 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1356 CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d", pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1358 if (pkt_fmt_mimetype != mimetype ||
1359 pkt_fmt_width != stream->width ||
1360 pkt_fmt_height != stream->height) {
1361 CAM_LOG_WARNING("change fmt: current 0x%x, %dx%d",
1362 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1363 media_format_unref(cb_info->pkt_fmt);
1364 cb_info->pkt_fmt = NULL;
1365 make_pkt_fmt = true;
1368 make_pkt_fmt = true;
1371 /* create packet format */
1373 CAM_LOG_WARNING("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1374 ret = media_format_create(&cb_info->pkt_fmt);
1375 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1376 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1377 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1378 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1379 CAM_LOG_WARNING("media_format_set : 0x%x", ret);
1381 CAM_LOG_WARNING("media_format_create failed 0x%x", ret);
1385 /* create media packet */
1386 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1387 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1388 (void *)cb_info, &pkt);
1389 if (ret != MEDIA_PACKET_ERROR_NONE) {
1390 CAM_LOG_ERROR("media_packet_create failed 0x%x", ret);
1391 tbm_surface_destroy(tsurf);
1395 CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1396 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1400 /* set media packet data */
1401 ret = media_packet_set_extra(pkt, (void *)mp_data);
1402 if (ret != MEDIA_PACKET_ERROR_NONE) {
1403 CAM_LOG_ERROR("media_packet_set_extra failed");
1405 _camera_media_packet_data_release(mp_data, cb_info);
1407 media_packet_destroy(pkt);
1409 /* set timestamp : msec -> nsec */
1410 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1411 CAM_LOG_WARNING("media_packet_set_pts failed");
1420 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1423 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1424 camera_media_packet_data *mp_data = NULL;
1425 tbm_surface_h tsurf = NULL;
1427 if (!pkt || !cb_info) {
1428 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1429 return MEDIA_PACKET_FINALIZE;
1432 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1433 if (ret != MEDIA_PACKET_ERROR_NONE) {
1434 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1435 return MEDIA_PACKET_FINALIZE;
1438 CAM_LOG_VERBOSE("mp_data[%p]", mp_data);
1440 g_mutex_lock(&cb_info->mp_data_mutex);
1442 _camera_media_packet_data_release(mp_data, cb_info);
1445 g_mutex_unlock(&cb_info->mp_data_mutex);
1447 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1448 if (ret != MEDIA_PACKET_ERROR_NONE)
1449 CAM_LOG_ERROR("get tbm_surface failed 0x%x", ret);
1452 tbm_surface_destroy(tsurf);
1456 return MEDIA_PACKET_FINALIZE;
1459 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1464 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1465 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1469 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1471 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1473 if (cb_info->user_cb[event] == NULL) {
1474 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1475 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1476 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1477 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1478 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1479 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1483 /* return buffer message should be sent for some events.
1484 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1485 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1486 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1487 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1492 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1498 muse_camera_msg_get(previous, recv_msg);
1499 muse_camera_msg_get(current, recv_msg);
1500 muse_camera_msg_get(by_policy, recv_msg);
1502 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1503 previous, current, by_policy);
1505 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1506 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1509 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1513 muse_camera_msg_get(state, recv_msg);
1515 CAM_LOG_INFO("FOCUS state - %d", state);
1517 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1520 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1521 CAM_LOG_INFO("CAPTURE_COMPLETED");
1522 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1524 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1525 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1526 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1529 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1533 muse_camera_msg_get(percent, recv_msg);
1535 CAM_LOG_INFO("HDR progress - %d %%", percent);
1537 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1540 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1546 muse_camera_msg_get(policy, recv_msg);
1547 muse_camera_msg_get(previous, recv_msg);
1548 muse_camera_msg_get(current, recv_msg);
1550 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1552 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1553 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1556 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1561 muse_camera_msg_get(policy, recv_msg);
1562 muse_camera_msg_get(state, recv_msg);
1564 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1566 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1567 (camera_state_e)state, cb_info->user_data[event]);
1570 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1571 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1573 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1576 int current_state = 0;
1578 muse_camera_msg_get(error, recv_msg);
1579 muse_camera_msg_get(current_state, recv_msg);
1581 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1583 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1584 (camera_state_e)current_state, cb_info->user_data[event]);
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1591 muse_camera_msg_get(param1, recv_msg);
1592 muse_camera_msg_get(param2, recv_msg);
1594 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1596 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1597 cb_info->user_cb[event] = NULL;
1598 cb_info->user_data[event] = NULL;
1599 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1604 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1606 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1608 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1610 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1612 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1614 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1616 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1618 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1620 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1622 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1624 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1626 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1629 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1631 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1632 muse_camera_msg_get(param1, recv_msg);
1634 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1636 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1637 cb_info->user_cb[event] = NULL;
1638 cb_info->user_data[event] = NULL;
1639 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1643 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1644 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1647 CAM_LOG_WARNING("unhandled event %d", event);
1651 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1656 static gboolean _camera_idle_event_callback(gpointer data)
1658 camera_cb_info_s *cb_info = NULL;
1659 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1661 if (cam_idle_event == NULL) {
1662 CAM_LOG_ERROR("cam_idle_event is NULL");
1667 g_mutex_lock(&g_cam_idle_event_lock);
1669 cb_info = cam_idle_event->cb_info;
1670 if (cb_info == NULL) {
1671 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1672 g_mutex_unlock(&g_cam_idle_event_lock);
1673 goto IDLE_EVENT_CALLBACK_DONE;
1676 /* remove event from list */
1677 if (cb_info->idle_event_list)
1678 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1680 g_mutex_unlock(&g_cam_idle_event_lock);
1683 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1685 IDLE_EVENT_CALLBACK_DONE:
1687 g_free(cam_idle_event);
1688 cam_idle_event = NULL;
1693 static gpointer _camera_msg_handler_func(gpointer data)
1697 camera_message_s *cam_msg = NULL;
1698 camera_idle_event_s *cam_idle_event = NULL;
1699 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1700 camera_cb_info_s *cb_info = NULL;
1702 if (!handler_info || !handler_info->cb_info) {
1703 CAM_LOG_ERROR("NULL handler %p", handler_info);
1707 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1708 type = handler_info->type;
1710 CAM_LOG_INFO("t:%d start", type);
1712 g_mutex_lock(&handler_info->mutex);
1714 while (g_atomic_int_get(&handler_info->running)) {
1715 if (g_queue_is_empty(handler_info->queue)) {
1716 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1717 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1718 CAM_LOG_VERBOSE("t[%d] signal received", type);
1720 if (g_atomic_int_get(&handler_info->running) == 0) {
1721 CAM_LOG_INFO("t:%d stop event thread", type);
1726 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1728 g_mutex_unlock(&handler_info->mutex);
1730 if (cam_msg == NULL) {
1731 CAM_LOG_ERROR("t:%d NULL message", type);
1732 g_mutex_lock(&handler_info->mutex);
1738 if (api < MUSE_CAMERA_API_MAX) {
1741 g_mutex_lock(&cb_info->api_mutex[api]);
1743 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1744 if (cb_info->api_waiting[api] > 0) {
1745 cb_info->api_ret[api] = ret;
1746 cb_info->api_activating[api] = TRUE;
1748 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1750 g_cond_signal(&cb_info->api_cond[api]);
1752 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1755 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1758 g_mutex_unlock(&cb_info->api_mutex[api]);
1759 } else if (api == MUSE_CAMERA_CB_EVENT) {
1760 switch (cam_msg->event_class) {
1761 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1762 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1764 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1765 cam_idle_event = g_new0(camera_idle_event_s, 1);
1766 if (cam_idle_event == NULL) {
1767 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1771 cam_idle_event->event = cam_msg->event;
1772 cam_idle_event->cb_info = cb_info;
1774 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1775 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1777 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1778 type, cam_msg->event, cam_idle_event);
1780 g_mutex_lock(&g_cam_idle_event_lock);
1781 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1782 g_mutex_unlock(&g_cam_idle_event_lock);
1784 g_idle_add_full(G_PRIORITY_DEFAULT,
1785 (GSourceFunc)_camera_idle_event_callback,
1786 (gpointer)cam_idle_event,
1790 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1794 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1800 g_mutex_lock(&handler_info->mutex);
1803 /* remove remained event */
1804 while (!g_queue_is_empty(handler_info->queue)) {
1805 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1807 CAM_LOG_INFO("t:%d remove camera message %p", type, cam_msg);
1811 CAM_LOG_WARNING("t:%d NULL camera message", type);
1815 g_mutex_unlock(&handler_info->mutex);
1817 CAM_LOG_INFO("t:%d return", type);
1823 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1825 camera_idle_event_s *cam_idle_event = NULL;
1828 if (cb_info == NULL) {
1829 CAM_LOG_ERROR("cb_info is NULL");
1833 g_mutex_lock(&g_cam_idle_event_lock);
1835 if (cb_info->idle_event_list == NULL) {
1836 CAM_LOG_INFO("No remained idle event");
1837 g_mutex_unlock(&g_cam_idle_event_lock);
1841 list = cb_info->idle_event_list;
1844 cam_idle_event = list->data;
1845 list = g_list_next(list);
1847 if (!cam_idle_event) {
1848 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1852 if (g_idle_remove_by_data(cam_idle_event)) {
1853 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1855 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1857 g_free(cam_idle_event);
1858 cam_idle_event = NULL;
1863 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1864 cam_idle_event, cam_idle_event->event);
1866 cam_idle_event->cb_info = NULL;
1868 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1871 g_list_free(cb_info->idle_event_list);
1872 cb_info->idle_event_list = NULL;
1874 g_mutex_unlock(&g_cam_idle_event_lock);
1880 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1882 camera_message_s *cam_msg = NULL;
1884 if (!cb_info || !msg) {
1885 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1889 cam_msg = g_new0(camera_message_s, 1);
1891 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1896 cam_msg->event = event;
1897 cam_msg->event_class = event_class;
1899 if (tfd && tfd[0] >= 0)
1900 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1902 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1904 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1905 api, event, event_class);
1907 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1908 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1909 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1910 g_cond_signal(&cb_info->preview_cb_info.cond);
1911 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1912 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1913 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1914 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1915 g_cond_signal(&cb_info->capture_cb_info.cond);
1916 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1918 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1919 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1920 g_cond_signal(&cb_info->msg_handler_info.cond);
1921 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1930 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1932 int ret = CAMERA_ERROR_NONE;
1936 int event_class = -1;
1940 if (!cb_info || !msg) {
1941 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
1945 CAM_LOG_DEBUG("msg[%s]", msg);
1947 if (!muse_camera_msg_get(api, msg)) {
1948 CAM_LOG_ERROR("failed to get camera api");
1952 if (api == MUSE_CAMERA_CB_EVENT) {
1953 if (!muse_camera_msg_get(event, msg) ||
1954 !muse_camera_msg_get(event_class, msg)) {
1955 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
1959 if (!muse_camera_msg_get(api_class, msg)) {
1960 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
1965 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1966 if (api >= MUSE_CAMERA_API_MAX) {
1967 CAM_LOG_ERROR("invalid api %d", api);
1971 if (!muse_camera_msg_get(ret, msg)) {
1972 CAM_LOG_ERROR("failed to get camera ret");
1976 g_mutex_lock(&cb_info->api_mutex[api]);
1979 case MUSE_CAMERA_API_CREATE:
1980 if (ret != CAMERA_ERROR_NONE) {
1981 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1982 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
1985 case MUSE_CAMERA_API_DESTROY:
1986 if (ret == CAMERA_ERROR_NONE) {
1987 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1988 CAM_LOG_INFO("camera destroy done. close client cb handler");
1992 muse_camera_msg_get(get_type, msg);
1993 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1994 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1995 muse_camera_msg_get(get_index, msg);
1998 case MUSE_CAMERA_GET_TYPE_INT:
1999 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2001 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2002 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2003 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2005 case MUSE_CAMERA_GET_TYPE_ARRAY:
2006 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
2007 muse_core_msg_deserialize("get_value",
2008 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2009 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2010 cb_info->get_display_roi_area[0],
2011 cb_info->get_display_roi_area[1],
2012 cb_info->get_display_roi_area[2],
2013 cb_info->get_display_roi_area[3]);
2015 muse_core_msg_deserialize("get_value",
2016 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2017 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2018 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2021 case MUSE_CAMERA_GET_TYPE_STRING:
2022 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2025 CAM_LOG_WARNING("unknown type %d", get_type);
2032 if (cb_info->api_waiting[api] > 0) {
2033 cb_info->api_ret[api] = ret;
2034 cb_info->api_activating[api] = TRUE;
2036 g_cond_signal(&cb_info->api_cond[api]);
2038 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2041 g_mutex_unlock(&cb_info->api_mutex[api]);
2042 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2043 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2045 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2052 static gpointer _camera_msg_recv_func(gpointer data)
2055 int recv_length = 0;
2056 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2057 char *recv_msg = NULL;
2058 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2061 CAM_LOG_ERROR("cb_info NULL");
2065 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2067 recv_msg = cb_info->recv_msg;
2069 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2070 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2073 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2074 if (recv_length <= 0) {
2075 cb_info->is_server_connected = FALSE;
2076 CAM_LOG_ERROR("receive msg failed - server disconnected");
2081 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2083 recv_msg[recv_length] = '\0';
2085 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2087 __camera_process_msg(cb_info, recv_msg, tfd);
2090 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2092 if (!cb_info->is_server_connected) {
2093 char *error_msg = NULL;
2095 if (cb_info->bufmgr == NULL) {
2096 CAM_LOG_ERROR("No need to send error(handle is not created)");
2100 if (cb_info->fd < 0) {
2101 CAM_LOG_ERROR("fd is closed in client side");
2105 /* send error msg for server disconnection */
2106 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2107 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2108 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2112 CAM_LOG_ERROR("error_msg failed");
2116 __camera_add_msg_to_queue(cb_info,
2117 MUSE_CAMERA_CB_EVENT,
2118 MUSE_CAMERA_EVENT_TYPE_ERROR,
2119 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2123 muse_core_msg_free(error_msg);
2126 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 CAM_LOG_INFO("t:%d", type);
2144 handler_info->type = type;
2145 handler_info->queue = g_queue_new();
2146 if (handler_info->queue == NULL) {
2147 CAM_LOG_ERROR("t:%d queue failed", type);
2151 g_mutex_init(&handler_info->mutex);
2152 g_cond_init(&handler_info->cond);
2154 handler_info->cb_info = (void *)cb_info;
2155 g_atomic_int_set(&handler_info->running, 1);
2157 handler_info->thread = g_thread_try_new(thread_name,
2158 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2159 if (handler_info->thread == NULL) {
2160 CAM_LOG_ERROR("t:%d thread failed", type);
2162 g_mutex_clear(&handler_info->mutex);
2163 g_cond_clear(&handler_info->cond);
2164 g_queue_free(handler_info->queue);
2165 handler_info->queue = NULL;
2170 CAM_LOG_INFO("t:%d done", type);
2176 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2180 if (!handler_info) {
2181 CAM_LOG_ERROR("NULL handler");
2185 if (!handler_info->thread) {
2186 CAM_LOG_WARNING("thread is not created");
2190 type = handler_info->type;
2192 CAM_LOG_INFO("t:%d thread %p", type, handler_info->thread);
2194 g_mutex_lock(&handler_info->mutex);
2195 g_atomic_int_set(&handler_info->running, 0);
2196 g_cond_signal(&handler_info->cond);
2197 g_mutex_unlock(&handler_info->mutex);
2199 g_thread_join(handler_info->thread);
2200 handler_info->thread = NULL;
2202 g_mutex_clear(&handler_info->mutex);
2203 g_cond_clear(&handler_info->cond);
2204 g_queue_free(handler_info->queue);
2205 handler_info->queue = NULL;
2207 CAM_LOG_INFO("t:%d done", type);
2213 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2215 camera_cb_info_s *cb_info = NULL;
2218 g_return_val_if_fail(sockfd > 0, NULL);
2220 cb_info = g_new0(camera_cb_info_s, 1);
2221 if (cb_info == NULL) {
2222 CAM_LOG_ERROR("cb_info failed");
2226 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2228 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2229 g_mutex_init(&cb_info->api_mutex[i]);
2230 g_cond_init(&cb_info->api_cond[i]);
2233 g_mutex_init(&cb_info->fd_lock);
2234 g_mutex_init(&cb_info->mp_data_mutex);
2236 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2237 g_mutex_init(&cb_info->user_cb_mutex[i]);
2239 /* message handler thread */
2240 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2241 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2242 CAM_LOG_ERROR("msg_handler_info failed");
2246 /* message handler thread for preview callback */
2247 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2248 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2249 CAM_LOG_ERROR("preview_cb_info failed");
2253 /* message handler thread for capture callback */
2254 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2255 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2256 CAM_LOG_ERROR("capture_cb_info failed");
2260 cb_info->fd = sockfd;
2261 cb_info->preview_cb_flag = 0;
2263 /* message receive thread */
2264 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2265 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2266 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2267 if (cb_info->msg_recv_thread == NULL) {
2268 CAM_LOG_ERROR("message receive thread creation failed");
2273 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2274 cb_info->fds[i] = -1;
2276 cb_info->is_server_connected = TRUE;
2282 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2283 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2284 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2286 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2287 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2289 g_mutex_clear(&cb_info->fd_lock);
2290 g_mutex_clear(&cb_info->mp_data_mutex);
2292 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2293 g_mutex_clear(&cb_info->api_mutex[i]);
2294 g_cond_clear(&cb_info->api_cond[i]);
2305 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2309 g_return_if_fail(cb_info != NULL);
2311 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2313 g_thread_join(cb_info->msg_recv_thread);
2314 cb_info->msg_recv_thread = NULL;
2316 CAM_LOG_INFO("msg_recv thread removed");
2318 /* destroy msg handler threads */
2319 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2320 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2321 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2323 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2324 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2326 g_mutex_clear(&cb_info->fd_lock);
2327 g_mutex_clear(&cb_info->mp_data_mutex);
2329 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2330 g_mutex_clear(&cb_info->api_mutex[i]);
2331 g_cond_clear(&cb_info->api_cond[i]);
2334 if (cb_info->fd > -1) {
2335 muse_client_close(cb_info->fd);
2339 if (cb_info->bufmgr) {
2340 tbm_bufmgr_deinit(cb_info->bufmgr);
2341 cb_info->bufmgr = NULL;
2343 if (cb_info->pkt_fmt) {
2344 media_format_unref(cb_info->pkt_fmt);
2345 cb_info->pkt_fmt = NULL;
2348 if (cb_info->dp_interface) {
2349 mm_display_interface_deinit(cb_info->dp_interface);
2350 cb_info->dp_interface = NULL;
2353 cb_info->preview_cb_flag = 0;
2361 int _camera_start_evas_rendering(camera_h camera)
2363 camera_cli_s *pc = (camera_cli_s *)camera;
2365 if (!pc || !pc->cb_info) {
2366 CAM_LOG_ERROR("NULL handle");
2367 return CAMERA_ERROR_INVALID_PARAMETER;
2370 CAM_LOG_INFO("start");
2372 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2373 CAM_LOG_ERROR("EVAS surface is not set");
2374 return CAMERA_ERROR_NONE;
2377 /* set evas render flag as RUN */
2378 pc->cb_info->run_evas_render = true;
2380 return CAMERA_ERROR_NONE;
2384 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2386 int ret = CAMERA_ERROR_NONE;
2387 camera_cli_s *pc = (camera_cli_s *)camera;
2389 if (!pc || !pc->cb_info) {
2390 CAM_LOG_ERROR("NULL handle");
2391 return CAMERA_ERROR_INVALID_PARAMETER;
2394 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2396 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2397 CAM_LOG_ERROR("EVAS surface is not set");
2398 return CAMERA_ERROR_NONE;
2401 /* set evas render flag as STOP and release buffers */
2402 pc->cb_info->run_evas_render = false;
2404 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2405 if (ret == MM_ERROR_NONE) {
2406 ret = CAMERA_ERROR_NONE;
2408 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2409 ret = CAMERA_ERROR_INVALID_OPERATION;
2416 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2418 int ret = CAMERA_ERROR_NONE;
2420 int module_index = -1;
2422 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2424 /* create muse connection */
2425 if (!key || !value) {
2426 CAM_LOG_ERROR("NULL pointer");
2427 return CAMERA_ERROR_INVALID_PARAMETER;
2430 sock_fd = muse_client_new();
2432 CAM_LOG_ERROR("muse_client_new failed");
2433 return CAMERA_ERROR_INVALID_OPERATION;
2436 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2437 CAM_LOG_ERROR("muse client get module index failed");
2438 ret = CAMERA_ERROR_INVALID_OPERATION;
2442 msg = muse_core_msg_new(api,
2443 MUSE_TYPE_INT, "module", module_index,
2444 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2447 CAM_LOG_ERROR("msg failed");
2448 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2452 ret = muse_core_msg_send(sock_fd, msg);
2454 muse_core_msg_free(msg);
2458 CAM_LOG_ERROR("send msg failed");
2459 ret = CAMERA_ERROR_INVALID_OPERATION;
2463 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2465 CAM_LOG_ERROR("recv msg failed %d", errno);
2466 ret = CAMERA_ERROR_INVALID_OPERATION;
2470 if (!muse_camera_msg_get(ret, recv_msg)) {
2471 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2472 ret = CAMERA_ERROR_INVALID_OPERATION;
2476 if (ret == CAMERA_ERROR_NONE)
2477 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2479 CAM_LOG_INFO("api %d - value %d", api, *value);
2483 muse_client_close(sock_fd);
2491 int camera_create(camera_device_e device, camera_h *camera)
2494 char *send_msg = NULL;
2496 int ret = CAMERA_ERROR_NONE;
2497 camera_cli_s *pc = NULL;
2498 tbm_bufmgr bufmgr = NULL;
2500 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2501 int module_index = -1;
2502 int device_type = (int)device;
2505 CAM_LOG_ERROR("NULL pointer");
2506 return CAMERA_ERROR_INVALID_PARAMETER;
2509 sock_fd = muse_client_new();
2511 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2512 ret = CAMERA_ERROR_INVALID_OPERATION;
2516 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2517 CAM_LOG_ERROR("muse client get module index failed");
2518 ret = CAMERA_ERROR_INVALID_OPERATION;
2522 send_msg = muse_core_msg_new(api,
2523 MUSE_TYPE_INT, "module", module_index,
2524 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2528 CAM_LOG_ERROR("NULL msg");
2529 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2533 send_ret = muse_core_msg_send(sock_fd, send_msg);
2535 muse_core_msg_free(send_msg);
2539 CAM_LOG_ERROR("send msg failed %d", errno);
2540 ret = CAMERA_ERROR_INVALID_OPERATION;
2544 pc = g_new0(camera_cli_s, 1);
2546 CAM_LOG_ERROR("camera_cli_s alloc failed");
2547 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2551 bufmgr = tbm_bufmgr_init(-1);
2552 if (bufmgr == NULL) {
2553 CAM_LOG_ERROR("get tbm bufmgr failed");
2554 ret = CAMERA_ERROR_INVALID_OPERATION;
2558 pc->cb_info = _camera_client_callback_new(sock_fd);
2559 if (pc->cb_info == NULL) {
2560 CAM_LOG_ERROR("cb_info alloc failed");
2561 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2567 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2569 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2571 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2573 if (ret == CAMERA_ERROR_NONE) {
2574 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2575 int user_buffer_supported = 0;
2576 intptr_t handle = 0;
2578 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2580 CAM_LOG_ERROR("Receiving Handle Failed!!");
2581 ret = CAMERA_ERROR_INVALID_OPERATION;
2585 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2586 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2588 g_mmcam_log_level = CAMERA_LOG_LEVEL_INFO;
2592 pc->remote_handle = handle;
2593 pc->cb_info->bufmgr = bufmgr;
2594 pc->cb_info->preview_format = preview_format;
2595 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2596 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2598 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2599 preview_format, user_buffer_supported, g_mmcam_log_level);
2601 *camera = (camera_h)pc;
2603 /* get display interface handle */
2604 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2605 CAM_LOG_WARNING("display interface init failed");
2614 tbm_bufmgr_deinit(bufmgr);
2619 muse_client_close(sock_fd);
2625 int temp_fd = pc->cb_info->fd;
2627 /* pc->cb_info->fd should be closed,
2628 because g_thread_join for msg_recv_thread is not returned
2629 in _camera_client_callback_destroy. */
2631 pc->cb_info->fd = -1;
2632 muse_client_close(temp_fd);
2635 _camera_client_callback_destroy(pc->cb_info);
2642 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2649 int camera_change_device(camera_h camera, camera_device_e device)
2652 int ret = CAMERA_ERROR_NONE;
2653 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2654 camera_cli_s *pc = (camera_cli_s *)camera;
2655 camera_msg_param param;
2657 if (!pc || !pc->cb_info) {
2658 CAM_LOG_ERROR("NULL handle");
2659 return CAMERA_ERROR_INVALID_PARAMETER;
2662 CAMERA_MSG_PARAM_SET(param, INT, device);
2664 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2666 if (ret == CAMERA_ERROR_NONE) {
2667 /* reset callback and user data */
2668 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2669 pc->cb_info->user_cb[i] = NULL;
2670 pc->cb_info->user_data[i] = NULL;
2672 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2679 int camera_destroy(camera_h camera)
2681 int ret = CAMERA_ERROR_NONE;
2682 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2683 camera_cli_s *pc = (camera_cli_s *)camera;
2685 if (!pc || !pc->cb_info) {
2686 CAM_LOG_ERROR("NULL handle");
2687 return CAMERA_ERROR_INVALID_PARAMETER;
2690 CAM_LOG_INFO("Enter");
2692 if (pc->cb_info->is_server_connected)
2693 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2695 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2697 if (ret == CAMERA_ERROR_NONE) {
2698 _camera_deactivate_idle_event_all(pc->cb_info);
2699 _camera_client_callback_destroy(pc->cb_info);
2706 CAM_LOG_INFO("ret : 0x%x", ret);
2711 int camera_start_preview(camera_h camera)
2713 int ret = CAMERA_ERROR_NONE;
2714 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2715 camera_cli_s *pc = (camera_cli_s *)camera;
2716 camera_state_e current_state = CAMERA_STATE_NONE;
2718 if (!pc || !pc->cb_info) {
2719 CAM_LOG_ERROR("NULL handle");
2720 return CAMERA_ERROR_INVALID_PARAMETER;
2723 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2724 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2726 ret = camera_get_state(camera, ¤t_state);
2727 if (ret != CAMERA_ERROR_NONE) {
2728 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2732 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2733 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2734 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2735 pc->cb_info->dp_info.type);
2736 return CAMERA_ERROR_INVALID_OPERATION;
2739 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2740 if (!_camera_allocate_preview_buffer(camera))
2741 return CAMERA_ERROR_INVALID_OPERATION;
2743 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2745 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2748 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2749 ret = _camera_start_evas_rendering(camera);
2750 if (ret != CAMERA_ERROR_NONE) {
2751 CAM_LOG_ERROR("stop preview because of error");
2752 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2756 CAM_LOG_INFO("ret : 0x%x", ret);
2762 int camera_stop_preview(camera_h camera)
2764 int ret = CAMERA_ERROR_NONE;
2765 camera_cli_s *pc = (camera_cli_s *)camera;
2766 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2767 camera_state_e current_state = CAMERA_STATE_NONE;
2769 if (!pc || !pc->cb_info) {
2770 CAM_LOG_ERROR("NULL handle");
2771 return CAMERA_ERROR_INVALID_PARAMETER;
2774 CAM_LOG_INFO("Enter");
2777 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2778 ret = camera_get_state(camera, ¤t_state);
2779 if (ret != CAMERA_ERROR_NONE) {
2780 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2784 if (current_state == CAMERA_STATE_PREVIEW) {
2785 ret = _camera_stop_evas_rendering(camera, false);
2786 if (ret != CAMERA_ERROR_NONE)
2791 /* send stop preview message */
2792 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2794 if (ret == CAMERA_ERROR_NONE) {
2795 if (pc->cb_info->user_buffer_supported)
2796 _camera_release_preview_buffer(camera);
2797 } else if (current_state == CAMERA_STATE_PREVIEW) {
2798 CAM_LOG_WARNING("restart evas rendering");
2799 _camera_start_evas_rendering(camera);
2802 CAM_LOG_INFO("ret : 0x%x", ret);
2808 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2810 int ret = CAMERA_ERROR_NONE;
2811 camera_cli_s *pc = (camera_cli_s *)camera;
2812 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2814 if (!pc || !pc->cb_info) {
2815 CAM_LOG_ERROR("NULL handle");
2816 return CAMERA_ERROR_INVALID_PARAMETER;
2819 CAM_LOG_INFO("Enter");
2821 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2822 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2824 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2825 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2827 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2829 CAM_LOG_INFO("ret : 0x%x", ret);
2835 bool camera_is_supported_continuous_capture(camera_h camera)
2837 int ret = CAMERA_ERROR_NONE;
2838 camera_cli_s *pc = (camera_cli_s *)camera;
2839 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2841 if (!pc || !pc->cb_info) {
2842 CAM_LOG_ERROR("NULL handle");
2843 return CAMERA_ERROR_INVALID_PARAMETER;
2846 CAM_LOG_INFO("Enter");
2848 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2851 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2855 CAM_LOG_INFO("ret : %d", ret);
2861 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)
2863 int ret = CAMERA_ERROR_NONE;
2864 camera_cli_s *pc = (camera_cli_s *)camera;
2865 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2866 camera_msg_param param;
2869 if (!pc || !pc->cb_info) {
2870 CAM_LOG_ERROR("NULL handle");
2871 return CAMERA_ERROR_INVALID_PARAMETER;
2874 CAM_LOG_INFO("Enter");
2876 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2877 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2879 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2880 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2882 value = (count << 16) | interval;
2883 CAMERA_MSG_PARAM_SET(param, INT, value);
2885 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2887 CAM_LOG_INFO("ret : 0x%x", ret);
2893 int camera_stop_continuous_capture(camera_h camera)
2895 int ret = CAMERA_ERROR_NONE;
2896 camera_cli_s *pc = (camera_cli_s *)camera;
2897 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2899 if (!pc || !pc->cb_info) {
2900 CAM_LOG_ERROR("NULL handle");
2901 return CAMERA_ERROR_INVALID_PARAMETER;
2904 CAM_LOG_INFO("Enter");
2906 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2908 CAM_LOG_INFO("ret : 0x%x", ret);
2914 bool camera_is_supported_face_detection(camera_h camera)
2916 int ret = CAMERA_ERROR_NONE;
2917 camera_cli_s *pc = (camera_cli_s *)camera;
2918 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2920 if (!pc || !pc->cb_info) {
2921 CAM_LOG_ERROR("NULL handle");
2922 return CAMERA_ERROR_INVALID_PARAMETER;
2925 CAM_LOG_INFO("Enter");
2927 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2930 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2934 CAM_LOG_INFO("ret : %d", ret);
2940 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2942 int ret = CAMERA_ERROR_NONE;
2943 camera_cli_s *pc = (camera_cli_s *)camera;
2944 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2946 if (!pc || !pc->cb_info) {
2947 CAM_LOG_ERROR("NULL handle");
2948 return CAMERA_ERROR_INVALID_PARAMETER;
2951 CAM_LOG_INFO("Enter");
2953 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2956 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2960 CAM_LOG_INFO("ret : %d", ret);
2966 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2968 int ret = CAMERA_ERROR_NONE;
2969 camera_cli_s *pc = (camera_cli_s *)camera;
2970 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2972 if (!pc || !pc->cb_info) {
2973 CAM_LOG_ERROR("NULL handle");
2974 return CAMERA_ERROR_INVALID_PARAMETER;
2977 CAM_LOG_INFO("Enter");
2979 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2982 CAM_LOG_ERROR("error is occurred 0x%x", ret);
2986 CAM_LOG_INFO("ret : %d", ret);
2991 int camera_get_device_count(camera_h camera, int *device_count)
2993 int ret = CAMERA_ERROR_NONE;
2994 camera_cli_s *pc = (camera_cli_s *)camera;
2995 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2997 if (!pc || !pc->cb_info) {
2998 CAM_LOG_ERROR("NULL handle");
2999 return CAMERA_ERROR_INVALID_PARAMETER;
3002 CAM_LOG_INFO("Enter");
3004 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3006 if (ret == CAMERA_ERROR_NONE)
3007 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3009 CAM_LOG_INFO("ret : 0x%x", ret);
3014 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3016 int ret = CAMERA_ERROR_NONE;
3017 camera_cli_s *pc = (camera_cli_s *)camera;
3018 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3020 if (!pc || !pc->cb_info) {
3021 CAM_LOG_ERROR("NULL handle");
3022 return CAMERA_ERROR_INVALID_PARAMETER;
3025 CAM_LOG_INFO("Enter");
3027 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3029 if (ret == CAMERA_ERROR_NONE) {
3030 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3032 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3033 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3035 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3038 CAM_LOG_INFO("ret : 0x%x", ret);
3043 int camera_stop_face_detection(camera_h camera)
3045 int ret = CAMERA_ERROR_NONE;
3046 camera_cli_s *pc = (camera_cli_s *)camera;
3047 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3049 if (!pc || !pc->cb_info) {
3050 CAM_LOG_ERROR("NULL handle");
3051 return CAMERA_ERROR_INVALID_PARAMETER;
3054 CAM_LOG_INFO("Enter");
3056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3058 if (ret == CAMERA_ERROR_NONE) {
3059 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3061 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3062 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3064 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3067 CAM_LOG_INFO("ret : 0x%x", ret);
3072 int camera_get_state(camera_h camera, camera_state_e *state)
3074 int ret = CAMERA_ERROR_NONE;
3075 camera_cli_s *pc = (camera_cli_s *)camera;
3076 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3078 if (!pc || !pc->cb_info || !state) {
3079 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3080 return CAMERA_ERROR_INVALID_PARAMETER;
3083 CAM_LOG_INFO("Enter");
3085 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3087 if (ret == CAMERA_ERROR_NONE)
3088 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3090 CAM_LOG_INFO("ret : 0x%x", ret);
3095 int camera_start_focusing(camera_h camera, bool continuous)
3097 int ret = CAMERA_ERROR_NONE;
3098 camera_cli_s *pc = (camera_cli_s *)camera;
3099 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3100 camera_msg_param param;
3101 int is_continuous = (int)continuous;
3103 if (!pc || !pc->cb_info) {
3104 CAM_LOG_ERROR("NULL handle");
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3108 CAM_LOG_INFO("Enter");
3110 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3112 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3114 CAM_LOG_INFO("ret : 0x%x", ret);
3119 int camera_cancel_focusing(camera_h camera)
3121 int ret = CAMERA_ERROR_NONE;
3122 camera_cli_s *pc = (camera_cli_s *)camera;
3123 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3125 if (!pc || !pc->cb_info) {
3126 CAM_LOG_ERROR("NULL handle");
3127 return CAMERA_ERROR_INVALID_PARAMETER;
3130 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3132 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3134 CAM_LOG_INFO("ret : 0x%x", ret);
3140 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3142 int mm_ret = MM_ERROR_NONE;
3143 int ret = CAMERA_ERROR_NONE;
3144 camera_cli_s *pc = (camera_cli_s *)camera;
3145 camera_cb_info_s *cb_info = NULL;
3146 camera_state_e current_state = CAMERA_STATE_NONE;
3147 camera_msg_param param;
3148 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3149 muse_camera_display_info_s *dp_info = NULL;
3151 if (!pc || !pc->cb_info) {
3152 CAM_LOG_ERROR("NULL handle");
3153 return CAMERA_ERROR_INVALID_PARAMETER;
3156 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3157 CAM_LOG_ERROR("invalid type %d", type);
3158 return CAMERA_ERROR_INVALID_PARAMETER;
3161 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3162 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3163 return CAMERA_ERROR_INVALID_PARAMETER;
3166 cb_info = (camera_cb_info_s *)pc->cb_info;
3167 dp_info = &cb_info->dp_info;
3169 ret = camera_get_state(camera, ¤t_state);
3170 if (ret != CAMERA_ERROR_NONE) {
3171 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3175 if (current_state != CAMERA_STATE_CREATED) {
3176 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3177 return CAMERA_ERROR_INVALID_STATE;
3180 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3182 if (type != MM_DISPLAY_TYPE_NONE) {
3183 /* check display interface handle */
3184 if (!cb_info->dp_interface) {
3185 CAM_LOG_ERROR("display interface not supported");
3186 return CAMERA_ERROR_NOT_SUPPORTED;
3189 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3190 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3191 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3192 return CAMERA_ERROR_NOT_SUPPORTED;
3193 } else if (mm_ret != MM_ERROR_NONE) {
3194 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3195 return CAMERA_ERROR_INVALID_OPERATION;
3198 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3199 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3201 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3202 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3203 dp_info->window_rect.width, dp_info->window_rect.height);
3204 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3206 camera_flip_e flip = CAMERA_FLIP_NONE;
3207 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3208 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3215 camera_get_display_flip(camera, &flip);
3216 camera_get_display_mode(camera, &mode);
3217 camera_get_display_rotation(camera, &rotation);
3218 camera_is_display_visible(camera, &visible);
3220 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3221 flip, mode, rotation, visible);
3223 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3224 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3225 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3226 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3228 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3229 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3230 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3231 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3237 if (mm_ret != MM_ERROR_NONE) {
3238 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3239 return CAMERA_ERROR_INVALID_OPERATION;
3242 dp_info->type = type;
3244 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3246 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3248 if (ret == CAMERA_ERROR_NONE) {
3249 if (type == MM_DISPLAY_TYPE_EVAS)
3250 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3257 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3259 CAM_LOG_INFO("type %d, display %p", type, display);
3260 return _camera_set_display(camera, (mm_display_type_e)type, display);
3264 int camera_set_preview_resolution(camera_h camera, int width, int height)
3266 int ret = CAMERA_ERROR_NONE;
3267 camera_state_e current_state = CAMERA_STATE_NONE;
3268 camera_cli_s *pc = (camera_cli_s *)camera;
3269 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3270 camera_msg_param param;
3273 if (!pc || !pc->cb_info) {
3274 CAM_LOG_ERROR("NULL handle");
3275 return CAMERA_ERROR_INVALID_PARAMETER;
3278 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3279 ret = camera_get_state(camera, ¤t_state);
3280 if (ret != CAMERA_ERROR_NONE) {
3281 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3285 if (current_state == CAMERA_STATE_PREVIEW) {
3286 ret = _camera_stop_evas_rendering(camera, true);
3287 if (ret != CAMERA_ERROR_NONE)
3292 value = (width << 16) | height;
3293 CAMERA_MSG_PARAM_SET(param, INT, value);
3295 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3297 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3299 CAM_LOG_INFO("ret : 0x%x", ret);
3301 if (current_state == CAMERA_STATE_PREVIEW) {
3302 CAM_LOG_WARNING("restart evas rendering");
3303 _camera_start_evas_rendering(camera);
3310 int camera_set_capture_resolution(camera_h camera, int width, int height)
3312 int ret = CAMERA_ERROR_NONE;
3313 camera_cli_s *pc = (camera_cli_s *)camera;
3314 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3315 camera_msg_param param;
3318 if (!pc || !pc->cb_info) {
3319 CAM_LOG_ERROR("NULL handle");
3320 return CAMERA_ERROR_INVALID_PARAMETER;
3323 CAM_LOG_INFO("Enter");
3325 value = (width << 16) | height;
3326 CAMERA_MSG_PARAM_SET(param, INT, value);
3328 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3330 CAM_LOG_INFO("ret : 0x%x", ret);
3336 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3338 int ret = CAMERA_ERROR_NONE;
3339 int set_format = (int)format;
3340 camera_cli_s *pc = (camera_cli_s *)camera;
3341 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3342 camera_msg_param param;
3344 if (!pc || !pc->cb_info) {
3345 CAM_LOG_ERROR("NULL handle");
3346 return CAMERA_ERROR_INVALID_PARAMETER;
3349 CAM_LOG_INFO("Enter - format %d", set_format);
3351 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3353 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3355 CAM_LOG_INFO("ret : 0x%x", ret);
3361 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3363 int ret = CAMERA_ERROR_NONE;
3364 int set_format = (int)format;
3365 camera_msg_param param;
3366 camera_cli_s *pc = (camera_cli_s *)camera;
3367 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3369 if (!pc || !pc->cb_info) {
3370 CAM_LOG_ERROR("NULL handle");
3371 return CAMERA_ERROR_INVALID_PARAMETER;
3374 CAM_LOG_INFO("Enter - format %d", set_format);
3376 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3378 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3380 if (ret == CAMERA_ERROR_NONE)
3381 pc->cb_info->preview_format = set_format;
3383 CAM_LOG_INFO("ret : 0x%x", ret);
3389 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3391 int ret = CAMERA_ERROR_NONE;
3392 camera_cli_s *pc = (camera_cli_s *)camera;
3393 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3395 if (!pc || !pc->cb_info || !width || !height) {
3396 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3397 return CAMERA_ERROR_INVALID_PARAMETER;
3400 CAM_LOG_INFO("Enter");
3402 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3404 if (ret == CAMERA_ERROR_NONE) {
3405 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3406 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3409 CAM_LOG_INFO("ret : 0x%x", ret);
3415 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3417 int ret = CAMERA_ERROR_NONE;
3418 int set_rotation = (int)rotation;
3419 camera_cli_s *pc = (camera_cli_s *)camera;
3420 camera_msg_param param;
3422 if (!pc || !pc->cb_info) {
3423 CAM_LOG_ERROR("NULL handle");
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3427 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3428 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3429 if (ret != MM_ERROR_NONE) {
3430 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3431 return CAMERA_ERROR_INVALID_OPERATION;
3435 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3437 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3443 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3445 int ret = CAMERA_ERROR_NONE;
3446 camera_cli_s *pc = (camera_cli_s *)camera;
3448 if (!pc || !pc->cb_info || !rotation) {
3449 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3450 return CAMERA_ERROR_INVALID_PARAMETER;
3453 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3455 if (ret == CAMERA_ERROR_NONE)
3456 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3462 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3464 int ret = CAMERA_ERROR_NONE;
3465 int set_flip = (int)flip;
3466 camera_cli_s *pc = (camera_cli_s *)camera;
3467 camera_msg_param param;
3469 if (!pc || !pc->cb_info) {
3470 CAM_LOG_ERROR("NULL handle");
3471 return CAMERA_ERROR_INVALID_PARAMETER;
3474 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3475 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3476 if (ret != MM_ERROR_NONE) {
3477 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3478 return CAMERA_ERROR_INVALID_OPERATION;
3482 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3484 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3490 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3492 int ret = CAMERA_ERROR_NONE;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3495 if (!pc || !pc->cb_info || !flip) {
3496 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3497 return CAMERA_ERROR_INVALID_PARAMETER;
3500 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3502 if (ret == CAMERA_ERROR_NONE)
3503 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3509 int camera_set_display_visible(camera_h camera, bool visible)
3511 int ret = CAMERA_ERROR_NONE;
3512 int set_visible = (int)visible;
3513 camera_cli_s *pc = (camera_cli_s *)camera;
3514 camera_msg_param param;
3516 if (!pc || !pc->cb_info) {
3517 CAM_LOG_ERROR("NULL handle");
3518 return CAMERA_ERROR_INVALID_PARAMETER;
3521 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3522 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3523 if (ret != MM_ERROR_NONE) {
3524 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3525 return CAMERA_ERROR_INVALID_OPERATION;
3529 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3531 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3537 int camera_is_display_visible(camera_h camera, bool *visible)
3539 int ret = CAMERA_ERROR_NONE;
3540 camera_cli_s *pc = (camera_cli_s *)camera;
3542 if (!pc || !pc->cb_info || !visible) {
3543 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3544 return CAMERA_ERROR_INVALID_PARAMETER;
3547 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3549 if (ret == CAMERA_ERROR_NONE)
3550 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3556 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3558 int ret = CAMERA_ERROR_NONE;
3559 int set_mode = (int)mode;
3560 camera_cli_s *pc = (camera_cli_s *)camera;
3561 camera_msg_param param;
3563 if (!pc || !pc->cb_info) {
3564 CAM_LOG_ERROR("NULL handle");
3565 return CAMERA_ERROR_INVALID_PARAMETER;
3568 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3569 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3570 if (ret != MM_ERROR_NONE) {
3571 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3572 return CAMERA_ERROR_INVALID_OPERATION;
3576 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3578 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3584 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3586 int ret = CAMERA_ERROR_NONE;
3587 camera_cli_s *pc = (camera_cli_s *)camera;
3589 if (!pc || !pc->cb_info || !mode) {
3590 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3591 return CAMERA_ERROR_INVALID_PARAMETER;
3594 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3596 if (ret == CAMERA_ERROR_NONE)
3597 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3603 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3605 int ret = CAMERA_ERROR_NONE;
3606 int set_hint = (int)hint;
3607 camera_cli_s *pc = (camera_cli_s *)camera;
3608 camera_msg_param param;
3610 if (!pc || !pc->cb_info) {
3611 CAM_LOG_ERROR("NULL handle");
3612 return CAMERA_ERROR_INVALID_PARAMETER;
3615 CAM_LOG_INFO("Enter - hint %d", set_hint);
3617 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3619 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3625 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3627 int ret = CAMERA_ERROR_NONE;
3628 camera_cli_s *pc = (camera_cli_s *)camera;
3629 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3631 if (!pc || !pc->cb_info || !hint) {
3632 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3633 return CAMERA_ERROR_INVALID_PARAMETER;
3636 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3638 if (ret == CAMERA_ERROR_NONE) {
3639 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3640 CAM_LOG_INFO("display reuse hint %d", *hint);
3647 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3649 int ret = CAMERA_ERROR_NONE;
3650 camera_cli_s *pc = (camera_cli_s *)camera;
3651 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3653 if (!pc || !pc->cb_info || !width || !height) {
3654 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3655 return CAMERA_ERROR_INVALID_PARAMETER;
3658 CAM_LOG_INFO("Enter");
3660 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3662 if (ret == CAMERA_ERROR_NONE) {
3663 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3664 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3667 CAM_LOG_INFO("ret : 0x%x", ret);
3673 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3675 int ret = CAMERA_ERROR_NONE;
3676 camera_cli_s *pc = (camera_cli_s *)camera;
3677 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3679 if (!pc || !pc->cb_info || !format) {
3680 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3681 return CAMERA_ERROR_INVALID_PARAMETER;
3684 CAM_LOG_INFO("Enter");
3686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3688 if (ret == CAMERA_ERROR_NONE)
3689 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3691 CAM_LOG_INFO("ret : 0x%x", ret);
3697 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3699 int ret = CAMERA_ERROR_NONE;
3700 camera_cli_s *pc = (camera_cli_s *)camera;
3701 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3703 if (!pc || !pc->cb_info || !format) {
3704 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3705 return CAMERA_ERROR_INVALID_PARAMETER;
3708 CAM_LOG_INFO("Enter");
3710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3712 if (ret == CAMERA_ERROR_NONE)
3713 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3715 CAM_LOG_INFO("ret : 0x%x", ret);
3721 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3723 int ret = CAMERA_ERROR_NONE;
3724 camera_cli_s *pc = (camera_cli_s *)camera;
3725 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3727 if (!pc || !pc->cb_info || !facing_direction) {
3728 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3729 return CAMERA_ERROR_INVALID_PARAMETER;
3732 CAM_LOG_INFO("Enter");
3734 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3736 if (ret == CAMERA_ERROR_NONE)
3737 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3739 CAM_LOG_INFO("ret : 0x%x", ret);
3745 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3747 int ret = CAMERA_ERROR_NONE;
3748 camera_cli_s *pc = (camera_cli_s *)camera;
3749 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3751 if (!pc || !pc->cb_info || !callback) {
3752 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3753 return CAMERA_ERROR_INVALID_PARAMETER;
3756 CAM_LOG_INFO("Enter");
3758 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3760 if (ret == CAMERA_ERROR_NONE) {
3761 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3763 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3764 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3766 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3768 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3771 CAM_LOG_INFO("ret : 0x%x", ret);
3777 int camera_unset_preview_cb(camera_h camera)
3779 int ret = CAMERA_ERROR_NONE;
3780 camera_cli_s *pc = (camera_cli_s *)camera;
3781 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3783 if (!pc || !pc->cb_info) {
3784 CAM_LOG_ERROR("NULL handle");
3785 return CAMERA_ERROR_INVALID_PARAMETER;
3788 CAM_LOG_INFO("Enter");
3790 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3792 if (ret == CAMERA_ERROR_NONE) {
3793 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3795 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3796 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3798 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3800 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3803 CAM_LOG_INFO("ret : 0x%x", ret);
3809 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3811 int ret = CAMERA_ERROR_NONE;
3812 camera_cli_s *pc = (camera_cli_s *)camera;
3813 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3815 if (!pc || !pc->cb_info) {
3816 CAM_LOG_ERROR("NULL handle");
3817 return CAMERA_ERROR_INVALID_PARAMETER;
3820 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3821 CAM_LOG_ERROR("NOT SUPPORTED");
3822 return CAMERA_ERROR_NOT_SUPPORTED;
3825 if (callback == NULL) {
3826 CAM_LOG_ERROR("NULL callback");
3827 return CAMERA_ERROR_INVALID_PARAMETER;
3830 CAM_LOG_INFO("Enter");
3832 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3834 if (ret == CAMERA_ERROR_NONE) {
3835 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3837 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3838 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3840 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3843 CAM_LOG_INFO("ret : 0x%x", ret);
3849 int camera_unset_media_packet_preview_cb(camera_h camera)
3851 int ret = CAMERA_ERROR_NONE;
3852 camera_cli_s *pc = (camera_cli_s *)camera;
3853 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3855 if (!pc || !pc->cb_info) {
3856 CAM_LOG_ERROR("NULL handle");
3857 return CAMERA_ERROR_INVALID_PARAMETER;
3860 CAM_LOG_INFO("Enter");
3862 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3864 if (ret == CAMERA_ERROR_NONE) {
3865 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3867 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3868 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3870 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3873 CAM_LOG_INFO("ret : 0x%x", ret);
3879 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3881 int ret = CAMERA_ERROR_NONE;
3882 camera_cli_s *pc = (camera_cli_s *)camera;
3883 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3885 if (!pc || !pc->cb_info || !callback) {
3886 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3887 return CAMERA_ERROR_INVALID_PARAMETER;
3890 CAM_LOG_INFO("Enter");
3892 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3894 if (ret == CAMERA_ERROR_NONE) {
3895 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3900 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3903 CAM_LOG_INFO("ret : 0x%x", ret);
3909 int camera_unset_state_changed_cb(camera_h camera)
3911 int ret = CAMERA_ERROR_NONE;
3912 camera_cli_s *pc = (camera_cli_s *)camera;
3913 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3915 if (!pc || !pc->cb_info) {
3916 CAM_LOG_ERROR("NULL handle");
3917 return CAMERA_ERROR_INVALID_PARAMETER;
3920 CAM_LOG_INFO("Enter");
3922 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3924 if (ret == CAMERA_ERROR_NONE) {
3925 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3927 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3928 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3930 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3933 CAM_LOG_INFO("ret : 0x%x", ret);
3939 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3941 int ret = CAMERA_ERROR_NONE;
3942 camera_cli_s *pc = (camera_cli_s *)camera;
3943 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3945 if (!pc || !pc->cb_info || !callback) {
3946 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3947 return CAMERA_ERROR_INVALID_PARAMETER;
3950 CAM_LOG_INFO("Enter");
3952 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3954 if (ret == CAMERA_ERROR_NONE) {
3955 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3957 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3958 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3960 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3963 CAM_LOG_INFO("ret : 0x%x", ret);
3969 int camera_unset_interrupted_cb(camera_h camera)
3971 int ret = CAMERA_ERROR_NONE;
3972 camera_cli_s *pc = (camera_cli_s *)camera;
3973 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3975 if (!pc || !pc->cb_info) {
3976 CAM_LOG_ERROR("NULL handle");
3977 return CAMERA_ERROR_INVALID_PARAMETER;
3980 CAM_LOG_INFO("Enter");
3982 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3984 if (ret == CAMERA_ERROR_NONE) {
3985 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3987 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3988 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3990 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3993 CAM_LOG_INFO("ret : 0x%x", ret);
3999 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4001 int ret = CAMERA_ERROR_NONE;
4002 camera_cli_s *pc = (camera_cli_s *)camera;
4003 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4005 if (!pc || !pc->cb_info || !callback) {
4006 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4007 return CAMERA_ERROR_INVALID_PARAMETER;
4010 CAM_LOG_INFO("Enter");
4012 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4014 if (ret == CAMERA_ERROR_NONE) {
4015 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4017 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4018 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4020 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4023 CAM_LOG_INFO("ret : 0x%x", ret);
4029 int camera_unset_interrupt_started_cb(camera_h camera)
4031 int ret = CAMERA_ERROR_NONE;
4032 camera_cli_s *pc = (camera_cli_s *)camera;
4033 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4035 if (!pc || !pc->cb_info) {
4036 CAM_LOG_ERROR("NULL handle");
4037 return CAMERA_ERROR_INVALID_PARAMETER;
4040 CAM_LOG_INFO("Enter");
4042 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4044 if (ret == CAMERA_ERROR_NONE) {
4045 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4047 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4048 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4050 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4053 CAM_LOG_INFO("ret : 0x%x", ret);
4059 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4061 int ret = CAMERA_ERROR_NONE;
4062 camera_cli_s *pc = (camera_cli_s *)camera;
4063 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4065 if (!pc || !pc->cb_info || !callback) {
4066 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4070 CAM_LOG_INFO("Enter");
4072 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4074 if (ret == CAMERA_ERROR_NONE) {
4075 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4077 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4078 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4080 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4083 CAM_LOG_INFO("ret : 0x%x", ret);
4089 int camera_unset_focus_changed_cb(camera_h camera)
4091 int ret = CAMERA_ERROR_NONE;
4092 camera_cli_s *pc = (camera_cli_s *)camera;
4093 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4095 if (!pc || !pc->cb_info) {
4096 CAM_LOG_ERROR("NULL handle");
4097 return CAMERA_ERROR_INVALID_PARAMETER;
4100 CAM_LOG_INFO("Enter");
4102 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4104 if (ret == CAMERA_ERROR_NONE) {
4105 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4107 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4108 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4110 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4113 CAM_LOG_INFO("ret : 0x%x", ret);
4119 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4121 int ret = CAMERA_ERROR_NONE;
4122 camera_cli_s *pc = (camera_cli_s *)camera;
4123 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4125 if (!pc || !pc->cb_info || !callback) {
4126 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4127 return CAMERA_ERROR_INVALID_PARAMETER;
4130 CAM_LOG_INFO("Enter");
4132 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4134 if (ret == CAMERA_ERROR_NONE) {
4135 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4137 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4138 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4140 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4143 CAM_LOG_INFO("ret : 0x%x", ret);
4149 int camera_unset_error_cb(camera_h camera)
4151 int ret = CAMERA_ERROR_NONE;
4152 camera_cli_s *pc = (camera_cli_s *)camera;
4153 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4155 if (!pc || !pc->cb_info) {
4156 CAM_LOG_ERROR("NULL handle");
4157 return CAMERA_ERROR_INVALID_PARAMETER;
4160 CAM_LOG_INFO("Enter");
4162 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4164 if (ret == CAMERA_ERROR_NONE) {
4165 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4167 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4168 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4170 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4173 CAM_LOG_INFO("ret : 0x%x", ret);
4179 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4181 int ret = CAMERA_ERROR_NONE;
4182 camera_cli_s *pc = (camera_cli_s *)camera;
4183 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4185 if (!pc || !pc->cb_info || !foreach_cb) {
4186 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4187 return CAMERA_ERROR_INVALID_PARAMETER;
4190 CAM_LOG_INFO("Enter");
4192 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4193 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 CAM_LOG_INFO("ret : 0x%x", ret);
4203 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4205 int ret = CAMERA_ERROR_NONE;
4206 camera_cli_s *pc = (camera_cli_s *)camera;
4207 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4209 if (!pc || !pc->cb_info || !foreach_cb) {
4210 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4211 return CAMERA_ERROR_INVALID_PARAMETER;
4214 CAM_LOG_INFO("Enter");
4216 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4217 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4219 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4221 CAM_LOG_INFO("ret : 0x%x", ret);
4227 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4229 int ret = CAMERA_ERROR_NONE;
4230 camera_cli_s *pc = (camera_cli_s *)camera;
4231 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4233 if (!pc || !pc->cb_info || !foreach_cb) {
4234 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4235 return CAMERA_ERROR_INVALID_PARAMETER;
4238 CAM_LOG_INFO("Enter");
4240 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4241 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4243 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4245 CAM_LOG_INFO("ret : 0x%x", ret);
4251 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4253 int ret = CAMERA_ERROR_NONE;
4254 camera_cli_s *pc = (camera_cli_s *)camera;
4255 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4257 if (!pc || !pc->cb_info || !foreach_cb) {
4258 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4259 return CAMERA_ERROR_INVALID_PARAMETER;
4262 CAM_LOG_INFO("Enter");
4264 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4265 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4267 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4269 CAM_LOG_INFO("ret : 0x%x", ret);
4275 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4277 int ret = CAMERA_ERROR_NONE;
4278 camera_cli_s *pc = (camera_cli_s *)camera;
4279 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4281 if (!pc || !pc->cb_info || !width || !height) {
4282 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4283 return CAMERA_ERROR_INVALID_PARAMETER;
4286 CAM_LOG_INFO("Enter");
4287 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4289 if (ret == CAMERA_ERROR_NONE) {
4290 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4291 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4294 CAM_LOG_INFO("ret : 0x%x", ret);
4300 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4302 int ret = CAMERA_ERROR_NONE;
4303 camera_cli_s *pc = (camera_cli_s *)camera;
4304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4306 if (!pc || !pc->cb_info || !angle) {
4307 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4308 return CAMERA_ERROR_INVALID_PARAMETER;
4311 CAM_LOG_INFO("Enter");
4313 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4315 if (ret == CAMERA_ERROR_NONE)
4316 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4318 CAM_LOG_INFO("ret : 0x%x", ret);
4324 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4326 int ret = CAMERA_ERROR_NONE;
4327 camera_cli_s *pc = (camera_cli_s *)camera;
4328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4329 camera_msg_param param;
4330 int set_mode = (int)mode;
4332 if (!pc || !pc->cb_info) {
4333 CAM_LOG_ERROR("NULL handle");
4334 return CAMERA_ERROR_INVALID_PARAMETER;
4337 CAM_LOG_INFO("Enter");
4339 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4341 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4343 CAM_LOG_INFO("ret : 0x%x", ret);
4349 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4355 if (!pc || !pc->cb_info || !mode) {
4356 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4357 return CAMERA_ERROR_INVALID_PARAMETER;
4360 CAM_LOG_INFO("Enter");
4362 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4364 if (ret == CAMERA_ERROR_NONE)
4365 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4367 CAM_LOG_INFO("ret : 0x%x", ret);
4373 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4375 int ret = CAMERA_ERROR_NONE;
4376 camera_cli_s *pc = (camera_cli_s *)camera;
4377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4379 if (!pc || !pc->cb_info || !foreach_cb) {
4380 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4381 return CAMERA_ERROR_INVALID_PARAMETER;
4384 CAM_LOG_INFO("Enter");
4386 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4387 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4389 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4391 CAM_LOG_INFO("Finish, return :%x", ret);
4397 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4399 int ret = CAMERA_ERROR_NONE;
4400 camera_cli_s *pc = (camera_cli_s *)camera;
4401 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4402 camera_msg_param param;
4403 int set_fps = (int)fps;
4405 if (!pc || !pc->cb_info) {
4406 CAM_LOG_ERROR("NULL handle");
4407 return CAMERA_ERROR_INVALID_PARAMETER;
4410 CAM_LOG_INFO("Enter");
4412 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4414 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4416 CAM_LOG_INFO("ret : 0x%x", ret);
4422 int camera_attr_set_image_quality(camera_h camera, int quality)
4424 int ret = CAMERA_ERROR_NONE;
4425 camera_cli_s *pc = (camera_cli_s *)camera;
4426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4427 camera_msg_param param;
4429 if (!pc || !pc->cb_info) {
4430 CAM_LOG_ERROR("NULL handle");
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 CAM_LOG_INFO("Enter");
4436 CAMERA_MSG_PARAM_SET(param, INT, quality);
4438 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4440 CAM_LOG_INFO("ret : 0x%x", ret);
4446 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4448 int ret = CAMERA_ERROR_NONE;
4449 camera_cli_s *pc = (camera_cli_s *)camera;
4450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4452 if (!pc || !pc->cb_info || !fps) {
4453 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4454 return CAMERA_ERROR_INVALID_PARAMETER;
4457 CAM_LOG_INFO("Enter");
4459 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4461 if (ret == CAMERA_ERROR_NONE)
4462 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4464 CAM_LOG_INFO("ret : 0x%x", ret);
4470 int camera_attr_get_image_quality(camera_h camera, int *quality)
4472 int ret = CAMERA_ERROR_NONE;
4473 camera_cli_s *pc = (camera_cli_s *)camera;
4474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4476 if (!pc || !pc->cb_info || !quality) {
4477 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4478 return CAMERA_ERROR_INVALID_PARAMETER;
4481 CAM_LOG_INFO("Enter");
4483 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4485 if (ret == CAMERA_ERROR_NONE)
4486 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4488 CAM_LOG_INFO("ret : 0x%x", ret);
4494 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4496 int ret = CAMERA_ERROR_NONE;
4497 camera_cli_s *pc = (camera_cli_s *)camera;
4498 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4500 if (!pc || !pc->cb_info || !bitrate) {
4501 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4502 return CAMERA_ERROR_INVALID_PARAMETER;
4505 CAM_LOG_INFO("Enter");
4507 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4509 if (ret == CAMERA_ERROR_NONE)
4510 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4512 CAM_LOG_INFO("ret : 0x%x", ret);
4518 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4520 int ret = CAMERA_ERROR_NONE;
4521 camera_cli_s *pc = (camera_cli_s *)camera;
4522 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4523 camera_msg_param param;
4524 int set_bitrate = bitrate;
4526 if (!pc || !pc->cb_info) {
4527 CAM_LOG_ERROR("NULL handle");
4528 return CAMERA_ERROR_INVALID_PARAMETER;
4531 CAM_LOG_INFO("Enter");
4533 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4535 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4537 CAM_LOG_INFO("ret : 0x%x", ret);
4543 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4545 int ret = CAMERA_ERROR_NONE;
4546 camera_cli_s *pc = (camera_cli_s *)camera;
4547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4549 if (!pc || !pc->cb_info || !interval) {
4550 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4551 return CAMERA_ERROR_INVALID_PARAMETER;
4554 CAM_LOG_INFO("Enter");
4556 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4558 if (ret == CAMERA_ERROR_NONE)
4559 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4561 CAM_LOG_INFO("ret : 0x%x", ret);
4567 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4569 int ret = CAMERA_ERROR_NONE;
4570 camera_cli_s *pc = (camera_cli_s *)camera;
4571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4572 camera_msg_param param;
4573 int set_gop_interval = interval;
4575 if (!pc || !pc->cb_info) {
4576 CAM_LOG_ERROR("NULL handle");
4577 return CAMERA_ERROR_INVALID_PARAMETER;
4580 CAM_LOG_INFO("Enter");
4582 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4584 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4586 CAM_LOG_INFO("ret : 0x%x", ret);
4592 int camera_attr_set_zoom(camera_h camera, int zoom)
4594 int ret = CAMERA_ERROR_NONE;
4595 camera_cli_s *pc = (camera_cli_s *)camera;
4596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4597 camera_msg_param param;
4599 if (!pc || !pc->cb_info) {
4600 CAM_LOG_ERROR("NULL handle");
4601 return CAMERA_ERROR_INVALID_PARAMETER;
4604 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4606 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4608 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4610 CAM_LOG_INFO("ret : 0x%x", ret);
4616 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4618 int ret = CAMERA_ERROR_NONE;
4619 camera_cli_s *pc = (camera_cli_s *)camera;
4620 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4621 camera_msg_param param;
4622 int set_mode = (int)mode;
4624 if (!pc || !pc->cb_info) {
4625 CAM_LOG_ERROR("NULL handle");
4626 return CAMERA_ERROR_INVALID_PARAMETER;
4629 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4631 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4633 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4639 int camera_attr_set_af_area(camera_h camera, int x, int y)
4641 int ret = CAMERA_ERROR_NONE;
4642 camera_cli_s *pc = (camera_cli_s *)camera;
4643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4644 camera_msg_param param;
4647 if (!pc || !pc->cb_info) {
4648 CAM_LOG_ERROR("NULL handle");
4649 return CAMERA_ERROR_INVALID_PARAMETER;
4652 CAM_LOG_INFO("Enter - %d,%d", x, y);
4654 value = (x << 16) | y;
4655 CAMERA_MSG_PARAM_SET(param, INT, value);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 CAM_LOG_INFO("ret : 0x%x", ret);
4665 int camera_attr_clear_af_area(camera_h camera)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4671 if (!pc || !pc->cb_info) {
4672 CAM_LOG_ERROR("NULL handle");
4673 return CAMERA_ERROR_INVALID_PARAMETER;
4676 CAM_LOG_INFO("Enter");
4678 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4680 CAM_LOG_INFO("ret : 0x%x", ret);
4686 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4688 int ret = CAMERA_ERROR_NONE;
4689 camera_cli_s *pc = (camera_cli_s *)camera;
4690 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4691 camera_msg_param param;
4692 int set_mode = (int)mode;
4694 if (!pc || !pc->cb_info) {
4695 CAM_LOG_ERROR("NULL handle");
4696 return CAMERA_ERROR_INVALID_PARAMETER;
4699 CAM_LOG_INFO("Enter");
4701 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4703 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4705 CAM_LOG_INFO("ret : 0x%x", ret);
4711 int camera_attr_set_exposure(camera_h camera, int value)
4713 int ret = CAMERA_ERROR_NONE;
4714 camera_cli_s *pc = (camera_cli_s *)camera;
4715 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4716 camera_msg_param param;
4718 if (!pc || !pc->cb_info) {
4719 CAM_LOG_ERROR("NULL handle");
4720 return CAMERA_ERROR_INVALID_PARAMETER;
4723 CAM_LOG_INFO("Enter");
4725 CAMERA_MSG_PARAM_SET(param, INT, value);
4727 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4729 CAM_LOG_INFO("ret : 0x%x", ret);
4735 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4737 int ret = CAMERA_ERROR_NONE;
4738 camera_cli_s *pc = (camera_cli_s *)camera;
4739 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4740 camera_msg_param param;
4741 int set_iso = (int)iso;
4743 if (!pc || !pc->cb_info) {
4744 CAM_LOG_ERROR("NULL handle");
4745 return CAMERA_ERROR_INVALID_PARAMETER;
4748 CAM_LOG_INFO("Enter");
4750 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4752 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4754 CAM_LOG_INFO("ret : 0x%x", ret);
4760 int camera_attr_set_brightness(camera_h camera, int level)
4762 int ret = CAMERA_ERROR_NONE;
4763 camera_cli_s *pc = (camera_cli_s *)camera;
4764 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4765 camera_msg_param param;
4767 if (!pc || !pc->cb_info) {
4768 CAM_LOG_ERROR("NULL handle");
4769 return CAMERA_ERROR_INVALID_PARAMETER;
4772 CAM_LOG_INFO("Enter");
4774 CAMERA_MSG_PARAM_SET(param, INT, level);
4776 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4778 CAM_LOG_INFO("ret : 0x%x", ret);
4784 int camera_attr_set_contrast(camera_h camera, int level)
4786 int ret = CAMERA_ERROR_NONE;
4787 camera_cli_s *pc = (camera_cli_s *)camera;
4788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4789 camera_msg_param param;
4791 if (!pc || !pc->cb_info) {
4792 CAM_LOG_ERROR("NULL handle");
4793 return CAMERA_ERROR_INVALID_PARAMETER;
4796 CAM_LOG_INFO("Enter");
4798 CAMERA_MSG_PARAM_SET(param, INT, level);
4800 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4802 CAM_LOG_INFO("ret : 0x%x", ret);
4808 int camera_attr_set_hue(camera_h camera, int level)
4810 int ret = CAMERA_ERROR_NONE;
4811 camera_cli_s *pc = (camera_cli_s *)camera;
4812 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4813 camera_msg_param param;
4815 if (!pc || !pc->cb_info) {
4816 CAM_LOG_ERROR("NULL handle");
4817 return CAMERA_ERROR_INVALID_PARAMETER;
4820 CAM_LOG_INFO("Enter");
4822 CAMERA_MSG_PARAM_SET(param, INT, level);
4824 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4826 CAM_LOG_INFO("ret : 0x%x", ret);
4832 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4834 int ret = CAMERA_ERROR_NONE;
4835 camera_cli_s *pc = (camera_cli_s *)camera;
4836 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4837 camera_msg_param param;
4838 int set_whitebalance = (int)wb;
4840 if (!pc || !pc->cb_info) {
4841 CAM_LOG_ERROR("NULL handle");
4842 return CAMERA_ERROR_INVALID_PARAMETER;
4845 CAM_LOG_INFO("Enter");
4847 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4849 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4851 CAM_LOG_INFO("ret : 0x%x", ret);
4857 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4859 int ret = CAMERA_ERROR_NONE;
4860 camera_cli_s *pc = (camera_cli_s *)camera;
4861 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4862 camera_msg_param param;
4863 int set_effect = (int)effect;
4865 if (!pc || !pc->cb_info) {
4866 CAM_LOG_ERROR("NULL handle");
4867 return CAMERA_ERROR_INVALID_PARAMETER;
4870 CAM_LOG_INFO("Enter");
4872 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4874 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4876 CAM_LOG_INFO("ret : 0x%x", ret);
4882 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4884 int ret = CAMERA_ERROR_NONE;
4885 camera_cli_s *pc = (camera_cli_s *)camera;
4886 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4887 camera_msg_param param;
4888 int set_mode = (int)mode;
4890 if (!pc || !pc->cb_info) {
4891 CAM_LOG_ERROR("NULL handle");
4892 return CAMERA_ERROR_INVALID_PARAMETER;
4895 CAM_LOG_INFO("Enter");
4897 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4899 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4901 CAM_LOG_INFO("ret : 0x%x", ret);
4907 int camera_attr_enable_tag(camera_h camera, bool enable)
4909 int ret = CAMERA_ERROR_NONE;
4910 camera_cli_s *pc = (camera_cli_s *)camera;
4911 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4912 camera_msg_param param;
4913 int set_enable = (int)enable;
4915 if (!pc || !pc->cb_info) {
4916 CAM_LOG_ERROR("NULL handle");
4917 return CAMERA_ERROR_INVALID_PARAMETER;
4920 CAM_LOG_INFO("Enter");
4922 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4924 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4926 CAM_LOG_INFO("ret : 0x%x", ret);
4932 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4934 int ret = CAMERA_ERROR_NONE;
4935 camera_cli_s *pc = (camera_cli_s *)camera;
4936 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4937 camera_msg_param param;
4939 if (!pc || !pc->cb_info || !description) {
4940 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4941 return CAMERA_ERROR_INVALID_PARAMETER;
4944 CAM_LOG_INFO("Enter");
4946 CAMERA_MSG_PARAM_SET(param, STRING, description);
4948 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4950 CAM_LOG_INFO("ret : 0x%x", ret);
4956 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4958 int ret = CAMERA_ERROR_NONE;
4959 camera_cli_s *pc = (camera_cli_s *)camera;
4960 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4961 camera_msg_param param;
4962 int set_orientation = (int)orientation;
4964 if (!pc || !pc->cb_info) {
4965 CAM_LOG_ERROR("NULL handle");
4966 return CAMERA_ERROR_INVALID_PARAMETER;
4969 CAM_LOG_INFO("Enter");
4971 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4973 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4975 CAM_LOG_INFO("ret : 0x%x", ret);
4981 int camera_attr_set_tag_software(camera_h camera, const char *software)
4983 int ret = CAMERA_ERROR_NONE;
4984 camera_cli_s *pc = (camera_cli_s *)camera;
4985 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4986 camera_msg_param param;
4988 if (!pc || !pc->cb_info || !software) {
4989 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4990 return CAMERA_ERROR_INVALID_PARAMETER;
4993 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4995 CAMERA_MSG_PARAM_SET(param, STRING, software);
4997 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4999 CAM_LOG_INFO("ret : 0x%x", ret);
5005 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5007 int ret = CAMERA_ERROR_NONE;
5008 camera_cli_s *pc = (camera_cli_s *)camera;
5009 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5010 double set_geotag[3] = {latitude, longitude, altitude};
5015 if (!pc || !pc->cb_info) {
5016 CAM_LOG_ERROR("NULL handle");
5017 return CAMERA_ERROR_INVALID_PARAMETER;
5020 CAM_LOG_INFO("Enter");
5022 length = sizeof(set_geotag) / sizeof(int) + \
5023 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5025 msg = muse_core_msg_new(api,
5026 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5029 CAM_LOG_ERROR("msg creation failed: api %d", api);
5030 return CAMERA_ERROR_OUT_OF_MEMORY;
5033 if (pc->cb_info->is_server_connected) {
5034 __camera_update_api_waiting(pc->cb_info, api, 1);
5036 g_mutex_lock(&pc->cb_info->fd_lock);
5037 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5038 g_mutex_unlock(&pc->cb_info->fd_lock);
5042 CAM_LOG_ERROR("message send failed");
5043 ret = CAMERA_ERROR_INVALID_OPERATION;
5045 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5048 __camera_update_api_waiting(pc->cb_info, api, -1);
5050 muse_core_msg_free(msg);
5052 CAM_LOG_INFO("ret : 0x%x", ret);
5058 int camera_attr_remove_geotag(camera_h camera)
5060 int ret = CAMERA_ERROR_NONE;
5061 camera_cli_s *pc = (camera_cli_s *)camera;
5062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5064 if (!pc || !pc->cb_info) {
5065 CAM_LOG_ERROR("NULL handle");
5066 return CAMERA_ERROR_INVALID_PARAMETER;
5069 CAM_LOG_INFO("Enter");
5071 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5073 CAM_LOG_INFO("ret : 0x%x", ret);
5079 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5081 int ret = CAMERA_ERROR_NONE;
5082 camera_cli_s *pc = (camera_cli_s *)camera;
5083 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5084 camera_msg_param param;
5085 int set_mode = (int)mode;
5087 if (!pc || !pc->cb_info) {
5088 CAM_LOG_ERROR("NULL handle");
5089 return CAMERA_ERROR_INVALID_PARAMETER;
5092 CAM_LOG_INFO("Enter");
5094 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5096 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5098 CAM_LOG_INFO("ret : 0x%x", ret);
5104 int camera_attr_get_zoom(camera_h camera, int *zoom)
5106 int ret = CAMERA_ERROR_NONE;
5107 camera_cli_s *pc = (camera_cli_s *)camera;
5108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5110 if (!pc || !pc->cb_info || !zoom) {
5111 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
5112 return CAMERA_ERROR_INVALID_PARAMETER;
5115 CAM_LOG_INFO("Enter");
5117 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5119 if (ret == CAMERA_ERROR_NONE)
5120 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5122 CAM_LOG_INFO("ret : 0x%x", ret);
5128 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5130 int ret = CAMERA_ERROR_NONE;
5131 camera_cli_s *pc = (camera_cli_s *)camera;
5132 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5134 if (!pc || !pc->cb_info || !min || !max) {
5135 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5136 return CAMERA_ERROR_INVALID_PARAMETER;
5139 CAM_LOG_INFO("Enter");
5141 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5143 if (ret == CAMERA_ERROR_NONE) {
5144 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5145 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5148 CAM_LOG_INFO("ret : 0x%x", ret);
5154 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5156 int ret = CAMERA_ERROR_NONE;
5157 camera_cli_s *pc = (camera_cli_s *)camera;
5158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5160 if (!pc || !pc->cb_info || !mode) {
5161 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5162 return CAMERA_ERROR_INVALID_PARAMETER;
5165 CAM_LOG_INFO("Enter");
5167 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5169 if (ret == CAMERA_ERROR_NONE)
5170 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5172 CAM_LOG_INFO("ret : 0x%x", ret);
5178 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5180 int ret = CAMERA_ERROR_NONE;
5181 camera_cli_s *pc = (camera_cli_s *)camera;
5182 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5184 if (!pc || !pc->cb_info || !mode) {
5185 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5186 return CAMERA_ERROR_INVALID_PARAMETER;
5189 CAM_LOG_INFO("Enter");
5191 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5193 if (ret == CAMERA_ERROR_NONE)
5194 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5196 CAM_LOG_INFO("ret : 0x%x", ret);
5202 int camera_attr_get_exposure(camera_h camera, int *value)
5204 int ret = CAMERA_ERROR_NONE;
5205 camera_cli_s *pc = (camera_cli_s *)camera;
5206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5208 if (!pc || !pc->cb_info || !value) {
5209 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5210 return CAMERA_ERROR_INVALID_PARAMETER;
5213 CAM_LOG_INFO("Enter");
5215 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5217 if (ret == CAMERA_ERROR_NONE)
5218 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5220 CAM_LOG_INFO("ret : 0x%x", ret);
5226 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5228 int ret = CAMERA_ERROR_NONE;
5229 camera_cli_s *pc = (camera_cli_s *)camera;
5230 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5232 if (!pc || !pc->cb_info || !min || !max) {
5233 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5234 return CAMERA_ERROR_INVALID_PARAMETER;
5237 CAM_LOG_INFO("Enter");
5239 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5241 if (ret == CAMERA_ERROR_NONE) {
5242 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5243 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5246 CAM_LOG_INFO("ret : 0x%x", ret);
5252 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5254 int ret = CAMERA_ERROR_NONE;
5255 camera_cli_s *pc = (camera_cli_s *)camera;
5256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5258 if (!pc || !pc->cb_info || !iso) {
5259 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5260 return CAMERA_ERROR_INVALID_PARAMETER;
5263 CAM_LOG_INFO("Enter");
5265 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5267 if (ret == CAMERA_ERROR_NONE)
5268 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5270 CAM_LOG_INFO("ret : 0x%x", ret);
5276 int camera_attr_get_brightness(camera_h camera, int *level)
5278 int ret = CAMERA_ERROR_NONE;
5279 camera_cli_s *pc = (camera_cli_s *)camera;
5280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5282 if (!pc || !pc->cb_info || !level) {
5283 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5284 return CAMERA_ERROR_INVALID_PARAMETER;
5287 CAM_LOG_INFO("Enter");
5289 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5291 if (ret == CAMERA_ERROR_NONE)
5292 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5294 CAM_LOG_INFO("ret : 0x%x", ret);
5300 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5302 int ret = CAMERA_ERROR_NONE;
5303 camera_cli_s *pc = (camera_cli_s *)camera;
5304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5306 if (!pc || !pc->cb_info || !min || !max) {
5307 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5308 return CAMERA_ERROR_INVALID_PARAMETER;
5311 CAM_LOG_INFO("Enter");
5313 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5315 if (ret == CAMERA_ERROR_NONE) {
5316 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5317 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5320 CAM_LOG_INFO("ret : 0x%x", ret);
5326 int camera_attr_get_contrast(camera_h camera, int *level)
5328 int ret = CAMERA_ERROR_NONE;
5329 camera_cli_s *pc = (camera_cli_s *)camera;
5330 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5332 if (!pc || !pc->cb_info || !level) {
5333 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5334 return CAMERA_ERROR_INVALID_PARAMETER;
5337 CAM_LOG_INFO("Enter");
5339 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5341 if (ret == CAMERA_ERROR_NONE)
5342 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5344 CAM_LOG_INFO("ret : 0x%x", ret);
5350 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5352 int ret = CAMERA_ERROR_NONE;
5353 camera_cli_s *pc = (camera_cli_s *)camera;
5354 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5356 if (!pc || !pc->cb_info || !min || !max) {
5357 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5358 return CAMERA_ERROR_INVALID_PARAMETER;
5361 CAM_LOG_INFO("Enter");
5363 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5365 if (ret == CAMERA_ERROR_NONE) {
5366 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5367 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5368 CAM_LOG_INFO("min %d, max %d", *min, *max);
5371 CAM_LOG_INFO("ret : 0x%x", ret);
5377 int camera_attr_get_hue(camera_h camera, int *level)
5379 int ret = CAMERA_ERROR_NONE;
5380 camera_cli_s *pc = (camera_cli_s *)camera;
5381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5383 if (!pc || !pc->cb_info || !level) {
5384 CAM_LOG_ERROR("NULL pointer %p %p", pc, level);
5385 return CAMERA_ERROR_INVALID_PARAMETER;
5388 CAM_LOG_INFO("Enter");
5390 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5392 if (ret == CAMERA_ERROR_NONE)
5393 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5395 CAM_LOG_INFO("ret : 0x%x", ret);
5401 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5403 int ret = CAMERA_ERROR_NONE;
5404 camera_cli_s *pc = (camera_cli_s *)camera;
5405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5407 if (!pc || !pc->cb_info || !min || !max) {
5408 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
5409 return CAMERA_ERROR_INVALID_PARAMETER;
5412 CAM_LOG_INFO("Enter");
5414 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5416 if (ret == CAMERA_ERROR_NONE) {
5417 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5418 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5419 CAM_LOG_INFO("min %d, max %d", *min, *max);
5422 CAM_LOG_INFO("ret : 0x%x", ret);
5428 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5430 int ret = CAMERA_ERROR_NONE;
5431 camera_cli_s *pc = (camera_cli_s *)camera;
5432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5434 if (!pc || !pc->cb_info || !wb) {
5435 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5439 CAM_LOG_INFO("Enter");
5441 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5443 if (ret == CAMERA_ERROR_NONE)
5444 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5446 CAM_LOG_INFO("ret : 0x%x", ret);
5452 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5454 int ret = CAMERA_ERROR_NONE;
5455 camera_cli_s *pc = (camera_cli_s *)camera;
5456 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5458 if (!pc || !pc->cb_info || !effect) {
5459 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5460 return CAMERA_ERROR_INVALID_PARAMETER;
5463 CAM_LOG_INFO("Enter");
5465 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5467 if (ret == CAMERA_ERROR_NONE)
5468 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5470 CAM_LOG_INFO("ret : 0x%x", ret);
5476 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5478 int ret = CAMERA_ERROR_NONE;
5479 camera_cli_s *pc = (camera_cli_s *)camera;
5480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5482 if (!pc || !pc->cb_info || !mode) {
5483 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5484 return CAMERA_ERROR_INVALID_PARAMETER;
5487 CAM_LOG_INFO("Enter");
5489 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5491 if (ret == CAMERA_ERROR_NONE)
5492 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5494 CAM_LOG_INFO("ret : 0x%x", ret);
5500 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5506 if (!pc || !pc->cb_info || !enable) {
5507 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5511 CAM_LOG_INFO("Enter");
5513 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5515 if (ret == CAMERA_ERROR_NONE)
5516 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5518 CAM_LOG_INFO("ret : 0x%x", ret);
5524 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5530 if (!pc || !pc->cb_info || !description) {
5531 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5535 CAM_LOG_INFO("Enter");
5537 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5539 if (ret == CAMERA_ERROR_NONE)
5540 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5542 CAM_LOG_INFO("ret : 0x%x", ret);
5548 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5550 int ret = CAMERA_ERROR_NONE;
5551 camera_cli_s *pc = (camera_cli_s *)camera;
5552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5554 if (!pc || !pc->cb_info || !orientation) {
5555 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5559 CAM_LOG_INFO("Enter");
5561 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5563 if (ret == CAMERA_ERROR_NONE)
5564 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5566 CAM_LOG_INFO("ret : 0x%x", ret);
5572 int camera_attr_get_tag_software(camera_h camera, char **software)
5574 int ret = CAMERA_ERROR_NONE;
5575 camera_cli_s *pc = (camera_cli_s *)camera;
5576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5578 if (!pc || !pc->cb_info || !software) {
5579 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5580 return CAMERA_ERROR_INVALID_PARAMETER;
5583 CAM_LOG_INFO("Enter");
5585 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5587 if (ret == CAMERA_ERROR_NONE)
5588 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5590 CAM_LOG_INFO("ret : 0x%x", ret);
5596 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5598 int ret = CAMERA_ERROR_NONE;
5599 camera_cli_s *pc = (camera_cli_s *)camera;
5600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5602 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5603 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5604 return CAMERA_ERROR_INVALID_PARAMETER;
5607 CAM_LOG_INFO("Enter");
5609 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5611 if (ret == CAMERA_ERROR_NONE) {
5612 *latitude = pc->cb_info->get_geotag[0];
5613 *longitude = pc->cb_info->get_geotag[1];
5614 *altitude = pc->cb_info->get_geotag[2];
5617 CAM_LOG_INFO("ret : 0x%x", ret);
5623 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5625 int ret = CAMERA_ERROR_NONE;
5626 camera_cli_s *pc = (camera_cli_s *)camera;
5627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5629 if (!pc || !pc->cb_info || !mode) {
5630 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5631 return CAMERA_ERROR_INVALID_PARAMETER;
5634 CAM_LOG_INFO("Enter");
5636 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5638 if (ret == CAMERA_ERROR_NONE)
5639 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5641 CAM_LOG_INFO("ret : 0x%x", ret);
5647 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5649 int ret = CAMERA_ERROR_NONE;
5650 int get_flash_state = 0;
5653 CAM_LOG_ERROR("NULL pointer");
5654 return CAMERA_ERROR_INVALID_PARAMETER;
5657 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5658 (int)device, "get_flash_state", &get_flash_state);
5660 if (ret == CAMERA_ERROR_NONE) {
5661 *state = (camera_flash_state_e)get_flash_state;
5662 CAM_LOG_INFO("flash state %d", *state);
5664 CAM_LOG_ERROR("failed 0x%x", ret);
5671 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5673 int ret = CAMERA_ERROR_NONE;
5674 camera_cli_s *pc = (camera_cli_s *)camera;
5675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5677 if (!pc || !pc->cb_info || !foreach_cb) {
5678 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5679 return CAMERA_ERROR_INVALID_PARAMETER;
5682 CAM_LOG_INFO("Enter");
5684 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5685 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5687 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5689 CAM_LOG_INFO("ret : 0x%x", ret);
5695 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5697 int ret = CAMERA_ERROR_NONE;
5698 camera_cli_s *pc = (camera_cli_s *)camera;
5699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5701 if (!pc || !pc->cb_info || !foreach_cb) {
5702 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5703 return CAMERA_ERROR_INVALID_PARAMETER;
5706 CAM_LOG_INFO("Enter");
5708 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5709 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5711 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5713 CAM_LOG_INFO("ret : 0x%x", ret);
5719 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5721 int ret = CAMERA_ERROR_NONE;
5722 camera_cli_s *pc = (camera_cli_s *)camera;
5723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5725 if (!pc || !pc->cb_info || !foreach_cb) {
5726 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5727 return CAMERA_ERROR_INVALID_PARAMETER;
5730 CAM_LOG_INFO("Enter");
5732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5735 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5737 CAM_LOG_INFO("ret : 0x%x", ret);
5743 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5745 int ret = CAMERA_ERROR_NONE;
5746 camera_cli_s *pc = (camera_cli_s *)camera;
5747 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5749 if (!pc || !pc->cb_info || !foreach_cb) {
5750 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5751 return CAMERA_ERROR_INVALID_PARAMETER;
5754 CAM_LOG_INFO("Enter");
5756 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5757 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5759 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5761 CAM_LOG_INFO("ret : 0x%x", ret);
5767 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5769 int ret = CAMERA_ERROR_NONE;
5770 camera_cli_s *pc = (camera_cli_s *)camera;
5771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5773 if (!pc || !pc->cb_info || !foreach_cb) {
5774 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5775 return CAMERA_ERROR_INVALID_PARAMETER;
5778 CAM_LOG_INFO("Enter");
5780 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5781 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5783 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5785 CAM_LOG_INFO("ret : 0x%x", ret);
5791 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5793 int ret = CAMERA_ERROR_NONE;
5794 camera_cli_s *pc = (camera_cli_s *)camera;
5795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5797 if (!pc || !pc->cb_info || !foreach_cb) {
5798 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5799 return CAMERA_ERROR_INVALID_PARAMETER;
5802 CAM_LOG_INFO("Enter");
5804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5809 CAM_LOG_INFO("ret : 0x%x", ret);
5815 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5817 int ret = CAMERA_ERROR_NONE;
5818 camera_cli_s *pc = (camera_cli_s *)camera;
5819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5821 if (!pc || !pc->cb_info || !foreach_cb) {
5822 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5823 return CAMERA_ERROR_INVALID_PARAMETER;
5826 CAM_LOG_INFO("Enter");
5828 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5829 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5831 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5833 CAM_LOG_INFO("ret : 0x%x", ret);
5839 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5841 int ret = CAMERA_ERROR_NONE;
5842 camera_cli_s *pc = (camera_cli_s *)camera;
5843 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5845 if (!pc || !pc->cb_info || !foreach_cb) {
5846 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5847 return CAMERA_ERROR_INVALID_PARAMETER;
5850 CAM_LOG_INFO("Enter");
5852 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5853 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5855 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5857 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5863 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)
5865 int ret = CAMERA_ERROR_NONE;
5866 camera_cli_s *pc = (camera_cli_s *)camera;
5867 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5868 camera_msg_param param;
5871 if (!pc || !pc->cb_info || !foreach_cb) {
5872 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5873 return CAMERA_ERROR_INVALID_PARAMETER;
5876 CAM_LOG_INFO("Enter");
5878 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5879 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5881 value = (width << 16) | height;
5882 CAMERA_MSG_PARAM_SET(param, INT, value);
5884 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5886 CAM_LOG_INFO("ret : 0x%x", ret);
5892 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5894 int ret = CAMERA_ERROR_NONE;
5895 camera_cli_s *pc = (camera_cli_s *)camera;
5896 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5898 if (!pc || !pc->cb_info || !foreach_cb) {
5899 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5900 return CAMERA_ERROR_INVALID_PARAMETER;
5903 CAM_LOG_INFO("Enter");
5905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5908 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 CAM_LOG_INFO("ret : 0x%x", ret);
5916 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5922 if (!pc || !pc->cb_info || !foreach_cb) {
5923 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5924 return CAMERA_ERROR_INVALID_PARAMETER;
5927 CAM_LOG_INFO("Enter");
5929 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5930 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5932 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5934 CAM_LOG_INFO("ret : 0x%x", ret);
5940 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5942 int ret = CAMERA_ERROR_NONE;
5943 camera_cli_s *pc = (camera_cli_s *)camera;
5944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5945 camera_msg_param param;
5946 int set_rotation = (int)rotation;
5948 if (!pc || !pc->cb_info) {
5949 CAM_LOG_ERROR("NULL handle");
5950 return CAMERA_ERROR_INVALID_PARAMETER;
5953 CAM_LOG_INFO("Enter");
5955 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5957 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5959 CAM_LOG_INFO("ret : 0x%x", ret);
5965 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5967 int ret = CAMERA_ERROR_NONE;
5968 camera_cli_s *pc = (camera_cli_s *)camera;
5969 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5971 if (!pc || !pc->cb_info || !rotation) {
5972 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5973 return CAMERA_ERROR_INVALID_PARAMETER;
5976 CAM_LOG_INFO("Enter");
5978 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5980 if (ret == CAMERA_ERROR_NONE)
5981 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5983 CAM_LOG_INFO("ret : 0x%x", ret);
5989 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5991 int ret = CAMERA_ERROR_NONE;
5992 camera_cli_s *pc = (camera_cli_s *)camera;
5993 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5994 camera_msg_param param;
5995 int set_flip = (int)flip;
5997 if (!pc || !pc->cb_info) {
5998 CAM_LOG_ERROR("NULL handle");
5999 return CAMERA_ERROR_INVALID_PARAMETER;
6002 CAM_LOG_INFO("Enter");
6004 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6006 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6008 CAM_LOG_INFO("ret : 0x%x", ret);
6014 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6016 int ret = CAMERA_ERROR_NONE;
6017 camera_cli_s *pc = (camera_cli_s *)camera;
6018 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6020 if (!pc || !pc->cb_info || !flip) {
6021 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
6022 return CAMERA_ERROR_INVALID_PARAMETER;
6025 CAM_LOG_INFO("Enter");
6027 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6029 if (ret == CAMERA_ERROR_NONE)
6030 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6032 CAM_LOG_INFO("ret : 0x%x", ret);
6037 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6039 int ret = CAMERA_ERROR_NONE;
6040 camera_cli_s *pc = (camera_cli_s *)camera;
6041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6042 camera_msg_param param;
6043 int set_mode = (int)mode;
6045 if (!pc || !pc->cb_info) {
6046 CAM_LOG_ERROR("NULL handle");
6047 return CAMERA_ERROR_INVALID_PARAMETER;
6050 CAM_LOG_INFO("Enter");
6052 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6054 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6056 CAM_LOG_INFO("ret : 0x%x", ret);
6062 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6064 int ret = CAMERA_ERROR_NONE;
6065 camera_cli_s *pc = (camera_cli_s *)camera;
6066 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6068 if (!pc || !pc->cb_info || !mode) {
6069 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6073 CAM_LOG_INFO("Enter");
6075 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6077 if (ret == CAMERA_ERROR_NONE)
6078 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6080 CAM_LOG_INFO("ret : 0x%x", ret);
6086 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6088 int ret = CAMERA_ERROR_NONE;
6089 camera_cli_s *pc = (camera_cli_s *)camera;
6090 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6092 if (!pc || !pc->cb_info) {
6093 CAM_LOG_ERROR("NULL handle");
6094 return CAMERA_ERROR_INVALID_PARAMETER;
6097 CAM_LOG_INFO("Enter");
6099 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6102 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6106 CAM_LOG_INFO("ret : %d", ret);
6112 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6114 int ret = CAMERA_ERROR_NONE;
6115 camera_cli_s *pc = (camera_cli_s *)camera;
6116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6118 if (!pc || !pc->cb_info) {
6119 CAM_LOG_ERROR("NULL handle");
6120 return CAMERA_ERROR_INVALID_PARAMETER;
6123 CAM_LOG_INFO("Enter");
6125 if (!camera_attr_is_supported_hdr_capture(camera)) {
6126 CAM_LOG_ERROR("HDR not supported");
6127 return CAMERA_ERROR_NOT_SUPPORTED;
6131 CAM_LOG_ERROR("NULL callback");
6132 return CAMERA_ERROR_INVALID_PARAMETER;
6135 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6137 if (ret == CAMERA_ERROR_NONE) {
6138 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6140 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6141 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6143 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6146 CAM_LOG_INFO("ret : 0x%x", ret);
6152 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6154 int ret = CAMERA_ERROR_NONE;
6155 camera_cli_s *pc = (camera_cli_s *)camera;
6156 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6158 if (!pc || !pc->cb_info) {
6159 CAM_LOG_ERROR("NULL handle");
6160 return CAMERA_ERROR_INVALID_PARAMETER;
6163 CAM_LOG_INFO("Enter");
6165 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6167 if (ret == CAMERA_ERROR_NONE) {
6168 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6170 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6171 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6173 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6176 CAM_LOG_INFO("ret : 0x%x", ret);
6182 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6184 int ret = CAMERA_ERROR_NONE;
6185 camera_cli_s *pc = (camera_cli_s *)camera;
6186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6187 camera_msg_param param;
6188 int set_enable = (int)enable;
6190 if (!pc || !pc->cb_info) {
6191 CAM_LOG_ERROR("NULL handle");
6192 return CAMERA_ERROR_INVALID_PARAMETER;
6195 CAM_LOG_INFO("Enter");
6197 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6199 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6201 CAM_LOG_INFO("ret : 0x%x", ret);
6207 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6209 int ret = CAMERA_ERROR_NONE;
6210 camera_cli_s *pc = (camera_cli_s *)camera;
6211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6213 if (!pc || !pc->cb_info || !enabled) {
6214 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6215 return CAMERA_ERROR_INVALID_PARAMETER;
6218 CAM_LOG_INFO("Enter");
6220 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6222 if (ret == CAMERA_ERROR_NONE)
6223 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6225 CAM_LOG_INFO("ret : 0x%x", ret);
6231 bool camera_attr_is_supported_anti_shake(camera_h camera)
6233 int ret = CAMERA_ERROR_NONE;
6234 camera_cli_s *pc = (camera_cli_s *)camera;
6235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6237 if (!pc || !pc->cb_info) {
6238 CAM_LOG_ERROR("NULL handle");
6239 return CAMERA_ERROR_INVALID_PARAMETER;
6242 CAM_LOG_INFO("Enter");
6244 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6247 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6251 CAM_LOG_INFO("ret : %d", ret);
6257 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6259 int ret = CAMERA_ERROR_NONE;
6260 camera_cli_s *pc = (camera_cli_s *)camera;
6261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6262 camera_msg_param param;
6263 int set_enable = (int)enable;
6265 if (!pc || !pc->cb_info) {
6266 CAM_LOG_ERROR("NULL handle");
6267 return CAMERA_ERROR_INVALID_PARAMETER;
6270 CAM_LOG_INFO("Enter");
6272 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6274 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6276 CAM_LOG_INFO("ret : 0x%x", ret);
6282 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6284 int ret = CAMERA_ERROR_NONE;
6285 camera_cli_s *pc = (camera_cli_s *)camera;
6286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6288 if (!pc || !pc->cb_info || !enabled) {
6289 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6290 return CAMERA_ERROR_INVALID_PARAMETER;
6293 CAM_LOG_INFO("Enter");
6295 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6297 if (ret == CAMERA_ERROR_NONE)
6298 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6300 CAM_LOG_INFO("ret : 0x%x", ret);
6306 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6308 int ret = CAMERA_ERROR_NONE;
6309 camera_cli_s *pc = (camera_cli_s *)camera;
6310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6312 if (!pc || !pc->cb_info) {
6313 CAM_LOG_ERROR("NULL handle");
6314 return CAMERA_ERROR_INVALID_PARAMETER;
6317 CAM_LOG_INFO("Enter");
6319 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6322 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6326 CAM_LOG_INFO("ret : %d", ret);
6332 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6334 int ret = CAMERA_ERROR_NONE;
6335 camera_cli_s *pc = (camera_cli_s *)camera;
6336 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6337 camera_msg_param param;
6338 int set_enable = (int)enable;
6340 if (!pc || !pc->cb_info) {
6341 CAM_LOG_ERROR("NULL handle");
6342 return CAMERA_ERROR_INVALID_PARAMETER;
6345 CAM_LOG_INFO("Enter");
6347 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6349 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6351 CAM_LOG_INFO("ret : 0x%x", ret);
6357 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6359 int ret = CAMERA_ERROR_NONE;
6360 camera_cli_s *pc = (camera_cli_s *)camera;
6361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6363 if (!pc || !pc->cb_info || !enabled) {
6364 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6365 return CAMERA_ERROR_INVALID_PARAMETER;
6368 CAM_LOG_INFO("Enter");
6370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6372 if (ret == CAMERA_ERROR_NONE)
6373 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6375 CAM_LOG_INFO("ret : 0x%x", ret);
6381 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6383 int ret = CAMERA_ERROR_NONE;
6384 camera_cli_s *pc = (camera_cli_s *)camera;
6385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6387 if (!pc || !pc->cb_info) {
6388 CAM_LOG_ERROR("NULL handle");
6389 return CAMERA_ERROR_INVALID_PARAMETER;
6392 CAM_LOG_INFO("Enter");
6394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6397 CAM_LOG_ERROR("error is occurred 0x%x", ret);
6401 CAM_LOG_INFO("ret : %d", ret);
6407 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6409 int ret = CAMERA_ERROR_NONE;
6410 camera_cli_s *pc = (camera_cli_s *)camera;
6411 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6412 camera_msg_param param;
6413 int set_disable = (int)disable;
6415 if (!pc || !pc->cb_info) {
6416 CAM_LOG_ERROR("NULL handle");
6417 return CAMERA_ERROR_INVALID_PARAMETER;
6420 CAM_LOG_INFO("Enter");
6422 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6424 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6426 CAM_LOG_INFO("ret : 0x%x", ret);
6432 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6434 int ret = CAMERA_ERROR_NONE;
6435 camera_cli_s *pc = (camera_cli_s *)camera;
6436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6437 camera_msg_param param0;
6438 camera_msg_param param1;
6440 if (!pc || !pc->cb_info) {
6441 CAM_LOG_ERROR("NULL handle");
6442 return CAMERA_ERROR_INVALID_PARAMETER;
6445 CAM_LOG_INFO("Enter");
6447 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6448 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6450 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6451 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6453 CAM_LOG_INFO("ret : 0x%x", ret);
6459 int camera_attr_get_pan(camera_h camera, int *pan_step)
6461 int ret = CAMERA_ERROR_NONE;
6462 camera_cli_s *pc = (camera_cli_s *)camera;
6463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6465 if (!pc || !pc->cb_info || !pan_step) {
6466 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6467 return CAMERA_ERROR_INVALID_PARAMETER;
6470 CAM_LOG_INFO("Enter");
6472 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6474 if (ret == CAMERA_ERROR_NONE)
6475 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6477 CAM_LOG_INFO("ret : 0x%x", ret);
6483 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6485 int ret = CAMERA_ERROR_NONE;
6486 camera_cli_s *pc = (camera_cli_s *)camera;
6487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6489 if (!pc || !pc->cb_info || !min || !max) {
6490 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6491 return CAMERA_ERROR_INVALID_PARAMETER;
6494 CAM_LOG_INFO("Enter");
6496 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6498 if (ret == CAMERA_ERROR_NONE) {
6499 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6500 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6503 CAM_LOG_INFO("ret : 0x%x", ret);
6509 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6511 int ret = CAMERA_ERROR_NONE;
6512 camera_cli_s *pc = (camera_cli_s *)camera;
6513 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6514 camera_msg_param param0;
6515 camera_msg_param param1;
6517 if (!pc || !pc->cb_info) {
6518 CAM_LOG_ERROR("NULL handle");
6519 return CAMERA_ERROR_INVALID_PARAMETER;
6522 CAM_LOG_INFO("Enter");
6524 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6525 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6527 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6528 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6530 CAM_LOG_INFO("ret : 0x%x", ret);
6536 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6538 int ret = CAMERA_ERROR_NONE;
6539 camera_cli_s *pc = (camera_cli_s *)camera;
6540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6542 if (!pc || !pc->cb_info || !tilt_step) {
6543 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6544 return CAMERA_ERROR_INVALID_PARAMETER;
6547 CAM_LOG_INFO("Enter");
6549 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6551 if (ret == CAMERA_ERROR_NONE)
6552 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6554 CAM_LOG_INFO("ret : 0x%x", ret);
6560 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6562 int ret = CAMERA_ERROR_NONE;
6563 camera_cli_s *pc = (camera_cli_s *)camera;
6564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6566 if (!pc || !pc->cb_info || !min || !max) {
6567 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max);
6568 return CAMERA_ERROR_INVALID_PARAMETER;
6571 CAM_LOG_INFO("Enter");
6573 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6575 if (ret == CAMERA_ERROR_NONE) {
6576 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6577 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6580 CAM_LOG_INFO("ret : 0x%x", ret);
6586 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6588 int ret = CAMERA_ERROR_NONE;
6589 camera_cli_s *pc = (camera_cli_s *)camera;
6590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6591 camera_msg_param param;
6592 int set_ptz_type = (int)ptz_type;
6594 if (!pc || !pc->cb_info) {
6595 CAM_LOG_ERROR("NULL handle");
6596 return CAMERA_ERROR_INVALID_PARAMETER;
6599 CAM_LOG_INFO("Enter");
6601 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6603 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6605 CAM_LOG_INFO("ret : 0x%x", ret);
6611 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6613 int ret = CAMERA_ERROR_NONE;
6614 camera_cli_s *pc = (camera_cli_s *)camera;
6615 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6617 if (!pc || !pc->cb_info || !foreach_cb) {
6618 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6619 return CAMERA_ERROR_INVALID_PARAMETER;
6622 CAM_LOG_INFO("Enter");
6624 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6625 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6627 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6629 CAM_LOG_INFO("ret : 0x%x", ret);
6635 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6637 int ret = CAMERA_ERROR_NONE;
6638 camera_cli_s *pc = (camera_cli_s *)camera;
6639 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6640 int set_display_roi_area[4] = {x, y, width, height};
6645 if (!pc || !pc->cb_info) {
6646 CAM_LOG_ERROR("NULL handle");
6647 return CAMERA_ERROR_INVALID_PARAMETER;
6650 CAM_LOG_INFO("Enter");
6652 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6653 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6654 if (ret != MM_ERROR_NONE) {
6655 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6656 return CAMERA_ERROR_INVALID_OPERATION;
6660 length = sizeof(set_display_roi_area) / sizeof(int) + \
6661 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6663 msg = muse_core_msg_new(api,
6664 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6667 CAM_LOG_ERROR("msg creation failed: api %d", api);
6668 return CAMERA_ERROR_OUT_OF_MEMORY;
6671 if (pc->cb_info->is_server_connected) {
6672 __camera_update_api_waiting(pc->cb_info, api, 1);
6674 g_mutex_lock(&pc->cb_info->fd_lock);
6675 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6676 g_mutex_unlock(&pc->cb_info->fd_lock);
6680 CAM_LOG_ERROR("message send failed");
6681 ret = CAMERA_ERROR_INVALID_OPERATION;
6683 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6686 __camera_update_api_waiting(pc->cb_info, api, -1);
6688 muse_core_msg_free(msg);
6690 CAM_LOG_INFO("ret : 0x%x", ret);
6696 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6698 camera_cli_s *pc = (camera_cli_s *)camera;
6699 int ret = CAMERA_ERROR_NONE;
6700 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6702 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6703 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6704 return CAMERA_ERROR_INVALID_PARAMETER;
6707 CAM_LOG_INFO("Enter");
6709 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6711 if (ret == CAMERA_ERROR_NONE) {
6712 *x = pc->cb_info->get_display_roi_area[0];
6713 *y = pc->cb_info->get_display_roi_area[1];
6714 *width = pc->cb_info->get_display_roi_area[2];
6715 *height = pc->cb_info->get_display_roi_area[3];
6718 CAM_LOG_INFO("ret : 0x%x", ret);
6724 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6726 int ret = CAMERA_ERROR_NONE;
6727 int get_device_state = 0;
6730 CAM_LOG_ERROR("NULL pointer");
6731 return CAMERA_ERROR_INVALID_PARAMETER;
6734 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6735 (int)device, "get_device_state", &get_device_state);
6737 if (ret == CAMERA_ERROR_NONE) {
6738 *state = (camera_device_state_e)get_device_state;
6739 CAM_LOG_INFO("device state %d", *state);
6741 CAM_LOG_ERROR("failed 0x%x", ret);
6748 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6750 int ret = CAMERA_ERROR_NONE;
6751 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6752 camera_cb_info *info = NULL;
6754 if (!callback || !cb_id) {
6755 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6756 return CAMERA_ERROR_INVALID_PARAMETER;
6759 /* check camera support */
6760 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6761 if (ret != CAMERA_ERROR_NONE) {
6762 CAM_LOG_ERROR("get device state failed");
6766 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6768 info = g_new0(camera_cb_info, 1);
6770 CAM_LOG_ERROR("info failed");
6771 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6775 info->id = ++g_cam_dev_state_changed_cb_id;
6776 info->callback = (void *)callback;
6777 info->user_data = user_data;
6781 /* subscribe dbus signal for camera state change */
6782 if (!g_cam_dev_state_changed_cb_conn) {
6783 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6784 if (!g_cam_dev_state_changed_cb_conn) {
6785 CAM_LOG_ERROR("failed to get gdbus connection");
6786 ret = CAMERA_ERROR_INVALID_OPERATION;
6790 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6791 MM_CAMCORDER_DBUS_OBJECT,
6792 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6793 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6795 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6796 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6797 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6798 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6799 CAM_LOG_ERROR("failed to get gdbus connection");
6800 ret = CAMERA_ERROR_INVALID_OPERATION;
6804 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6807 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6809 CAM_LOG_INFO("callback id %d", info->id);
6812 if (ret != CAMERA_ERROR_NONE) {
6818 if (g_cam_dev_state_changed_cb_conn) {
6819 g_object_unref(g_cam_dev_state_changed_cb_conn);
6820 g_cam_dev_state_changed_cb_conn = NULL;
6824 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6830 int camera_remove_device_state_changed_cb(int cb_id)
6832 int ret = CAMERA_ERROR_NONE;
6833 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6834 GList *tmp_list = NULL;
6835 camera_cb_info *info = NULL;
6837 /* check camera support */
6838 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6839 if (ret != CAMERA_ERROR_NONE) {
6840 CAM_LOG_ERROR("get device state failed");
6844 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6846 if (!g_cam_dev_state_changed_cb_list) {
6847 CAM_LOG_ERROR("there is no callback info");
6848 ret = CAMERA_ERROR_INVALID_OPERATION;
6852 tmp_list = g_cam_dev_state_changed_cb_list;
6855 info = tmp_list->data;
6856 tmp_list = tmp_list->next;
6859 CAM_LOG_WARNING("NULL info");
6863 if (info->id == cb_id) {
6864 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6869 if (!g_cam_dev_state_changed_cb_list) {
6870 /* no remained callback */
6871 if (g_cam_dev_state_changed_cb_conn) {
6872 /* unsubscribe signal */
6873 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6874 g_cam_dev_state_changed_cb_subscribe_id = 0;
6876 /* unref connection */
6877 g_object_unref(g_cam_dev_state_changed_cb_conn);
6878 g_cam_dev_state_changed_cb_conn = NULL;
6882 CAM_LOG_INFO("id %d callback removed", cb_id);
6883 ret = CAMERA_ERROR_NONE;
6889 CAM_LOG_ERROR("id %d callback not found", cb_id);
6890 ret = CAMERA_ERROR_INVALID_PARAMETER;
6893 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);