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;
43 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
44 int *ret, int timeout);
45 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
46 int *ret, camera_msg_param *param, int timeout);
47 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
48 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
49 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
50 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
51 static void _camera_release_imported_bo(tbm_bo *bo);
52 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
53 camera_media_packet_data *mp_data, media_packet_h *packet);
54 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
55 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
56 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
57 static gboolean _camera_allocate_preview_buffer(camera_h camera);
58 static void _camera_release_preview_buffer(camera_h camera);
61 static gboolean _camera_allocate_preview_buffer(camera_h camera)
64 int ret = CAMERA_ERROR_NONE;
65 int format = CAMERA_PIXEL_FORMAT_INVALID;
69 camera_cli_s *pc = (camera_cli_s *)camera;
70 camera_cb_info_s *cb_info = NULL;
72 if (!pc || !pc->cb_info) {
73 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
77 cb_info = pc->cb_info;
81 /* get preview info and calculate size */
82 ret = camera_get_preview_format(camera, &format);
83 if (ret != CAMERA_ERROR_NONE) {
84 LOGE("get preview format failed 0x%x", ret);
88 ret = camera_get_preview_resolution(camera, &width, &height);
89 if (ret != CAMERA_ERROR_NONE) {
90 LOGE("get preview resolution failed 0x%x", ret);
94 LOGD("preview %dx%d, format %d", width, height, format);
97 case CAMERA_PIXEL_FORMAT_INVZ:
98 buffer_size = width * height;
100 case CAMERA_PIXEL_FORMAT_NV12:
101 case CAMERA_PIXEL_FORMAT_I420:
102 buffer_size = (width * height * 3) >> 1;
104 case CAMERA_PIXEL_FORMAT_YUYV:
105 case CAMERA_PIXEL_FORMAT_UYVY:
106 buffer_size = width * height * 2;
109 LOGE("unhandled format %d", format);
110 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
113 LOGD("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
115 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
116 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
117 if (!cb_info->bos[i]) {
118 LOGE("bo alloc failed [%d,i:%d]", buffer_size, i);
119 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
122 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
123 if (cb_info->fds[i] < 0) {
124 LOGE("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
125 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
128 LOGD("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
135 _ALLOCATE_PREVIEW_BUFFER_FAILED:
136 _camera_release_preview_buffer(camera);
141 static void _camera_release_preview_buffer(camera_h camera)
144 camera_cli_s *pc = (camera_cli_s *)camera;
145 camera_cb_info_s *cb_info = NULL;
147 if (!pc || !pc->cb_info) {
148 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
154 cb_info = pc->cb_info;
156 /* close exported fd and bos */
157 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
158 LOGD("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
160 if (cb_info->bos[i]) {
161 tbm_bo_unref(cb_info->bos[i]);
162 cb_info->bos[i] = NULL;
167 if (cb_info->fds[i] >= 0) {
168 close(cb_info->fds[i]);
169 cb_info->fds[i] = -1;
179 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
182 api < 0 || api >= MUSE_CAMERA_API_MAX) {
183 LOGE("invalid param %p %d", cb_info, api);
187 g_mutex_lock(&(cb_info->api_mutex[api]));
188 cb_info->api_waiting[api] += value;
189 g_mutex_unlock(&(cb_info->api_mutex[api]));
191 /*LOGD("api %d, value %d, waiting %d",
192 api, value, cb_info->api_waiting[api]);*/
198 static void __camera_device_state_changed_cb(GDBusConnection *connection,
199 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
200 const gchar *signal_name, GVariant *param, gpointer user_data)
203 camera_device_e device = CAMERA_DEVICE_CAMERA0;
204 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
205 GList *tmp_list = NULL;
206 camera_cb_info *info = NULL;
208 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
210 if (!g_cam_dev_state_changed_cb_list || !param) {
211 LOGW("no callback or NULL param %p", param);
215 /* get device and state */
216 g_variant_get(param, "(i)", &value);
218 device = value >> 16;
219 state = 0x0000ffff & value;
221 LOGD("device %d, state %d", device, state);
223 tmp_list = g_cam_dev_state_changed_cb_list;
226 info = (camera_cb_info *)tmp_list->data;
229 if (info->callback) {
230 LOGD("start id[%d] callback", info->id);
231 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
232 LOGD("returned id[%d] callback", info->id);
234 LOGW("NULL callback for id %d", info->id);
238 tmp_list = tmp_list->next;
242 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
248 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
254 int num_buffer_fd = 0;
255 unsigned char *buf_pos = NULL;
258 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
259 tbm_bo_handle bo_handle = {.ptr = NULL};
260 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
261 tbm_bo data_bo = NULL;
262 tbm_bo_handle data_bo_handle = {.ptr = NULL};
264 camera_msg_param param;
265 camera_preview_data_s frame;
266 camera_stream_data_s *stream = NULL;
267 camera_media_packet_data *mp_data = NULL;
268 media_packet_h pkt = NULL;
269 media_packet_h pkt_evas = NULL;
271 /* tfd[0]: MMCamcorderVideoStreamDataType
272 tfd[1]: data_bo or zero copy bo[0]
273 tfd[2]: zero copy bo[1]
274 tfd[3]: zero copy bo[2] */
276 if (!cb_info || !recv_msg || !tfd) {
277 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
281 muse_camera_msg_get(preview_fd, recv_msg);
282 muse_camera_msg_get(num_buffer_fd, recv_msg);
284 /*LOGD("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);*/
286 memset(&frame, 0x0, sizeof(camera_preview_data_s));
289 LOGE("invalid fd %d", tfd[0]);
294 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
296 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
297 LOGE("invalid num buffer fd %d", num_buffer_fd);
298 goto _PREVIEW_CB_HANDLER_DONE;
301 if (num_buffer_fd == 0 && tfd[1] >= 0) {
302 /* import tbm data_bo and get virtual address */
303 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
304 LOGE("failed to import data fd %d", tfd[1]);
305 goto _PREVIEW_CB_HANDLER_DONE;
309 /* import tbm bo and get virtual address */
310 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
311 LOGE("failed to import fd %d", tfd[0]);
312 goto _PREVIEW_CB_HANDLER_DONE;
315 buf_pos = (unsigned char *)bo_handle.ptr;
317 /* get stream info */
318 stream = (camera_stream_data_s *)buf_pos;
320 for (i = 0 ; i < num_buffer_fd ; i++) {
321 /* import buffer bo and get virtual address */
322 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
323 LOGE("failed to import buffer fd %d", tfd[i + 1]);
324 goto _PREVIEW_CB_HANDLER_DONE;
328 /* call preview callback */
329 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
330 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
332 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
333 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
336 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
337 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
339 if (ret == CAMERA_ERROR_NONE) {
340 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
341 if (ret != CAMERA_ERROR_NONE) {
342 LOGE("create pkt for evas failed");
343 _camera_media_packet_data_release(mp_data, cb_info);
349 /* call media packet callback */
350 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
351 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
353 if (ret == CAMERA_ERROR_NONE) {
354 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
356 if (ret == CAMERA_ERROR_NONE) {
357 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
358 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
360 _camera_media_packet_data_release(mp_data, cb_info);
366 /* call evas renderer */
368 if (cb_info->run_evas_render) {
369 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
371 LOGW("evas renderer is stopped, skip this buffer...");
372 media_packet_destroy(pkt_evas);
377 /* send message for preview callback return */
378 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
379 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
381 _PREVIEW_CB_HANDLER_DONE:
382 if (mp_data == NULL) {
383 /* release imported bo */
384 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
385 _camera_release_imported_bo(&buffer_bo[i]);
387 /* unmap and unref tbm bo */
388 _camera_release_imported_bo(&data_bo);
389 _camera_release_imported_bo(&bo);
391 /* close imported fd */
392 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
402 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
404 /*LOGD("return buffer Done");*/
411 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
415 int capture_fd_main = 0;
416 int capture_fd_post = 0;
417 int capture_fd_thumb = 0;
418 unsigned char *buf_pos = NULL;
420 camera_image_data_s *rImage = NULL;
421 camera_image_data_s *rPostview = NULL;
422 camera_image_data_s *rThumbnail = NULL;
424 tbm_bo bo_main = NULL;
425 tbm_bo bo_post = NULL;
426 tbm_bo bo_thumb = NULL;
427 tbm_bo_handle bo_main_handle = {.ptr = NULL};
428 tbm_bo_handle bo_post_handle = {.ptr = NULL};
429 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
431 if (!cb_info || !recv_msg || !tfd) {
432 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
436 muse_camera_msg_get(capture_fd_main, recv_msg);
437 muse_camera_msg_get(capture_fd_post, recv_msg);
438 muse_camera_msg_get(capture_fd_thumb, recv_msg);
440 LOGD("capture fd %d %d %d, received fd %d %d %d",
441 capture_fd_main, capture_fd_post, capture_fd_thumb,
442 tfd[0], tfd[1], tfd[2]);
444 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
445 LOGE("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
446 goto _CAPTURE_CB_HANDLER_DONE;
449 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
450 LOGW("NULL callback");
451 goto _CAPTURE_CB_HANDLER_DONE;
454 /* import tbm bo and get virtual address */
455 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
456 LOGE("failed to import fd [%d] for main", tfd[tfd_index]);
457 goto _CAPTURE_CB_HANDLER_DONE;
460 buf_pos = (unsigned char *)bo_main_handle.ptr;
461 rImage = (camera_image_data_s *)buf_pos;
462 rImage->data = buf_pos + sizeof(camera_image_data_s);
463 if (rImage->exif && rImage->exif_size > 0) {
464 rImage->exif = rImage->data + rImage->size;
467 rImage->exif_size = 0;
470 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
471 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
473 if (capture_fd_post >= 0) {
474 /* import tbm bo and get virtual address */
476 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
477 buf_pos = (unsigned char *)bo_post_handle.ptr;
478 rPostview = (camera_image_data_s *)buf_pos;
479 LOGD("rPostview->size : %d", rPostview->size);
480 rPostview->data = buf_pos + sizeof(camera_image_data_s);
482 LOGE("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
486 if (capture_fd_thumb >= 0) {
487 /* import tbm bo and get virtual address */
489 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
490 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
491 rThumbnail = (camera_image_data_s *)buf_pos;
492 LOGD("rThumbnail->size : %d", rThumbnail->size);
493 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
495 LOGE("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
499 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
500 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
502 _CAPTURE_CB_HANDLER_DONE:
504 if (capture_fd_main >= 0) {
505 _camera_release_imported_bo(&bo_main);
506 _camera_msg_return_buffer(capture_fd_main, cb_info);
509 if (capture_fd_post >= 0) {
510 _camera_release_imported_bo(&bo_post);
511 _camera_msg_return_buffer(capture_fd_post, cb_info);
514 if (capture_fd_thumb >= 0) {
515 _camera_release_imported_bo(&bo_thumb);
516 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
519 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
521 LOGD("close %d", tfd[i]);
529 LOGD("return buffer done");
535 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
539 camera_detected_face_s *faces = NULL;
542 tbm_bo_handle bo_handle = {.ptr = NULL};
544 if (!cb_info || !recv_msg || !tfd) {
545 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
549 muse_camera_msg_get(count, recv_msg);
550 muse_camera_msg_get(face_fd, recv_msg);
552 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
553 LOGD("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
556 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
558 faces = bo_handle.ptr;
565 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
566 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
569 _camera_release_imported_bo(&bo);
571 LOGW("skip face detection message [count %d, fd %d, cb %p]",
572 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
576 _camera_msg_return_buffer(face_fd, cb_info);
582 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
584 tbm_bo tmp_bo = NULL;
585 tbm_bo_handle tmp_bo_handle = {NULL, };
587 if (!bufmgr || !bo || !bo_handle || fd < 0) {
588 LOGE("invalid parameter - %p %p %p, fd %d",
589 bufmgr, bo, bo_handle, fd);
593 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
594 if (tmp_bo == NULL) {
595 LOGE("import failed - fd %d", fd);
599 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
600 if (tmp_bo_handle.ptr == NULL) {
601 LOGE("map failed %p", tmp_bo);
602 tbm_bo_unref(tmp_bo);
607 tbm_bo_unmap(tmp_bo);
609 /* set bo and bo_handle */
611 *bo_handle = tmp_bo_handle;
616 static void _camera_release_imported_bo(tbm_bo *bo)
629 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
631 int ret = CAMERA_ERROR_NONE;
634 if (!cb_info->is_server_connected) {
635 LOGE("server is disconnected");
636 return CAMERA_ERROR_SERVICE_DISCONNECTED;
639 g_mutex_lock(&(cb_info->api_mutex[api]));
641 LOGD("api [%d], timeout [%d sec]", api, time_out);
643 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
645 while (!cb_info->api_activating[api]) {
646 if (time_out == CAMERA_CB_NO_TIMEOUT) {
647 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
648 LOGW("api %d returned 0x%x", api, cb_info->api_ret[api]);
649 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
650 LOGE("api %d TIMED OUT!", api);
651 ret = CAMERA_ERROR_INVALID_OPERATION;
655 if (!cb_info->api_activating[api])
656 LOGW("invalid signal received, wait again...");
659 ret = cb_info->api_ret[api];
660 cb_info->api_activating[api] = FALSE;
663 g_mutex_unlock(&(cb_info->api_mutex[api]));
665 if (ret != CAMERA_ERROR_NONE)
666 LOGE("api %d : error 0x%x", api, ret);
672 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
673 int *ret, int timeout)
679 LOGE("NULL info - api %d", api);
682 *ret = CAMERA_ERROR_INVALID_PARAMETER;
687 msg = muse_core_msg_new(api, NULL);
689 LOGE("msg failed: api %d", api);
692 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
697 /*LOGD("send msg %s", msg);*/
699 if (cb_info->is_server_connected) {
700 __camera_update_api_waiting(cb_info, api, 1);
702 g_mutex_lock(&cb_info->fd_lock);
703 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
704 g_mutex_unlock(&cb_info->fd_lock);
708 LOGE("msg send failed");
710 *ret = CAMERA_ERROR_INVALID_OPERATION;
713 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
716 __camera_update_api_waiting(cb_info, api, -1);
718 muse_core_msg_free(msg);
724 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
725 int *ret, camera_msg_param *param, int timeout)
731 if (!cb_info || !param) {
732 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
735 *ret = CAMERA_ERROR_INVALID_PARAMETER;
740 /*LOGD("type %d, name %s", param->type, param->name);*/
742 switch (param->type) {
744 msg = muse_core_msg_new(api,
745 param->type, param->name, param->value.value_INT,
748 case MUSE_TYPE_STRING:
749 msg = muse_core_msg_new(api,
750 param->type, param->name, param->value.value_STRING,
753 case MUSE_TYPE_ARRAY:
754 array_length = param->value_size / sizeof(int) + \
755 (param->value_size % sizeof(int) ? 1 : 0);
757 msg = muse_core_msg_new(api,
758 param->type, param->name, array_length, param->value.value_ARRAY,
762 LOGE("unknown type %d", param->type);
767 LOGE("msg failed: api %d", api);
770 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
775 /*LOGD("send msg %s", msg);*/
777 if (cb_info->is_server_connected) {
778 __camera_update_api_waiting(cb_info, api, 1);
780 g_mutex_lock(&cb_info->fd_lock);
781 send_ret = muse_core_msg_send(cb_info->fd, msg);
782 g_mutex_unlock(&cb_info->fd_lock);
786 LOGE("msg send failed");
789 *ret = CAMERA_ERROR_INVALID_OPERATION;
792 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
795 __camera_update_api_waiting(cb_info, api, -1);
797 muse_core_msg_free(msg);
803 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
804 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
806 int func_ret = CAMERA_ERROR_NONE;
810 if (!cb_info || !param0 || !param1) {
811 LOGE("invalid ptr %p %p %p : api %d",
812 cb_info, param0, param1, api);
813 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
814 goto _SEND_PARAM2_INT_DONE;
817 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
819 param0->name, param0->value.value_INT,
820 param1->name, param1->value.value_INT);*/
822 msg = muse_core_msg_new(api,
823 param0->type, param0->name, param0->value.value_INT,
824 param1->type, param1->name, param1->value.value_INT,
827 LOGE("msg failed: api %d", api);
828 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
829 goto _SEND_PARAM2_INT_DONE;
832 /*LOGD("send msg [%s]", msg);*/
834 if (cb_info->is_server_connected) {
835 __camera_update_api_waiting(cb_info, api, 1);
837 g_mutex_lock(&cb_info->fd_lock);
838 send_ret = muse_core_msg_send(cb_info->fd, msg);
839 g_mutex_unlock(&cb_info->fd_lock);
843 LOGE("msg send failed");
845 func_ret = CAMERA_ERROR_INVALID_OPERATION;
847 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
850 __camera_update_api_waiting(cb_info, api, -1);
852 muse_core_msg_free(msg);
854 _SEND_PARAM2_INT_DONE:
862 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
864 camera_msg_param param;
867 LOGW("invalid fd %d", ret_fd);
871 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
873 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
879 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
881 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
882 in_format >= MM_PIXEL_FORMAT_NUM ||
883 out_format == NULL) {
884 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
885 return CAMERA_ERROR_INVALID_PARAMETER;
889 case MM_PIXEL_FORMAT_NV12:
890 case MM_PIXEL_FORMAT_NV12T:
891 *out_format = TBM_FORMAT_NV12;
894 case MM_PIXEL_FORMAT_NV16:
895 *out_format = TBM_FORMAT_NV16;
897 case MM_PIXEL_FORMAT_NV21:
898 *out_format = TBM_FORMAT_NV21;
900 case MM_PIXEL_FORMAT_YUYV:
901 *out_format = TBM_FORMAT_YUYV;
903 case MM_PIXEL_FORMAT_UYVY:
904 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
905 *out_format = TBM_FORMAT_UYVY;
907 case MM_PIXEL_FORMAT_422P:
908 *out_format = TBM_FORMAT_YUV422;
910 case MM_PIXEL_FORMAT_I420:
911 *out_format = TBM_FORMAT_YUV420;
913 case MM_PIXEL_FORMAT_YV12:
914 *out_format = TBM_FORMAT_YVU420;
916 case MM_PIXEL_FORMAT_RGB565:
917 *out_format = TBM_FORMAT_RGB565;
919 case MM_PIXEL_FORMAT_RGB888:
920 *out_format = TBM_FORMAT_RGB888;
922 case MM_PIXEL_FORMAT_RGBA:
923 *out_format = TBM_FORMAT_RGBA8888;
925 case MM_PIXEL_FORMAT_ARGB:
926 *out_format = TBM_FORMAT_ARGB8888;
929 LOGE("invalid in_format %d", in_format);
930 return CAMERA_ERROR_INVALID_PARAMETER;
934 return CAMERA_ERROR_NONE;
938 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
940 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
941 in_format >= MM_PIXEL_FORMAT_NUM ||
943 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
944 return CAMERA_ERROR_INVALID_PARAMETER;
948 case MM_PIXEL_FORMAT_NV12:
949 case MM_PIXEL_FORMAT_NV12T:
950 *mimetype = MEDIA_FORMAT_NV12;
953 case MM_PIXEL_FORMAT_NV16:
954 *mimetype = MEDIA_FORMAT_NV16;
956 case MM_PIXEL_FORMAT_NV21:
957 *mimetype = MEDIA_FORMAT_NV21;
959 case MM_PIXEL_FORMAT_YUYV:
960 *mimetype = MEDIA_FORMAT_YUYV;
962 case MM_PIXEL_FORMAT_UYVY:
963 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
964 *mimetype = MEDIA_FORMAT_UYVY;
966 case MM_PIXEL_FORMAT_422P:
967 *mimetype = MEDIA_FORMAT_422P;
969 case MM_PIXEL_FORMAT_I420:
970 *mimetype = MEDIA_FORMAT_I420;
972 case MM_PIXEL_FORMAT_YV12:
973 *mimetype = MEDIA_FORMAT_YV12;
975 case MM_PIXEL_FORMAT_RGB565:
976 *mimetype = MEDIA_FORMAT_RGB565;
978 case MM_PIXEL_FORMAT_RGB888:
979 *mimetype = MEDIA_FORMAT_RGB888;
981 case MM_PIXEL_FORMAT_RGBA:
982 *mimetype = MEDIA_FORMAT_RGBA;
984 case MM_PIXEL_FORMAT_ARGB:
985 *mimetype = MEDIA_FORMAT_ARGB;
988 LOGE("invalid in_format %d", in_format);
989 return CAMERA_ERROR_INVALID_PARAMETER;
993 return CAMERA_ERROR_NONE;
996 void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
997 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1000 unsigned char *buf_pos = NULL;
1002 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1003 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1007 /* set frame info */
1008 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1009 frame->format = MM_PIXEL_FORMAT_UYVY;
1011 frame->format = stream->format;
1013 frame->width = stream->width;
1014 frame->height = stream->height;
1015 frame->timestamp = stream->timestamp;
1016 frame->num_of_planes = stream->num_planes;
1018 if (num_buffer_fd == 0) {
1021 if (!data_bo_handle || !data_bo_handle->ptr) {
1022 LOGE("NULL pointer");
1026 buf_pos = data_bo_handle->ptr;
1028 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1029 frame->data.encoded_plane.data = buf_pos;
1030 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1031 frame->data.encoded_plane.is_delta_frame = (bool)stream->data.encoded.is_delta_frame;
1032 total_size = stream->data.encoded.length_data;
1033 } else if (stream->format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
1034 frame->data.encoded_plane.data = buf_pos;
1035 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1036 total_size = stream->data.encoded.length_data;
1037 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1038 frame->data.depth_plane.data = buf_pos;
1039 frame->data.depth_plane.size = stream->data.depth.length_data;
1040 total_size = stream->data.depth.length_data;
1041 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1042 stream->format == MM_PIXEL_FORMAT_ARGB) {
1043 frame->data.rgb_plane.data = buf_pos;
1044 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1045 total_size = stream->data.rgb.length_data;
1047 switch (stream->num_planes) {
1049 frame->data.single_plane.yuv = buf_pos;
1050 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1051 total_size = stream->data.yuv420.length_yuv;
1054 frame->data.double_plane.y = buf_pos;
1055 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1056 buf_pos += stream->data.yuv420sp.length_y;
1057 frame->data.double_plane.uv = buf_pos;
1058 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1059 total_size = stream->data.yuv420sp.length_y + \
1060 stream->data.yuv420sp.length_uv;
1063 frame->data.triple_plane.y = buf_pos;
1064 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1065 buf_pos += stream->data.yuv420p.length_y;
1066 frame->data.triple_plane.u = buf_pos;
1067 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1068 buf_pos += stream->data.yuv420p.length_u;
1069 frame->data.triple_plane.v = buf_pos;
1070 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1071 total_size = stream->data.yuv420p.length_y + \
1072 stream->data.yuv420p.length_u + \
1073 stream->data.yuv420p.length_v;
1082 switch (stream->num_planes) {
1085 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1086 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1087 total_size = stream->data.yuv420.length_yuv;
1091 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1092 if (stream->num_planes == (unsigned int)num_buffer_fd)
1093 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1095 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1096 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1097 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1098 total_size = stream->data.yuv420sp.length_y + \
1099 stream->data.yuv420sp.length_uv;
1103 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1104 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1105 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1106 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1108 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1109 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1111 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1112 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1113 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1114 total_size = stream->data.yuv420p.length_y + \
1115 stream->data.yuv420p.length_u + \
1116 stream->data.yuv420p.length_v;
1125 LOGD("format %d, %dx%d, size %d plane num %d",
1126 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1132 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1133 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1136 int ret = CAMERA_ERROR_NONE;
1137 camera_media_packet_data *tmp_mp_data = NULL;
1141 return CAMERA_ERROR_INVALID_PARAMETER;
1144 if (*mp_data == NULL) {
1145 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1147 tmp_mp_data->ret_fd = ret_fd;
1148 tmp_mp_data->fd = tfd[0];
1149 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1150 tmp_mp_data->bo = bo;
1154 tmp_mp_data->data_bo = data_bo;
1155 tmp_mp_data->data_fd = tfd[1];
1158 for (i = 0 ; i < num_buffer_fd ; i++) {
1159 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1160 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1164 tmp_mp_data->ref_cnt++;
1166 *mp_data = tmp_mp_data;
1167 /*LOGD("mp_data %p", tmp_mp_data);*/
1169 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1170 LOGE("failed to alloc media packet data");
1173 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1179 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1183 if (!mp_data || !cb_info) {
1184 LOGE("NULL pointer %p %p", mp_data, cb_info);
1188 if (mp_data->ref_cnt > 1) {
1190 LOGD("ref count %d", mp_data->ref_cnt);
1192 /* release imported bo and close imported fd */
1193 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1194 tbm_bo_unref(mp_data->buffer_bo[i]);
1195 mp_data->buffer_bo[i] = NULL;
1197 close(mp_data->buffer_fd[i]);
1198 mp_data->buffer_fd[i] = -1;
1201 /* unref tbm bo and close imported fd */
1204 _camera_release_imported_bo(&mp_data->bo);
1206 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1207 close(mp_data->data_fd);
1208 mp_data->data_fd = -1;
1210 _camera_release_imported_bo(&mp_data->data_bo);
1213 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1221 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1222 camera_media_packet_data *mp_data, media_packet_h *packet)
1224 media_packet_h pkt = NULL;
1225 bool make_pkt_fmt = false;
1226 tbm_surface_h tsurf = NULL;
1227 tbm_surface_info_s tsurf_info;
1228 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1229 uint32_t bo_format = 0;
1232 int num_buffer_fd = 0;
1233 tbm_bo *buffer_bo = NULL;
1235 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1236 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1237 cb_info, stream, mp_data, packet);
1238 return CAMERA_ERROR_INVALID_PARAMETER;
1241 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1242 buffer_bo = mp_data->buffer_bo;
1243 num_buffer_fd = mp_data->num_buffer_fd;
1245 /* create tbm surface */
1246 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1247 tsurf_info.planes[i].stride = stream->stride[i];
1249 /* get tbm surface format */
1250 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1251 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1253 if (ret == CAMERA_ERROR_NONE) {
1254 tsurf_info.width = stream->width;
1255 tsurf_info.height = stream->height;
1256 tsurf_info.format = bo_format;
1257 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1258 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1260 if (num_buffer_fd > 0) {
1261 switch (bo_format) {
1262 case TBM_FORMAT_NV12:
1263 case TBM_FORMAT_NV21:
1264 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1265 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1266 tsurf_info.planes[0].offset = 0;
1267 if (num_buffer_fd == 1)
1268 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1269 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1272 case TBM_FORMAT_YUV420:
1273 case TBM_FORMAT_YVU420:
1274 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1275 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1276 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1277 tsurf_info.planes[0].offset = 0;
1278 if (num_buffer_fd == 1) {
1279 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1280 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1282 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1284 case TBM_FORMAT_UYVY:
1285 case TBM_FORMAT_YUYV:
1286 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1287 tsurf_info.planes[0].offset = 0;
1288 tsurf_info.size = tsurf_info.planes[0].size;
1295 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1296 } else if (mp_data->data_bo) {
1298 switch (bo_format) {
1299 case TBM_FORMAT_NV12:
1300 case TBM_FORMAT_NV21:
1301 tsurf_info.planes[0].size = stream->width * stream->height;
1302 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1303 tsurf_info.planes[0].offset = 0;
1304 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1305 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1307 case TBM_FORMAT_YUV420:
1308 case TBM_FORMAT_YVU420:
1309 tsurf_info.planes[0].size = stream->width * stream->height;
1310 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1311 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1312 tsurf_info.planes[0].offset = 0;
1313 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1314 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1315 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1317 case TBM_FORMAT_UYVY:
1318 case TBM_FORMAT_YUYV:
1319 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1320 tsurf_info.planes[0].offset = 0;
1321 tsurf_info.size = tsurf_info.planes[0].size;
1327 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1330 /*LOGD("tbm surface %p", tsurf);*/
1334 /* check media packet format */
1335 if (cb_info->pkt_fmt) {
1336 int pkt_fmt_width = 0;
1337 int pkt_fmt_height = 0;
1338 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1340 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1341 if (pkt_fmt_mimetype != mimetype ||
1342 pkt_fmt_width != stream->width ||
1343 pkt_fmt_height != stream->height) {
1344 LOGW("change fmt: current 0x%x, %dx%d",
1345 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1346 media_format_unref(cb_info->pkt_fmt);
1347 cb_info->pkt_fmt = NULL;
1348 make_pkt_fmt = true;
1351 make_pkt_fmt = true;
1354 /* create packet format */
1356 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1357 ret = media_format_create(&cb_info->pkt_fmt);
1358 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1359 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1360 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1361 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1362 LOGW("media_format_set : 0x%x", ret);
1364 LOGW("media_format_create failed 0x%x", ret);
1368 /* create media packet */
1369 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1370 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1371 (void *)cb_info, &pkt);
1372 if (ret != MEDIA_PACKET_ERROR_NONE) {
1373 LOGE("media_packet_create failed 0x%x", ret);
1374 tbm_surface_destroy(tsurf);
1378 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1379 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1383 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1384 /* set media packet data */
1385 ret = media_packet_set_extra(pkt, (void *)mp_data);
1386 if (ret != MEDIA_PACKET_ERROR_NONE) {
1387 LOGE("media_packet_set_extra failed");
1389 _camera_media_packet_data_release(mp_data, cb_info);
1391 media_packet_destroy(pkt);
1393 /* set timestamp : msec -> nsec */
1394 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1395 LOGW("media_packet_set_pts failed");
1404 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1407 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1408 camera_media_packet_data *mp_data = NULL;
1409 tbm_surface_h tsurf = NULL;
1411 if (!pkt || !cb_info) {
1412 LOGE("NULL pointer %p %p", pkt, cb_info);
1413 return MEDIA_PACKET_FINALIZE;
1416 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1417 if (ret != MEDIA_PACKET_ERROR_NONE) {
1418 LOGE("media_packet_get_extra failed 0x%x", ret);
1419 return MEDIA_PACKET_FINALIZE;
1422 /*LOGD("mp_data %p", mp_data);*/
1424 g_mutex_lock(&cb_info->mp_data_mutex);
1426 _camera_media_packet_data_release(mp_data, cb_info);
1429 g_mutex_unlock(&cb_info->mp_data_mutex);
1431 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1432 if (ret != MEDIA_PACKET_ERROR_NONE)
1433 LOGE("get tbm_surface failed 0x%x", ret);
1436 tbm_surface_destroy(tsurf);
1440 return MEDIA_PACKET_FINALIZE;
1443 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1448 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1449 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1453 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1455 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1457 if (cb_info->user_cb[event] == NULL) {
1458 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1459 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1460 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1461 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1462 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1463 LOGW("NULL callback for event %d, return here", event);
1467 /* return buffer message should be sent for some events.
1468 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1469 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1470 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1471 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1476 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1482 muse_camera_msg_get(previous, recv_msg);
1483 muse_camera_msg_get(current, recv_msg);
1484 muse_camera_msg_get(by_policy, recv_msg);
1486 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1487 previous, current, by_policy);
1489 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1490 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1493 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1497 muse_camera_msg_get(state, recv_msg);
1499 LOGD("FOCUS state - %d", state);
1501 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1504 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1505 LOGD("CAPTURE_COMPLETED");
1506 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1508 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1509 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1510 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1513 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1517 muse_camera_msg_get(percent, recv_msg);
1519 LOGD("HDR progress - %d %%", percent);
1521 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1524 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1530 muse_camera_msg_get(policy, recv_msg);
1531 muse_camera_msg_get(previous, recv_msg);
1532 muse_camera_msg_get(current, recv_msg);
1534 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1536 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1537 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1540 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1545 muse_camera_msg_get(policy, recv_msg);
1546 muse_camera_msg_get(state, recv_msg);
1548 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1550 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1551 (camera_state_e)state, cb_info->user_data[event]);
1554 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1555 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1557 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1560 int current_state = 0;
1562 muse_camera_msg_get(error, recv_msg);
1563 muse_camera_msg_get(current_state, recv_msg);
1565 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1567 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1568 (camera_state_e)current_state, cb_info->user_data[event]);
1572 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1574 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1575 muse_camera_msg_get(param1, recv_msg);
1576 muse_camera_msg_get(param2, recv_msg);
1578 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1580 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1581 cb_info->user_cb[event] = NULL;
1582 cb_info->user_data[event] = NULL;
1583 LOGW("stop foreach callback for event %d", event);
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1604 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1606 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1608 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1610 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1613 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1615 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1616 muse_camera_msg_get(param1, recv_msg);
1618 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1620 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1621 cb_info->user_cb[event] = NULL;
1622 cb_info->user_data[event] = NULL;
1623 LOGW("stop foreach callback for event %d", event);
1627 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1628 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1631 LOGW("unhandled event %d", event);
1635 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1640 static gboolean _camera_idle_event_callback(gpointer data)
1642 camera_cb_info_s *cb_info = NULL;
1643 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1645 if (cam_idle_event == NULL) {
1646 LOGE("cam_idle_event is NULL");
1651 g_mutex_lock(&g_cam_idle_event_lock);
1653 cb_info = cam_idle_event->cb_info;
1654 if (cb_info == NULL) {
1655 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1656 g_mutex_unlock(&g_cam_idle_event_lock);
1657 goto IDLE_EVENT_CALLBACK_DONE;
1660 /* remove event from list */
1661 if (cb_info->idle_event_list)
1662 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1664 g_mutex_unlock(&g_cam_idle_event_lock);
1667 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1669 IDLE_EVENT_CALLBACK_DONE:
1671 g_free(cam_idle_event);
1672 cam_idle_event = NULL;
1677 static gpointer _camera_msg_handler_func(gpointer data)
1681 camera_message_s *cam_msg = NULL;
1682 camera_idle_event_s *cam_idle_event = NULL;
1683 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1684 camera_cb_info_s *cb_info = NULL;
1686 if (!handler_info || !handler_info->cb_info) {
1687 LOGE("NULL handler %p", handler_info);
1691 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1692 type = handler_info->type;
1694 LOGD("t:%d start", type);
1696 g_mutex_lock(&handler_info->mutex);
1698 while (g_atomic_int_get(&handler_info->running)) {
1699 if (g_queue_is_empty(handler_info->queue)) {
1700 /*LOGD("t:%d signal wait...", type);*/
1701 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1702 /*LOGD("t:%d signal received", type);*/
1704 if (g_atomic_int_get(&handler_info->running) == 0) {
1705 LOGD("t:%d stop event thread", type);
1710 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1712 g_mutex_unlock(&handler_info->mutex);
1714 if (cam_msg == NULL) {
1715 LOGE("t:%d NULL message", type);
1716 g_mutex_lock(&handler_info->mutex);
1722 if (api < MUSE_CAMERA_API_MAX) {
1725 g_mutex_lock(&cb_info->api_mutex[api]);
1727 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1728 if (cb_info->api_waiting[api] > 0) {
1729 cb_info->api_ret[api] = ret;
1730 cb_info->api_activating[api] = TRUE;
1732 /*LOGD("t:%d camera api %d - return 0x%x", type, api, ret);*/
1734 g_cond_signal(&cb_info->api_cond[api]);
1736 LOGW("no waiting for this api [%d]", api);
1739 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1742 g_mutex_unlock(&cb_info->api_mutex[api]);
1743 } else if (api == MUSE_CAMERA_CB_EVENT) {
1744 switch (cam_msg->event_class) {
1745 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1746 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1748 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1749 cam_idle_event = g_new0(camera_idle_event_s, 1);
1750 if (cam_idle_event == NULL) {
1751 LOGE("t:%d cam_idle_event alloc failed", type);
1755 cam_idle_event->event = cam_msg->event;
1756 cam_idle_event->cb_info = cb_info;
1758 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1759 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1761 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1763 g_mutex_lock(&g_cam_idle_event_lock);
1764 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1765 g_mutex_unlock(&g_cam_idle_event_lock);
1767 g_idle_add_full(G_PRIORITY_DEFAULT,
1768 (GSourceFunc)_camera_idle_event_callback,
1769 (gpointer)cam_idle_event,
1773 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1777 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1783 g_mutex_lock(&handler_info->mutex);
1786 /* remove remained event */
1787 while (!g_queue_is_empty(handler_info->queue)) {
1788 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1790 LOGD("t:%d remove camera message %p", type, cam_msg);
1794 LOGW("t:%d NULL camera message", type);
1798 g_mutex_unlock(&handler_info->mutex);
1800 LOGD("t:%d return", type);
1806 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1808 camera_idle_event_s *cam_idle_event = NULL;
1811 if (cb_info == NULL) {
1812 LOGE("cb_info is NULL");
1816 g_mutex_lock(&g_cam_idle_event_lock);
1818 if (cb_info->idle_event_list == NULL) {
1819 LOGD("No remained idle event");
1820 g_mutex_unlock(&g_cam_idle_event_lock);
1824 list = cb_info->idle_event_list;
1827 cam_idle_event = list->data;
1828 list = g_list_next(list);
1830 if (!cam_idle_event) {
1831 LOGW("Fail to remove idle event. The event is NULL");
1835 if (g_idle_remove_by_data(cam_idle_event)) {
1836 LOGW("remove idle event %p done", cam_idle_event);
1838 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1840 g_free(cam_idle_event);
1841 cam_idle_event = NULL;
1846 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1847 cam_idle_event, cam_idle_event->event);
1849 cam_idle_event->cb_info = NULL;
1851 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1854 g_list_free(cb_info->idle_event_list);
1855 cb_info->idle_event_list = NULL;
1857 g_mutex_unlock(&g_cam_idle_event_lock);
1863 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1865 camera_message_s *cam_msg = NULL;
1867 if (!cb_info || !msg) {
1868 LOGE("NULL pointer %p %p", cb_info, msg);
1872 cam_msg = g_new0(camera_message_s, 1);
1874 LOGE("failed to alloc cam_msg for [%s]", msg);
1879 cam_msg->event = event;
1880 cam_msg->event_class = event_class;
1882 if (tfd && tfd[0] >= 0)
1883 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1885 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1887 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1889 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1890 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1891 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1892 g_cond_signal(&cb_info->preview_cb_info.cond);
1893 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1894 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1895 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1896 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1897 g_cond_signal(&cb_info->capture_cb_info.cond);
1898 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1900 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1901 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1902 g_cond_signal(&cb_info->msg_handler_info.cond);
1903 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1912 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1914 int ret = CAMERA_ERROR_NONE;
1918 int event_class = -1;
1922 if (!cb_info || !msg) {
1923 LOGE("invalid ptr %p %p", cb_info, msg);
1927 /*LOGD("msg [%s]", msg);*/
1929 if (!muse_camera_msg_get(api, msg)) {
1930 LOGE("failed to get camera api");
1934 if (api == MUSE_CAMERA_CB_EVENT) {
1935 if (!muse_camera_msg_get(event, msg) ||
1936 !muse_camera_msg_get(event_class, msg)) {
1937 LOGE("failed to get camera event or event_class [%s]", msg);
1941 if (!muse_camera_msg_get(api_class, msg)) {
1942 LOGE("failed to get camera api_class [%s]", msg);
1947 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1948 if (api >= MUSE_CAMERA_API_MAX) {
1949 LOGE("invalid api %d", api);
1953 if (!muse_camera_msg_get(ret, msg)) {
1954 LOGE("failed to get camera ret");
1958 g_mutex_lock(&cb_info->api_mutex[api]);
1961 case MUSE_CAMERA_API_CREATE:
1962 if (ret != CAMERA_ERROR_NONE) {
1963 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1964 LOGE("camera create error 0x%x. close client cb handler", ret);
1967 case MUSE_CAMERA_API_DESTROY:
1968 if (ret == CAMERA_ERROR_NONE) {
1969 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1970 LOGD("camera destroy done. close client cb handler");
1974 muse_camera_msg_get(get_type, msg);
1975 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1976 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1977 muse_camera_msg_get(get_index, msg);
1980 case MUSE_CAMERA_GET_TYPE_INT:
1981 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1983 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1984 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1985 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1987 case MUSE_CAMERA_GET_TYPE_ARRAY:
1988 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1989 muse_core_msg_deserialize("get_value",
1990 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1991 LOGD("get display roi %d,%d,%dx%d",
1992 cb_info->get_display_roi_area[0],
1993 cb_info->get_display_roi_area[1],
1994 cb_info->get_display_roi_area[2],
1995 cb_info->get_display_roi_area[3]);
1997 muse_core_msg_deserialize("get_value",
1998 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1999 LOGD("get geotag %lf, %lf, %lf",
2000 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2003 case MUSE_CAMERA_GET_TYPE_STRING:
2004 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2007 LOGW("unknown type %d", get_type);
2014 if (cb_info->api_waiting[api] > 0) {
2015 cb_info->api_ret[api] = ret;
2016 cb_info->api_activating[api] = TRUE;
2018 g_cond_signal(&cb_info->api_cond[api]);
2020 LOGW("no waiting for this api [%d]", api);
2023 g_mutex_unlock(&cb_info->api_mutex[api]);
2024 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2025 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2027 LOGW("unknown camera api %d, class %d", api, api_class);
2034 static gpointer _camera_msg_recv_func(gpointer data)
2037 int recv_length = 0;
2038 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2039 char *recv_msg = NULL;
2040 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2043 LOGE("cb_info NULL");
2047 LOGD("start - fd : %d", cb_info->fd);
2049 recv_msg = cb_info->recv_msg;
2051 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2052 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2055 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2056 if (recv_length <= 0) {
2057 cb_info->is_server_connected = FALSE;
2058 LOGE("receive msg failed - server disconnected");
2064 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2067 recv_msg[recv_length] = '\0';
2069 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2071 __camera_process_msg(cb_info, recv_msg, tfd);
2074 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2076 if (!cb_info->is_server_connected) {
2077 char *error_msg = NULL;
2079 if (cb_info->bufmgr == NULL) {
2080 LOGE("No need to send error(handle is not created)");
2084 if (cb_info->fd < 0) {
2085 LOGE("fd is closed in client side");
2089 /* send error msg for server disconnection */
2090 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2091 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2092 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2096 LOGE("error_msg failed");
2100 __camera_add_msg_to_queue(cb_info,
2101 MUSE_CAMERA_CB_EVENT,
2102 MUSE_CAMERA_EVENT_TYPE_ERROR,
2103 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2107 muse_core_msg_free(error_msg);
2110 LOGE("add error msg for service disconnection done");
2117 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2118 int type, const char *thread_name, camera_cb_info_s *cb_info)
2120 if (!handler_info || !thread_name || !cb_info) {
2121 LOGE("t:%d NULL %p %p %p",
2122 type, handler_info, thread_name, cb_info);
2128 handler_info->type = type;
2129 handler_info->queue = g_queue_new();
2130 if (handler_info->queue == NULL) {
2131 LOGE("t:%d queue failed", type);
2135 g_mutex_init(&handler_info->mutex);
2136 g_cond_init(&handler_info->cond);
2138 handler_info->cb_info = (void *)cb_info;
2139 g_atomic_int_set(&handler_info->running, 1);
2141 handler_info->thread = g_thread_try_new(thread_name,
2142 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2143 if (handler_info->thread == NULL) {
2144 LOGE("t:%d thread failed", type);
2146 g_mutex_clear(&handler_info->mutex);
2147 g_cond_clear(&handler_info->cond);
2148 g_queue_free(handler_info->queue);
2149 handler_info->queue = NULL;
2154 LOGD("t:%d done", type);
2160 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2164 if (!handler_info) {
2165 LOGE("NULL handler");
2169 if (!handler_info->thread) {
2170 LOGW("thread is not created");
2174 type = handler_info->type;
2176 LOGD("t:%d thread %p", type, handler_info->thread);
2178 g_mutex_lock(&handler_info->mutex);
2179 g_atomic_int_set(&handler_info->running, 0);
2180 g_cond_signal(&handler_info->cond);
2181 g_mutex_unlock(&handler_info->mutex);
2183 g_thread_join(handler_info->thread);
2184 handler_info->thread = NULL;
2186 g_mutex_clear(&handler_info->mutex);
2187 g_cond_clear(&handler_info->cond);
2188 g_queue_free(handler_info->queue);
2189 handler_info->queue = NULL;
2191 LOGD("t:%d done", type);
2197 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2199 camera_cb_info_s *cb_info = NULL;
2202 g_return_val_if_fail(sockfd > 0, NULL);
2204 cb_info = g_new0(camera_cb_info_s, 1);
2205 if (cb_info == NULL) {
2206 LOGE("cb_info failed");
2210 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2212 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2213 g_mutex_init(&cb_info->api_mutex[i]);
2214 g_cond_init(&cb_info->api_cond[i]);
2217 g_mutex_init(&cb_info->fd_lock);
2218 g_mutex_init(&cb_info->mp_data_mutex);
2220 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2221 g_mutex_init(&cb_info->user_cb_mutex[i]);
2223 /* message handler thread */
2224 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2225 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2226 LOGE("msg_handler_info failed");
2230 /* message handler thread for preview callback */
2231 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2232 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2233 LOGE("preview_cb_info failed");
2237 /* message handler thread for capture callback */
2238 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2239 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2240 LOGE("capture_cb_info failed");
2244 cb_info->fd = sockfd;
2245 cb_info->preview_cb_flag = 0;
2247 /* message receive thread */
2248 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2249 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2250 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2251 if (cb_info->msg_recv_thread == NULL) {
2252 LOGE("message receive thread creation failed");
2257 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2258 cb_info->fds[i] = -1;
2260 cb_info->is_server_connected = TRUE;
2266 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2267 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2268 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2270 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2271 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2273 g_mutex_clear(&cb_info->fd_lock);
2274 g_mutex_clear(&cb_info->mp_data_mutex);
2276 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2277 g_mutex_clear(&cb_info->api_mutex[i]);
2278 g_cond_clear(&cb_info->api_cond[i]);
2289 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2293 g_return_if_fail(cb_info != NULL);
2295 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2297 g_thread_join(cb_info->msg_recv_thread);
2298 cb_info->msg_recv_thread = NULL;
2300 LOGD("msg_recv thread removed");
2302 /* destroy msg handler threads */
2303 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2304 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2305 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2307 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2308 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2310 g_mutex_clear(&cb_info->fd_lock);
2311 g_mutex_clear(&cb_info->mp_data_mutex);
2313 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2314 g_mutex_clear(&cb_info->api_mutex[i]);
2315 g_cond_clear(&cb_info->api_cond[i]);
2318 if (cb_info->fd > -1) {
2319 muse_client_close(cb_info->fd);
2323 if (cb_info->bufmgr) {
2324 tbm_bufmgr_deinit(cb_info->bufmgr);
2325 cb_info->bufmgr = NULL;
2327 if (cb_info->pkt_fmt) {
2328 media_format_unref(cb_info->pkt_fmt);
2329 cb_info->pkt_fmt = NULL;
2332 if (cb_info->dp_interface) {
2333 mm_display_interface_deinit(cb_info->dp_interface);
2334 cb_info->dp_interface = NULL;
2337 cb_info->preview_cb_flag = 0;
2345 int _camera_start_evas_rendering(camera_h camera)
2347 camera_cli_s *pc = (camera_cli_s *)camera;
2349 if (!pc || !pc->cb_info) {
2350 LOGE("NULL handle");
2351 return CAMERA_ERROR_INVALID_PARAMETER;
2356 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2357 LOGE("EVAS surface is not set");
2358 return CAMERA_ERROR_NONE;
2361 /* set evas render flag as RUN */
2362 pc->cb_info->run_evas_render = true;
2364 return CAMERA_ERROR_NONE;
2368 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2370 int ret = CAMERA_ERROR_NONE;
2371 camera_cli_s *pc = (camera_cli_s *)camera;
2373 if (!pc || !pc->cb_info) {
2374 LOGE("NULL handle");
2375 return CAMERA_ERROR_INVALID_PARAMETER;
2378 LOGD("stop - keep screen %d", keep_screen);
2380 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2381 LOGE("EVAS surface is not set");
2382 return CAMERA_ERROR_NONE;
2385 /* set evas render flag as STOP and release buffers */
2386 pc->cb_info->run_evas_render = false;
2388 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2389 if (ret == MM_ERROR_NONE) {
2390 ret = CAMERA_ERROR_NONE;
2392 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2393 ret = CAMERA_ERROR_INVALID_OPERATION;
2400 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2402 int ret = CAMERA_ERROR_NONE;
2404 int module_index = -1;
2406 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2408 /* create muse connection */
2409 if (!key || !value) {
2410 LOGE("NULL pointer");
2411 return CAMERA_ERROR_INVALID_PARAMETER;
2414 sock_fd = muse_client_new();
2416 LOGE("muse_client_new failed");
2417 return CAMERA_ERROR_INVALID_OPERATION;
2420 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2421 LOGE("muse client get module index failed");
2422 ret = CAMERA_ERROR_INVALID_OPERATION;
2426 msg = muse_core_msg_new(api,
2427 MUSE_TYPE_INT, "module", module_index,
2428 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2432 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2436 ret = muse_core_msg_send(sock_fd, msg);
2438 muse_core_msg_free(msg);
2442 LOGE("send msg failed");
2443 ret = CAMERA_ERROR_INVALID_OPERATION;
2447 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2449 LOGE("recv msg failed %d", errno);
2450 ret = CAMERA_ERROR_INVALID_OPERATION;
2454 if (!muse_camera_msg_get(ret, recv_msg)) {
2455 LOGE("failed to get return value from msg [%s]", recv_msg);
2456 ret = CAMERA_ERROR_INVALID_OPERATION;
2460 if (ret == CAMERA_ERROR_NONE)
2461 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2463 LOGD("api %d - value %d", api, *value);
2467 muse_client_close(sock_fd);
2475 int camera_create(camera_device_e device, camera_h *camera)
2478 char *send_msg = NULL;
2480 int ret = CAMERA_ERROR_NONE;
2481 camera_cli_s *pc = NULL;
2482 tbm_bufmgr bufmgr = NULL;
2484 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2485 int module_index = -1;
2486 int device_type = (int)device;
2489 LOGE("NULL pointer");
2490 return CAMERA_ERROR_INVALID_PARAMETER;
2493 sock_fd = muse_client_new();
2495 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2496 ret = CAMERA_ERROR_INVALID_OPERATION;
2500 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2501 LOGE("muse client get module index failed");
2502 ret = CAMERA_ERROR_INVALID_OPERATION;
2506 send_msg = muse_core_msg_new(api,
2507 MUSE_TYPE_INT, "module", module_index,
2508 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2513 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2517 send_ret = muse_core_msg_send(sock_fd, send_msg);
2519 muse_core_msg_free(send_msg);
2523 LOGE("send msg failed %d", errno);
2524 ret = CAMERA_ERROR_INVALID_OPERATION;
2528 pc = g_new0(camera_cli_s, 1);
2530 LOGE("camera_cli_s alloc failed");
2531 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2535 bufmgr = tbm_bufmgr_init(-1);
2536 if (bufmgr == NULL) {
2537 LOGE("get tbm bufmgr failed");
2538 ret = CAMERA_ERROR_INVALID_OPERATION;
2542 pc->cb_info = _camera_client_callback_new(sock_fd);
2543 if (pc->cb_info == NULL) {
2544 LOGE("cb_info alloc failed");
2545 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2551 LOGD("cb info : %d", pc->cb_info->fd);
2553 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2555 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2557 if (ret == CAMERA_ERROR_NONE) {
2558 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2559 int user_buffer_supported = 0;
2560 intptr_t handle = 0;
2562 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2564 LOGE("Receiving Handle Failed!!");
2565 ret = CAMERA_ERROR_INVALID_OPERATION;
2569 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2570 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2572 pc->remote_handle = handle;
2573 pc->cb_info->bufmgr = bufmgr;
2574 pc->cb_info->preview_format = preview_format;
2575 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2576 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2578 LOGD("default preview format %d, user buffer %d",
2579 preview_format, user_buffer_supported);
2581 *camera = (camera_h)pc;
2583 /* get display interface handle */
2584 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2585 LOGW("display interface init failed");
2594 tbm_bufmgr_deinit(bufmgr);
2599 muse_client_close(sock_fd);
2605 int temp_fd = pc->cb_info->fd;
2607 /* pc->cb_info->fd should be closed,
2608 because g_thread_join for msg_recv_thread is not returned
2609 in _camera_client_callback_destroy. */
2611 pc->cb_info->fd = -1;
2612 muse_client_close(temp_fd);
2615 _camera_client_callback_destroy(pc->cb_info);
2622 LOGE("camera create error : 0x%x", ret);
2629 int camera_change_device(camera_h camera, camera_device_e device)
2632 int ret = CAMERA_ERROR_NONE;
2633 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2634 camera_cli_s *pc = (camera_cli_s *)camera;
2635 camera_msg_param param;
2637 if (!pc || !pc->cb_info) {
2638 LOGE("NULL handle");
2639 return CAMERA_ERROR_INVALID_PARAMETER;
2642 CAMERA_MSG_PARAM_SET(param, INT, device);
2644 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2646 if (ret == CAMERA_ERROR_NONE) {
2647 /* reset callback and user data */
2648 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2649 pc->cb_info->user_cb[i] = NULL;
2650 pc->cb_info->user_data[i] = NULL;
2652 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2659 int camera_destroy(camera_h camera)
2661 int ret = CAMERA_ERROR_NONE;
2662 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2663 camera_cli_s *pc = (camera_cli_s *)camera;
2665 if (!pc || !pc->cb_info) {
2666 LOGE("NULL handle");
2667 return CAMERA_ERROR_INVALID_PARAMETER;
2672 if (pc->cb_info->is_server_connected)
2673 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2675 LOGW("server disconnected. release resource without send message.");
2677 if (ret == CAMERA_ERROR_NONE) {
2678 _camera_deactivate_idle_event_all(pc->cb_info);
2679 _camera_client_callback_destroy(pc->cb_info);
2686 LOGD("ret : 0x%x", ret);
2691 int camera_start_preview(camera_h camera)
2693 int ret = CAMERA_ERROR_NONE;
2694 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2695 camera_cli_s *pc = (camera_cli_s *)camera;
2696 camera_state_e current_state = CAMERA_STATE_NONE;
2698 if (!pc || !pc->cb_info) {
2699 LOGE("NULL handle");
2700 return CAMERA_ERROR_INVALID_PARAMETER;
2703 LOGD("Enter : preview format %d, display type %d",
2704 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2706 ret = camera_get_state(camera, ¤t_state);
2707 if (ret != CAMERA_ERROR_NONE) {
2708 LOGE("failed to get current state 0x%x", ret);
2712 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2713 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2714 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2715 pc->cb_info->dp_info.type);
2716 return CAMERA_ERROR_INVALID_OPERATION;
2719 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2720 if (!_camera_allocate_preview_buffer(camera))
2721 return CAMERA_ERROR_INVALID_OPERATION;
2723 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2725 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2728 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2729 ret = _camera_start_evas_rendering(camera);
2730 if (ret != CAMERA_ERROR_NONE) {
2731 LOGE("stop preview because of error");
2732 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2736 LOGD("ret : 0x%x", ret);
2742 int camera_stop_preview(camera_h camera)
2744 int ret = CAMERA_ERROR_NONE;
2745 camera_cli_s *pc = (camera_cli_s *)camera;
2746 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2747 camera_state_e current_state = CAMERA_STATE_NONE;
2749 if (!pc || !pc->cb_info) {
2750 LOGE("NULL handle");
2751 return CAMERA_ERROR_INVALID_PARAMETER;
2757 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2758 ret = camera_get_state(camera, ¤t_state);
2759 if (ret != CAMERA_ERROR_NONE) {
2760 LOGE("failed to get current state 0x%x", ret);
2764 if (current_state == CAMERA_STATE_PREVIEW) {
2765 ret = _camera_stop_evas_rendering(camera, false);
2766 if (ret != CAMERA_ERROR_NONE)
2771 /* send stop preview message */
2772 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2774 if (ret == CAMERA_ERROR_NONE) {
2775 if (pc->cb_info->user_buffer_supported)
2776 _camera_release_preview_buffer(camera);
2777 } else if (current_state == CAMERA_STATE_PREVIEW) {
2778 LOGW("restart evas rendering");
2779 _camera_start_evas_rendering(camera);
2782 LOGD("ret : 0x%x", ret);
2788 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2790 int ret = CAMERA_ERROR_NONE;
2791 camera_cli_s *pc = (camera_cli_s *)camera;
2792 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2794 if (!pc || !pc->cb_info) {
2795 LOGE("NULL handle");
2796 return CAMERA_ERROR_INVALID_PARAMETER;
2801 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2802 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2809 LOGD("ret : 0x%x", ret);
2815 bool camera_is_supported_continuous_capture(camera_h camera)
2817 int ret = CAMERA_ERROR_NONE;
2818 camera_cli_s *pc = (camera_cli_s *)camera;
2819 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2821 if (!pc || !pc->cb_info) {
2822 LOGE("NULL handle");
2823 return CAMERA_ERROR_INVALID_PARAMETER;
2828 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2831 LOGE("error is occurred 0x%x", ret);
2835 LOGD("ret : %d", ret);
2841 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)
2843 int ret = CAMERA_ERROR_NONE;
2844 camera_cli_s *pc = (camera_cli_s *)camera;
2845 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2846 camera_msg_param param;
2849 if (!pc || !pc->cb_info) {
2850 LOGE("NULL handle");
2851 return CAMERA_ERROR_INVALID_PARAMETER;
2856 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2857 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2859 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2860 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2862 value = (count << 16) | interval;
2863 CAMERA_MSG_PARAM_SET(param, INT, value);
2865 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2867 LOGD("ret : 0x%x", ret);
2873 int camera_stop_continuous_capture(camera_h camera)
2875 int ret = CAMERA_ERROR_NONE;
2876 camera_cli_s *pc = (camera_cli_s *)camera;
2877 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2879 if (!pc || !pc->cb_info) {
2880 LOGE("NULL handle");
2881 return CAMERA_ERROR_INVALID_PARAMETER;
2886 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2888 LOGD("ret : 0x%x", ret);
2894 bool camera_is_supported_face_detection(camera_h camera)
2896 int ret = CAMERA_ERROR_NONE;
2897 camera_cli_s *pc = (camera_cli_s *)camera;
2898 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2900 if (!pc || !pc->cb_info) {
2901 LOGE("NULL handle");
2902 return CAMERA_ERROR_INVALID_PARAMETER;
2907 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2910 LOGE("error is occurred 0x%x", ret);
2914 LOGD("ret : %d", ret);
2920 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2922 int ret = CAMERA_ERROR_NONE;
2923 camera_cli_s *pc = (camera_cli_s *)camera;
2924 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2926 if (!pc || !pc->cb_info) {
2927 LOGE("NULL handle");
2928 return CAMERA_ERROR_INVALID_PARAMETER;
2933 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2936 LOGE("error is occurred 0x%x", ret);
2940 LOGD("ret : %d", ret);
2946 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2948 int ret = CAMERA_ERROR_NONE;
2949 camera_cli_s *pc = (camera_cli_s *)camera;
2950 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2952 if (!pc || !pc->cb_info) {
2953 LOGE("NULL handle");
2954 return CAMERA_ERROR_INVALID_PARAMETER;
2959 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2962 LOGE("error is occurred 0x%x", ret);
2966 LOGD("ret : %d", ret);
2971 int camera_get_device_count(camera_h camera, int *device_count)
2973 int ret = CAMERA_ERROR_NONE;
2974 camera_cli_s *pc = (camera_cli_s *)camera;
2975 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2977 if (!pc || !pc->cb_info) {
2978 LOGE("NULL handle");
2979 return CAMERA_ERROR_INVALID_PARAMETER;
2984 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2986 if (ret == CAMERA_ERROR_NONE)
2987 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2989 LOGD("ret : 0x%x", ret);
2994 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2996 int ret = CAMERA_ERROR_NONE;
2997 camera_cli_s *pc = (camera_cli_s *)camera;
2998 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3000 if (!pc || !pc->cb_info) {
3001 LOGE("NULL handle");
3002 return CAMERA_ERROR_INVALID_PARAMETER;
3007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3009 if (ret == CAMERA_ERROR_NONE) {
3010 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3012 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3013 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3015 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3018 LOGD("ret : 0x%x", ret);
3023 int camera_stop_face_detection(camera_h camera)
3025 int ret = CAMERA_ERROR_NONE;
3026 camera_cli_s *pc = (camera_cli_s *)camera;
3027 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3029 if (!pc || !pc->cb_info) {
3030 LOGE("NULL handle");
3031 return CAMERA_ERROR_INVALID_PARAMETER;
3036 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3038 if (ret == CAMERA_ERROR_NONE) {
3039 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3041 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3042 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3044 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3047 LOGD("ret : 0x%x", ret);
3052 int camera_get_state(camera_h camera, camera_state_e *state)
3054 int ret = CAMERA_ERROR_NONE;
3055 camera_cli_s *pc = (camera_cli_s *)camera;
3056 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3058 if (!pc || !pc->cb_info || !state) {
3059 LOGE("NULL pointer %p %p", pc, state);
3060 return CAMERA_ERROR_INVALID_PARAMETER;
3065 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3067 if (ret == CAMERA_ERROR_NONE)
3068 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3070 LOGD("ret : 0x%x", ret);
3075 int camera_start_focusing(camera_h camera, bool continuous)
3077 int ret = CAMERA_ERROR_NONE;
3078 camera_cli_s *pc = (camera_cli_s *)camera;
3079 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3080 camera_msg_param param;
3081 int is_continuous = (int)continuous;
3083 if (!pc || !pc->cb_info) {
3084 LOGE("NULL handle");
3085 return CAMERA_ERROR_INVALID_PARAMETER;
3090 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3092 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3094 LOGD("ret : 0x%x", ret);
3099 int camera_cancel_focusing(camera_h camera)
3101 int ret = CAMERA_ERROR_NONE;
3102 camera_cli_s *pc = (camera_cli_s *)camera;
3103 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3105 if (!pc || !pc->cb_info) {
3106 LOGE("NULL handle");
3107 return CAMERA_ERROR_INVALID_PARAMETER;
3110 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3112 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3114 LOGD("ret : 0x%x", ret);
3120 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3122 int mm_ret = MM_ERROR_NONE;
3123 int ret = CAMERA_ERROR_NONE;
3124 camera_cli_s *pc = (camera_cli_s *)camera;
3125 camera_cb_info_s *cb_info = NULL;
3126 camera_state_e current_state = CAMERA_STATE_NONE;
3127 camera_msg_param param;
3128 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3129 muse_camera_display_info_s *dp_info = NULL;
3131 if (!pc || !pc->cb_info) {
3132 LOGE("NULL handle");
3133 return CAMERA_ERROR_INVALID_PARAMETER;
3136 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3137 LOGE("invalid type %d", type);
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3142 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3143 return CAMERA_ERROR_INVALID_PARAMETER;
3146 cb_info = (camera_cb_info_s *)pc->cb_info;
3147 dp_info = &cb_info->dp_info;
3149 ret = camera_get_state(camera, ¤t_state);
3150 if (ret != CAMERA_ERROR_NONE) {
3151 LOGE("failed to get current state 0x%x", ret);
3155 if (current_state != CAMERA_STATE_CREATED) {
3156 LOGE("INVALID_STATE : current %d", current_state);
3157 return CAMERA_ERROR_INVALID_STATE;
3160 LOGD("Enter - type : %d, display : %p", type, display);
3162 if (type != MM_DISPLAY_TYPE_NONE) {
3163 /* check display interface handle */
3164 if (!cb_info->dp_interface) {
3165 LOGE("display interface not supported");
3166 return CAMERA_ERROR_NOT_SUPPORTED;
3169 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3170 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3171 LOGE("[NOT_SUPPORTED] type %d", type);
3172 return CAMERA_ERROR_NOT_SUPPORTED;
3173 } else if (mm_ret != MM_ERROR_NONE) {
3174 LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3175 return CAMERA_ERROR_INVALID_OPERATION;
3178 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3179 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3181 LOGD("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3182 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3183 dp_info->window_rect.width, dp_info->window_rect.height);
3184 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3186 camera_flip_e flip = CAMERA_FLIP_NONE;
3187 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3188 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3195 camera_get_display_flip(camera, &flip);
3196 camera_get_display_mode(camera, &mode);
3197 camera_get_display_rotation(camera, &rotation);
3198 camera_is_display_visible(camera, &visible);
3199 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3201 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3202 flip, mode, rotation, visible, x, y, width, height);
3204 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3205 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3206 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3207 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3209 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3210 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3215 if (mm_ret != MM_ERROR_NONE) {
3216 LOGE("mm_ret 0x%x failed", mm_ret);
3217 return CAMERA_ERROR_INVALID_OPERATION;
3220 dp_info->type = type;
3222 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3224 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3226 if (ret == CAMERA_ERROR_NONE) {
3227 if (type == MM_DISPLAY_TYPE_EVAS)
3228 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3235 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3237 LOGD("type %d, display %p", type, display);
3238 return _camera_set_display(camera, (mm_display_type_e)type, display);
3242 int camera_set_preview_resolution(camera_h camera, int width, int height)
3244 int ret = CAMERA_ERROR_NONE;
3245 camera_state_e current_state = CAMERA_STATE_NONE;
3246 camera_cli_s *pc = (camera_cli_s *)camera;
3247 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3248 camera_msg_param param;
3251 if (!pc || !pc->cb_info) {
3252 LOGE("NULL handle");
3253 return CAMERA_ERROR_INVALID_PARAMETER;
3256 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3257 ret = camera_get_state(camera, ¤t_state);
3258 if (ret != CAMERA_ERROR_NONE) {
3259 LOGE("failed to get current state 0x%x", ret);
3263 if (current_state == CAMERA_STATE_PREVIEW) {
3264 ret = _camera_stop_evas_rendering(camera, true);
3265 if (ret != CAMERA_ERROR_NONE)
3270 value = (width << 16) | height;
3271 CAMERA_MSG_PARAM_SET(param, INT, value);
3273 LOGD("%dx%d -> 0x%x", width, height, value);
3275 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3277 LOGD("ret : 0x%x", ret);
3279 if (current_state == CAMERA_STATE_PREVIEW) {
3280 LOGW("restart evas rendering");
3281 _camera_start_evas_rendering(camera);
3288 int camera_set_capture_resolution(camera_h camera, int width, int height)
3290 int ret = CAMERA_ERROR_NONE;
3291 camera_cli_s *pc = (camera_cli_s *)camera;
3292 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3293 camera_msg_param param;
3296 if (!pc || !pc->cb_info) {
3297 LOGE("NULL handle");
3298 return CAMERA_ERROR_INVALID_PARAMETER;
3303 value = (width << 16) | height;
3304 CAMERA_MSG_PARAM_SET(param, INT, value);
3306 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3308 LOGD("ret : 0x%x", ret);
3314 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3316 int ret = CAMERA_ERROR_NONE;
3317 int set_format = (int)format;
3318 camera_cli_s *pc = (camera_cli_s *)camera;
3319 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3320 camera_msg_param param;
3322 if (!pc || !pc->cb_info) {
3323 LOGE("NULL handle");
3324 return CAMERA_ERROR_INVALID_PARAMETER;
3327 LOGD("Enter - format %d", set_format);
3329 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3331 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3333 LOGD("ret : 0x%x", ret);
3339 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3341 int ret = CAMERA_ERROR_NONE;
3342 int set_format = (int)format;
3343 camera_msg_param param;
3344 camera_cli_s *pc = (camera_cli_s *)camera;
3345 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3347 if (!pc || !pc->cb_info) {
3348 LOGE("NULL handle");
3349 return CAMERA_ERROR_INVALID_PARAMETER;
3352 LOGD("Enter - format %d", set_format);
3354 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3356 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3358 if (ret == CAMERA_ERROR_NONE)
3359 pc->cb_info->preview_format = set_format;
3361 LOGD("ret : 0x%x", ret);
3367 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3369 int ret = CAMERA_ERROR_NONE;
3370 camera_cli_s *pc = (camera_cli_s *)camera;
3371 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3373 if (!pc || !pc->cb_info || !width || !height) {
3374 LOGE("NULL pointer %p %p %p", pc, width, height);
3375 return CAMERA_ERROR_INVALID_PARAMETER;
3380 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3382 if (ret == CAMERA_ERROR_NONE) {
3383 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3384 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3387 LOGD("ret : 0x%x", ret);
3393 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3395 int ret = CAMERA_ERROR_NONE;
3396 int set_rotation = (int)rotation;
3397 camera_cli_s *pc = (camera_cli_s *)camera;
3398 camera_msg_param param;
3400 if (!pc || !pc->cb_info) {
3401 LOGE("NULL handle");
3402 return CAMERA_ERROR_INVALID_PARAMETER;
3405 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3406 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3407 if (ret != MM_ERROR_NONE) {
3408 LOGE("failed to set rotation for evas surface 0x%x", ret);
3409 return CAMERA_ERROR_INVALID_OPERATION;
3413 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3415 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3421 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3423 int ret = CAMERA_ERROR_NONE;
3424 camera_cli_s *pc = (camera_cli_s *)camera;
3426 if (!pc || !pc->cb_info || !rotation) {
3427 LOGE("NULL pointer %p %p", pc, rotation);
3428 return CAMERA_ERROR_INVALID_PARAMETER;
3431 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3433 if (ret == CAMERA_ERROR_NONE)
3434 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3440 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3442 int ret = CAMERA_ERROR_NONE;
3443 int set_flip = (int)flip;
3444 camera_cli_s *pc = (camera_cli_s *)camera;
3445 camera_msg_param param;
3447 if (!pc || !pc->cb_info) {
3448 LOGE("NULL handle");
3449 return CAMERA_ERROR_INVALID_PARAMETER;
3452 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3453 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3454 if (ret != MM_ERROR_NONE) {
3455 LOGE("failed to set flip for evas surface 0x%x", ret);
3456 return CAMERA_ERROR_INVALID_OPERATION;
3460 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3462 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3468 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3470 int ret = CAMERA_ERROR_NONE;
3471 camera_cli_s *pc = (camera_cli_s *)camera;
3473 if (!pc || !pc->cb_info || !flip) {
3474 LOGE("NULL pointer %p %p", pc, flip);
3475 return CAMERA_ERROR_INVALID_PARAMETER;
3478 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3480 if (ret == CAMERA_ERROR_NONE)
3481 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3487 int camera_set_display_visible(camera_h camera, bool visible)
3489 int ret = CAMERA_ERROR_NONE;
3490 int set_visible = (int)visible;
3491 camera_cli_s *pc = (camera_cli_s *)camera;
3492 camera_msg_param param;
3494 if (!pc || !pc->cb_info) {
3495 LOGE("NULL handle");
3496 return CAMERA_ERROR_INVALID_PARAMETER;
3499 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3500 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3501 if (ret != MM_ERROR_NONE) {
3502 LOGE("failed to set visible for evas surface 0x%x", ret);
3503 return CAMERA_ERROR_INVALID_OPERATION;
3507 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3509 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3515 int camera_is_display_visible(camera_h camera, bool *visible)
3517 int ret = CAMERA_ERROR_NONE;
3518 camera_cli_s *pc = (camera_cli_s *)camera;
3520 if (!pc || !pc->cb_info || !visible) {
3521 LOGE("NULL pointer %p %p", pc, visible);
3522 return CAMERA_ERROR_INVALID_PARAMETER;
3525 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3527 if (ret == CAMERA_ERROR_NONE)
3528 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3534 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3536 int ret = CAMERA_ERROR_NONE;
3537 int set_mode = (int)mode;
3538 camera_cli_s *pc = (camera_cli_s *)camera;
3539 camera_msg_param param;
3541 if (!pc || !pc->cb_info) {
3542 LOGE("NULL handle");
3543 return CAMERA_ERROR_INVALID_PARAMETER;
3546 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3547 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3548 if (ret != MM_ERROR_NONE) {
3549 LOGE("failed to set geometry for evas surface 0x%x", ret);
3550 return CAMERA_ERROR_INVALID_OPERATION;
3554 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3556 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3562 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3564 int ret = CAMERA_ERROR_NONE;
3565 camera_cli_s *pc = (camera_cli_s *)camera;
3567 if (!pc || !pc->cb_info || !mode) {
3568 LOGE("NULL pointer %p %p", pc, mode);
3569 return CAMERA_ERROR_INVALID_PARAMETER;
3572 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3574 if (ret == CAMERA_ERROR_NONE)
3575 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3581 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3583 int ret = CAMERA_ERROR_NONE;
3584 int set_hint = (int)hint;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3586 camera_msg_param param;
3588 if (!pc || !pc->cb_info) {
3589 LOGE("NULL handle");
3590 return CAMERA_ERROR_INVALID_PARAMETER;
3593 LOGD("Enter - hint %d", set_hint);
3595 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3597 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3603 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3605 int ret = CAMERA_ERROR_NONE;
3606 camera_cli_s *pc = (camera_cli_s *)camera;
3607 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3609 if (!pc || !pc->cb_info || !hint) {
3610 LOGE("NULL pointer %p %p", pc, hint);
3611 return CAMERA_ERROR_INVALID_PARAMETER;
3614 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3616 if (ret == CAMERA_ERROR_NONE) {
3617 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3618 LOGD("display reuse hint %d", *hint);
3625 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
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_CAPTURE_RESOLUTION;
3631 if (!pc || !pc->cb_info || !width || !height) {
3632 LOGE("NULL pointer %p %p %p", pc, width, height);
3633 return CAMERA_ERROR_INVALID_PARAMETER;
3638 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3640 if (ret == CAMERA_ERROR_NONE) {
3641 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3642 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3645 LOGD("ret : 0x%x", ret);
3651 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3653 int ret = CAMERA_ERROR_NONE;
3654 camera_cli_s *pc = (camera_cli_s *)camera;
3655 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3657 if (!pc || !pc->cb_info || !format) {
3658 LOGE("NULL pointer %p %p", pc, format);
3659 return CAMERA_ERROR_INVALID_PARAMETER;
3664 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3666 if (ret == CAMERA_ERROR_NONE)
3667 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3669 LOGD("ret : 0x%x", ret);
3675 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3677 int ret = CAMERA_ERROR_NONE;
3678 camera_cli_s *pc = (camera_cli_s *)camera;
3679 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3681 if (!pc || !pc->cb_info || !format) {
3682 LOGE("NULL pointer %p %p", pc, format);
3683 return CAMERA_ERROR_INVALID_PARAMETER;
3688 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3690 if (ret == CAMERA_ERROR_NONE)
3691 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3693 LOGD("ret : 0x%x", ret);
3699 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3701 int ret = CAMERA_ERROR_NONE;
3702 camera_cli_s *pc = (camera_cli_s *)camera;
3703 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3705 if (!pc || !pc->cb_info || !facing_direction) {
3706 LOGE("NULL pointer %p %p", pc, facing_direction);
3707 return CAMERA_ERROR_INVALID_PARAMETER;
3712 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3714 if (ret == CAMERA_ERROR_NONE)
3715 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3717 LOGD("ret : 0x%x", ret);
3723 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3725 int ret = CAMERA_ERROR_NONE;
3726 camera_cli_s *pc = (camera_cli_s *)camera;
3727 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3729 if (!pc || !pc->cb_info || !callback) {
3730 LOGE("NULL pointer %p %p", pc, callback);
3731 return CAMERA_ERROR_INVALID_PARAMETER;
3736 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3738 if (ret == CAMERA_ERROR_NONE) {
3739 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3741 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3742 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3744 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3746 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3749 LOGD("ret : 0x%x", ret);
3755 int camera_unset_preview_cb(camera_h camera)
3757 int ret = CAMERA_ERROR_NONE;
3758 camera_cli_s *pc = (camera_cli_s *)camera;
3759 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3761 if (!pc || !pc->cb_info) {
3762 LOGE("NULL handle");
3763 return CAMERA_ERROR_INVALID_PARAMETER;
3768 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3770 if (ret == CAMERA_ERROR_NONE) {
3771 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3773 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3774 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3776 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3778 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3781 LOGD("ret : 0x%x", ret);
3787 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3789 int ret = CAMERA_ERROR_NONE;
3790 camera_cli_s *pc = (camera_cli_s *)camera;
3791 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3793 if (!pc || !pc->cb_info) {
3794 LOGE("NULL handle");
3795 return CAMERA_ERROR_INVALID_PARAMETER;
3798 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3799 LOGE("NOT SUPPORTED");
3800 return CAMERA_ERROR_NOT_SUPPORTED;
3803 if (callback == NULL) {
3804 LOGE("NULL callback");
3805 return CAMERA_ERROR_INVALID_PARAMETER;
3810 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3812 if (ret == CAMERA_ERROR_NONE) {
3813 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3815 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3816 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3818 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3821 LOGD("ret : 0x%x", ret);
3827 int camera_unset_media_packet_preview_cb(camera_h camera)
3829 int ret = CAMERA_ERROR_NONE;
3830 camera_cli_s *pc = (camera_cli_s *)camera;
3831 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3833 if (!pc || !pc->cb_info) {
3834 LOGE("NULL handle");
3835 return CAMERA_ERROR_INVALID_PARAMETER;
3840 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3842 if (ret == CAMERA_ERROR_NONE) {
3843 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3845 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3846 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3848 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3851 LOGD("ret : 0x%x", ret);
3857 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3859 int ret = CAMERA_ERROR_NONE;
3860 camera_cli_s *pc = (camera_cli_s *)camera;
3861 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3863 if (!pc || !pc->cb_info || !callback) {
3864 LOGE("NULL pointer %p %p", pc, callback);
3865 return CAMERA_ERROR_INVALID_PARAMETER;
3870 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3872 if (ret == CAMERA_ERROR_NONE) {
3873 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3875 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3876 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3878 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3881 LOGD("ret : 0x%x", ret);
3887 int camera_unset_state_changed_cb(camera_h camera)
3889 int ret = CAMERA_ERROR_NONE;
3890 camera_cli_s *pc = (camera_cli_s *)camera;
3891 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3893 if (!pc || !pc->cb_info) {
3894 LOGE("NULL handle");
3895 return CAMERA_ERROR_INVALID_PARAMETER;
3900 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3902 if (ret == CAMERA_ERROR_NONE) {
3903 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3908 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3911 LOGD("ret : 0x%x", ret);
3917 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3919 int ret = CAMERA_ERROR_NONE;
3920 camera_cli_s *pc = (camera_cli_s *)camera;
3921 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3923 if (!pc || !pc->cb_info || !callback) {
3924 LOGE("NULL pointer %p %p", pc, callback);
3925 return CAMERA_ERROR_INVALID_PARAMETER;
3930 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3932 if (ret == CAMERA_ERROR_NONE) {
3933 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3935 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3936 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3938 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3941 LOGD("ret : 0x%x", ret);
3947 int camera_unset_interrupted_cb(camera_h camera)
3949 int ret = CAMERA_ERROR_NONE;
3950 camera_cli_s *pc = (camera_cli_s *)camera;
3951 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3953 if (!pc || !pc->cb_info) {
3954 LOGE("NULL handle");
3955 return CAMERA_ERROR_INVALID_PARAMETER;
3960 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3962 if (ret == CAMERA_ERROR_NONE) {
3963 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3965 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3966 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3968 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3971 LOGD("ret : 0x%x", ret);
3977 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3979 int ret = CAMERA_ERROR_NONE;
3980 camera_cli_s *pc = (camera_cli_s *)camera;
3981 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3983 if (!pc || !pc->cb_info || !callback) {
3984 LOGE("NULL pointer %p %p", pc, callback);
3985 return CAMERA_ERROR_INVALID_PARAMETER;
3990 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3992 if (ret == CAMERA_ERROR_NONE) {
3993 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3995 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3996 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3998 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4001 LOGD("ret : 0x%x", ret);
4007 int camera_unset_interrupt_started_cb(camera_h camera)
4009 int ret = CAMERA_ERROR_NONE;
4010 camera_cli_s *pc = (camera_cli_s *)camera;
4011 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4013 if (!pc || !pc->cb_info) {
4014 LOGE("NULL handle");
4015 return CAMERA_ERROR_INVALID_PARAMETER;
4020 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4022 if (ret == CAMERA_ERROR_NONE) {
4023 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4028 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4031 LOGD("ret : 0x%x", ret);
4037 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4043 if (!pc || !pc->cb_info || !callback) {
4044 LOGE("NULL pointer %p %p", pc, callback);
4045 return CAMERA_ERROR_INVALID_PARAMETER;
4050 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4052 if (ret == CAMERA_ERROR_NONE) {
4053 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4055 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4056 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4058 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4061 LOGD("ret : 0x%x", ret);
4067 int camera_unset_focus_changed_cb(camera_h camera)
4069 int ret = CAMERA_ERROR_NONE;
4070 camera_cli_s *pc = (camera_cli_s *)camera;
4071 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4073 if (!pc || !pc->cb_info) {
4074 LOGE("NULL handle");
4075 return CAMERA_ERROR_INVALID_PARAMETER;
4080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4082 if (ret == CAMERA_ERROR_NONE) {
4083 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4085 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4086 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4088 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4091 LOGD("ret : 0x%x", ret);
4097 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4099 int ret = CAMERA_ERROR_NONE;
4100 camera_cli_s *pc = (camera_cli_s *)camera;
4101 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4103 if (!pc || !pc->cb_info || !callback) {
4104 LOGE("NULL pointer %p %p", pc, callback);
4105 return CAMERA_ERROR_INVALID_PARAMETER;
4110 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4112 if (ret == CAMERA_ERROR_NONE) {
4113 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4115 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4116 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4118 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4121 LOGD("ret : 0x%x", ret);
4127 int camera_unset_error_cb(camera_h camera)
4129 int ret = CAMERA_ERROR_NONE;
4130 camera_cli_s *pc = (camera_cli_s *)camera;
4131 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4133 if (!pc || !pc->cb_info) {
4134 LOGE("NULL handle");
4135 return CAMERA_ERROR_INVALID_PARAMETER;
4140 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4142 if (ret == CAMERA_ERROR_NONE) {
4143 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4145 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4146 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4148 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4151 LOGD("ret : 0x%x", ret);
4157 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4159 int ret = CAMERA_ERROR_NONE;
4160 camera_cli_s *pc = (camera_cli_s *)camera;
4161 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4163 if (!pc || !pc->cb_info || !foreach_cb) {
4164 LOGE("NULL pointer %p %p", pc, foreach_cb);
4165 return CAMERA_ERROR_INVALID_PARAMETER;
4170 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4171 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4173 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4175 LOGD("ret : 0x%x", ret);
4181 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4183 int ret = CAMERA_ERROR_NONE;
4184 camera_cli_s *pc = (camera_cli_s *)camera;
4185 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4187 if (!pc || !pc->cb_info || !foreach_cb) {
4188 LOGE("NULL pointer %p %p", pc, foreach_cb);
4189 return CAMERA_ERROR_INVALID_PARAMETER;
4194 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4195 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4197 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4199 LOGD("ret : 0x%x", ret);
4205 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4207 int ret = CAMERA_ERROR_NONE;
4208 camera_cli_s *pc = (camera_cli_s *)camera;
4209 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4211 if (!pc || !pc->cb_info || !foreach_cb) {
4212 LOGE("NULL pointer %p %p", pc, foreach_cb);
4213 return CAMERA_ERROR_INVALID_PARAMETER;
4218 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4219 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4221 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4223 LOGD("ret : 0x%x", ret);
4229 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4231 int ret = CAMERA_ERROR_NONE;
4232 camera_cli_s *pc = (camera_cli_s *)camera;
4233 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4235 if (!pc || !pc->cb_info || !foreach_cb) {
4236 LOGE("NULL pointer %p %p", pc, foreach_cb);
4237 return CAMERA_ERROR_INVALID_PARAMETER;
4242 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4243 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4247 LOGD("ret : 0x%x", ret);
4253 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4259 if (!pc || !pc->cb_info || !width || !height) {
4260 LOGE("NULL pointer %p %p %p", pc, width, height);
4261 return CAMERA_ERROR_INVALID_PARAMETER;
4265 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4267 if (ret == CAMERA_ERROR_NONE) {
4268 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4269 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4272 LOGD("ret : 0x%x", ret);
4278 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4280 int ret = CAMERA_ERROR_NONE;
4281 camera_cli_s *pc = (camera_cli_s *)camera;
4282 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4284 if (!pc || !pc->cb_info || !angle) {
4285 LOGE("NULL pointer %p %p", pc, angle);
4286 return CAMERA_ERROR_INVALID_PARAMETER;
4291 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4293 if (ret == CAMERA_ERROR_NONE)
4294 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4296 LOGD("ret : 0x%x", ret);
4302 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4307 camera_msg_param param;
4308 int set_mode = (int)mode;
4310 if (!pc || !pc->cb_info) {
4311 LOGE("NULL handle");
4312 return CAMERA_ERROR_INVALID_PARAMETER;
4317 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4319 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4321 LOGD("ret : 0x%x", ret);
4327 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4329 int ret = CAMERA_ERROR_NONE;
4330 camera_cli_s *pc = (camera_cli_s *)camera;
4331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4333 if (!pc || !pc->cb_info || !mode) {
4334 LOGE("NULL pointer %p %p", pc, mode);
4335 return CAMERA_ERROR_INVALID_PARAMETER;
4340 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4342 if (ret == CAMERA_ERROR_NONE)
4343 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4345 LOGD("ret : 0x%x", ret);
4351 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4353 int ret = CAMERA_ERROR_NONE;
4354 camera_cli_s *pc = (camera_cli_s *)camera;
4355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4357 if (!pc || !pc->cb_info || !foreach_cb) {
4358 LOGE("NULL pointer %p %p", pc, foreach_cb);
4359 return CAMERA_ERROR_INVALID_PARAMETER;
4364 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4365 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4367 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4369 LOGD("Finish, return :%x", ret);
4375 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4377 int ret = CAMERA_ERROR_NONE;
4378 camera_cli_s *pc = (camera_cli_s *)camera;
4379 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4380 camera_msg_param param;
4381 int set_fps = (int)fps;
4383 if (!pc || !pc->cb_info) {
4384 LOGE("NULL handle");
4385 return CAMERA_ERROR_INVALID_PARAMETER;
4390 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4392 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4394 LOGD("ret : 0x%x", ret);
4400 int camera_attr_set_image_quality(camera_h camera, int quality)
4402 int ret = CAMERA_ERROR_NONE;
4403 camera_cli_s *pc = (camera_cli_s *)camera;
4404 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4405 camera_msg_param param;
4407 if (!pc || !pc->cb_info) {
4408 LOGE("NULL handle");
4409 return CAMERA_ERROR_INVALID_PARAMETER;
4414 CAMERA_MSG_PARAM_SET(param, INT, quality);
4416 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4418 LOGD("ret : 0x%x", ret);
4424 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4426 int ret = CAMERA_ERROR_NONE;
4427 camera_cli_s *pc = (camera_cli_s *)camera;
4428 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4430 if (!pc || !pc->cb_info || !fps) {
4431 LOGE("NULL pointer %p %p", pc, fps);
4432 return CAMERA_ERROR_INVALID_PARAMETER;
4437 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4439 if (ret == CAMERA_ERROR_NONE)
4440 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4442 LOGD("ret : 0x%x", ret);
4448 int camera_attr_get_image_quality(camera_h camera, int *quality)
4450 int ret = CAMERA_ERROR_NONE;
4451 camera_cli_s *pc = (camera_cli_s *)camera;
4452 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4454 if (!pc || !pc->cb_info || !quality) {
4455 LOGE("NULL pointer %p %p", pc, quality);
4456 return CAMERA_ERROR_INVALID_PARAMETER;
4461 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4463 if (ret == CAMERA_ERROR_NONE)
4464 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4466 LOGD("ret : 0x%x", ret);
4472 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4474 int ret = CAMERA_ERROR_NONE;
4475 camera_cli_s *pc = (camera_cli_s *)camera;
4476 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4478 if (!pc || !pc->cb_info || !bitrate) {
4479 LOGE("NULL pointer %p %p", pc, bitrate);
4480 return CAMERA_ERROR_INVALID_PARAMETER;
4485 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4487 if (ret == CAMERA_ERROR_NONE)
4488 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4490 LOGD("ret : 0x%x", ret);
4496 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4498 int ret = CAMERA_ERROR_NONE;
4499 camera_cli_s *pc = (camera_cli_s *)camera;
4500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4501 camera_msg_param param;
4502 int set_bitrate = bitrate;
4504 if (!pc || !pc->cb_info) {
4505 LOGE("NULL handle");
4506 return CAMERA_ERROR_INVALID_PARAMETER;
4511 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4513 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4515 LOGD("ret : 0x%x", ret);
4521 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4523 int ret = CAMERA_ERROR_NONE;
4524 camera_cli_s *pc = (camera_cli_s *)camera;
4525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4527 if (!pc || !pc->cb_info || !interval) {
4528 LOGE("NULL pointer %p %p", pc, interval);
4529 return CAMERA_ERROR_INVALID_PARAMETER;
4534 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4536 if (ret == CAMERA_ERROR_NONE)
4537 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4539 LOGD("ret : 0x%x", ret);
4545 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4547 int ret = CAMERA_ERROR_NONE;
4548 camera_cli_s *pc = (camera_cli_s *)camera;
4549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4550 camera_msg_param param;
4551 int set_gop_interval = interval;
4553 if (!pc || !pc->cb_info) {
4554 LOGE("NULL handle");
4555 return CAMERA_ERROR_INVALID_PARAMETER;
4560 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4562 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4564 LOGD("ret : 0x%x", ret);
4570 int camera_attr_set_zoom(camera_h camera, int zoom)
4572 int ret = CAMERA_ERROR_NONE;
4573 camera_cli_s *pc = (camera_cli_s *)camera;
4574 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4575 camera_msg_param param;
4577 if (!pc || !pc->cb_info) {
4578 LOGE("NULL handle");
4579 return CAMERA_ERROR_INVALID_PARAMETER;
4582 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4584 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4586 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4588 LOGD("ret : 0x%x", ret);
4594 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4596 int ret = CAMERA_ERROR_NONE;
4597 camera_cli_s *pc = (camera_cli_s *)camera;
4598 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4599 camera_msg_param param;
4600 int set_mode = (int)mode;
4602 if (!pc || !pc->cb_info) {
4603 LOGE("NULL handle");
4604 return CAMERA_ERROR_INVALID_PARAMETER;
4607 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4609 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4611 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4617 int camera_attr_set_af_area(camera_h camera, int x, int y)
4619 int ret = CAMERA_ERROR_NONE;
4620 camera_cli_s *pc = (camera_cli_s *)camera;
4621 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4622 camera_msg_param param;
4625 if (!pc || !pc->cb_info) {
4626 LOGE("NULL handle");
4627 return CAMERA_ERROR_INVALID_PARAMETER;
4630 LOGD("Enter - %d,%d", x, y);
4632 value = (x << 16) | y;
4633 CAMERA_MSG_PARAM_SET(param, INT, value);
4635 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4637 LOGD("ret : 0x%x", ret);
4643 int camera_attr_clear_af_area(camera_h camera)
4645 int ret = CAMERA_ERROR_NONE;
4646 camera_cli_s *pc = (camera_cli_s *)camera;
4647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4649 if (!pc || !pc->cb_info) {
4650 LOGE("NULL handle");
4651 return CAMERA_ERROR_INVALID_PARAMETER;
4656 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4658 LOGD("ret : 0x%x", ret);
4664 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4666 int ret = CAMERA_ERROR_NONE;
4667 camera_cli_s *pc = (camera_cli_s *)camera;
4668 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4669 camera_msg_param param;
4670 int set_mode = (int)mode;
4672 if (!pc || !pc->cb_info) {
4673 LOGE("NULL handle");
4674 return CAMERA_ERROR_INVALID_PARAMETER;
4679 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4683 LOGD("ret : 0x%x", ret);
4689 int camera_attr_set_exposure(camera_h camera, int value)
4691 int ret = CAMERA_ERROR_NONE;
4692 camera_cli_s *pc = (camera_cli_s *)camera;
4693 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4694 camera_msg_param param;
4696 if (!pc || !pc->cb_info) {
4697 LOGE("NULL handle");
4698 return CAMERA_ERROR_INVALID_PARAMETER;
4703 CAMERA_MSG_PARAM_SET(param, INT, value);
4705 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4707 LOGD("ret : 0x%x", ret);
4713 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4715 int ret = CAMERA_ERROR_NONE;
4716 camera_cli_s *pc = (camera_cli_s *)camera;
4717 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4718 camera_msg_param param;
4719 int set_iso = (int)iso;
4721 if (!pc || !pc->cb_info) {
4722 LOGE("NULL handle");
4723 return CAMERA_ERROR_INVALID_PARAMETER;
4728 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 LOGD("ret : 0x%x", ret);
4738 int camera_attr_set_brightness(camera_h camera, int level)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4743 camera_msg_param param;
4745 if (!pc || !pc->cb_info) {
4746 LOGE("NULL handle");
4747 return CAMERA_ERROR_INVALID_PARAMETER;
4752 CAMERA_MSG_PARAM_SET(param, INT, level);
4754 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4756 LOGD("ret : 0x%x", ret);
4762 int camera_attr_set_contrast(camera_h camera, int level)
4764 int ret = CAMERA_ERROR_NONE;
4765 camera_cli_s *pc = (camera_cli_s *)camera;
4766 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4767 camera_msg_param param;
4769 if (!pc || !pc->cb_info) {
4770 LOGE("NULL handle");
4771 return CAMERA_ERROR_INVALID_PARAMETER;
4776 CAMERA_MSG_PARAM_SET(param, INT, level);
4778 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4780 LOGD("ret : 0x%x", ret);
4786 int camera_attr_set_hue(camera_h camera, int level)
4788 int ret = CAMERA_ERROR_NONE;
4789 camera_cli_s *pc = (camera_cli_s *)camera;
4790 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4791 camera_msg_param param;
4793 if (!pc || !pc->cb_info) {
4794 LOGE("NULL handle");
4795 return CAMERA_ERROR_INVALID_PARAMETER;
4800 CAMERA_MSG_PARAM_SET(param, INT, level);
4802 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4804 LOGD("ret : 0x%x", ret);
4810 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4812 int ret = CAMERA_ERROR_NONE;
4813 camera_cli_s *pc = (camera_cli_s *)camera;
4814 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4815 camera_msg_param param;
4816 int set_whitebalance = (int)wb;
4818 if (!pc || !pc->cb_info) {
4819 LOGE("NULL handle");
4820 return CAMERA_ERROR_INVALID_PARAMETER;
4825 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4827 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4829 LOGD("ret : 0x%x", ret);
4835 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4837 int ret = CAMERA_ERROR_NONE;
4838 camera_cli_s *pc = (camera_cli_s *)camera;
4839 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4840 camera_msg_param param;
4841 int set_effect = (int)effect;
4843 if (!pc || !pc->cb_info) {
4844 LOGE("NULL handle");
4845 return CAMERA_ERROR_INVALID_PARAMETER;
4850 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4852 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4854 LOGD("ret : 0x%x", ret);
4860 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4862 int ret = CAMERA_ERROR_NONE;
4863 camera_cli_s *pc = (camera_cli_s *)camera;
4864 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4865 camera_msg_param param;
4866 int set_mode = (int)mode;
4868 if (!pc || !pc->cb_info) {
4869 LOGE("NULL handle");
4870 return CAMERA_ERROR_INVALID_PARAMETER;
4875 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4877 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4879 LOGD("ret : 0x%x", ret);
4885 int camera_attr_enable_tag(camera_h camera, bool enable)
4887 int ret = CAMERA_ERROR_NONE;
4888 camera_cli_s *pc = (camera_cli_s *)camera;
4889 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4890 camera_msg_param param;
4891 int set_enable = (int)enable;
4893 if (!pc || !pc->cb_info) {
4894 LOGE("NULL handle");
4895 return CAMERA_ERROR_INVALID_PARAMETER;
4900 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4902 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4904 LOGD("ret : 0x%x", ret);
4910 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4912 int ret = CAMERA_ERROR_NONE;
4913 camera_cli_s *pc = (camera_cli_s *)camera;
4914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4915 camera_msg_param param;
4917 if (!pc || !pc->cb_info || !description) {
4918 LOGE("NULL pointer %p %p", pc, description);
4919 return CAMERA_ERROR_INVALID_PARAMETER;
4924 CAMERA_MSG_PARAM_SET(param, STRING, description);
4926 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4928 LOGD("ret : 0x%x", ret);
4934 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4936 int ret = CAMERA_ERROR_NONE;
4937 camera_cli_s *pc = (camera_cli_s *)camera;
4938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4939 camera_msg_param param;
4940 int set_orientation = (int)orientation;
4942 if (!pc || !pc->cb_info) {
4943 LOGE("NULL handle");
4944 return CAMERA_ERROR_INVALID_PARAMETER;
4949 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4951 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4953 LOGD("ret : 0x%x", ret);
4959 int camera_attr_set_tag_software(camera_h camera, const char *software)
4961 int ret = CAMERA_ERROR_NONE;
4962 camera_cli_s *pc = (camera_cli_s *)camera;
4963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4964 camera_msg_param param;
4966 if (!pc || !pc->cb_info || !software) {
4967 LOGE("NULL pointer %p %p", pc, software);
4968 return CAMERA_ERROR_INVALID_PARAMETER;
4971 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4973 CAMERA_MSG_PARAM_SET(param, STRING, software);
4975 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4977 LOGD("ret : 0x%x", ret);
4983 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4985 int ret = CAMERA_ERROR_NONE;
4986 camera_cli_s *pc = (camera_cli_s *)camera;
4987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4988 double set_geotag[3] = {latitude, longitude, altitude};
4993 if (!pc || !pc->cb_info) {
4994 LOGE("NULL handle");
4995 return CAMERA_ERROR_INVALID_PARAMETER;
5000 length = sizeof(set_geotag) / sizeof(int) + \
5001 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5003 msg = muse_core_msg_new(api,
5004 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5007 LOGE("msg creation failed: api %d", api);
5008 return CAMERA_ERROR_OUT_OF_MEMORY;
5011 if (pc->cb_info->is_server_connected) {
5012 __camera_update_api_waiting(pc->cb_info, api, 1);
5014 g_mutex_lock(&pc->cb_info->fd_lock);
5015 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5016 g_mutex_unlock(&pc->cb_info->fd_lock);
5020 LOGE("message send failed");
5021 ret = CAMERA_ERROR_INVALID_OPERATION;
5023 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5026 __camera_update_api_waiting(pc->cb_info, api, -1);
5028 muse_core_msg_free(msg);
5030 LOGD("ret : 0x%x", ret);
5036 int camera_attr_remove_geotag(camera_h camera)
5038 int ret = CAMERA_ERROR_NONE;
5039 camera_cli_s *pc = (camera_cli_s *)camera;
5040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5042 if (!pc || !pc->cb_info) {
5043 LOGE("NULL handle");
5044 return CAMERA_ERROR_INVALID_PARAMETER;
5049 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5051 LOGD("ret : 0x%x", ret);
5057 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5059 int ret = CAMERA_ERROR_NONE;
5060 camera_cli_s *pc = (camera_cli_s *)camera;
5061 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5062 camera_msg_param param;
5063 int set_mode = (int)mode;
5065 if (!pc || !pc->cb_info) {
5066 LOGE("NULL handle");
5067 return CAMERA_ERROR_INVALID_PARAMETER;
5072 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5074 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5076 LOGD("ret : 0x%x", ret);
5082 int camera_attr_get_zoom(camera_h camera, int *zoom)
5084 int ret = CAMERA_ERROR_NONE;
5085 camera_cli_s *pc = (camera_cli_s *)camera;
5086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5088 if (!pc || !pc->cb_info || !zoom) {
5089 LOGE("NULL pointer %p %p", pc, zoom);
5090 return CAMERA_ERROR_INVALID_PARAMETER;
5095 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5097 if (ret == CAMERA_ERROR_NONE)
5098 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5100 LOGD("ret : 0x%x", ret);
5106 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5108 int ret = CAMERA_ERROR_NONE;
5109 camera_cli_s *pc = (camera_cli_s *)camera;
5110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5112 if (!pc || !pc->cb_info || !min || !max) {
5113 LOGE("NULL pointer %p %p %p", pc, min, max);
5114 return CAMERA_ERROR_INVALID_PARAMETER;
5119 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5121 if (ret == CAMERA_ERROR_NONE) {
5122 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5123 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5126 LOGD("ret : 0x%x", ret);
5132 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5134 int ret = CAMERA_ERROR_NONE;
5135 camera_cli_s *pc = (camera_cli_s *)camera;
5136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5138 if (!pc || !pc->cb_info || !mode) {
5139 LOGE("NULL pointer %p %p", pc, mode);
5140 return CAMERA_ERROR_INVALID_PARAMETER;
5145 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5147 if (ret == CAMERA_ERROR_NONE)
5148 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5150 LOGD("ret : 0x%x", ret);
5156 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5158 int ret = CAMERA_ERROR_NONE;
5159 camera_cli_s *pc = (camera_cli_s *)camera;
5160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5162 if (!pc || !pc->cb_info || !mode) {
5163 LOGE("NULL pointer %p %p", pc, mode);
5164 return CAMERA_ERROR_INVALID_PARAMETER;
5169 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5171 if (ret == CAMERA_ERROR_NONE)
5172 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5174 LOGD("ret : 0x%x", ret);
5180 int camera_attr_get_exposure(camera_h camera, int *value)
5182 int ret = CAMERA_ERROR_NONE;
5183 camera_cli_s *pc = (camera_cli_s *)camera;
5184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5186 if (!pc || !pc->cb_info || !value) {
5187 LOGE("NULL pointer %p %p", pc, value);
5188 return CAMERA_ERROR_INVALID_PARAMETER;
5193 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5195 if (ret == CAMERA_ERROR_NONE)
5196 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5198 LOGD("ret : 0x%x", ret);
5204 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5206 int ret = CAMERA_ERROR_NONE;
5207 camera_cli_s *pc = (camera_cli_s *)camera;
5208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5210 if (!pc || !pc->cb_info || !min || !max) {
5211 LOGE("NULL pointer %p %p %p", pc, min, max);
5212 return CAMERA_ERROR_INVALID_PARAMETER;
5217 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5219 if (ret == CAMERA_ERROR_NONE) {
5220 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5221 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5224 LOGD("ret : 0x%x", ret);
5230 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5232 int ret = CAMERA_ERROR_NONE;
5233 camera_cli_s *pc = (camera_cli_s *)camera;
5234 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5236 if (!pc || !pc->cb_info || !iso) {
5237 LOGE("NULL pointer %p %p", pc, iso);
5238 return CAMERA_ERROR_INVALID_PARAMETER;
5243 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5245 if (ret == CAMERA_ERROR_NONE)
5246 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5248 LOGD("ret : 0x%x", ret);
5254 int camera_attr_get_brightness(camera_h camera, int *level)
5256 int ret = CAMERA_ERROR_NONE;
5257 camera_cli_s *pc = (camera_cli_s *)camera;
5258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5260 if (!pc || !pc->cb_info || !level) {
5261 LOGE("NULL pointer %p %p", pc, level);
5262 return CAMERA_ERROR_INVALID_PARAMETER;
5267 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5269 if (ret == CAMERA_ERROR_NONE)
5270 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5272 LOGD("ret : 0x%x", ret);
5278 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5280 int ret = CAMERA_ERROR_NONE;
5281 camera_cli_s *pc = (camera_cli_s *)camera;
5282 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5284 if (!pc || !pc->cb_info || !min || !max) {
5285 LOGE("NULL pointer %p %p %p", pc, min, max);
5286 return CAMERA_ERROR_INVALID_PARAMETER;
5291 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5293 if (ret == CAMERA_ERROR_NONE) {
5294 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5295 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5298 LOGD("ret : 0x%x", ret);
5304 int camera_attr_get_contrast(camera_h camera, int *level)
5306 int ret = CAMERA_ERROR_NONE;
5307 camera_cli_s *pc = (camera_cli_s *)camera;
5308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5310 if (!pc || !pc->cb_info || !level) {
5311 LOGE("NULL pointer %p %p", pc, level);
5312 return CAMERA_ERROR_INVALID_PARAMETER;
5317 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5319 if (ret == CAMERA_ERROR_NONE)
5320 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5322 LOGD("ret : 0x%x", ret);
5328 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5330 int ret = CAMERA_ERROR_NONE;
5331 camera_cli_s *pc = (camera_cli_s *)camera;
5332 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5334 if (!pc || !pc->cb_info || !min || !max) {
5335 LOGE("NULL pointer %p %p %p", pc, min, max);
5336 return CAMERA_ERROR_INVALID_PARAMETER;
5341 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5343 if (ret == CAMERA_ERROR_NONE) {
5344 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5345 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5346 LOGD("min %d, max %d", *min, *max);
5349 LOGD("ret : 0x%x", ret);
5355 int camera_attr_get_hue(camera_h camera, int *level)
5357 int ret = CAMERA_ERROR_NONE;
5358 camera_cli_s *pc = (camera_cli_s *)camera;
5359 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5361 if (!pc || !pc->cb_info || !level) {
5362 LOGE("NULL pointer %p %p", pc, level);
5363 return CAMERA_ERROR_INVALID_PARAMETER;
5368 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5370 if (ret == CAMERA_ERROR_NONE)
5371 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5373 LOGD("ret : 0x%x", ret);
5379 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5381 int ret = CAMERA_ERROR_NONE;
5382 camera_cli_s *pc = (camera_cli_s *)camera;
5383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5385 if (!pc || !pc->cb_info || !min || !max) {
5386 LOGE("NULL pointer %p %p %p", pc, min, max);
5387 return CAMERA_ERROR_INVALID_PARAMETER;
5392 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5394 if (ret == CAMERA_ERROR_NONE) {
5395 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5396 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5397 LOGD("min %d, max %d", *min, *max);
5400 LOGD("ret : 0x%x", ret);
5406 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5408 int ret = CAMERA_ERROR_NONE;
5409 camera_cli_s *pc = (camera_cli_s *)camera;
5410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5412 if (!pc || !pc->cb_info || !wb) {
5413 LOGE("NULL pointer %p %p", pc, wb);
5414 return CAMERA_ERROR_INVALID_PARAMETER;
5419 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5421 if (ret == CAMERA_ERROR_NONE)
5422 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5424 LOGD("ret : 0x%x", ret);
5430 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5432 int ret = CAMERA_ERROR_NONE;
5433 camera_cli_s *pc = (camera_cli_s *)camera;
5434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5436 if (!pc || !pc->cb_info || !effect) {
5437 LOGE("NULL pointer %p %p", pc, effect);
5438 return CAMERA_ERROR_INVALID_PARAMETER;
5443 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5445 if (ret == CAMERA_ERROR_NONE)
5446 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5448 LOGD("ret : 0x%x", ret);
5454 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5456 int ret = CAMERA_ERROR_NONE;
5457 camera_cli_s *pc = (camera_cli_s *)camera;
5458 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5460 if (!pc || !pc->cb_info || !mode) {
5461 LOGE("NULL pointer %p %p", pc, mode);
5462 return CAMERA_ERROR_INVALID_PARAMETER;
5467 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5469 if (ret == CAMERA_ERROR_NONE)
5470 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5472 LOGD("ret : 0x%x", ret);
5478 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5480 int ret = CAMERA_ERROR_NONE;
5481 camera_cli_s *pc = (camera_cli_s *)camera;
5482 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5484 if (!pc || !pc->cb_info || !enable) {
5485 LOGE("NULL pointer %p %p", pc, enable);
5486 return CAMERA_ERROR_INVALID_PARAMETER;
5491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5493 if (ret == CAMERA_ERROR_NONE)
5494 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5496 LOGD("ret : 0x%x", ret);
5502 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5504 int ret = CAMERA_ERROR_NONE;
5505 camera_cli_s *pc = (camera_cli_s *)camera;
5506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5508 if (!pc || !pc->cb_info || !description) {
5509 LOGE("NULL pointer %p %p", pc, description);
5510 return CAMERA_ERROR_INVALID_PARAMETER;
5515 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5517 if (ret == CAMERA_ERROR_NONE)
5518 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5520 LOGD("ret : 0x%x", ret);
5526 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5528 int ret = CAMERA_ERROR_NONE;
5529 camera_cli_s *pc = (camera_cli_s *)camera;
5530 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5532 if (!pc || !pc->cb_info || !orientation) {
5533 LOGE("NULL pointer %p %p", pc, orientation);
5534 return CAMERA_ERROR_INVALID_PARAMETER;
5539 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5541 if (ret == CAMERA_ERROR_NONE)
5542 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5544 LOGD("ret : 0x%x", ret);
5550 int camera_attr_get_tag_software(camera_h camera, char **software)
5552 int ret = CAMERA_ERROR_NONE;
5553 camera_cli_s *pc = (camera_cli_s *)camera;
5554 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5556 if (!pc || !pc->cb_info || !software) {
5557 LOGE("NULL pointer %p %p", pc, software);
5558 return CAMERA_ERROR_INVALID_PARAMETER;
5563 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5565 if (ret == CAMERA_ERROR_NONE)
5566 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5568 LOGD("ret : 0x%x", ret);
5574 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5576 int ret = CAMERA_ERROR_NONE;
5577 camera_cli_s *pc = (camera_cli_s *)camera;
5578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5580 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5581 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5582 return CAMERA_ERROR_INVALID_PARAMETER;
5587 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5589 if (ret == CAMERA_ERROR_NONE) {
5590 *latitude = pc->cb_info->get_geotag[0];
5591 *longitude = pc->cb_info->get_geotag[1];
5592 *altitude = pc->cb_info->get_geotag[2];
5595 LOGD("ret : 0x%x", ret);
5601 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5603 int ret = CAMERA_ERROR_NONE;
5604 camera_cli_s *pc = (camera_cli_s *)camera;
5605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5607 if (!pc || !pc->cb_info || !mode) {
5608 LOGE("NULL pointer %p %p", pc, mode);
5609 return CAMERA_ERROR_INVALID_PARAMETER;
5614 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5616 if (ret == CAMERA_ERROR_NONE)
5617 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5619 LOGD("ret : 0x%x", ret);
5625 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5627 int ret = CAMERA_ERROR_NONE;
5628 int get_flash_state = 0;
5631 LOGE("NULL pointer");
5632 return CAMERA_ERROR_INVALID_PARAMETER;
5635 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5636 (int)device, "get_flash_state", &get_flash_state);
5638 if (ret == CAMERA_ERROR_NONE) {
5639 *state = (camera_flash_state_e)get_flash_state;
5640 LOGD("flash state %d", *state);
5642 LOGE("failed 0x%x", ret);
5649 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5651 int ret = CAMERA_ERROR_NONE;
5652 camera_cli_s *pc = (camera_cli_s *)camera;
5653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5655 if (!pc || !pc->cb_info || !foreach_cb) {
5656 LOGE("NULL pointer %p %p", pc, foreach_cb);
5657 return CAMERA_ERROR_INVALID_PARAMETER;
5662 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5663 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5665 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5667 LOGD("ret : 0x%x", ret);
5673 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5675 int ret = CAMERA_ERROR_NONE;
5676 camera_cli_s *pc = (camera_cli_s *)camera;
5677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5679 if (!pc || !pc->cb_info || !foreach_cb) {
5680 LOGE("NULL pointer %p %p", pc, foreach_cb);
5681 return CAMERA_ERROR_INVALID_PARAMETER;
5686 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5687 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5689 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5691 LOGD("ret : 0x%x", ret);
5697 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5703 if (!pc || !pc->cb_info || !foreach_cb) {
5704 LOGE("NULL pointer %p %p", pc, foreach_cb);
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5710 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5711 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5713 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5715 LOGD("ret : 0x%x", ret);
5721 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5723 int ret = CAMERA_ERROR_NONE;
5724 camera_cli_s *pc = (camera_cli_s *)camera;
5725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5727 if (!pc || !pc->cb_info || !foreach_cb) {
5728 LOGE("NULL pointer %p %p", pc, foreach_cb);
5729 return CAMERA_ERROR_INVALID_PARAMETER;
5734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5737 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5739 LOGD("ret : 0x%x", ret);
5745 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5747 int ret = CAMERA_ERROR_NONE;
5748 camera_cli_s *pc = (camera_cli_s *)camera;
5749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5751 if (!pc || !pc->cb_info || !foreach_cb) {
5752 LOGE("NULL pointer %p %p", pc, foreach_cb);
5753 return CAMERA_ERROR_INVALID_PARAMETER;
5758 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5759 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5761 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5763 LOGD("ret : 0x%x", ret);
5769 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5771 int ret = CAMERA_ERROR_NONE;
5772 camera_cli_s *pc = (camera_cli_s *)camera;
5773 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5775 if (!pc || !pc->cb_info || !foreach_cb) {
5776 LOGE("NULL pointer %p %p", pc, foreach_cb);
5777 return CAMERA_ERROR_INVALID_PARAMETER;
5782 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5783 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5785 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5787 LOGD("ret : 0x%x", ret);
5793 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5795 int ret = CAMERA_ERROR_NONE;
5796 camera_cli_s *pc = (camera_cli_s *)camera;
5797 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5799 if (!pc || !pc->cb_info || !foreach_cb) {
5800 LOGE("NULL pointer %p %p", pc, foreach_cb);
5801 return CAMERA_ERROR_INVALID_PARAMETER;
5806 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5807 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5809 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5811 LOGD("ret : 0x%x", ret);
5817 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5819 int ret = CAMERA_ERROR_NONE;
5820 camera_cli_s *pc = (camera_cli_s *)camera;
5821 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5823 if (!pc || !pc->cb_info || !foreach_cb) {
5824 LOGE("NULL pointer %p %p", pc, foreach_cb);
5825 return CAMERA_ERROR_INVALID_PARAMETER;
5830 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5831 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5833 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5835 LOGD("Enter, handle :%td", pc->remote_handle);
5841 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)
5843 int ret = CAMERA_ERROR_NONE;
5844 camera_cli_s *pc = (camera_cli_s *)camera;
5845 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5846 camera_msg_param param;
5849 if (!pc || !pc->cb_info || !foreach_cb) {
5850 LOGE("NULL pointer %p %p", pc, foreach_cb);
5851 return CAMERA_ERROR_INVALID_PARAMETER;
5856 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5857 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5859 value = (width << 16) | height;
5860 CAMERA_MSG_PARAM_SET(param, INT, value);
5862 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5864 LOGD("ret : 0x%x", ret);
5870 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5872 int ret = CAMERA_ERROR_NONE;
5873 camera_cli_s *pc = (camera_cli_s *)camera;
5874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5876 if (!pc || !pc->cb_info || !foreach_cb) {
5877 LOGE("NULL pointer %p %p", pc, foreach_cb);
5878 return CAMERA_ERROR_INVALID_PARAMETER;
5883 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5884 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5886 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5888 LOGD("ret : 0x%x", ret);
5894 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5896 int ret = CAMERA_ERROR_NONE;
5897 camera_cli_s *pc = (camera_cli_s *)camera;
5898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5900 if (!pc || !pc->cb_info || !foreach_cb) {
5901 LOGE("NULL pointer %p %p", pc, foreach_cb);
5902 return CAMERA_ERROR_INVALID_PARAMETER;
5907 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5908 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5910 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5912 LOGD("ret : 0x%x", ret);
5918 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5920 int ret = CAMERA_ERROR_NONE;
5921 camera_cli_s *pc = (camera_cli_s *)camera;
5922 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5923 camera_msg_param param;
5924 int set_rotation = (int)rotation;
5926 if (!pc || !pc->cb_info) {
5927 LOGE("NULL handle");
5928 return CAMERA_ERROR_INVALID_PARAMETER;
5933 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5935 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5937 LOGD("ret : 0x%x", ret);
5943 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5945 int ret = CAMERA_ERROR_NONE;
5946 camera_cli_s *pc = (camera_cli_s *)camera;
5947 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5949 if (!pc || !pc->cb_info || !rotation) {
5950 LOGE("NULL pointer %p %p", pc, rotation);
5951 return CAMERA_ERROR_INVALID_PARAMETER;
5956 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5958 if (ret == CAMERA_ERROR_NONE)
5959 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5961 LOGD("ret : 0x%x", ret);
5967 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5969 int ret = CAMERA_ERROR_NONE;
5970 camera_cli_s *pc = (camera_cli_s *)camera;
5971 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5972 camera_msg_param param;
5973 int set_flip = (int)flip;
5975 if (!pc || !pc->cb_info) {
5976 LOGE("NULL handle");
5977 return CAMERA_ERROR_INVALID_PARAMETER;
5982 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5984 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5986 LOGD("ret : 0x%x", ret);
5992 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5994 int ret = CAMERA_ERROR_NONE;
5995 camera_cli_s *pc = (camera_cli_s *)camera;
5996 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5998 if (!pc || !pc->cb_info || !flip) {
5999 LOGE("NULL pointer %p %p", pc, flip);
6000 return CAMERA_ERROR_INVALID_PARAMETER;
6005 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6007 if (ret == CAMERA_ERROR_NONE)
6008 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6010 LOGD("ret : 0x%x", ret);
6015 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6017 int ret = CAMERA_ERROR_NONE;
6018 camera_cli_s *pc = (camera_cli_s *)camera;
6019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6020 camera_msg_param param;
6021 int set_mode = (int)mode;
6023 if (!pc || !pc->cb_info) {
6024 LOGE("NULL handle");
6025 return CAMERA_ERROR_INVALID_PARAMETER;
6030 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6032 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6034 LOGD("ret : 0x%x", ret);
6040 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6042 int ret = CAMERA_ERROR_NONE;
6043 camera_cli_s *pc = (camera_cli_s *)camera;
6044 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6046 if (!pc || !pc->cb_info || !mode) {
6047 LOGE("NULL pointer %p %p", pc, mode);
6048 return CAMERA_ERROR_INVALID_PARAMETER;
6053 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6055 if (ret == CAMERA_ERROR_NONE)
6056 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6058 LOGD("ret : 0x%x", ret);
6064 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6066 int ret = CAMERA_ERROR_NONE;
6067 camera_cli_s *pc = (camera_cli_s *)camera;
6068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6070 if (!pc || !pc->cb_info) {
6071 LOGE("NULL handle");
6072 return CAMERA_ERROR_INVALID_PARAMETER;
6077 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6080 LOGE("error is occurred 0x%x", ret);
6084 LOGD("ret : %d", ret);
6090 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6092 int ret = CAMERA_ERROR_NONE;
6093 camera_cli_s *pc = (camera_cli_s *)camera;
6094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6096 if (!pc || !pc->cb_info) {
6097 LOGE("NULL handle");
6098 return CAMERA_ERROR_INVALID_PARAMETER;
6103 if (!camera_attr_is_supported_hdr_capture(camera)) {
6104 LOGE("HDR not supported");
6105 return CAMERA_ERROR_NOT_SUPPORTED;
6109 LOGE("NULL callback");
6110 return CAMERA_ERROR_INVALID_PARAMETER;
6113 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 if (ret == CAMERA_ERROR_NONE) {
6116 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6118 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6119 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6121 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6124 LOGD("ret : 0x%x", ret);
6130 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6132 int ret = CAMERA_ERROR_NONE;
6133 camera_cli_s *pc = (camera_cli_s *)camera;
6134 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6136 if (!pc || !pc->cb_info) {
6137 LOGE("NULL handle");
6138 return CAMERA_ERROR_INVALID_PARAMETER;
6143 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6145 if (ret == CAMERA_ERROR_NONE) {
6146 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6148 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6149 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6151 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6154 LOGD("ret : 0x%x", ret);
6160 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6162 int ret = CAMERA_ERROR_NONE;
6163 camera_cli_s *pc = (camera_cli_s *)camera;
6164 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6165 camera_msg_param param;
6166 int set_enable = (int)enable;
6168 if (!pc || !pc->cb_info) {
6169 LOGE("NULL handle");
6170 return CAMERA_ERROR_INVALID_PARAMETER;
6175 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6177 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6179 LOGD("ret : 0x%x", ret);
6185 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6187 int ret = CAMERA_ERROR_NONE;
6188 camera_cli_s *pc = (camera_cli_s *)camera;
6189 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6191 if (!pc || !pc->cb_info || !enabled) {
6192 LOGE("NULL pointer %p %p", pc, enabled);
6193 return CAMERA_ERROR_INVALID_PARAMETER;
6198 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6200 if (ret == CAMERA_ERROR_NONE)
6201 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6203 LOGD("ret : 0x%x", ret);
6209 bool camera_attr_is_supported_anti_shake(camera_h camera)
6211 int ret = CAMERA_ERROR_NONE;
6212 camera_cli_s *pc = (camera_cli_s *)camera;
6213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6215 if (!pc || !pc->cb_info) {
6216 LOGE("NULL handle");
6217 return CAMERA_ERROR_INVALID_PARAMETER;
6222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6225 LOGE("error is occurred 0x%x", ret);
6229 LOGD("ret : %d", ret);
6235 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6237 int ret = CAMERA_ERROR_NONE;
6238 camera_cli_s *pc = (camera_cli_s *)camera;
6239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6240 camera_msg_param param;
6241 int set_enable = (int)enable;
6243 if (!pc || !pc->cb_info) {
6244 LOGE("NULL handle");
6245 return CAMERA_ERROR_INVALID_PARAMETER;
6250 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6252 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6254 LOGD("ret : 0x%x", ret);
6260 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6262 int ret = CAMERA_ERROR_NONE;
6263 camera_cli_s *pc = (camera_cli_s *)camera;
6264 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6266 if (!pc || !pc->cb_info || !enabled) {
6267 LOGE("NULL pointer %p %p", pc, enabled);
6268 return CAMERA_ERROR_INVALID_PARAMETER;
6273 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6275 if (ret == CAMERA_ERROR_NONE)
6276 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6278 LOGD("ret : 0x%x", ret);
6284 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6286 int ret = CAMERA_ERROR_NONE;
6287 camera_cli_s *pc = (camera_cli_s *)camera;
6288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6290 if (!pc || !pc->cb_info) {
6291 LOGE("NULL handle");
6292 return CAMERA_ERROR_INVALID_PARAMETER;
6297 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6300 LOGE("error is occurred 0x%x", ret);
6304 LOGD("ret : %d", ret);
6310 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6312 int ret = CAMERA_ERROR_NONE;
6313 camera_cli_s *pc = (camera_cli_s *)camera;
6314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6315 camera_msg_param param;
6316 int set_enable = (int)enable;
6318 if (!pc || !pc->cb_info) {
6319 LOGE("NULL handle");
6320 return CAMERA_ERROR_INVALID_PARAMETER;
6325 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6327 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6329 LOGD("ret : 0x%x", ret);
6335 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6337 int ret = CAMERA_ERROR_NONE;
6338 camera_cli_s *pc = (camera_cli_s *)camera;
6339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6341 if (!pc || !pc->cb_info || !enabled) {
6342 LOGE("NULL pointer %p %p", pc, enabled);
6343 return CAMERA_ERROR_INVALID_PARAMETER;
6348 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6350 if (ret == CAMERA_ERROR_NONE)
6351 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6353 LOGD("ret : 0x%x", ret);
6359 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6361 int ret = CAMERA_ERROR_NONE;
6362 camera_cli_s *pc = (camera_cli_s *)camera;
6363 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6365 if (!pc || !pc->cb_info) {
6366 LOGE("NULL handle");
6367 return CAMERA_ERROR_INVALID_PARAMETER;
6372 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6375 LOGE("error is occurred 0x%x", ret);
6379 LOGD("ret : %d", ret);
6385 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6387 int ret = CAMERA_ERROR_NONE;
6388 camera_cli_s *pc = (camera_cli_s *)camera;
6389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6390 camera_msg_param param;
6391 int set_disable = (int)disable;
6393 if (!pc || !pc->cb_info) {
6394 LOGE("NULL handle");
6395 return CAMERA_ERROR_INVALID_PARAMETER;
6400 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6402 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6404 LOGD("ret : 0x%x", ret);
6410 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6412 int ret = CAMERA_ERROR_NONE;
6413 camera_cli_s *pc = (camera_cli_s *)camera;
6414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6415 camera_msg_param param0;
6416 camera_msg_param param1;
6418 if (!pc || !pc->cb_info) {
6419 LOGE("NULL handle");
6420 return CAMERA_ERROR_INVALID_PARAMETER;
6425 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6426 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6428 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6429 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6431 LOGD("ret : 0x%x", ret);
6437 int camera_attr_get_pan(camera_h camera, int *pan_step)
6439 int ret = CAMERA_ERROR_NONE;
6440 camera_cli_s *pc = (camera_cli_s *)camera;
6441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6443 if (!pc || !pc->cb_info || !pan_step) {
6444 LOGE("NULL pointer %p %p", pc, pan_step);
6445 return CAMERA_ERROR_INVALID_PARAMETER;
6450 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6452 if (ret == CAMERA_ERROR_NONE)
6453 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6455 LOGD("ret : 0x%x", ret);
6461 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6463 int ret = CAMERA_ERROR_NONE;
6464 camera_cli_s *pc = (camera_cli_s *)camera;
6465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6467 if (!pc || !pc->cb_info || !min || !max) {
6468 LOGE("NULL pointer %p %p %p", pc, min, max);
6469 return CAMERA_ERROR_INVALID_PARAMETER;
6474 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6476 if (ret == CAMERA_ERROR_NONE) {
6477 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6478 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6481 LOGD("ret : 0x%x", ret);
6487 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6489 int ret = CAMERA_ERROR_NONE;
6490 camera_cli_s *pc = (camera_cli_s *)camera;
6491 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6492 camera_msg_param param0;
6493 camera_msg_param param1;
6495 if (!pc || !pc->cb_info) {
6496 LOGE("NULL handle");
6497 return CAMERA_ERROR_INVALID_PARAMETER;
6502 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6503 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6505 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6506 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6508 LOGD("ret : 0x%x", ret);
6514 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6516 int ret = CAMERA_ERROR_NONE;
6517 camera_cli_s *pc = (camera_cli_s *)camera;
6518 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6520 if (!pc || !pc->cb_info || !tilt_step) {
6521 LOGE("NULL pointer %p %p", pc, tilt_step);
6522 return CAMERA_ERROR_INVALID_PARAMETER;
6527 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6529 if (ret == CAMERA_ERROR_NONE)
6530 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6532 LOGD("ret : 0x%x", ret);
6538 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6540 int ret = CAMERA_ERROR_NONE;
6541 camera_cli_s *pc = (camera_cli_s *)camera;
6542 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6544 if (!pc || !pc->cb_info || !min || !max) {
6545 LOGE("NULL pointer %p %p %p", pc, min, max);
6546 return CAMERA_ERROR_INVALID_PARAMETER;
6551 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6553 if (ret == CAMERA_ERROR_NONE) {
6554 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6555 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6558 LOGD("ret : 0x%x", ret);
6564 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6566 int ret = CAMERA_ERROR_NONE;
6567 camera_cli_s *pc = (camera_cli_s *)camera;
6568 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6569 camera_msg_param param;
6570 int set_ptz_type = (int)ptz_type;
6572 if (!pc || !pc->cb_info) {
6573 LOGE("NULL handle");
6574 return CAMERA_ERROR_INVALID_PARAMETER;
6579 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6581 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6583 LOGD("ret : 0x%x", ret);
6589 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6591 int ret = CAMERA_ERROR_NONE;
6592 camera_cli_s *pc = (camera_cli_s *)camera;
6593 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6595 if (!pc || !pc->cb_info || !foreach_cb) {
6596 LOGE("NULL pointer %p %p", pc, foreach_cb);
6597 return CAMERA_ERROR_INVALID_PARAMETER;
6602 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6603 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6605 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6607 LOGD("ret : 0x%x", ret);
6613 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6615 int ret = CAMERA_ERROR_NONE;
6616 camera_cli_s *pc = (camera_cli_s *)camera;
6617 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6618 int set_display_roi_area[4] = {x, y, width, height};
6623 if (!pc || !pc->cb_info) {
6624 LOGE("NULL handle");
6625 return CAMERA_ERROR_INVALID_PARAMETER;
6630 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6631 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6632 if (ret != MM_ERROR_NONE) {
6633 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6634 return CAMERA_ERROR_INVALID_OPERATION;
6638 length = sizeof(set_display_roi_area) / sizeof(int) + \
6639 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6641 msg = muse_core_msg_new(api,
6642 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6645 LOGE("msg creation failed: api %d", api);
6646 return CAMERA_ERROR_OUT_OF_MEMORY;
6649 if (pc->cb_info->is_server_connected) {
6650 __camera_update_api_waiting(pc->cb_info, api, 1);
6652 g_mutex_lock(&pc->cb_info->fd_lock);
6653 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6654 g_mutex_unlock(&pc->cb_info->fd_lock);
6658 LOGE("message send failed");
6659 ret = CAMERA_ERROR_INVALID_OPERATION;
6661 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6664 __camera_update_api_waiting(pc->cb_info, api, -1);
6666 muse_core_msg_free(msg);
6668 LOGD("ret : 0x%x", ret);
6674 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6676 camera_cli_s *pc = (camera_cli_s *)camera;
6677 int ret = CAMERA_ERROR_NONE;
6678 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6680 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6681 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6682 return CAMERA_ERROR_INVALID_PARAMETER;
6687 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6689 if (ret == CAMERA_ERROR_NONE) {
6690 *x = pc->cb_info->get_display_roi_area[0];
6691 *y = pc->cb_info->get_display_roi_area[1];
6692 *width = pc->cb_info->get_display_roi_area[2];
6693 *height = pc->cb_info->get_display_roi_area[3];
6696 LOGD("ret : 0x%x", ret);
6702 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6704 int ret = CAMERA_ERROR_NONE;
6705 int get_device_state = 0;
6708 LOGE("NULL pointer");
6709 return CAMERA_ERROR_INVALID_PARAMETER;
6712 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6713 (int)device, "get_device_state", &get_device_state);
6715 if (ret == CAMERA_ERROR_NONE) {
6716 *state = (camera_device_state_e)get_device_state;
6717 LOGD("device state %d", *state);
6719 LOGE("failed 0x%x", ret);
6726 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6728 int ret = CAMERA_ERROR_NONE;
6729 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6730 camera_cb_info *info = NULL;
6732 if (!callback || !cb_id) {
6733 LOGE("invalid pointer %p %p", callback, cb_id);
6734 return CAMERA_ERROR_INVALID_PARAMETER;
6737 /* check camera support */
6738 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6739 if (ret != CAMERA_ERROR_NONE) {
6740 LOGE("get device state failed");
6744 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6746 info = g_new0(camera_cb_info, 1);
6748 LOGE("info failed");
6749 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6753 info->id = ++g_cam_dev_state_changed_cb_id;
6754 info->callback = (void *)callback;
6755 info->user_data = user_data;
6759 /* subscribe dbus signal for camera state change */
6760 if (!g_cam_dev_state_changed_cb_conn) {
6761 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6762 if (!g_cam_dev_state_changed_cb_conn) {
6763 LOGE("failed to get gdbus connection");
6764 ret = CAMERA_ERROR_INVALID_OPERATION;
6768 LOGD("subscribe signal %s - %s - %s",
6769 MM_CAMCORDER_DBUS_OBJECT,
6770 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6771 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6773 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6774 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6775 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6776 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6777 LOGE("failed to get gdbus connection");
6778 ret = CAMERA_ERROR_INVALID_OPERATION;
6782 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6785 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6787 LOGD("callback id %d", info->id);
6790 if (ret != CAMERA_ERROR_NONE) {
6796 if (g_cam_dev_state_changed_cb_conn) {
6797 g_object_unref(g_cam_dev_state_changed_cb_conn);
6798 g_cam_dev_state_changed_cb_conn = NULL;
6802 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6808 int camera_remove_device_state_changed_cb(int cb_id)
6810 int ret = CAMERA_ERROR_NONE;
6811 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6812 GList *tmp_list = NULL;
6813 camera_cb_info *info = NULL;
6815 /* check camera support */
6816 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6817 if (ret != CAMERA_ERROR_NONE) {
6818 LOGE("get device state failed");
6822 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6824 if (!g_cam_dev_state_changed_cb_list) {
6825 LOGE("there is no callback info");
6826 ret = CAMERA_ERROR_INVALID_OPERATION;
6830 tmp_list = g_cam_dev_state_changed_cb_list;
6833 info = tmp_list->data;
6834 tmp_list = tmp_list->next;
6841 if (info->id == cb_id) {
6842 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6847 if (!g_cam_dev_state_changed_cb_list) {
6848 /* no remained callback */
6849 if (g_cam_dev_state_changed_cb_conn) {
6850 /* unsubscribe signal */
6851 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6852 g_cam_dev_state_changed_cb_subscribe_id = 0;
6854 /* unref connection */
6855 g_object_unref(g_cam_dev_state_changed_cb_conn);
6856 g_cam_dev_state_changed_cb_conn = NULL;
6860 LOGD("id %d callback removed", cb_id);
6861 ret = CAMERA_ERROR_NONE;
6867 LOGE("id %d callback not found", cb_id);
6868 ret = CAMERA_ERROR_INVALID_PARAMETER;
6871 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);