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);
3200 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d",
3201 flip, mode, rotation, visible);
3203 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3204 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3205 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3206 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3208 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3209 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3210 LOGD("current setting : roi %d,%d,%dx%d", x, y, width, height);
3211 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3217 if (mm_ret != MM_ERROR_NONE) {
3218 LOGE("mm_ret 0x%x failed", mm_ret);
3219 return CAMERA_ERROR_INVALID_OPERATION;
3222 dp_info->type = type;
3224 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3226 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3228 if (ret == CAMERA_ERROR_NONE) {
3229 if (type == MM_DISPLAY_TYPE_EVAS)
3230 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3237 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3239 LOGD("type %d, display %p", type, display);
3240 return _camera_set_display(camera, (mm_display_type_e)type, display);
3244 int camera_set_preview_resolution(camera_h camera, int width, int height)
3246 int ret = CAMERA_ERROR_NONE;
3247 camera_state_e current_state = CAMERA_STATE_NONE;
3248 camera_cli_s *pc = (camera_cli_s *)camera;
3249 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3250 camera_msg_param param;
3253 if (!pc || !pc->cb_info) {
3254 LOGE("NULL handle");
3255 return CAMERA_ERROR_INVALID_PARAMETER;
3258 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3259 ret = camera_get_state(camera, ¤t_state);
3260 if (ret != CAMERA_ERROR_NONE) {
3261 LOGE("failed to get current state 0x%x", ret);
3265 if (current_state == CAMERA_STATE_PREVIEW) {
3266 ret = _camera_stop_evas_rendering(camera, true);
3267 if (ret != CAMERA_ERROR_NONE)
3272 value = (width << 16) | height;
3273 CAMERA_MSG_PARAM_SET(param, INT, value);
3275 LOGD("%dx%d -> 0x%x", width, height, value);
3277 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3279 LOGD("ret : 0x%x", ret);
3281 if (current_state == CAMERA_STATE_PREVIEW) {
3282 LOGW("restart evas rendering");
3283 _camera_start_evas_rendering(camera);
3290 int camera_set_capture_resolution(camera_h camera, int width, int height)
3292 int ret = CAMERA_ERROR_NONE;
3293 camera_cli_s *pc = (camera_cli_s *)camera;
3294 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3295 camera_msg_param param;
3298 if (!pc || !pc->cb_info) {
3299 LOGE("NULL handle");
3300 return CAMERA_ERROR_INVALID_PARAMETER;
3305 value = (width << 16) | height;
3306 CAMERA_MSG_PARAM_SET(param, INT, value);
3308 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3310 LOGD("ret : 0x%x", ret);
3316 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3318 int ret = CAMERA_ERROR_NONE;
3319 int set_format = (int)format;
3320 camera_cli_s *pc = (camera_cli_s *)camera;
3321 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3322 camera_msg_param param;
3324 if (!pc || !pc->cb_info) {
3325 LOGE("NULL handle");
3326 return CAMERA_ERROR_INVALID_PARAMETER;
3329 LOGD("Enter - format %d", set_format);
3331 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3333 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3335 LOGD("ret : 0x%x", ret);
3341 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3343 int ret = CAMERA_ERROR_NONE;
3344 int set_format = (int)format;
3345 camera_msg_param param;
3346 camera_cli_s *pc = (camera_cli_s *)camera;
3347 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3349 if (!pc || !pc->cb_info) {
3350 LOGE("NULL handle");
3351 return CAMERA_ERROR_INVALID_PARAMETER;
3354 LOGD("Enter - format %d", set_format);
3356 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3358 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3360 if (ret == CAMERA_ERROR_NONE)
3361 pc->cb_info->preview_format = set_format;
3363 LOGD("ret : 0x%x", ret);
3369 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3371 int ret = CAMERA_ERROR_NONE;
3372 camera_cli_s *pc = (camera_cli_s *)camera;
3373 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3375 if (!pc || !pc->cb_info || !width || !height) {
3376 LOGE("NULL pointer %p %p %p", pc, width, height);
3377 return CAMERA_ERROR_INVALID_PARAMETER;
3382 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3384 if (ret == CAMERA_ERROR_NONE) {
3385 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3386 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3389 LOGD("ret : 0x%x", ret);
3395 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3397 int ret = CAMERA_ERROR_NONE;
3398 int set_rotation = (int)rotation;
3399 camera_cli_s *pc = (camera_cli_s *)camera;
3400 camera_msg_param param;
3402 if (!pc || !pc->cb_info) {
3403 LOGE("NULL handle");
3404 return CAMERA_ERROR_INVALID_PARAMETER;
3407 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3408 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3409 if (ret != MM_ERROR_NONE) {
3410 LOGE("failed to set rotation for evas surface 0x%x", ret);
3411 return CAMERA_ERROR_INVALID_OPERATION;
3415 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3417 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3423 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3425 int ret = CAMERA_ERROR_NONE;
3426 camera_cli_s *pc = (camera_cli_s *)camera;
3428 if (!pc || !pc->cb_info || !rotation) {
3429 LOGE("NULL pointer %p %p", pc, rotation);
3430 return CAMERA_ERROR_INVALID_PARAMETER;
3433 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3435 if (ret == CAMERA_ERROR_NONE)
3436 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3442 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3444 int ret = CAMERA_ERROR_NONE;
3445 int set_flip = (int)flip;
3446 camera_cli_s *pc = (camera_cli_s *)camera;
3447 camera_msg_param param;
3449 if (!pc || !pc->cb_info) {
3450 LOGE("NULL handle");
3451 return CAMERA_ERROR_INVALID_PARAMETER;
3454 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3455 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3456 if (ret != MM_ERROR_NONE) {
3457 LOGE("failed to set flip for evas surface 0x%x", ret);
3458 return CAMERA_ERROR_INVALID_OPERATION;
3462 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3464 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3470 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3472 int ret = CAMERA_ERROR_NONE;
3473 camera_cli_s *pc = (camera_cli_s *)camera;
3475 if (!pc || !pc->cb_info || !flip) {
3476 LOGE("NULL pointer %p %p", pc, flip);
3477 return CAMERA_ERROR_INVALID_PARAMETER;
3480 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3482 if (ret == CAMERA_ERROR_NONE)
3483 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3489 int camera_set_display_visible(camera_h camera, bool visible)
3491 int ret = CAMERA_ERROR_NONE;
3492 int set_visible = (int)visible;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3494 camera_msg_param param;
3496 if (!pc || !pc->cb_info) {
3497 LOGE("NULL handle");
3498 return CAMERA_ERROR_INVALID_PARAMETER;
3501 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3502 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3503 if (ret != MM_ERROR_NONE) {
3504 LOGE("failed to set visible for evas surface 0x%x", ret);
3505 return CAMERA_ERROR_INVALID_OPERATION;
3509 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3511 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3517 int camera_is_display_visible(camera_h camera, bool *visible)
3519 int ret = CAMERA_ERROR_NONE;
3520 camera_cli_s *pc = (camera_cli_s *)camera;
3522 if (!pc || !pc->cb_info || !visible) {
3523 LOGE("NULL pointer %p %p", pc, visible);
3524 return CAMERA_ERROR_INVALID_PARAMETER;
3527 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3529 if (ret == CAMERA_ERROR_NONE)
3530 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3536 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3538 int ret = CAMERA_ERROR_NONE;
3539 int set_mode = (int)mode;
3540 camera_cli_s *pc = (camera_cli_s *)camera;
3541 camera_msg_param param;
3543 if (!pc || !pc->cb_info) {
3544 LOGE("NULL handle");
3545 return CAMERA_ERROR_INVALID_PARAMETER;
3548 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3549 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3550 if (ret != MM_ERROR_NONE) {
3551 LOGE("failed to set geometry for evas surface 0x%x", ret);
3552 return CAMERA_ERROR_INVALID_OPERATION;
3556 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3558 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3564 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3566 int ret = CAMERA_ERROR_NONE;
3567 camera_cli_s *pc = (camera_cli_s *)camera;
3569 if (!pc || !pc->cb_info || !mode) {
3570 LOGE("NULL pointer %p %p", pc, mode);
3571 return CAMERA_ERROR_INVALID_PARAMETER;
3574 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3576 if (ret == CAMERA_ERROR_NONE)
3577 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3583 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3585 int ret = CAMERA_ERROR_NONE;
3586 int set_hint = (int)hint;
3587 camera_cli_s *pc = (camera_cli_s *)camera;
3588 camera_msg_param param;
3590 if (!pc || !pc->cb_info) {
3591 LOGE("NULL handle");
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3595 LOGD("Enter - hint %d", set_hint);
3597 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3599 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3605 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3607 int ret = CAMERA_ERROR_NONE;
3608 camera_cli_s *pc = (camera_cli_s *)camera;
3609 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3611 if (!pc || !pc->cb_info || !hint) {
3612 LOGE("NULL pointer %p %p", pc, hint);
3613 return CAMERA_ERROR_INVALID_PARAMETER;
3616 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3618 if (ret == CAMERA_ERROR_NONE) {
3619 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3620 LOGD("display reuse hint %d", *hint);
3627 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3629 int ret = CAMERA_ERROR_NONE;
3630 camera_cli_s *pc = (camera_cli_s *)camera;
3631 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3633 if (!pc || !pc->cb_info || !width || !height) {
3634 LOGE("NULL pointer %p %p %p", pc, width, height);
3635 return CAMERA_ERROR_INVALID_PARAMETER;
3640 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3642 if (ret == CAMERA_ERROR_NONE) {
3643 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3644 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3647 LOGD("ret : 0x%x", ret);
3653 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3655 int ret = CAMERA_ERROR_NONE;
3656 camera_cli_s *pc = (camera_cli_s *)camera;
3657 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3659 if (!pc || !pc->cb_info || !format) {
3660 LOGE("NULL pointer %p %p", pc, format);
3661 return CAMERA_ERROR_INVALID_PARAMETER;
3666 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3668 if (ret == CAMERA_ERROR_NONE)
3669 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3671 LOGD("ret : 0x%x", ret);
3677 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3679 int ret = CAMERA_ERROR_NONE;
3680 camera_cli_s *pc = (camera_cli_s *)camera;
3681 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3683 if (!pc || !pc->cb_info || !format) {
3684 LOGE("NULL pointer %p %p", pc, format);
3685 return CAMERA_ERROR_INVALID_PARAMETER;
3690 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3692 if (ret == CAMERA_ERROR_NONE)
3693 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3695 LOGD("ret : 0x%x", ret);
3701 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3703 int ret = CAMERA_ERROR_NONE;
3704 camera_cli_s *pc = (camera_cli_s *)camera;
3705 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3707 if (!pc || !pc->cb_info || !facing_direction) {
3708 LOGE("NULL pointer %p %p", pc, facing_direction);
3709 return CAMERA_ERROR_INVALID_PARAMETER;
3714 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3716 if (ret == CAMERA_ERROR_NONE)
3717 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3719 LOGD("ret : 0x%x", ret);
3725 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3727 int ret = CAMERA_ERROR_NONE;
3728 camera_cli_s *pc = (camera_cli_s *)camera;
3729 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3731 if (!pc || !pc->cb_info || !callback) {
3732 LOGE("NULL pointer %p %p", pc, callback);
3733 return CAMERA_ERROR_INVALID_PARAMETER;
3738 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3740 if (ret == CAMERA_ERROR_NONE) {
3741 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3743 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3744 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3746 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3748 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3751 LOGD("ret : 0x%x", ret);
3757 int camera_unset_preview_cb(camera_h camera)
3759 int ret = CAMERA_ERROR_NONE;
3760 camera_cli_s *pc = (camera_cli_s *)camera;
3761 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3763 if (!pc || !pc->cb_info) {
3764 LOGE("NULL handle");
3765 return CAMERA_ERROR_INVALID_PARAMETER;
3770 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3772 if (ret == CAMERA_ERROR_NONE) {
3773 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3775 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3776 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3778 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3780 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3783 LOGD("ret : 0x%x", ret);
3789 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3791 int ret = CAMERA_ERROR_NONE;
3792 camera_cli_s *pc = (camera_cli_s *)camera;
3793 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3795 if (!pc || !pc->cb_info) {
3796 LOGE("NULL handle");
3797 return CAMERA_ERROR_INVALID_PARAMETER;
3800 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3801 LOGE("NOT SUPPORTED");
3802 return CAMERA_ERROR_NOT_SUPPORTED;
3805 if (callback == NULL) {
3806 LOGE("NULL callback");
3807 return CAMERA_ERROR_INVALID_PARAMETER;
3812 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3814 if (ret == CAMERA_ERROR_NONE) {
3815 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3820 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3823 LOGD("ret : 0x%x", ret);
3829 int camera_unset_media_packet_preview_cb(camera_h camera)
3831 int ret = CAMERA_ERROR_NONE;
3832 camera_cli_s *pc = (camera_cli_s *)camera;
3833 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3835 if (!pc || !pc->cb_info) {
3836 LOGE("NULL handle");
3837 return CAMERA_ERROR_INVALID_PARAMETER;
3842 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3844 if (ret == CAMERA_ERROR_NONE) {
3845 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3847 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3848 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3850 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3853 LOGD("ret : 0x%x", ret);
3859 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3861 int ret = CAMERA_ERROR_NONE;
3862 camera_cli_s *pc = (camera_cli_s *)camera;
3863 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3865 if (!pc || !pc->cb_info || !callback) {
3866 LOGE("NULL pointer %p %p", pc, callback);
3867 return CAMERA_ERROR_INVALID_PARAMETER;
3872 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3874 if (ret == CAMERA_ERROR_NONE) {
3875 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3877 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3878 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3880 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3883 LOGD("ret : 0x%x", ret);
3889 int camera_unset_state_changed_cb(camera_h camera)
3891 int ret = CAMERA_ERROR_NONE;
3892 camera_cli_s *pc = (camera_cli_s *)camera;
3893 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3895 if (!pc || !pc->cb_info) {
3896 LOGE("NULL handle");
3897 return CAMERA_ERROR_INVALID_PARAMETER;
3902 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3904 if (ret == CAMERA_ERROR_NONE) {
3905 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3907 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3908 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3910 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3913 LOGD("ret : 0x%x", ret);
3919 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3921 int ret = CAMERA_ERROR_NONE;
3922 camera_cli_s *pc = (camera_cli_s *)camera;
3923 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3925 if (!pc || !pc->cb_info || !callback) {
3926 LOGE("NULL pointer %p %p", pc, callback);
3927 return CAMERA_ERROR_INVALID_PARAMETER;
3932 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3934 if (ret == CAMERA_ERROR_NONE) {
3935 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3937 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3938 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3940 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3943 LOGD("ret : 0x%x", ret);
3949 int camera_unset_interrupted_cb(camera_h camera)
3951 int ret = CAMERA_ERROR_NONE;
3952 camera_cli_s *pc = (camera_cli_s *)camera;
3953 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3955 if (!pc || !pc->cb_info) {
3956 LOGE("NULL handle");
3957 return CAMERA_ERROR_INVALID_PARAMETER;
3962 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3964 if (ret == CAMERA_ERROR_NONE) {
3965 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3967 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3968 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3970 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3973 LOGD("ret : 0x%x", ret);
3979 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3981 int ret = CAMERA_ERROR_NONE;
3982 camera_cli_s *pc = (camera_cli_s *)camera;
3983 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3985 if (!pc || !pc->cb_info || !callback) {
3986 LOGE("NULL pointer %p %p", pc, callback);
3987 return CAMERA_ERROR_INVALID_PARAMETER;
3992 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3994 if (ret == CAMERA_ERROR_NONE) {
3995 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3997 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3998 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4000 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4003 LOGD("ret : 0x%x", ret);
4009 int camera_unset_interrupt_started_cb(camera_h camera)
4011 int ret = CAMERA_ERROR_NONE;
4012 camera_cli_s *pc = (camera_cli_s *)camera;
4013 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4015 if (!pc || !pc->cb_info) {
4016 LOGE("NULL handle");
4017 return CAMERA_ERROR_INVALID_PARAMETER;
4022 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4024 if (ret == CAMERA_ERROR_NONE) {
4025 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4027 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4028 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4030 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4033 LOGD("ret : 0x%x", ret);
4039 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4041 int ret = CAMERA_ERROR_NONE;
4042 camera_cli_s *pc = (camera_cli_s *)camera;
4043 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4045 if (!pc || !pc->cb_info || !callback) {
4046 LOGE("NULL pointer %p %p", pc, callback);
4047 return CAMERA_ERROR_INVALID_PARAMETER;
4052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4054 if (ret == CAMERA_ERROR_NONE) {
4055 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4057 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4058 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4060 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4063 LOGD("ret : 0x%x", ret);
4069 int camera_unset_focus_changed_cb(camera_h camera)
4071 int ret = CAMERA_ERROR_NONE;
4072 camera_cli_s *pc = (camera_cli_s *)camera;
4073 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4075 if (!pc || !pc->cb_info) {
4076 LOGE("NULL handle");
4077 return CAMERA_ERROR_INVALID_PARAMETER;
4082 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4084 if (ret == CAMERA_ERROR_NONE) {
4085 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4087 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4088 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4090 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4093 LOGD("ret : 0x%x", ret);
4099 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4101 int ret = CAMERA_ERROR_NONE;
4102 camera_cli_s *pc = (camera_cli_s *)camera;
4103 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4105 if (!pc || !pc->cb_info || !callback) {
4106 LOGE("NULL pointer %p %p", pc, callback);
4107 return CAMERA_ERROR_INVALID_PARAMETER;
4112 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4114 if (ret == CAMERA_ERROR_NONE) {
4115 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4117 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4118 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4120 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4123 LOGD("ret : 0x%x", ret);
4129 int camera_unset_error_cb(camera_h camera)
4131 int ret = CAMERA_ERROR_NONE;
4132 camera_cli_s *pc = (camera_cli_s *)camera;
4133 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4135 if (!pc || !pc->cb_info) {
4136 LOGE("NULL handle");
4137 return CAMERA_ERROR_INVALID_PARAMETER;
4142 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4144 if (ret == CAMERA_ERROR_NONE) {
4145 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4147 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4148 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4150 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4153 LOGD("ret : 0x%x", ret);
4159 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4161 int ret = CAMERA_ERROR_NONE;
4162 camera_cli_s *pc = (camera_cli_s *)camera;
4163 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4165 if (!pc || !pc->cb_info || !foreach_cb) {
4166 LOGE("NULL pointer %p %p", pc, foreach_cb);
4167 return CAMERA_ERROR_INVALID_PARAMETER;
4172 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4173 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4175 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4177 LOGD("ret : 0x%x", ret);
4183 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4185 int ret = CAMERA_ERROR_NONE;
4186 camera_cli_s *pc = (camera_cli_s *)camera;
4187 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4189 if (!pc || !pc->cb_info || !foreach_cb) {
4190 LOGE("NULL pointer %p %p", pc, foreach_cb);
4191 return CAMERA_ERROR_INVALID_PARAMETER;
4196 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4197 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4199 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4201 LOGD("ret : 0x%x", ret);
4207 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4209 int ret = CAMERA_ERROR_NONE;
4210 camera_cli_s *pc = (camera_cli_s *)camera;
4211 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4213 if (!pc || !pc->cb_info || !foreach_cb) {
4214 LOGE("NULL pointer %p %p", pc, foreach_cb);
4215 return CAMERA_ERROR_INVALID_PARAMETER;
4220 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4221 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4223 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4225 LOGD("ret : 0x%x", ret);
4231 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4233 int ret = CAMERA_ERROR_NONE;
4234 camera_cli_s *pc = (camera_cli_s *)camera;
4235 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4237 if (!pc || !pc->cb_info || !foreach_cb) {
4238 LOGE("NULL pointer %p %p", pc, foreach_cb);
4239 return CAMERA_ERROR_INVALID_PARAMETER;
4244 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4245 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4247 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4249 LOGD("ret : 0x%x", ret);
4255 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4257 int ret = CAMERA_ERROR_NONE;
4258 camera_cli_s *pc = (camera_cli_s *)camera;
4259 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4261 if (!pc || !pc->cb_info || !width || !height) {
4262 LOGE("NULL pointer %p %p %p", pc, width, height);
4263 return CAMERA_ERROR_INVALID_PARAMETER;
4267 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4269 if (ret == CAMERA_ERROR_NONE) {
4270 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4271 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4274 LOGD("ret : 0x%x", ret);
4280 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4282 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4286 if (!pc || !pc->cb_info || !angle) {
4287 LOGE("NULL pointer %p %p", pc, angle);
4288 return CAMERA_ERROR_INVALID_PARAMETER;
4293 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4295 if (ret == CAMERA_ERROR_NONE)
4296 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4298 LOGD("ret : 0x%x", ret);
4304 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4306 int ret = CAMERA_ERROR_NONE;
4307 camera_cli_s *pc = (camera_cli_s *)camera;
4308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4309 camera_msg_param param;
4310 int set_mode = (int)mode;
4312 if (!pc || !pc->cb_info) {
4313 LOGE("NULL handle");
4314 return CAMERA_ERROR_INVALID_PARAMETER;
4319 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4321 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4323 LOGD("ret : 0x%x", ret);
4329 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4331 int ret = CAMERA_ERROR_NONE;
4332 camera_cli_s *pc = (camera_cli_s *)camera;
4333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4335 if (!pc || !pc->cb_info || !mode) {
4336 LOGE("NULL pointer %p %p", pc, mode);
4337 return CAMERA_ERROR_INVALID_PARAMETER;
4342 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4344 if (ret == CAMERA_ERROR_NONE)
4345 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4347 LOGD("ret : 0x%x", ret);
4353 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4355 int ret = CAMERA_ERROR_NONE;
4356 camera_cli_s *pc = (camera_cli_s *)camera;
4357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4359 if (!pc || !pc->cb_info || !foreach_cb) {
4360 LOGE("NULL pointer %p %p", pc, foreach_cb);
4361 return CAMERA_ERROR_INVALID_PARAMETER;
4366 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4367 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4369 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4371 LOGD("Finish, return :%x", ret);
4377 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4379 int ret = CAMERA_ERROR_NONE;
4380 camera_cli_s *pc = (camera_cli_s *)camera;
4381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4382 camera_msg_param param;
4383 int set_fps = (int)fps;
4385 if (!pc || !pc->cb_info) {
4386 LOGE("NULL handle");
4387 return CAMERA_ERROR_INVALID_PARAMETER;
4392 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4394 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4396 LOGD("ret : 0x%x", ret);
4402 int camera_attr_set_image_quality(camera_h camera, int quality)
4404 int ret = CAMERA_ERROR_NONE;
4405 camera_cli_s *pc = (camera_cli_s *)camera;
4406 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4407 camera_msg_param param;
4409 if (!pc || !pc->cb_info) {
4410 LOGE("NULL handle");
4411 return CAMERA_ERROR_INVALID_PARAMETER;
4416 CAMERA_MSG_PARAM_SET(param, INT, quality);
4418 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4420 LOGD("ret : 0x%x", ret);
4426 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4428 int ret = CAMERA_ERROR_NONE;
4429 camera_cli_s *pc = (camera_cli_s *)camera;
4430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4432 if (!pc || !pc->cb_info || !fps) {
4433 LOGE("NULL pointer %p %p", pc, fps);
4434 return CAMERA_ERROR_INVALID_PARAMETER;
4439 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4441 if (ret == CAMERA_ERROR_NONE)
4442 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4444 LOGD("ret : 0x%x", ret);
4450 int camera_attr_get_image_quality(camera_h camera, int *quality)
4452 int ret = CAMERA_ERROR_NONE;
4453 camera_cli_s *pc = (camera_cli_s *)camera;
4454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4456 if (!pc || !pc->cb_info || !quality) {
4457 LOGE("NULL pointer %p %p", pc, quality);
4458 return CAMERA_ERROR_INVALID_PARAMETER;
4463 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4465 if (ret == CAMERA_ERROR_NONE)
4466 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4468 LOGD("ret : 0x%x", ret);
4474 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4476 int ret = CAMERA_ERROR_NONE;
4477 camera_cli_s *pc = (camera_cli_s *)camera;
4478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4480 if (!pc || !pc->cb_info || !bitrate) {
4481 LOGE("NULL pointer %p %p", pc, bitrate);
4482 return CAMERA_ERROR_INVALID_PARAMETER;
4487 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4489 if (ret == CAMERA_ERROR_NONE)
4490 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4492 LOGD("ret : 0x%x", ret);
4498 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4500 int ret = CAMERA_ERROR_NONE;
4501 camera_cli_s *pc = (camera_cli_s *)camera;
4502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4503 camera_msg_param param;
4504 int set_bitrate = bitrate;
4506 if (!pc || !pc->cb_info) {
4507 LOGE("NULL handle");
4508 return CAMERA_ERROR_INVALID_PARAMETER;
4513 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4515 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4517 LOGD("ret : 0x%x", ret);
4523 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4525 int ret = CAMERA_ERROR_NONE;
4526 camera_cli_s *pc = (camera_cli_s *)camera;
4527 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4529 if (!pc || !pc->cb_info || !interval) {
4530 LOGE("NULL pointer %p %p", pc, interval);
4531 return CAMERA_ERROR_INVALID_PARAMETER;
4536 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4538 if (ret == CAMERA_ERROR_NONE)
4539 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4541 LOGD("ret : 0x%x", ret);
4547 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4549 int ret = CAMERA_ERROR_NONE;
4550 camera_cli_s *pc = (camera_cli_s *)camera;
4551 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4552 camera_msg_param param;
4553 int set_gop_interval = interval;
4555 if (!pc || !pc->cb_info) {
4556 LOGE("NULL handle");
4557 return CAMERA_ERROR_INVALID_PARAMETER;
4562 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4564 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4566 LOGD("ret : 0x%x", ret);
4572 int camera_attr_set_zoom(camera_h camera, int zoom)
4574 int ret = CAMERA_ERROR_NONE;
4575 camera_cli_s *pc = (camera_cli_s *)camera;
4576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4577 camera_msg_param param;
4579 if (!pc || !pc->cb_info) {
4580 LOGE("NULL handle");
4581 return CAMERA_ERROR_INVALID_PARAMETER;
4584 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4586 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4588 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4590 LOGD("ret : 0x%x", ret);
4596 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4598 int ret = CAMERA_ERROR_NONE;
4599 camera_cli_s *pc = (camera_cli_s *)camera;
4600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4601 camera_msg_param param;
4602 int set_mode = (int)mode;
4604 if (!pc || !pc->cb_info) {
4605 LOGE("NULL handle");
4606 return CAMERA_ERROR_INVALID_PARAMETER;
4609 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4611 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4613 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4619 int camera_attr_set_af_area(camera_h camera, int x, int y)
4621 int ret = CAMERA_ERROR_NONE;
4622 camera_cli_s *pc = (camera_cli_s *)camera;
4623 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4624 camera_msg_param param;
4627 if (!pc || !pc->cb_info) {
4628 LOGE("NULL handle");
4629 return CAMERA_ERROR_INVALID_PARAMETER;
4632 LOGD("Enter - %d,%d", x, y);
4634 value = (x << 16) | y;
4635 CAMERA_MSG_PARAM_SET(param, INT, value);
4637 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4639 LOGD("ret : 0x%x", ret);
4645 int camera_attr_clear_af_area(camera_h camera)
4647 int ret = CAMERA_ERROR_NONE;
4648 camera_cli_s *pc = (camera_cli_s *)camera;
4649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4651 if (!pc || !pc->cb_info) {
4652 LOGE("NULL handle");
4653 return CAMERA_ERROR_INVALID_PARAMETER;
4658 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4660 LOGD("ret : 0x%x", ret);
4666 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4668 int ret = CAMERA_ERROR_NONE;
4669 camera_cli_s *pc = (camera_cli_s *)camera;
4670 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4671 camera_msg_param param;
4672 int set_mode = (int)mode;
4674 if (!pc || !pc->cb_info) {
4675 LOGE("NULL handle");
4676 return CAMERA_ERROR_INVALID_PARAMETER;
4681 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4683 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4685 LOGD("ret : 0x%x", ret);
4691 int camera_attr_set_exposure(camera_h camera, int value)
4693 int ret = CAMERA_ERROR_NONE;
4694 camera_cli_s *pc = (camera_cli_s *)camera;
4695 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4696 camera_msg_param param;
4698 if (!pc || !pc->cb_info) {
4699 LOGE("NULL handle");
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4705 CAMERA_MSG_PARAM_SET(param, INT, value);
4707 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4709 LOGD("ret : 0x%x", ret);
4715 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4717 int ret = CAMERA_ERROR_NONE;
4718 camera_cli_s *pc = (camera_cli_s *)camera;
4719 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4720 camera_msg_param param;
4721 int set_iso = (int)iso;
4723 if (!pc || !pc->cb_info) {
4724 LOGE("NULL handle");
4725 return CAMERA_ERROR_INVALID_PARAMETER;
4730 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4734 LOGD("ret : 0x%x", ret);
4740 int camera_attr_set_brightness(camera_h camera, int level)
4742 int ret = CAMERA_ERROR_NONE;
4743 camera_cli_s *pc = (camera_cli_s *)camera;
4744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4745 camera_msg_param param;
4747 if (!pc || !pc->cb_info) {
4748 LOGE("NULL handle");
4749 return CAMERA_ERROR_INVALID_PARAMETER;
4754 CAMERA_MSG_PARAM_SET(param, INT, level);
4756 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4758 LOGD("ret : 0x%x", ret);
4764 int camera_attr_set_contrast(camera_h camera, int level)
4766 int ret = CAMERA_ERROR_NONE;
4767 camera_cli_s *pc = (camera_cli_s *)camera;
4768 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4769 camera_msg_param param;
4771 if (!pc || !pc->cb_info) {
4772 LOGE("NULL handle");
4773 return CAMERA_ERROR_INVALID_PARAMETER;
4778 CAMERA_MSG_PARAM_SET(param, INT, level);
4780 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4782 LOGD("ret : 0x%x", ret);
4788 int camera_attr_set_hue(camera_h camera, int level)
4790 int ret = CAMERA_ERROR_NONE;
4791 camera_cli_s *pc = (camera_cli_s *)camera;
4792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4793 camera_msg_param param;
4795 if (!pc || !pc->cb_info) {
4796 LOGE("NULL handle");
4797 return CAMERA_ERROR_INVALID_PARAMETER;
4802 CAMERA_MSG_PARAM_SET(param, INT, level);
4804 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4806 LOGD("ret : 0x%x", ret);
4812 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4817 camera_msg_param param;
4818 int set_whitebalance = (int)wb;
4820 if (!pc || !pc->cb_info) {
4821 LOGE("NULL handle");
4822 return CAMERA_ERROR_INVALID_PARAMETER;
4827 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4829 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4831 LOGD("ret : 0x%x", ret);
4837 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4839 int ret = CAMERA_ERROR_NONE;
4840 camera_cli_s *pc = (camera_cli_s *)camera;
4841 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4842 camera_msg_param param;
4843 int set_effect = (int)effect;
4845 if (!pc || !pc->cb_info) {
4846 LOGE("NULL handle");
4847 return CAMERA_ERROR_INVALID_PARAMETER;
4852 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4854 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4856 LOGD("ret : 0x%x", ret);
4862 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4864 int ret = CAMERA_ERROR_NONE;
4865 camera_cli_s *pc = (camera_cli_s *)camera;
4866 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4867 camera_msg_param param;
4868 int set_mode = (int)mode;
4870 if (!pc || !pc->cb_info) {
4871 LOGE("NULL handle");
4872 return CAMERA_ERROR_INVALID_PARAMETER;
4877 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4879 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4881 LOGD("ret : 0x%x", ret);
4887 int camera_attr_enable_tag(camera_h camera, bool enable)
4889 int ret = CAMERA_ERROR_NONE;
4890 camera_cli_s *pc = (camera_cli_s *)camera;
4891 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4892 camera_msg_param param;
4893 int set_enable = (int)enable;
4895 if (!pc || !pc->cb_info) {
4896 LOGE("NULL handle");
4897 return CAMERA_ERROR_INVALID_PARAMETER;
4902 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4906 LOGD("ret : 0x%x", ret);
4912 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4917 camera_msg_param param;
4919 if (!pc || !pc->cb_info || !description) {
4920 LOGE("NULL pointer %p %p", pc, description);
4921 return CAMERA_ERROR_INVALID_PARAMETER;
4926 CAMERA_MSG_PARAM_SET(param, STRING, description);
4928 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4930 LOGD("ret : 0x%x", ret);
4936 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4938 int ret = CAMERA_ERROR_NONE;
4939 camera_cli_s *pc = (camera_cli_s *)camera;
4940 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4941 camera_msg_param param;
4942 int set_orientation = (int)orientation;
4944 if (!pc || !pc->cb_info) {
4945 LOGE("NULL handle");
4946 return CAMERA_ERROR_INVALID_PARAMETER;
4951 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4953 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4955 LOGD("ret : 0x%x", ret);
4961 int camera_attr_set_tag_software(camera_h camera, const char *software)
4963 int ret = CAMERA_ERROR_NONE;
4964 camera_cli_s *pc = (camera_cli_s *)camera;
4965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4966 camera_msg_param param;
4968 if (!pc || !pc->cb_info || !software) {
4969 LOGE("NULL pointer %p %p", pc, software);
4970 return CAMERA_ERROR_INVALID_PARAMETER;
4973 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4975 CAMERA_MSG_PARAM_SET(param, STRING, software);
4977 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4979 LOGD("ret : 0x%x", ret);
4985 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4987 int ret = CAMERA_ERROR_NONE;
4988 camera_cli_s *pc = (camera_cli_s *)camera;
4989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4990 double set_geotag[3] = {latitude, longitude, altitude};
4995 if (!pc || !pc->cb_info) {
4996 LOGE("NULL handle");
4997 return CAMERA_ERROR_INVALID_PARAMETER;
5002 length = sizeof(set_geotag) / sizeof(int) + \
5003 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5005 msg = muse_core_msg_new(api,
5006 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5009 LOGE("msg creation failed: api %d", api);
5010 return CAMERA_ERROR_OUT_OF_MEMORY;
5013 if (pc->cb_info->is_server_connected) {
5014 __camera_update_api_waiting(pc->cb_info, api, 1);
5016 g_mutex_lock(&pc->cb_info->fd_lock);
5017 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5018 g_mutex_unlock(&pc->cb_info->fd_lock);
5022 LOGE("message send failed");
5023 ret = CAMERA_ERROR_INVALID_OPERATION;
5025 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5028 __camera_update_api_waiting(pc->cb_info, api, -1);
5030 muse_core_msg_free(msg);
5032 LOGD("ret : 0x%x", ret);
5038 int camera_attr_remove_geotag(camera_h camera)
5040 int ret = CAMERA_ERROR_NONE;
5041 camera_cli_s *pc = (camera_cli_s *)camera;
5042 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5044 if (!pc || !pc->cb_info) {
5045 LOGE("NULL handle");
5046 return CAMERA_ERROR_INVALID_PARAMETER;
5051 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5053 LOGD("ret : 0x%x", ret);
5059 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5061 int ret = CAMERA_ERROR_NONE;
5062 camera_cli_s *pc = (camera_cli_s *)camera;
5063 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5064 camera_msg_param param;
5065 int set_mode = (int)mode;
5067 if (!pc || !pc->cb_info) {
5068 LOGE("NULL handle");
5069 return CAMERA_ERROR_INVALID_PARAMETER;
5074 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5076 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5078 LOGD("ret : 0x%x", ret);
5084 int camera_attr_get_zoom(camera_h camera, int *zoom)
5086 int ret = CAMERA_ERROR_NONE;
5087 camera_cli_s *pc = (camera_cli_s *)camera;
5088 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5090 if (!pc || !pc->cb_info || !zoom) {
5091 LOGE("NULL pointer %p %p", pc, zoom);
5092 return CAMERA_ERROR_INVALID_PARAMETER;
5097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5099 if (ret == CAMERA_ERROR_NONE)
5100 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5102 LOGD("ret : 0x%x", ret);
5108 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5110 int ret = CAMERA_ERROR_NONE;
5111 camera_cli_s *pc = (camera_cli_s *)camera;
5112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5114 if (!pc || !pc->cb_info || !min || !max) {
5115 LOGE("NULL pointer %p %p %p", pc, min, max);
5116 return CAMERA_ERROR_INVALID_PARAMETER;
5121 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5123 if (ret == CAMERA_ERROR_NONE) {
5124 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5125 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5128 LOGD("ret : 0x%x", ret);
5134 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5136 int ret = CAMERA_ERROR_NONE;
5137 camera_cli_s *pc = (camera_cli_s *)camera;
5138 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5140 if (!pc || !pc->cb_info || !mode) {
5141 LOGE("NULL pointer %p %p", pc, mode);
5142 return CAMERA_ERROR_INVALID_PARAMETER;
5147 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5149 if (ret == CAMERA_ERROR_NONE)
5150 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5152 LOGD("ret : 0x%x", ret);
5158 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5160 int ret = CAMERA_ERROR_NONE;
5161 camera_cli_s *pc = (camera_cli_s *)camera;
5162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5164 if (!pc || !pc->cb_info || !mode) {
5165 LOGE("NULL pointer %p %p", pc, mode);
5166 return CAMERA_ERROR_INVALID_PARAMETER;
5171 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5173 if (ret == CAMERA_ERROR_NONE)
5174 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5176 LOGD("ret : 0x%x", ret);
5182 int camera_attr_get_exposure(camera_h camera, int *value)
5184 int ret = CAMERA_ERROR_NONE;
5185 camera_cli_s *pc = (camera_cli_s *)camera;
5186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5188 if (!pc || !pc->cb_info || !value) {
5189 LOGE("NULL pointer %p %p", pc, value);
5190 return CAMERA_ERROR_INVALID_PARAMETER;
5195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5197 if (ret == CAMERA_ERROR_NONE)
5198 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5200 LOGD("ret : 0x%x", ret);
5206 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5208 int ret = CAMERA_ERROR_NONE;
5209 camera_cli_s *pc = (camera_cli_s *)camera;
5210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5212 if (!pc || !pc->cb_info || !min || !max) {
5213 LOGE("NULL pointer %p %p %p", pc, min, max);
5214 return CAMERA_ERROR_INVALID_PARAMETER;
5219 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5221 if (ret == CAMERA_ERROR_NONE) {
5222 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5223 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5226 LOGD("ret : 0x%x", ret);
5232 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5234 int ret = CAMERA_ERROR_NONE;
5235 camera_cli_s *pc = (camera_cli_s *)camera;
5236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5238 if (!pc || !pc->cb_info || !iso) {
5239 LOGE("NULL pointer %p %p", pc, iso);
5240 return CAMERA_ERROR_INVALID_PARAMETER;
5245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5247 if (ret == CAMERA_ERROR_NONE)
5248 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5250 LOGD("ret : 0x%x", ret);
5256 int camera_attr_get_brightness(camera_h camera, int *level)
5258 int ret = CAMERA_ERROR_NONE;
5259 camera_cli_s *pc = (camera_cli_s *)camera;
5260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5262 if (!pc || !pc->cb_info || !level) {
5263 LOGE("NULL pointer %p %p", pc, level);
5264 return CAMERA_ERROR_INVALID_PARAMETER;
5269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5271 if (ret == CAMERA_ERROR_NONE)
5272 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5274 LOGD("ret : 0x%x", ret);
5280 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5282 int ret = CAMERA_ERROR_NONE;
5283 camera_cli_s *pc = (camera_cli_s *)camera;
5284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5286 if (!pc || !pc->cb_info || !min || !max) {
5287 LOGE("NULL pointer %p %p %p", pc, min, max);
5288 return CAMERA_ERROR_INVALID_PARAMETER;
5293 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5295 if (ret == CAMERA_ERROR_NONE) {
5296 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5297 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5300 LOGD("ret : 0x%x", ret);
5306 int camera_attr_get_contrast(camera_h camera, int *level)
5308 int ret = CAMERA_ERROR_NONE;
5309 camera_cli_s *pc = (camera_cli_s *)camera;
5310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5312 if (!pc || !pc->cb_info || !level) {
5313 LOGE("NULL pointer %p %p", pc, level);
5314 return CAMERA_ERROR_INVALID_PARAMETER;
5319 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5321 if (ret == CAMERA_ERROR_NONE)
5322 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5324 LOGD("ret : 0x%x", ret);
5330 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5332 int ret = CAMERA_ERROR_NONE;
5333 camera_cli_s *pc = (camera_cli_s *)camera;
5334 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5336 if (!pc || !pc->cb_info || !min || !max) {
5337 LOGE("NULL pointer %p %p %p", pc, min, max);
5338 return CAMERA_ERROR_INVALID_PARAMETER;
5343 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5345 if (ret == CAMERA_ERROR_NONE) {
5346 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5347 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5348 LOGD("min %d, max %d", *min, *max);
5351 LOGD("ret : 0x%x", ret);
5357 int camera_attr_get_hue(camera_h camera, int *level)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5363 if (!pc || !pc->cb_info || !level) {
5364 LOGE("NULL pointer %p %p", pc, level);
5365 return CAMERA_ERROR_INVALID_PARAMETER;
5370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 if (ret == CAMERA_ERROR_NONE)
5373 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5375 LOGD("ret : 0x%x", ret);
5381 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5383 int ret = CAMERA_ERROR_NONE;
5384 camera_cli_s *pc = (camera_cli_s *)camera;
5385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5387 if (!pc || !pc->cb_info || !min || !max) {
5388 LOGE("NULL pointer %p %p %p", pc, min, max);
5389 return CAMERA_ERROR_INVALID_PARAMETER;
5394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 if (ret == CAMERA_ERROR_NONE) {
5397 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5398 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5399 LOGD("min %d, max %d", *min, *max);
5402 LOGD("ret : 0x%x", ret);
5408 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5410 int ret = CAMERA_ERROR_NONE;
5411 camera_cli_s *pc = (camera_cli_s *)camera;
5412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5414 if (!pc || !pc->cb_info || !wb) {
5415 LOGE("NULL pointer %p %p", pc, wb);
5416 return CAMERA_ERROR_INVALID_PARAMETER;
5421 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5423 if (ret == CAMERA_ERROR_NONE)
5424 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5426 LOGD("ret : 0x%x", ret);
5432 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5434 int ret = CAMERA_ERROR_NONE;
5435 camera_cli_s *pc = (camera_cli_s *)camera;
5436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5438 if (!pc || !pc->cb_info || !effect) {
5439 LOGE("NULL pointer %p %p", pc, effect);
5440 return CAMERA_ERROR_INVALID_PARAMETER;
5445 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5447 if (ret == CAMERA_ERROR_NONE)
5448 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5450 LOGD("ret : 0x%x", ret);
5456 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5458 int ret = CAMERA_ERROR_NONE;
5459 camera_cli_s *pc = (camera_cli_s *)camera;
5460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5462 if (!pc || !pc->cb_info || !mode) {
5463 LOGE("NULL pointer %p %p", pc, mode);
5464 return CAMERA_ERROR_INVALID_PARAMETER;
5469 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5471 if (ret == CAMERA_ERROR_NONE)
5472 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5474 LOGD("ret : 0x%x", ret);
5480 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5482 int ret = CAMERA_ERROR_NONE;
5483 camera_cli_s *pc = (camera_cli_s *)camera;
5484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5486 if (!pc || !pc->cb_info || !enable) {
5487 LOGE("NULL pointer %p %p", pc, enable);
5488 return CAMERA_ERROR_INVALID_PARAMETER;
5493 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5495 if (ret == CAMERA_ERROR_NONE)
5496 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5498 LOGD("ret : 0x%x", ret);
5504 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5506 int ret = CAMERA_ERROR_NONE;
5507 camera_cli_s *pc = (camera_cli_s *)camera;
5508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5510 if (!pc || !pc->cb_info || !description) {
5511 LOGE("NULL pointer %p %p", pc, description);
5512 return CAMERA_ERROR_INVALID_PARAMETER;
5517 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5519 if (ret == CAMERA_ERROR_NONE)
5520 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5522 LOGD("ret : 0x%x", ret);
5528 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5530 int ret = CAMERA_ERROR_NONE;
5531 camera_cli_s *pc = (camera_cli_s *)camera;
5532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5534 if (!pc || !pc->cb_info || !orientation) {
5535 LOGE("NULL pointer %p %p", pc, orientation);
5536 return CAMERA_ERROR_INVALID_PARAMETER;
5541 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5543 if (ret == CAMERA_ERROR_NONE)
5544 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5546 LOGD("ret : 0x%x", ret);
5552 int camera_attr_get_tag_software(camera_h camera, char **software)
5554 int ret = CAMERA_ERROR_NONE;
5555 camera_cli_s *pc = (camera_cli_s *)camera;
5556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5558 if (!pc || !pc->cb_info || !software) {
5559 LOGE("NULL pointer %p %p", pc, software);
5560 return CAMERA_ERROR_INVALID_PARAMETER;
5565 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5567 if (ret == CAMERA_ERROR_NONE)
5568 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5570 LOGD("ret : 0x%x", ret);
5576 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5578 int ret = CAMERA_ERROR_NONE;
5579 camera_cli_s *pc = (camera_cli_s *)camera;
5580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5582 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5583 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5584 return CAMERA_ERROR_INVALID_PARAMETER;
5589 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5591 if (ret == CAMERA_ERROR_NONE) {
5592 *latitude = pc->cb_info->get_geotag[0];
5593 *longitude = pc->cb_info->get_geotag[1];
5594 *altitude = pc->cb_info->get_geotag[2];
5597 LOGD("ret : 0x%x", ret);
5603 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5605 int ret = CAMERA_ERROR_NONE;
5606 camera_cli_s *pc = (camera_cli_s *)camera;
5607 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5609 if (!pc || !pc->cb_info || !mode) {
5610 LOGE("NULL pointer %p %p", pc, mode);
5611 return CAMERA_ERROR_INVALID_PARAMETER;
5616 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5618 if (ret == CAMERA_ERROR_NONE)
5619 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5621 LOGD("ret : 0x%x", ret);
5627 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5629 int ret = CAMERA_ERROR_NONE;
5630 int get_flash_state = 0;
5633 LOGE("NULL pointer");
5634 return CAMERA_ERROR_INVALID_PARAMETER;
5637 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5638 (int)device, "get_flash_state", &get_flash_state);
5640 if (ret == CAMERA_ERROR_NONE) {
5641 *state = (camera_flash_state_e)get_flash_state;
5642 LOGD("flash state %d", *state);
5644 LOGE("failed 0x%x", ret);
5651 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5653 int ret = CAMERA_ERROR_NONE;
5654 camera_cli_s *pc = (camera_cli_s *)camera;
5655 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5657 if (!pc || !pc->cb_info || !foreach_cb) {
5658 LOGE("NULL pointer %p %p", pc, foreach_cb);
5659 return CAMERA_ERROR_INVALID_PARAMETER;
5664 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5665 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5667 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5669 LOGD("ret : 0x%x", ret);
5675 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5677 int ret = CAMERA_ERROR_NONE;
5678 camera_cli_s *pc = (camera_cli_s *)camera;
5679 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5681 if (!pc || !pc->cb_info || !foreach_cb) {
5682 LOGE("NULL pointer %p %p", pc, foreach_cb);
5683 return CAMERA_ERROR_INVALID_PARAMETER;
5688 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5689 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5691 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5693 LOGD("ret : 0x%x", ret);
5699 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5701 int ret = CAMERA_ERROR_NONE;
5702 camera_cli_s *pc = (camera_cli_s *)camera;
5703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5705 if (!pc || !pc->cb_info || !foreach_cb) {
5706 LOGE("NULL pointer %p %p", pc, foreach_cb);
5707 return CAMERA_ERROR_INVALID_PARAMETER;
5712 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5713 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5715 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5717 LOGD("ret : 0x%x", ret);
5723 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5725 int ret = CAMERA_ERROR_NONE;
5726 camera_cli_s *pc = (camera_cli_s *)camera;
5727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5729 if (!pc || !pc->cb_info || !foreach_cb) {
5730 LOGE("NULL pointer %p %p", pc, foreach_cb);
5731 return CAMERA_ERROR_INVALID_PARAMETER;
5736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5739 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5741 LOGD("ret : 0x%x", ret);
5747 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5749 int ret = CAMERA_ERROR_NONE;
5750 camera_cli_s *pc = (camera_cli_s *)camera;
5751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5753 if (!pc || !pc->cb_info || !foreach_cb) {
5754 LOGE("NULL pointer %p %p", pc, foreach_cb);
5755 return CAMERA_ERROR_INVALID_PARAMETER;
5760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5763 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5765 LOGD("ret : 0x%x", ret);
5771 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5773 int ret = CAMERA_ERROR_NONE;
5774 camera_cli_s *pc = (camera_cli_s *)camera;
5775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5777 if (!pc || !pc->cb_info || !foreach_cb) {
5778 LOGE("NULL pointer %p %p", pc, foreach_cb);
5779 return CAMERA_ERROR_INVALID_PARAMETER;
5784 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5785 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5787 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5789 LOGD("ret : 0x%x", ret);
5795 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5797 int ret = CAMERA_ERROR_NONE;
5798 camera_cli_s *pc = (camera_cli_s *)camera;
5799 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5801 if (!pc || !pc->cb_info || !foreach_cb) {
5802 LOGE("NULL pointer %p %p", pc, foreach_cb);
5803 return CAMERA_ERROR_INVALID_PARAMETER;
5808 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5809 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5813 LOGD("ret : 0x%x", ret);
5819 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5825 if (!pc || !pc->cb_info || !foreach_cb) {
5826 LOGE("NULL pointer %p %p", pc, foreach_cb);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5832 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5833 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5835 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5837 LOGD("Enter, handle :%td", pc->remote_handle);
5843 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)
5845 int ret = CAMERA_ERROR_NONE;
5846 camera_cli_s *pc = (camera_cli_s *)camera;
5847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5848 camera_msg_param param;
5851 if (!pc || !pc->cb_info || !foreach_cb) {
5852 LOGE("NULL pointer %p %p", pc, foreach_cb);
5853 return CAMERA_ERROR_INVALID_PARAMETER;
5858 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5859 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5861 value = (width << 16) | height;
5862 CAMERA_MSG_PARAM_SET(param, INT, value);
5864 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5866 LOGD("ret : 0x%x", ret);
5872 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5874 int ret = CAMERA_ERROR_NONE;
5875 camera_cli_s *pc = (camera_cli_s *)camera;
5876 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5878 if (!pc || !pc->cb_info || !foreach_cb) {
5879 LOGE("NULL pointer %p %p", pc, foreach_cb);
5880 return CAMERA_ERROR_INVALID_PARAMETER;
5885 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5886 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5888 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5890 LOGD("ret : 0x%x", ret);
5896 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5898 int ret = CAMERA_ERROR_NONE;
5899 camera_cli_s *pc = (camera_cli_s *)camera;
5900 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5902 if (!pc || !pc->cb_info || !foreach_cb) {
5903 LOGE("NULL pointer %p %p", pc, foreach_cb);
5904 return CAMERA_ERROR_INVALID_PARAMETER;
5909 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5910 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5912 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5914 LOGD("ret : 0x%x", ret);
5920 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5922 int ret = CAMERA_ERROR_NONE;
5923 camera_cli_s *pc = (camera_cli_s *)camera;
5924 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5925 camera_msg_param param;
5926 int set_rotation = (int)rotation;
5928 if (!pc || !pc->cb_info) {
5929 LOGE("NULL handle");
5930 return CAMERA_ERROR_INVALID_PARAMETER;
5935 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5937 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5939 LOGD("ret : 0x%x", ret);
5945 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5947 int ret = CAMERA_ERROR_NONE;
5948 camera_cli_s *pc = (camera_cli_s *)camera;
5949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5951 if (!pc || !pc->cb_info || !rotation) {
5952 LOGE("NULL pointer %p %p", pc, rotation);
5953 return CAMERA_ERROR_INVALID_PARAMETER;
5958 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5960 if (ret == CAMERA_ERROR_NONE)
5961 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5963 LOGD("ret : 0x%x", ret);
5969 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5971 int ret = CAMERA_ERROR_NONE;
5972 camera_cli_s *pc = (camera_cli_s *)camera;
5973 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5974 camera_msg_param param;
5975 int set_flip = (int)flip;
5977 if (!pc || !pc->cb_info) {
5978 LOGE("NULL handle");
5979 return CAMERA_ERROR_INVALID_PARAMETER;
5984 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5986 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5988 LOGD("ret : 0x%x", ret);
5994 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5996 int ret = CAMERA_ERROR_NONE;
5997 camera_cli_s *pc = (camera_cli_s *)camera;
5998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6000 if (!pc || !pc->cb_info || !flip) {
6001 LOGE("NULL pointer %p %p", pc, flip);
6002 return CAMERA_ERROR_INVALID_PARAMETER;
6007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6009 if (ret == CAMERA_ERROR_NONE)
6010 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6012 LOGD("ret : 0x%x", ret);
6017 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6019 int ret = CAMERA_ERROR_NONE;
6020 camera_cli_s *pc = (camera_cli_s *)camera;
6021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6022 camera_msg_param param;
6023 int set_mode = (int)mode;
6025 if (!pc || !pc->cb_info) {
6026 LOGE("NULL handle");
6027 return CAMERA_ERROR_INVALID_PARAMETER;
6032 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6034 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6036 LOGD("ret : 0x%x", ret);
6042 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6044 int ret = CAMERA_ERROR_NONE;
6045 camera_cli_s *pc = (camera_cli_s *)camera;
6046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6048 if (!pc || !pc->cb_info || !mode) {
6049 LOGE("NULL pointer %p %p", pc, mode);
6050 return CAMERA_ERROR_INVALID_PARAMETER;
6055 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6057 if (ret == CAMERA_ERROR_NONE)
6058 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6060 LOGD("ret : 0x%x", ret);
6066 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6068 int ret = CAMERA_ERROR_NONE;
6069 camera_cli_s *pc = (camera_cli_s *)camera;
6070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6072 if (!pc || !pc->cb_info) {
6073 LOGE("NULL handle");
6074 return CAMERA_ERROR_INVALID_PARAMETER;
6079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6082 LOGE("error is occurred 0x%x", ret);
6086 LOGD("ret : %d", ret);
6092 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6094 int ret = CAMERA_ERROR_NONE;
6095 camera_cli_s *pc = (camera_cli_s *)camera;
6096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6098 if (!pc || !pc->cb_info) {
6099 LOGE("NULL handle");
6100 return CAMERA_ERROR_INVALID_PARAMETER;
6105 if (!camera_attr_is_supported_hdr_capture(camera)) {
6106 LOGE("HDR not supported");
6107 return CAMERA_ERROR_NOT_SUPPORTED;
6111 LOGE("NULL callback");
6112 return CAMERA_ERROR_INVALID_PARAMETER;
6115 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6117 if (ret == CAMERA_ERROR_NONE) {
6118 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6120 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6121 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6123 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6126 LOGD("ret : 0x%x", ret);
6132 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6134 int ret = CAMERA_ERROR_NONE;
6135 camera_cli_s *pc = (camera_cli_s *)camera;
6136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6138 if (!pc || !pc->cb_info) {
6139 LOGE("NULL handle");
6140 return CAMERA_ERROR_INVALID_PARAMETER;
6145 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6147 if (ret == CAMERA_ERROR_NONE) {
6148 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6150 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6151 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6153 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6156 LOGD("ret : 0x%x", ret);
6162 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6164 int ret = CAMERA_ERROR_NONE;
6165 camera_cli_s *pc = (camera_cli_s *)camera;
6166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6167 camera_msg_param param;
6168 int set_enable = (int)enable;
6170 if (!pc || !pc->cb_info) {
6171 LOGE("NULL handle");
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6177 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6179 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6181 LOGD("ret : 0x%x", ret);
6187 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6189 int ret = CAMERA_ERROR_NONE;
6190 camera_cli_s *pc = (camera_cli_s *)camera;
6191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6193 if (!pc || !pc->cb_info || !enabled) {
6194 LOGE("NULL pointer %p %p", pc, enabled);
6195 return CAMERA_ERROR_INVALID_PARAMETER;
6200 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6202 if (ret == CAMERA_ERROR_NONE)
6203 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6205 LOGD("ret : 0x%x", ret);
6211 bool camera_attr_is_supported_anti_shake(camera_h camera)
6213 int ret = CAMERA_ERROR_NONE;
6214 camera_cli_s *pc = (camera_cli_s *)camera;
6215 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6217 if (!pc || !pc->cb_info) {
6218 LOGE("NULL handle");
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6224 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6227 LOGE("error is occurred 0x%x", ret);
6231 LOGD("ret : %d", ret);
6237 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6239 int ret = CAMERA_ERROR_NONE;
6240 camera_cli_s *pc = (camera_cli_s *)camera;
6241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6242 camera_msg_param param;
6243 int set_enable = (int)enable;
6245 if (!pc || !pc->cb_info) {
6246 LOGE("NULL handle");
6247 return CAMERA_ERROR_INVALID_PARAMETER;
6252 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6254 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6256 LOGD("ret : 0x%x", ret);
6262 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_cli_s *pc = (camera_cli_s *)camera;
6266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6268 if (!pc || !pc->cb_info || !enabled) {
6269 LOGE("NULL pointer %p %p", pc, enabled);
6270 return CAMERA_ERROR_INVALID_PARAMETER;
6275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6277 if (ret == CAMERA_ERROR_NONE)
6278 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6280 LOGD("ret : 0x%x", ret);
6286 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6288 int ret = CAMERA_ERROR_NONE;
6289 camera_cli_s *pc = (camera_cli_s *)camera;
6290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6292 if (!pc || !pc->cb_info) {
6293 LOGE("NULL handle");
6294 return CAMERA_ERROR_INVALID_PARAMETER;
6299 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6302 LOGE("error is occurred 0x%x", ret);
6306 LOGD("ret : %d", ret);
6312 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6314 int ret = CAMERA_ERROR_NONE;
6315 camera_cli_s *pc = (camera_cli_s *)camera;
6316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6317 camera_msg_param param;
6318 int set_enable = (int)enable;
6320 if (!pc || !pc->cb_info) {
6321 LOGE("NULL handle");
6322 return CAMERA_ERROR_INVALID_PARAMETER;
6327 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6331 LOGD("ret : 0x%x", ret);
6337 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6339 int ret = CAMERA_ERROR_NONE;
6340 camera_cli_s *pc = (camera_cli_s *)camera;
6341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6343 if (!pc || !pc->cb_info || !enabled) {
6344 LOGE("NULL pointer %p %p", pc, enabled);
6345 return CAMERA_ERROR_INVALID_PARAMETER;
6350 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6352 if (ret == CAMERA_ERROR_NONE)
6353 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6355 LOGD("ret : 0x%x", ret);
6361 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6363 int ret = CAMERA_ERROR_NONE;
6364 camera_cli_s *pc = (camera_cli_s *)camera;
6365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6367 if (!pc || !pc->cb_info) {
6368 LOGE("NULL handle");
6369 return CAMERA_ERROR_INVALID_PARAMETER;
6374 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6377 LOGE("error is occurred 0x%x", ret);
6381 LOGD("ret : %d", ret);
6387 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6389 int ret = CAMERA_ERROR_NONE;
6390 camera_cli_s *pc = (camera_cli_s *)camera;
6391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6392 camera_msg_param param;
6393 int set_disable = (int)disable;
6395 if (!pc || !pc->cb_info) {
6396 LOGE("NULL handle");
6397 return CAMERA_ERROR_INVALID_PARAMETER;
6402 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6406 LOGD("ret : 0x%x", ret);
6412 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6414 int ret = CAMERA_ERROR_NONE;
6415 camera_cli_s *pc = (camera_cli_s *)camera;
6416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6417 camera_msg_param param0;
6418 camera_msg_param param1;
6420 if (!pc || !pc->cb_info) {
6421 LOGE("NULL handle");
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6427 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6428 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6430 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6431 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6433 LOGD("ret : 0x%x", ret);
6439 int camera_attr_get_pan(camera_h camera, int *pan_step)
6441 int ret = CAMERA_ERROR_NONE;
6442 camera_cli_s *pc = (camera_cli_s *)camera;
6443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6445 if (!pc || !pc->cb_info || !pan_step) {
6446 LOGE("NULL pointer %p %p", pc, pan_step);
6447 return CAMERA_ERROR_INVALID_PARAMETER;
6452 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6454 if (ret == CAMERA_ERROR_NONE)
6455 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6457 LOGD("ret : 0x%x", ret);
6463 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6465 int ret = CAMERA_ERROR_NONE;
6466 camera_cli_s *pc = (camera_cli_s *)camera;
6467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6469 if (!pc || !pc->cb_info || !min || !max) {
6470 LOGE("NULL pointer %p %p %p", pc, min, max);
6471 return CAMERA_ERROR_INVALID_PARAMETER;
6476 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6478 if (ret == CAMERA_ERROR_NONE) {
6479 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6480 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6483 LOGD("ret : 0x%x", ret);
6489 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6491 int ret = CAMERA_ERROR_NONE;
6492 camera_cli_s *pc = (camera_cli_s *)camera;
6493 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6494 camera_msg_param param0;
6495 camera_msg_param param1;
6497 if (!pc || !pc->cb_info) {
6498 LOGE("NULL handle");
6499 return CAMERA_ERROR_INVALID_PARAMETER;
6504 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6505 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6507 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6508 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6510 LOGD("ret : 0x%x", ret);
6516 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6518 int ret = CAMERA_ERROR_NONE;
6519 camera_cli_s *pc = (camera_cli_s *)camera;
6520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6522 if (!pc || !pc->cb_info || !tilt_step) {
6523 LOGE("NULL pointer %p %p", pc, tilt_step);
6524 return CAMERA_ERROR_INVALID_PARAMETER;
6529 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6531 if (ret == CAMERA_ERROR_NONE)
6532 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6534 LOGD("ret : 0x%x", ret);
6540 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6542 int ret = CAMERA_ERROR_NONE;
6543 camera_cli_s *pc = (camera_cli_s *)camera;
6544 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6546 if (!pc || !pc->cb_info || !min || !max) {
6547 LOGE("NULL pointer %p %p %p", pc, min, max);
6548 return CAMERA_ERROR_INVALID_PARAMETER;
6553 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6555 if (ret == CAMERA_ERROR_NONE) {
6556 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6557 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6560 LOGD("ret : 0x%x", ret);
6566 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6568 int ret = CAMERA_ERROR_NONE;
6569 camera_cli_s *pc = (camera_cli_s *)camera;
6570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6571 camera_msg_param param;
6572 int set_ptz_type = (int)ptz_type;
6574 if (!pc || !pc->cb_info) {
6575 LOGE("NULL handle");
6576 return CAMERA_ERROR_INVALID_PARAMETER;
6581 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6583 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6585 LOGD("ret : 0x%x", ret);
6591 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6593 int ret = CAMERA_ERROR_NONE;
6594 camera_cli_s *pc = (camera_cli_s *)camera;
6595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6597 if (!pc || !pc->cb_info || !foreach_cb) {
6598 LOGE("NULL pointer %p %p", pc, foreach_cb);
6599 return CAMERA_ERROR_INVALID_PARAMETER;
6604 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6605 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6607 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6609 LOGD("ret : 0x%x", ret);
6615 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6617 int ret = CAMERA_ERROR_NONE;
6618 camera_cli_s *pc = (camera_cli_s *)camera;
6619 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6620 int set_display_roi_area[4] = {x, y, width, height};
6625 if (!pc || !pc->cb_info) {
6626 LOGE("NULL handle");
6627 return CAMERA_ERROR_INVALID_PARAMETER;
6632 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6633 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6634 if (ret != MM_ERROR_NONE) {
6635 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6636 return CAMERA_ERROR_INVALID_OPERATION;
6640 length = sizeof(set_display_roi_area) / sizeof(int) + \
6641 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6643 msg = muse_core_msg_new(api,
6644 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6647 LOGE("msg creation failed: api %d", api);
6648 return CAMERA_ERROR_OUT_OF_MEMORY;
6651 if (pc->cb_info->is_server_connected) {
6652 __camera_update_api_waiting(pc->cb_info, api, 1);
6654 g_mutex_lock(&pc->cb_info->fd_lock);
6655 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6656 g_mutex_unlock(&pc->cb_info->fd_lock);
6660 LOGE("message send failed");
6661 ret = CAMERA_ERROR_INVALID_OPERATION;
6663 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6666 __camera_update_api_waiting(pc->cb_info, api, -1);
6668 muse_core_msg_free(msg);
6670 LOGD("ret : 0x%x", ret);
6676 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6678 camera_cli_s *pc = (camera_cli_s *)camera;
6679 int ret = CAMERA_ERROR_NONE;
6680 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6682 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6683 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6684 return CAMERA_ERROR_INVALID_PARAMETER;
6689 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6691 if (ret == CAMERA_ERROR_NONE) {
6692 *x = pc->cb_info->get_display_roi_area[0];
6693 *y = pc->cb_info->get_display_roi_area[1];
6694 *width = pc->cb_info->get_display_roi_area[2];
6695 *height = pc->cb_info->get_display_roi_area[3];
6698 LOGD("ret : 0x%x", ret);
6704 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6706 int ret = CAMERA_ERROR_NONE;
6707 int get_device_state = 0;
6710 LOGE("NULL pointer");
6711 return CAMERA_ERROR_INVALID_PARAMETER;
6714 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6715 (int)device, "get_device_state", &get_device_state);
6717 if (ret == CAMERA_ERROR_NONE) {
6718 *state = (camera_device_state_e)get_device_state;
6719 LOGD("device state %d", *state);
6721 LOGE("failed 0x%x", ret);
6728 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6730 int ret = CAMERA_ERROR_NONE;
6731 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6732 camera_cb_info *info = NULL;
6734 if (!callback || !cb_id) {
6735 LOGE("invalid pointer %p %p", callback, cb_id);
6736 return CAMERA_ERROR_INVALID_PARAMETER;
6739 /* check camera support */
6740 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6741 if (ret != CAMERA_ERROR_NONE) {
6742 LOGE("get device state failed");
6746 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6748 info = g_new0(camera_cb_info, 1);
6750 LOGE("info failed");
6751 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6755 info->id = ++g_cam_dev_state_changed_cb_id;
6756 info->callback = (void *)callback;
6757 info->user_data = user_data;
6761 /* subscribe dbus signal for camera state change */
6762 if (!g_cam_dev_state_changed_cb_conn) {
6763 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6764 if (!g_cam_dev_state_changed_cb_conn) {
6765 LOGE("failed to get gdbus connection");
6766 ret = CAMERA_ERROR_INVALID_OPERATION;
6770 LOGD("subscribe signal %s - %s - %s",
6771 MM_CAMCORDER_DBUS_OBJECT,
6772 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6773 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6775 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6776 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6777 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6778 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6779 LOGE("failed to get gdbus connection");
6780 ret = CAMERA_ERROR_INVALID_OPERATION;
6784 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6787 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6789 LOGD("callback id %d", info->id);
6792 if (ret != CAMERA_ERROR_NONE) {
6798 if (g_cam_dev_state_changed_cb_conn) {
6799 g_object_unref(g_cam_dev_state_changed_cb_conn);
6800 g_cam_dev_state_changed_cb_conn = NULL;
6804 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6810 int camera_remove_device_state_changed_cb(int cb_id)
6812 int ret = CAMERA_ERROR_NONE;
6813 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6814 GList *tmp_list = NULL;
6815 camera_cb_info *info = NULL;
6817 /* check camera support */
6818 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6819 if (ret != CAMERA_ERROR_NONE) {
6820 LOGE("get device state failed");
6824 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6826 if (!g_cam_dev_state_changed_cb_list) {
6827 LOGE("there is no callback info");
6828 ret = CAMERA_ERROR_INVALID_OPERATION;
6832 tmp_list = g_cam_dev_state_changed_cb_list;
6835 info = tmp_list->data;
6836 tmp_list = tmp_list->next;
6843 if (info->id == cb_id) {
6844 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6849 if (!g_cam_dev_state_changed_cb_list) {
6850 /* no remained callback */
6851 if (g_cam_dev_state_changed_cb_conn) {
6852 /* unsubscribe signal */
6853 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6854 g_cam_dev_state_changed_cb_subscribe_id = 0;
6856 /* unref connection */
6857 g_object_unref(g_cam_dev_state_changed_cb_conn);
6858 g_cam_dev_state_changed_cb_conn = NULL;
6862 LOGD("id %d callback removed", cb_id);
6863 ret = CAMERA_ERROR_NONE;
6869 LOGE("id %d callback not found", cb_id);
6870 ret = CAMERA_ERROR_INVALID_PARAMETER;
6873 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);