2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
37 #define MODULE_NAME "camera"
39 /* for device changed callback */
40 static GMutex g_cam_dev_state_changed_cb_lock;
41 static GList *g_cam_dev_state_changed_cb_list;
42 static int g_cam_dev_state_changed_cb_id;
43 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
44 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static GMutex g_cam_idle_event_lock;
47 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
48 int *ret, int timeout);
49 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param, int timeout);
51 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
52 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
53 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
54 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
55 static void _camera_release_imported_bo(tbm_bo *bo);
56 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
57 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
58 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
59 camera_media_packet_data *mp_data, media_packet_h *packet);
60 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
61 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
62 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
63 static gboolean _camera_allocate_preview_buffer(camera_h camera);
64 static void _camera_release_preview_buffer(camera_h camera);
67 static gboolean _camera_allocate_preview_buffer(camera_h camera)
70 int ret = CAMERA_ERROR_NONE;
71 int format = CAMERA_PIXEL_FORMAT_INVALID;
75 camera_cli_s *pc = (camera_cli_s *)camera;
76 camera_cb_info_s *cb_info = NULL;
78 if (!pc || !pc->cb_info) {
79 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
83 cb_info = pc->cb_info;
87 /* get preview info and calculate size */
88 ret = camera_get_preview_format(camera, &format);
89 if (ret != CAMERA_ERROR_NONE) {
90 LOGE("get preview format failed 0x%x", ret);
94 ret = camera_get_preview_resolution(camera, &width, &height);
95 if (ret != CAMERA_ERROR_NONE) {
96 LOGE("get preview resolution failed 0x%x", ret);
100 LOGD("preview %dx%d, format %d", width, height, format);
103 case CAMERA_PIXEL_FORMAT_INVZ:
104 buffer_size = width * height;
106 case CAMERA_PIXEL_FORMAT_NV12:
107 case CAMERA_PIXEL_FORMAT_I420:
108 buffer_size = (width * height * 3) >> 1;
110 case CAMERA_PIXEL_FORMAT_YUYV:
111 case CAMERA_PIXEL_FORMAT_UYVY:
112 buffer_size = width * height * 2;
115 LOGE("unhandled format %d", format);
116 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
119 LOGD("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
121 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
122 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
123 if (!cb_info->bos[i]) {
124 LOGE("bo alloc failed [%d,i:%d]", buffer_size, i);
125 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
128 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
129 if (cb_info->fds[i] < 0) {
130 LOGE("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
131 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
134 LOGD("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
141 _ALLOCATE_PREVIEW_BUFFER_FAILED:
142 _camera_release_preview_buffer(camera);
147 static void _camera_release_preview_buffer(camera_h camera)
150 camera_cli_s *pc = (camera_cli_s *)camera;
151 camera_cb_info_s *cb_info = NULL;
153 if (!pc || !pc->cb_info) {
154 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
160 cb_info = pc->cb_info;
162 /* close exported fd and bos */
163 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
164 LOGD("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
166 if (cb_info->bos[i]) {
167 tbm_bo_unref(cb_info->bos[i]);
168 cb_info->bos[i] = NULL;
173 if (cb_info->fds[i] >= 0) {
174 close(cb_info->fds[i]);
175 cb_info->fds[i] = -1;
185 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
188 api < 0 || api >= MUSE_CAMERA_API_MAX) {
189 LOGE("invalid param %p %d", cb_info, api);
193 g_mutex_lock(&(cb_info->api_mutex[api]));
194 cb_info->api_waiting[api] += value;
195 g_mutex_unlock(&(cb_info->api_mutex[api]));
197 /*LOGD("api %d, value %d, waiting %d",
198 api, value, cb_info->api_waiting[api]);*/
204 static void __camera_device_state_changed_cb(GDBusConnection *connection,
205 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
206 const gchar *signal_name, GVariant *param, gpointer user_data)
209 camera_device_e device = CAMERA_DEVICE_CAMERA0;
210 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
211 GList *tmp_list = NULL;
212 camera_cb_info *info = NULL;
214 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
216 if (!g_cam_dev_state_changed_cb_list || !param) {
217 LOGW("no callback or NULL param %p", param);
221 /* get device and state */
222 g_variant_get(param, "(i)", &value);
224 device = value >> 16;
225 state = 0x0000ffff & value;
227 LOGD("device %d, state %d", device, state);
229 tmp_list = g_cam_dev_state_changed_cb_list;
232 info = (camera_cb_info *)tmp_list->data;
235 if (info->callback) {
236 LOGD("start id[%d] callback", info->id);
237 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
238 LOGD("returned id[%d] callback", info->id);
240 LOGW("NULL callback for id %d", info->id);
244 tmp_list = tmp_list->next;
248 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
254 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
260 int num_buffer_fd = 0;
261 unsigned char *buf_pos = NULL;
264 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
265 tbm_bo_handle bo_handle = {.ptr = NULL};
266 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
267 tbm_bo data_bo = NULL;
268 tbm_bo_handle data_bo_handle = {.ptr = NULL};
270 camera_msg_param param;
271 camera_preview_data_s frame;
272 camera_stream_data_s *stream = NULL;
273 camera_media_packet_data *mp_data = NULL;
274 media_packet_h pkt = NULL;
275 media_packet_h pkt_evas = NULL;
277 /* tfd[0]: MMCamcorderVideoStreamDataType
278 tfd[1]: data_bo or zero copy bo[0]
279 tfd[2]: zero copy bo[1]
280 tfd[3]: zero copy bo[2] */
282 if (!cb_info || !recv_msg || !tfd) {
283 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
287 muse_camera_msg_get(preview_fd, recv_msg);
288 muse_camera_msg_get(num_buffer_fd, recv_msg);
290 /*LOGD("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);*/
292 memset(&frame, 0x0, sizeof(camera_preview_data_s));
295 LOGE("invalid fd %d", tfd[0]);
300 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
302 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
303 LOGE("invalid num buffer fd %d", num_buffer_fd);
304 goto _PREVIEW_CB_HANDLER_DONE;
307 if (num_buffer_fd == 0 && tfd[1] >= 0) {
308 /* import tbm data_bo and get virtual address */
309 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
310 LOGE("failed to import data fd %d", tfd[1]);
311 goto _PREVIEW_CB_HANDLER_DONE;
315 /* import tbm bo and get virtual address */
316 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
317 LOGE("failed to import fd %d", tfd[0]);
318 goto _PREVIEW_CB_HANDLER_DONE;
321 buf_pos = (unsigned char *)bo_handle.ptr;
323 /* get stream info */
324 stream = (camera_stream_data_s *)buf_pos;
326 for (i = 0 ; i < num_buffer_fd ; i++) {
327 /* import buffer bo and get virtual address */
328 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
329 LOGE("failed to import buffer fd %d", tfd[i + 1]);
330 goto _PREVIEW_CB_HANDLER_DONE;
334 /* call preview callback */
335 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
336 _camera_preview_frame_create(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
338 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
339 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
342 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
343 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
345 if (ret == CAMERA_ERROR_NONE) {
346 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
347 if (ret != CAMERA_ERROR_NONE) {
348 LOGE("create pkt for evas failed");
349 _camera_media_packet_data_release(mp_data, cb_info);
355 /* call media packet callback */
356 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
357 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
359 if (ret == CAMERA_ERROR_NONE) {
360 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
362 if (ret == CAMERA_ERROR_NONE) {
363 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
364 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
366 _camera_media_packet_data_release(mp_data, cb_info);
372 /* call evas renderer */
374 if (cb_info->run_evas_render) {
375 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
377 LOGW("evas renderer is stopped, skip this buffer...");
378 media_packet_destroy(pkt_evas);
383 /* send message for preview callback return */
384 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
385 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
387 _PREVIEW_CB_HANDLER_DONE:
388 if (mp_data == NULL) {
389 /* release imported bo */
390 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
391 _camera_release_imported_bo(&buffer_bo[i]);
393 /* unmap and unref tbm bo */
394 _camera_release_imported_bo(&data_bo);
395 _camera_release_imported_bo(&bo);
397 /* close imported fd */
398 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
408 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
410 /*LOGD("return buffer Done");*/
417 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
421 int capture_fd_main = 0;
422 int capture_fd_post = 0;
423 int capture_fd_thumb = 0;
424 unsigned char *buf_pos = NULL;
426 camera_image_data_s *rImage = NULL;
427 camera_image_data_s *rPostview = NULL;
428 camera_image_data_s *rThumbnail = NULL;
430 tbm_bo bo_main = NULL;
431 tbm_bo bo_post = NULL;
432 tbm_bo bo_thumb = NULL;
433 tbm_bo_handle bo_main_handle = {.ptr = NULL};
434 tbm_bo_handle bo_post_handle = {.ptr = NULL};
435 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
437 if (!cb_info || !recv_msg || !tfd) {
438 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
442 muse_camera_msg_get(capture_fd_main, recv_msg);
443 muse_camera_msg_get(capture_fd_post, recv_msg);
444 muse_camera_msg_get(capture_fd_thumb, recv_msg);
446 LOGD("capture fd %d %d %d, received fd %d %d %d",
447 capture_fd_main, capture_fd_post, capture_fd_thumb,
448 tfd[0], tfd[1], tfd[2]);
450 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
451 LOGE("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
452 goto _CAPTURE_CB_HANDLER_DONE;
455 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
456 LOGW("NULL callback");
457 goto _CAPTURE_CB_HANDLER_DONE;
460 /* import tbm bo and get virtual address */
461 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
462 LOGE("failed to import fd [%d] for main", tfd[tfd_index]);
463 goto _CAPTURE_CB_HANDLER_DONE;
466 buf_pos = (unsigned char *)bo_main_handle.ptr;
467 rImage = (camera_image_data_s *)buf_pos;
468 rImage->data = buf_pos + sizeof(camera_image_data_s);
469 if (rImage->exif && rImage->exif_size > 0) {
470 rImage->exif = rImage->data + rImage->size;
473 rImage->exif_size = 0;
476 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
477 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
479 if (capture_fd_post >= 0) {
480 /* import tbm bo and get virtual address */
482 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
483 buf_pos = (unsigned char *)bo_post_handle.ptr;
484 rPostview = (camera_image_data_s *)buf_pos;
485 LOGD("rPostview->size : %d", rPostview->size);
486 rPostview->data = buf_pos + sizeof(camera_image_data_s);
488 LOGE("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
492 if (capture_fd_thumb >= 0) {
493 /* import tbm bo and get virtual address */
495 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
496 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
497 rThumbnail = (camera_image_data_s *)buf_pos;
498 LOGD("rThumbnail->size : %d", rThumbnail->size);
499 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
501 LOGE("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
505 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
506 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
508 _CAPTURE_CB_HANDLER_DONE:
510 if (capture_fd_main >= 0) {
511 _camera_release_imported_bo(&bo_main);
512 _camera_msg_return_buffer(capture_fd_main, cb_info);
515 if (capture_fd_post >= 0) {
516 _camera_release_imported_bo(&bo_post);
517 _camera_msg_return_buffer(capture_fd_post, cb_info);
520 if (capture_fd_thumb >= 0) {
521 _camera_release_imported_bo(&bo_thumb);
522 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
525 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
527 LOGD("close %d", tfd[i]);
535 LOGD("return buffer done");
541 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
545 camera_detected_face_s *faces = NULL;
548 tbm_bo_handle bo_handle = {.ptr = NULL};
550 if (!cb_info || !recv_msg || !tfd) {
551 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
555 muse_camera_msg_get(count, recv_msg);
556 muse_camera_msg_get(face_fd, recv_msg);
558 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
559 LOGD("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
562 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
564 faces = bo_handle.ptr;
571 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
572 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
575 _camera_release_imported_bo(&bo);
577 LOGW("skip face detection message [count %d, fd %d, cb %p]",
578 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
582 _camera_msg_return_buffer(face_fd, cb_info);
588 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
590 tbm_bo tmp_bo = NULL;
591 tbm_bo_handle tmp_bo_handle = {NULL, };
593 if (!bufmgr || !bo || !bo_handle || fd < 0) {
594 LOGE("invalid parameter - %p %p %p, fd %d",
595 bufmgr, bo, bo_handle, fd);
599 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
600 if (tmp_bo == NULL) {
601 LOGE("import failed - fd %d", fd);
605 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
606 if (tmp_bo_handle.ptr == NULL) {
607 LOGE("map failed %p", tmp_bo);
608 tbm_bo_unref(tmp_bo);
613 tbm_bo_unmap(tmp_bo);
615 /* set bo and bo_handle */
617 *bo_handle = tmp_bo_handle;
622 static void _camera_release_imported_bo(tbm_bo *bo)
635 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
637 int ret = CAMERA_ERROR_NONE;
640 /*LOGD("Enter api : %d", api);*/
642 if (!cb_info->is_server_connected) {
643 LOGE("server is disconnected");
644 return CAMERA_ERROR_SERVICE_DISCONNECTED;
647 g_mutex_lock(&(cb_info->api_mutex[api]));
649 if (cb_info->api_activating[api] == 0) {
650 if (time_out == CAMERA_CB_NO_TIMEOUT) {
651 LOGW("wait for api %d", api);
652 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
653 ret = cb_info->api_ret[api];
654 cb_info->api_activating[api] = 0;
655 LOGW("api %d returned 0x%x", api, ret);
657 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
658 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
659 ret = cb_info->api_ret[api];
660 cb_info->api_activating[api] = 0;
661 /*LOGD("return value : 0x%x", ret);*/
663 ret = CAMERA_ERROR_INVALID_OPERATION;
664 LOGE("api %d was TIMED OUT!", api);
668 ret = cb_info->api_ret[api];
669 cb_info->api_activating[api] = 0;
671 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
674 g_mutex_unlock(&(cb_info->api_mutex[api]));
676 if (ret != CAMERA_ERROR_NONE)
677 LOGE("api %d : error 0x%x", api, ret);
683 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
684 int *ret, int timeout)
690 LOGE("NULL info - api %d", api);
693 *ret = CAMERA_ERROR_INVALID_PARAMETER;
698 msg = muse_core_msg_new(api, NULL);
700 LOGE("msg failed: api %d", api);
703 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
708 /*LOGD("send msg %s", msg);*/
710 if (cb_info->is_server_connected) {
711 __camera_update_api_waiting(cb_info, api, 1);
713 g_mutex_lock(&cb_info->fd_lock);
714 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
715 g_mutex_unlock(&cb_info->fd_lock);
719 LOGE("msg send failed");
721 *ret = CAMERA_ERROR_INVALID_OPERATION;
724 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
727 __camera_update_api_waiting(cb_info, api, -1);
729 muse_core_msg_free(msg);
735 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
736 int *ret, camera_msg_param *param, int timeout)
742 if (!cb_info || !param) {
743 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
746 *ret = CAMERA_ERROR_INVALID_PARAMETER;
751 /*LOGD("type %d, name %s", param->type, param->name);*/
753 switch (param->type) {
755 msg = muse_core_msg_new(api,
756 param->type, param->name, param->value.value_INT,
759 case MUSE_TYPE_STRING:
760 msg = muse_core_msg_new(api,
761 param->type, param->name, param->value.value_STRING,
764 case MUSE_TYPE_ARRAY:
765 array_length = param->value_size / sizeof(int) + \
766 (param->value_size % sizeof(int) ? 1 : 0);
768 msg = muse_core_msg_new(api,
769 param->type, param->name, array_length, param->value.value_ARRAY,
773 LOGE("unknown type %d", param->type);
778 LOGE("msg failed: api %d", api);
781 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
786 /*LOGD("send msg %s", msg);*/
788 if (cb_info->is_server_connected) {
789 __camera_update_api_waiting(cb_info, api, 1);
791 g_mutex_lock(&cb_info->fd_lock);
792 send_ret = muse_core_msg_send(cb_info->fd, msg);
793 g_mutex_unlock(&cb_info->fd_lock);
797 LOGE("msg send failed");
800 *ret = CAMERA_ERROR_INVALID_OPERATION;
803 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
806 __camera_update_api_waiting(cb_info, api, -1);
808 muse_core_msg_free(msg);
814 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
815 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
817 int func_ret = CAMERA_ERROR_NONE;
821 if (!cb_info || !param0 || !param1) {
822 LOGE("invalid ptr %p %p %p : api %d",
823 cb_info, param0, param1, api);
824 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
825 goto _SEND_PARAM2_INT_DONE;
828 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
830 param0->name, param0->value.value_INT,
831 param1->name, param1->value.value_INT);*/
833 msg = muse_core_msg_new(api,
834 param0->type, param0->name, param0->value.value_INT,
835 param1->type, param1->name, param1->value.value_INT,
838 LOGE("msg failed: api %d", api);
839 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
840 goto _SEND_PARAM2_INT_DONE;
843 /*LOGD("send msg [%s]", msg);*/
845 if (cb_info->is_server_connected) {
846 __camera_update_api_waiting(cb_info, api, 1);
848 g_mutex_lock(&cb_info->fd_lock);
849 send_ret = muse_core_msg_send(cb_info->fd, msg);
850 g_mutex_unlock(&cb_info->fd_lock);
854 LOGE("msg send failed");
856 func_ret = CAMERA_ERROR_INVALID_OPERATION;
858 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
861 __camera_update_api_waiting(cb_info, api, -1);
863 muse_core_msg_free(msg);
865 _SEND_PARAM2_INT_DONE:
873 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
875 camera_msg_param param;
878 LOGW("invalid fd %d", ret_fd);
882 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
884 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
890 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
892 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
893 in_format >= MM_PIXEL_FORMAT_NUM ||
894 out_format == NULL) {
895 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
896 return CAMERA_ERROR_INVALID_PARAMETER;
900 case MM_PIXEL_FORMAT_NV12:
901 case MM_PIXEL_FORMAT_NV12T:
902 *out_format = TBM_FORMAT_NV12;
905 case MM_PIXEL_FORMAT_NV16:
906 *out_format = TBM_FORMAT_NV16;
908 case MM_PIXEL_FORMAT_NV21:
909 *out_format = TBM_FORMAT_NV21;
911 case MM_PIXEL_FORMAT_YUYV:
912 *out_format = TBM_FORMAT_YUYV;
914 case MM_PIXEL_FORMAT_UYVY:
915 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
916 *out_format = TBM_FORMAT_UYVY;
918 case MM_PIXEL_FORMAT_422P:
919 *out_format = TBM_FORMAT_YUV422;
921 case MM_PIXEL_FORMAT_I420:
922 *out_format = TBM_FORMAT_YUV420;
924 case MM_PIXEL_FORMAT_YV12:
925 *out_format = TBM_FORMAT_YVU420;
927 case MM_PIXEL_FORMAT_RGB565:
928 *out_format = TBM_FORMAT_RGB565;
930 case MM_PIXEL_FORMAT_RGB888:
931 *out_format = TBM_FORMAT_RGB888;
933 case MM_PIXEL_FORMAT_RGBA:
934 *out_format = TBM_FORMAT_RGBA8888;
936 case MM_PIXEL_FORMAT_ARGB:
937 *out_format = TBM_FORMAT_ARGB8888;
940 LOGE("invalid in_format %d", in_format);
941 return CAMERA_ERROR_INVALID_PARAMETER;
945 return CAMERA_ERROR_NONE;
949 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
951 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
952 in_format >= MM_PIXEL_FORMAT_NUM ||
954 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
955 return CAMERA_ERROR_INVALID_PARAMETER;
959 case MM_PIXEL_FORMAT_NV12:
960 case MM_PIXEL_FORMAT_NV12T:
961 *mimetype = MEDIA_FORMAT_NV12;
964 case MM_PIXEL_FORMAT_NV16:
965 *mimetype = MEDIA_FORMAT_NV16;
967 case MM_PIXEL_FORMAT_NV21:
968 *mimetype = MEDIA_FORMAT_NV21;
970 case MM_PIXEL_FORMAT_YUYV:
971 *mimetype = MEDIA_FORMAT_YUYV;
973 case MM_PIXEL_FORMAT_UYVY:
974 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
975 *mimetype = MEDIA_FORMAT_UYVY;
977 case MM_PIXEL_FORMAT_422P:
978 *mimetype = MEDIA_FORMAT_422P;
980 case MM_PIXEL_FORMAT_I420:
981 *mimetype = MEDIA_FORMAT_I420;
983 case MM_PIXEL_FORMAT_YV12:
984 *mimetype = MEDIA_FORMAT_YV12;
986 case MM_PIXEL_FORMAT_RGB565:
987 *mimetype = MEDIA_FORMAT_RGB565;
989 case MM_PIXEL_FORMAT_RGB888:
990 *mimetype = MEDIA_FORMAT_RGB888;
992 case MM_PIXEL_FORMAT_RGBA:
993 *mimetype = MEDIA_FORMAT_RGBA;
995 case MM_PIXEL_FORMAT_ARGB:
996 *mimetype = MEDIA_FORMAT_ARGB;
999 LOGE("invalid in_format %d", in_format);
1000 return CAMERA_ERROR_INVALID_PARAMETER;
1004 return CAMERA_ERROR_NONE;
1007 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
1008 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1011 unsigned char *buf_pos = NULL;
1013 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1014 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1018 /* set frame info */
1019 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1020 frame->format = MM_PIXEL_FORMAT_UYVY;
1022 frame->format = stream->format;
1024 frame->width = stream->width;
1025 frame->height = stream->height;
1026 frame->timestamp = stream->timestamp;
1027 frame->num_of_planes = stream->num_planes;
1029 if (num_buffer_fd == 0) {
1032 if (!data_bo_handle || !data_bo_handle->ptr) {
1033 LOGE("NULL pointer");
1037 buf_pos = data_bo_handle->ptr;
1039 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1040 frame->data.encoded_plane.data = buf_pos;
1041 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1042 total_size = stream->data.encoded.length_data;
1043 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1044 frame->data.depth_plane.data = buf_pos;
1045 frame->data.depth_plane.size = stream->data.depth.length_data;
1046 total_size = stream->data.depth.length_data;
1047 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1048 stream->format == MM_PIXEL_FORMAT_ARGB) {
1049 frame->data.rgb_plane.data = buf_pos;
1050 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1051 total_size = stream->data.rgb.length_data;
1053 switch (stream->num_planes) {
1055 frame->data.single_plane.yuv = buf_pos;
1056 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1057 total_size = stream->data.yuv420.length_yuv;
1060 frame->data.double_plane.y = buf_pos;
1061 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1062 buf_pos += stream->data.yuv420sp.length_y;
1063 frame->data.double_plane.uv = buf_pos;
1064 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1065 total_size = stream->data.yuv420sp.length_y + \
1066 stream->data.yuv420sp.length_uv;
1069 frame->data.triple_plane.y = buf_pos;
1070 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1071 buf_pos += stream->data.yuv420p.length_y;
1072 frame->data.triple_plane.u = buf_pos;
1073 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1074 buf_pos += stream->data.yuv420p.length_u;
1075 frame->data.triple_plane.v = buf_pos;
1076 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1077 total_size = stream->data.yuv420p.length_y + \
1078 stream->data.yuv420p.length_u + \
1079 stream->data.yuv420p.length_v;
1088 switch (stream->num_planes) {
1091 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1092 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1093 total_size = stream->data.yuv420.length_yuv;
1097 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1098 if (stream->num_planes == (unsigned int)num_buffer_fd)
1099 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1101 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1102 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1103 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1104 total_size = stream->data.yuv420sp.length_y + \
1105 stream->data.yuv420sp.length_uv;
1109 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1110 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1111 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1112 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1114 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1115 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1117 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1118 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1119 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1120 total_size = stream->data.yuv420p.length_y + \
1121 stream->data.yuv420p.length_u + \
1122 stream->data.yuv420p.length_v;
1131 LOGD("format %d, %dx%d, size %d plane num %d",
1132 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1138 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1139 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1142 int ret = CAMERA_ERROR_NONE;
1143 camera_media_packet_data *tmp_mp_data = NULL;
1147 return CAMERA_ERROR_INVALID_PARAMETER;
1150 if (*mp_data == NULL) {
1151 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1153 tmp_mp_data->ret_fd = ret_fd;
1154 tmp_mp_data->fd = tfd[0];
1155 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1156 tmp_mp_data->bo = bo;
1160 tmp_mp_data->data_bo = data_bo;
1161 tmp_mp_data->data_fd = tfd[1];
1164 for (i = 0 ; i < num_buffer_fd ; i++) {
1165 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1166 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1170 tmp_mp_data->ref_cnt++;
1172 *mp_data = tmp_mp_data;
1173 /*LOGD("mp_data %p", tmp_mp_data);*/
1175 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1176 LOGE("failed to alloc media packet data");
1179 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1185 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1189 if (!mp_data || !cb_info) {
1190 LOGE("NULL pointer %p %p", mp_data, cb_info);
1194 if (mp_data->ref_cnt > 1) {
1196 LOGD("ref count %d", mp_data->ref_cnt);
1198 /* release imported bo and close imported fd */
1199 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1200 tbm_bo_unref(mp_data->buffer_bo[i]);
1201 mp_data->buffer_bo[i] = NULL;
1203 close(mp_data->buffer_fd[i]);
1204 mp_data->buffer_fd[i] = -1;
1207 /* unref tbm bo and close imported fd */
1210 _camera_release_imported_bo(&mp_data->bo);
1212 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1213 close(mp_data->data_fd);
1214 mp_data->data_fd = -1;
1216 _camera_release_imported_bo(&mp_data->data_bo);
1219 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1228 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1229 camera_media_packet_data *mp_data, media_packet_h *packet)
1231 media_packet_h pkt = NULL;
1232 bool make_pkt_fmt = false;
1233 tbm_surface_h tsurf = NULL;
1234 tbm_surface_info_s tsurf_info;
1235 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1236 uint32_t bo_format = 0;
1239 int num_buffer_fd = 0;
1240 tbm_bo *buffer_bo = NULL;
1242 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1243 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1244 cb_info, stream, mp_data, packet);
1245 return CAMERA_ERROR_INVALID_PARAMETER;
1248 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1249 buffer_bo = mp_data->buffer_bo;
1250 num_buffer_fd = mp_data->num_buffer_fd;
1252 /* create tbm surface */
1253 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1254 tsurf_info.planes[i].stride = stream->stride[i];
1256 /* get tbm surface format */
1257 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1258 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1260 if (ret == CAMERA_ERROR_NONE) {
1261 tsurf_info.width = stream->width;
1262 tsurf_info.height = stream->height;
1263 tsurf_info.format = bo_format;
1264 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1265 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1267 if (num_buffer_fd > 0) {
1268 switch (bo_format) {
1269 case TBM_FORMAT_NV12:
1270 case TBM_FORMAT_NV21:
1271 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1272 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1273 tsurf_info.planes[0].offset = 0;
1274 if (num_buffer_fd == 1)
1275 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1276 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1279 case TBM_FORMAT_YUV420:
1280 case TBM_FORMAT_YVU420:
1281 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1282 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1283 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1284 tsurf_info.planes[0].offset = 0;
1285 if (num_buffer_fd == 1) {
1286 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1287 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1289 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1291 case TBM_FORMAT_UYVY:
1292 case TBM_FORMAT_YUYV:
1293 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1294 tsurf_info.planes[0].offset = 0;
1295 tsurf_info.size = tsurf_info.planes[0].size;
1302 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1303 } else if (mp_data->data_bo) {
1305 switch (bo_format) {
1306 case TBM_FORMAT_NV12:
1307 case TBM_FORMAT_NV21:
1308 tsurf_info.planes[0].size = stream->width * stream->height;
1309 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1310 tsurf_info.planes[0].offset = 0;
1311 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1312 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1314 case TBM_FORMAT_YUV420:
1315 case TBM_FORMAT_YVU420:
1316 tsurf_info.planes[0].size = stream->width * stream->height;
1317 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1318 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1319 tsurf_info.planes[0].offset = 0;
1320 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1321 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1322 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1324 case TBM_FORMAT_UYVY:
1325 case TBM_FORMAT_YUYV:
1326 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1327 tsurf_info.planes[0].offset = 0;
1328 tsurf_info.size = tsurf_info.planes[0].size;
1334 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1337 /*LOGD("tbm surface %p", tsurf);*/
1341 /* check media packet format */
1342 if (cb_info->pkt_fmt) {
1343 int pkt_fmt_width = 0;
1344 int pkt_fmt_height = 0;
1345 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1347 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1348 if (pkt_fmt_mimetype != mimetype ||
1349 pkt_fmt_width != stream->width ||
1350 pkt_fmt_height != stream->height) {
1351 LOGW("change fmt: current 0x%x, %dx%d",
1352 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1353 media_format_unref(cb_info->pkt_fmt);
1354 cb_info->pkt_fmt = NULL;
1355 make_pkt_fmt = true;
1358 make_pkt_fmt = true;
1361 /* create packet format */
1363 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1364 ret = media_format_create(&cb_info->pkt_fmt);
1365 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1366 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1367 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1368 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1369 LOGW("media_format_set : 0x%x", ret);
1371 LOGW("media_format_create failed 0x%x", ret);
1375 /* create media packet */
1376 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1377 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1378 (void *)cb_info, &pkt);
1379 if (ret != MEDIA_PACKET_ERROR_NONE) {
1380 LOGE("media_packet_create failed 0x%x", ret);
1381 tbm_surface_destroy(tsurf);
1385 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1386 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1390 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1391 /* set media packet data */
1392 ret = media_packet_set_extra(pkt, (void *)mp_data);
1393 if (ret != MEDIA_PACKET_ERROR_NONE) {
1394 LOGE("media_packet_set_extra failed");
1396 _camera_media_packet_data_release(mp_data, cb_info);
1399 media_packet_destroy(pkt);
1402 /* set timestamp : msec -> nsec */
1403 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1404 LOGW("media_packet_set_pts failed");
1413 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1416 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1417 camera_media_packet_data *mp_data = NULL;
1418 tbm_surface_h tsurf = NULL;
1420 if (!pkt || !cb_info) {
1421 LOGE("NULL pointer %p %p", pkt, cb_info);
1422 return MEDIA_PACKET_FINALIZE;
1425 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1426 if (ret != MEDIA_PACKET_ERROR_NONE) {
1427 LOGE("media_packet_get_extra failed 0x%x", ret);
1428 return MEDIA_PACKET_FINALIZE;
1431 /*LOGD("mp_data %p", mp_data);*/
1433 g_mutex_lock(&cb_info->mp_data_mutex);
1435 _camera_media_packet_data_release(mp_data, cb_info);
1438 g_mutex_unlock(&cb_info->mp_data_mutex);
1440 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1441 if (ret != MEDIA_PACKET_ERROR_NONE)
1442 LOGE("get tbm_surface failed 0x%x", ret);
1445 tbm_surface_destroy(tsurf);
1449 return MEDIA_PACKET_FINALIZE;
1452 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1457 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1458 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1462 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1464 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1466 if (cb_info->user_cb[event] == NULL) {
1467 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1468 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1469 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1470 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1471 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1472 LOGW("NULL callback for event %d, return here", event);
1476 /* return buffer message should be sent for some events.
1477 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1478 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1479 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1480 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1485 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1491 muse_camera_msg_get(previous, recv_msg);
1492 muse_camera_msg_get(current, recv_msg);
1493 muse_camera_msg_get(by_policy, recv_msg);
1495 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1496 previous, current, by_policy);
1498 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1499 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1502 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1506 muse_camera_msg_get(state, recv_msg);
1508 LOGD("FOCUS state - %d", state);
1510 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1513 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1514 LOGD("CAPTURE_COMPLETED");
1515 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1517 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1518 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1519 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1522 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1526 muse_camera_msg_get(percent, recv_msg);
1528 LOGD("HDR progress - %d %%", percent);
1530 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1533 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1539 muse_camera_msg_get(policy, recv_msg);
1540 muse_camera_msg_get(previous, recv_msg);
1541 muse_camera_msg_get(current, recv_msg);
1543 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1545 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1546 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1549 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1554 muse_camera_msg_get(policy, recv_msg);
1555 muse_camera_msg_get(state, recv_msg);
1557 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1559 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1560 (camera_state_e)state, cb_info->user_data[event]);
1563 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1564 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1566 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1569 int current_state = 0;
1571 muse_camera_msg_get(error, recv_msg);
1572 muse_camera_msg_get(current_state, recv_msg);
1574 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1576 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1577 (camera_state_e)current_state, cb_info->user_data[event]);
1581 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1583 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1584 muse_camera_msg_get(param1, recv_msg);
1585 muse_camera_msg_get(param2, recv_msg);
1587 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1589 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1590 cb_info->user_cb[event] = NULL;
1591 cb_info->user_data[event] = NULL;
1592 LOGW("stop foreach callback for event %d", event);
1595 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1597 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1599 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1601 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1603 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1605 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1607 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1609 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1611 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1613 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1615 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1617 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1619 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1622 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1624 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1625 muse_camera_msg_get(param1, recv_msg);
1627 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1629 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1630 cb_info->user_cb[event] = NULL;
1631 cb_info->user_data[event] = NULL;
1632 LOGW("stop foreach callback for event %d", event);
1636 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1637 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1640 LOGW("unhandled event %d", event);
1644 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1649 static gboolean _camera_idle_event_callback(gpointer data)
1651 camera_cb_info_s *cb_info = NULL;
1652 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1654 if (cam_idle_event == NULL) {
1655 LOGE("cam_idle_event is NULL");
1660 g_mutex_lock(&g_cam_idle_event_lock);
1662 cb_info = cam_idle_event->cb_info;
1663 if (cb_info == NULL) {
1664 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1665 g_mutex_unlock(&g_cam_idle_event_lock);
1666 goto IDLE_EVENT_CALLBACK_DONE;
1669 /* remove event from list */
1670 if (cb_info->idle_event_list)
1671 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1673 g_mutex_unlock(&g_cam_idle_event_lock);
1676 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1678 IDLE_EVENT_CALLBACK_DONE:
1680 g_free(cam_idle_event);
1681 cam_idle_event = NULL;
1686 static gpointer _camera_msg_handler_func(gpointer data)
1690 camera_message_s *cam_msg = NULL;
1691 camera_idle_event_s *cam_idle_event = NULL;
1692 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1693 camera_cb_info_s *cb_info = NULL;
1695 if (!handler_info || !handler_info->cb_info) {
1696 LOGE("NULL handler %p", handler_info);
1700 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1701 type = handler_info->type;
1703 LOGD("t:%d start", type);
1705 g_mutex_lock(&handler_info->mutex);
1707 while (g_atomic_int_get(&handler_info->running)) {
1708 if (g_queue_is_empty(handler_info->queue)) {
1709 /*LOGD("t:%d signal wait...", type);*/
1710 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1711 /*LOGD("t:%d signal received", type);*/
1713 if (g_atomic_int_get(&handler_info->running) == 0) {
1714 LOGD("t:%d stop event thread", type);
1719 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1721 g_mutex_unlock(&handler_info->mutex);
1723 if (cam_msg == NULL) {
1724 LOGE("t:%d NULL message", type);
1725 g_mutex_lock(&handler_info->mutex);
1731 if (api < MUSE_CAMERA_API_MAX) {
1734 g_mutex_lock(&cb_info->api_mutex[api]);
1736 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1737 if (cb_info->api_waiting[api] > 0) {
1738 cb_info->api_ret[api] = ret;
1739 cb_info->api_activating[api] = 1;
1741 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1743 g_cond_signal(&cb_info->api_cond[api]);
1745 LOGW("no waiting for this api [%d]", api);
1748 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1751 g_mutex_unlock(&cb_info->api_mutex[api]);
1752 } else if (api == MUSE_CAMERA_CB_EVENT) {
1753 switch (cam_msg->event_class) {
1754 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1755 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1757 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1758 cam_idle_event = g_new0(camera_idle_event_s, 1);
1759 if (cam_idle_event == NULL) {
1760 LOGE("t:%d cam_idle_event alloc failed", type);
1764 cam_idle_event->event = cam_msg->event;
1765 cam_idle_event->cb_info = cb_info;
1767 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1768 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1770 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1772 g_mutex_lock(&g_cam_idle_event_lock);
1773 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1774 g_mutex_unlock(&g_cam_idle_event_lock);
1776 g_idle_add_full(G_PRIORITY_DEFAULT,
1777 (GSourceFunc)_camera_idle_event_callback,
1778 (gpointer)cam_idle_event,
1782 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1786 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1792 g_mutex_lock(&handler_info->mutex);
1795 /* remove remained event */
1796 while (!g_queue_is_empty(handler_info->queue)) {
1797 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1799 LOGD("t:%d remove camera message %p", type, cam_msg);
1803 LOGW("t:%d NULL camera message", type);
1807 g_mutex_unlock(&handler_info->mutex);
1809 LOGD("t:%d return", type);
1815 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1817 camera_idle_event_s *cam_idle_event = NULL;
1820 if (cb_info == NULL) {
1821 LOGE("cb_info is NULL");
1825 g_mutex_lock(&g_cam_idle_event_lock);
1827 if (cb_info->idle_event_list == NULL) {
1828 LOGD("No remained idle event");
1829 g_mutex_unlock(&g_cam_idle_event_lock);
1833 list = cb_info->idle_event_list;
1836 cam_idle_event = list->data;
1837 list = g_list_next(list);
1839 if (!cam_idle_event) {
1840 LOGW("Fail to remove idle event. The event is NULL");
1844 if (g_idle_remove_by_data(cam_idle_event)) {
1845 LOGW("remove idle event %p done", cam_idle_event);
1847 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1849 g_free(cam_idle_event);
1850 cam_idle_event = NULL;
1855 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1856 cam_idle_event, cam_idle_event->event);
1858 cam_idle_event->cb_info = NULL;
1860 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1863 g_list_free(cb_info->idle_event_list);
1864 cb_info->idle_event_list = NULL;
1866 g_mutex_unlock(&g_cam_idle_event_lock);
1872 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1874 camera_message_s *cam_msg = NULL;
1876 if (!cb_info || !msg) {
1877 LOGE("NULL pointer %p %p", cb_info, msg);
1881 cam_msg = g_new0(camera_message_s, 1);
1883 LOGE("failed to alloc cam_msg for [%s]", msg);
1888 cam_msg->event = event;
1889 cam_msg->event_class = event_class;
1891 if (tfd && tfd[0] >= 0)
1892 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1894 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1896 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1898 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1899 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1900 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1901 g_cond_signal(&cb_info->preview_cb_info.cond);
1902 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1903 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1904 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1905 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1906 g_cond_signal(&cb_info->capture_cb_info.cond);
1907 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1909 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1910 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1911 g_cond_signal(&cb_info->msg_handler_info.cond);
1912 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1921 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1923 int ret = CAMERA_ERROR_NONE;
1927 int event_class = -1;
1931 if (!cb_info || !msg) {
1932 LOGE("invalid ptr %p %p", cb_info, msg);
1936 /*LOGD("msg [%s]", msg);*/
1938 if (!muse_camera_msg_get(api, msg)) {
1939 LOGE("failed to get camera api");
1943 if (api == MUSE_CAMERA_CB_EVENT) {
1944 if (!muse_camera_msg_get(event, msg) ||
1945 !muse_camera_msg_get(event_class, msg)) {
1946 LOGE("failed to get camera event or event_class [%s]", msg);
1950 if (!muse_camera_msg_get(api_class, msg)) {
1951 LOGE("failed to get camera api_class [%s]", msg);
1956 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1957 if (api >= MUSE_CAMERA_API_MAX) {
1958 LOGE("invalid api %d", api);
1962 if (!muse_camera_msg_get(ret, msg)) {
1963 LOGE("failed to get camera ret");
1967 g_mutex_lock(&cb_info->api_mutex[api]);
1970 case MUSE_CAMERA_API_CREATE:
1971 if (ret != CAMERA_ERROR_NONE) {
1972 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1973 LOGE("camera create error 0x%x. close client cb handler", ret);
1976 case MUSE_CAMERA_API_DESTROY:
1977 if (ret == CAMERA_ERROR_NONE) {
1978 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1979 LOGD("camera destroy done. close client cb handler");
1983 muse_camera_msg_get(get_type, msg);
1984 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1985 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1986 muse_camera_msg_get(get_index, msg);
1989 case MUSE_CAMERA_GET_TYPE_INT:
1990 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1992 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1993 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1994 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1996 case MUSE_CAMERA_GET_TYPE_ARRAY:
1997 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1998 muse_core_msg_deserialize("get_value",
1999 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2000 LOGD("get display roi %d,%d,%dx%d",
2001 cb_info->get_display_roi_area[0],
2002 cb_info->get_display_roi_area[1],
2003 cb_info->get_display_roi_area[2],
2004 cb_info->get_display_roi_area[3]);
2006 muse_core_msg_deserialize("get_value",
2007 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2008 LOGD("get geotag %lf, %lf, %lf",
2009 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2012 case MUSE_CAMERA_GET_TYPE_STRING:
2013 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2016 LOGW("unknown type %d", get_type);
2023 if (cb_info->api_waiting[api] > 0) {
2024 cb_info->api_ret[api] = ret;
2025 cb_info->api_activating[api] = 1;
2027 g_cond_signal(&cb_info->api_cond[api]);
2029 LOGW("no waiting for this api [%d]", api);
2032 g_mutex_unlock(&cb_info->api_mutex[api]);
2033 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2034 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2036 LOGW("unknown camera api %d, class %d", api, api_class);
2043 static gpointer _camera_msg_recv_func(gpointer data)
2046 int recv_length = 0;
2047 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2048 char *recv_msg = NULL;
2049 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2052 LOGE("cb_info NULL");
2056 LOGD("start - fd : %d", cb_info->fd);
2058 recv_msg = cb_info->recv_msg;
2060 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2061 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2064 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2065 if (recv_length <= 0) {
2066 cb_info->is_server_connected = FALSE;
2067 LOGE("receive msg failed - server disconnected");
2073 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2076 recv_msg[recv_length] = '\0';
2078 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2080 __camera_process_msg(cb_info, recv_msg, tfd);
2083 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2085 if (!cb_info->is_server_connected) {
2086 char *error_msg = NULL;
2088 if (cb_info->bufmgr == NULL) {
2089 LOGE("No need to send error(handle is not created)");
2093 if (cb_info->fd < 0) {
2094 LOGE("fd is closed in client side");
2098 /* send error msg for server disconnection */
2099 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2100 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2101 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2105 LOGE("error_msg failed");
2109 __camera_add_msg_to_queue(cb_info,
2110 MUSE_CAMERA_CB_EVENT,
2111 MUSE_CAMERA_EVENT_TYPE_ERROR,
2112 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2116 muse_core_msg_free(error_msg);
2119 LOGE("add error msg for service disconnection done");
2126 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2127 int type, const char *thread_name, camera_cb_info_s *cb_info)
2129 if (!handler_info || !thread_name || !cb_info) {
2130 LOGE("t:%d NULL %p %p %p",
2131 type, handler_info, thread_name, cb_info);
2137 handler_info->type = type;
2138 handler_info->queue = g_queue_new();
2139 if (handler_info->queue == NULL) {
2140 LOGE("t:%d queue failed", type);
2144 g_mutex_init(&handler_info->mutex);
2145 g_cond_init(&handler_info->cond);
2147 handler_info->cb_info = (void *)cb_info;
2148 g_atomic_int_set(&handler_info->running, 1);
2150 handler_info->thread = g_thread_try_new(thread_name,
2151 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2152 if (handler_info->thread == NULL) {
2153 LOGE("t:%d thread failed", type);
2155 g_mutex_clear(&handler_info->mutex);
2156 g_cond_clear(&handler_info->cond);
2157 g_queue_free(handler_info->queue);
2158 handler_info->queue = NULL;
2163 LOGD("t:%d done", type);
2169 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2173 if (!handler_info) {
2174 LOGE("NULL handler");
2178 if (!handler_info->thread) {
2179 LOGW("thread is not created");
2183 type = handler_info->type;
2185 LOGD("t:%d thread %p", type, handler_info->thread);
2187 g_mutex_lock(&handler_info->mutex);
2188 g_atomic_int_set(&handler_info->running, 0);
2189 g_cond_signal(&handler_info->cond);
2190 g_mutex_unlock(&handler_info->mutex);
2192 g_thread_join(handler_info->thread);
2193 handler_info->thread = NULL;
2195 g_mutex_clear(&handler_info->mutex);
2196 g_cond_clear(&handler_info->cond);
2197 g_queue_free(handler_info->queue);
2198 handler_info->queue = NULL;
2200 LOGD("t:%d done", type);
2206 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2208 camera_cb_info_s *cb_info = NULL;
2211 g_return_val_if_fail(sockfd > 0, NULL);
2213 cb_info = g_new0(camera_cb_info_s, 1);
2214 if (cb_info == NULL) {
2215 LOGE("cb_info failed");
2219 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2221 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2222 g_mutex_init(&cb_info->api_mutex[i]);
2223 g_cond_init(&cb_info->api_cond[i]);
2226 g_mutex_init(&cb_info->fd_lock);
2227 g_mutex_init(&cb_info->mp_data_mutex);
2229 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2230 g_mutex_init(&cb_info->user_cb_mutex[i]);
2232 /* message handler thread */
2233 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2234 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2235 LOGE("msg_handler_info failed");
2239 /* message handler thread for preview callback */
2240 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2241 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2242 LOGE("preview_cb_info failed");
2246 /* message handler thread for capture callback */
2247 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2248 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2249 LOGE("capture_cb_info failed");
2253 cb_info->fd = sockfd;
2254 cb_info->preview_cb_flag = 0;
2256 /* message receive thread */
2257 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2258 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2259 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2260 if (cb_info->msg_recv_thread == NULL) {
2261 LOGE("message receive thread creation failed");
2266 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2267 cb_info->fds[i] = -1;
2269 cb_info->is_server_connected = TRUE;
2275 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2276 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2277 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2279 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2280 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2282 g_mutex_clear(&cb_info->fd_lock);
2283 g_mutex_clear(&cb_info->mp_data_mutex);
2285 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2286 g_mutex_clear(&cb_info->api_mutex[i]);
2287 g_cond_clear(&cb_info->api_cond[i]);
2298 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2302 g_return_if_fail(cb_info != NULL);
2304 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2306 g_thread_join(cb_info->msg_recv_thread);
2307 cb_info->msg_recv_thread = NULL;
2309 LOGD("msg_recv thread removed");
2311 /* destroy msg handler threads */
2312 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2313 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2314 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2316 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2317 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2319 g_mutex_clear(&cb_info->fd_lock);
2320 g_mutex_clear(&cb_info->mp_data_mutex);
2322 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2323 g_mutex_clear(&cb_info->api_mutex[i]);
2324 g_cond_clear(&cb_info->api_cond[i]);
2327 if (cb_info->fd > -1) {
2328 muse_client_close(cb_info->fd);
2332 if (cb_info->bufmgr) {
2333 tbm_bufmgr_deinit(cb_info->bufmgr);
2334 cb_info->bufmgr = NULL;
2336 if (cb_info->pkt_fmt) {
2337 media_format_unref(cb_info->pkt_fmt);
2338 cb_info->pkt_fmt = NULL;
2341 if (cb_info->dp_interface) {
2342 mm_display_interface_deinit(cb_info->dp_interface);
2343 cb_info->dp_interface = NULL;
2346 cb_info->preview_cb_flag = 0;
2355 int _camera_start_evas_rendering(camera_h camera)
2357 camera_cli_s *pc = (camera_cli_s *)camera;
2359 if (!pc || !pc->cb_info) {
2360 LOGE("NULL handle");
2361 return CAMERA_ERROR_INVALID_PARAMETER;
2366 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2367 LOGE("EVAS surface is not set");
2368 return CAMERA_ERROR_NONE;
2371 /* set evas render flag as RUN */
2372 pc->cb_info->run_evas_render = true;
2374 return CAMERA_ERROR_NONE;
2378 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2380 int ret = CAMERA_ERROR_NONE;
2381 camera_cli_s *pc = (camera_cli_s *)camera;
2383 if (!pc || !pc->cb_info) {
2384 LOGE("NULL handle");
2385 return CAMERA_ERROR_INVALID_PARAMETER;
2388 LOGD("stop - keep screen %d", keep_screen);
2390 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2391 LOGE("EVAS surface is not set");
2392 return CAMERA_ERROR_NONE;
2395 /* set evas render flag as STOP and release buffers */
2396 pc->cb_info->run_evas_render = false;
2398 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2399 if (ret == MM_ERROR_NONE) {
2400 ret = CAMERA_ERROR_NONE;
2402 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2403 ret = CAMERA_ERROR_INVALID_OPERATION;
2410 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2412 int ret = CAMERA_ERROR_NONE;
2414 int module_index = -1;
2416 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2418 /* create muse connection */
2419 if (!key || !value) {
2420 LOGE("NULL pointer");
2421 return CAMERA_ERROR_INVALID_PARAMETER;
2424 sock_fd = muse_client_new();
2426 LOGE("muse_client_new failed");
2427 return CAMERA_ERROR_INVALID_OPERATION;
2430 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2431 LOGE("muse client get module index failed");
2432 ret = CAMERA_ERROR_INVALID_OPERATION;
2436 msg = muse_core_msg_new(api,
2437 MUSE_TYPE_INT, "module", module_index,
2438 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2442 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2446 ret = muse_core_msg_send(sock_fd, msg);
2448 muse_core_msg_free(msg);
2452 LOGE("send msg failed");
2453 ret = CAMERA_ERROR_INVALID_OPERATION;
2457 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2459 LOGE("recv msg failed %d", errno);
2460 ret = CAMERA_ERROR_INVALID_OPERATION;
2464 if (!muse_camera_msg_get(ret, recv_msg)) {
2465 LOGE("failed to get return value from msg [%s]", recv_msg);
2466 ret = CAMERA_ERROR_INVALID_OPERATION;
2470 if (ret == CAMERA_ERROR_NONE)
2471 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2473 LOGD("api %d - value %d", api, *value);
2477 muse_client_close(sock_fd);
2485 int camera_create(camera_device_e device, camera_h *camera)
2488 char *send_msg = NULL;
2490 int ret = CAMERA_ERROR_NONE;
2492 camera_cli_s *pc = NULL;
2493 tbm_bufmgr bufmgr = NULL;
2495 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2496 int module_index = -1;
2497 int device_type = (int)device;
2500 LOGE("NULL pointer");
2501 return CAMERA_ERROR_INVALID_PARAMETER;
2504 sock_fd = muse_client_new();
2506 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2507 ret = CAMERA_ERROR_INVALID_OPERATION;
2513 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2514 LOGE("muse client get module index failed");
2515 ret = CAMERA_ERROR_INVALID_OPERATION;
2519 send_msg = muse_core_msg_new(api,
2520 MUSE_TYPE_INT, "module", module_index,
2521 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2522 MUSE_TYPE_INT, "pid", pid,
2527 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2531 send_ret = muse_core_msg_send(sock_fd, send_msg);
2533 muse_core_msg_free(send_msg);
2537 LOGE("send msg failed %d", errno);
2538 ret = CAMERA_ERROR_INVALID_OPERATION;
2542 pc = g_new0(camera_cli_s, 1);
2544 LOGE("camera_cli_s alloc failed");
2545 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2549 bufmgr = tbm_bufmgr_init(-1);
2550 if (bufmgr == NULL) {
2551 LOGE("get tbm bufmgr failed");
2552 ret = CAMERA_ERROR_INVALID_OPERATION;
2556 pc->cb_info = _camera_client_callback_new(sock_fd);
2557 if (pc->cb_info == NULL) {
2558 LOGE("cb_info alloc failed");
2559 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2565 LOGD("cb info : %d", pc->cb_info->fd);
2567 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2569 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2571 if (ret == CAMERA_ERROR_NONE) {
2572 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2573 int user_buffer_supported = 0;
2574 intptr_t handle = 0;
2576 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2578 LOGE("Receiving Handle Failed!!");
2579 ret = CAMERA_ERROR_INVALID_OPERATION;
2583 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2584 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2586 pc->remote_handle = handle;
2587 pc->cb_info->bufmgr = bufmgr;
2588 pc->cb_info->preview_format = preview_format;
2589 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2590 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2592 LOGD("default preview format %d, user buffer %d",
2593 preview_format, user_buffer_supported);
2595 *camera = (camera_h)pc;
2597 /* get display interface handle */
2598 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2599 LOGW("display interface init failed");
2608 tbm_bufmgr_deinit(bufmgr);
2613 muse_client_close(sock_fd);
2619 int temp_fd = pc->cb_info->fd;
2621 /* pc->cb_info->fd should be closed,
2622 because g_thread_join for msg_recv_thread is not returned
2623 in _camera_client_callback_destroy. */
2625 pc->cb_info->fd = -1;
2626 muse_client_close(temp_fd);
2629 _camera_client_callback_destroy(pc->cb_info);
2636 LOGE("camera create error : 0x%x", ret);
2643 int camera_change_device(camera_h camera, camera_device_e device)
2646 int ret = CAMERA_ERROR_NONE;
2647 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2648 camera_cli_s *pc = (camera_cli_s *)camera;
2649 camera_msg_param param;
2651 if (!pc || !pc->cb_info) {
2652 LOGE("NULL handle");
2653 return CAMERA_ERROR_INVALID_PARAMETER;
2656 CAMERA_MSG_PARAM_SET(param, INT, device);
2658 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2660 if (ret == CAMERA_ERROR_NONE) {
2661 /* reset callback and user data */
2662 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2663 pc->cb_info->user_cb[i] = NULL;
2664 pc->cb_info->user_data[i] = NULL;
2666 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2673 int camera_destroy(camera_h camera)
2675 int ret = CAMERA_ERROR_NONE;
2676 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2677 camera_cli_s *pc = (camera_cli_s *)camera;
2679 if (!pc || !pc->cb_info) {
2680 LOGE("NULL handle");
2681 return CAMERA_ERROR_INVALID_PARAMETER;
2686 if (pc->cb_info->is_server_connected)
2687 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2689 LOGW("server disconnected. release resource without send message.");
2691 if (ret == CAMERA_ERROR_NONE) {
2692 _camera_deactivate_idle_event_all(pc->cb_info);
2693 _camera_client_callback_destroy(pc->cb_info);
2700 LOGD("ret : 0x%x", ret);
2705 int camera_start_preview(camera_h camera)
2707 int ret = CAMERA_ERROR_NONE;
2708 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2709 camera_cli_s *pc = (camera_cli_s *)camera;
2710 camera_state_e current_state = CAMERA_STATE_NONE;
2712 if (!pc || !pc->cb_info) {
2713 LOGE("NULL handle");
2714 return CAMERA_ERROR_INVALID_PARAMETER;
2717 LOGD("Enter : preview format %d, display type %d",
2718 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2720 ret = camera_get_state(camera, ¤t_state);
2721 if (ret != CAMERA_ERROR_NONE) {
2722 LOGE("failed to get current state 0x%x", ret);
2726 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2727 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2728 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2729 pc->cb_info->dp_info.type);
2730 return CAMERA_ERROR_INVALID_OPERATION;
2733 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2734 if (!_camera_allocate_preview_buffer(camera))
2735 return CAMERA_ERROR_INVALID_OPERATION;
2737 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2739 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2742 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2743 ret = _camera_start_evas_rendering(camera);
2744 if (ret != CAMERA_ERROR_NONE) {
2745 LOGE("stop preview because of error");
2746 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2750 LOGD("ret : 0x%x", ret);
2756 int camera_stop_preview(camera_h camera)
2758 int ret = CAMERA_ERROR_NONE;
2759 camera_cli_s *pc = (camera_cli_s *)camera;
2760 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2761 camera_state_e current_state = CAMERA_STATE_NONE;
2763 if (!pc || !pc->cb_info) {
2764 LOGE("NULL handle");
2765 return CAMERA_ERROR_INVALID_PARAMETER;
2771 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2772 ret = camera_get_state(camera, ¤t_state);
2773 if (ret != CAMERA_ERROR_NONE) {
2774 LOGE("failed to get current state 0x%x", ret);
2778 if (current_state == CAMERA_STATE_PREVIEW) {
2779 ret = _camera_stop_evas_rendering(camera, false);
2780 if (ret != CAMERA_ERROR_NONE)
2785 /* send stop preview message */
2786 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2788 if (ret == CAMERA_ERROR_NONE) {
2789 if (pc->cb_info->user_buffer_supported)
2790 _camera_release_preview_buffer(camera);
2791 } else if (current_state == CAMERA_STATE_PREVIEW) {
2792 LOGW("restart evas rendering");
2793 _camera_start_evas_rendering(camera);
2796 LOGD("ret : 0x%x", ret);
2802 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2804 int ret = CAMERA_ERROR_NONE;
2805 camera_cli_s *pc = (camera_cli_s *)camera;
2806 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2808 if (!pc || !pc->cb_info) {
2809 LOGE("NULL handle");
2810 return CAMERA_ERROR_INVALID_PARAMETER;
2815 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2816 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2821 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2823 LOGD("ret : 0x%x", ret);
2829 bool camera_is_supported_continuous_capture(camera_h camera)
2831 int ret = CAMERA_ERROR_NONE;
2832 camera_cli_s *pc = (camera_cli_s *)camera;
2833 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2835 if (!pc || !pc->cb_info) {
2836 LOGE("NULL handle");
2837 return CAMERA_ERROR_INVALID_PARAMETER;
2842 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2845 LOGE("error is occurred 0x%x", ret);
2849 LOGD("ret : %d", ret);
2855 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)
2857 int ret = CAMERA_ERROR_NONE;
2858 camera_cli_s *pc = (camera_cli_s *)camera;
2859 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2860 camera_msg_param param;
2863 if (!pc || !pc->cb_info) {
2864 LOGE("NULL handle");
2865 return CAMERA_ERROR_INVALID_PARAMETER;
2870 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2871 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2876 value = (count << 16) | interval;
2877 CAMERA_MSG_PARAM_SET(param, INT, value);
2879 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2881 LOGD("ret : 0x%x", ret);
2887 int camera_stop_continuous_capture(camera_h camera)
2889 int ret = CAMERA_ERROR_NONE;
2890 camera_cli_s *pc = (camera_cli_s *)camera;
2891 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2893 if (!pc || !pc->cb_info) {
2894 LOGE("NULL handle");
2895 return CAMERA_ERROR_INVALID_PARAMETER;
2900 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2902 LOGD("ret : 0x%x", ret);
2908 bool camera_is_supported_face_detection(camera_h camera)
2910 int ret = CAMERA_ERROR_NONE;
2911 camera_cli_s *pc = (camera_cli_s *)camera;
2912 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2914 if (!pc || !pc->cb_info) {
2915 LOGE("NULL handle");
2916 return CAMERA_ERROR_INVALID_PARAMETER;
2921 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2924 LOGE("error is occurred 0x%x", ret);
2928 LOGD("ret : %d", ret);
2934 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2936 int ret = CAMERA_ERROR_NONE;
2937 camera_cli_s *pc = (camera_cli_s *)camera;
2938 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2940 if (!pc || !pc->cb_info) {
2941 LOGE("NULL handle");
2942 return CAMERA_ERROR_INVALID_PARAMETER;
2947 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2950 LOGE("error is occurred 0x%x", ret);
2954 LOGD("ret : %d", ret);
2960 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2962 int ret = CAMERA_ERROR_NONE;
2963 camera_cli_s *pc = (camera_cli_s *)camera;
2964 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2966 if (!pc || !pc->cb_info) {
2967 LOGE("NULL handle");
2968 return CAMERA_ERROR_INVALID_PARAMETER;
2973 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2976 LOGE("error is occurred 0x%x", ret);
2980 LOGD("ret : %d", ret);
2985 int camera_get_device_count(camera_h camera, int *device_count)
2987 int ret = CAMERA_ERROR_NONE;
2988 camera_cli_s *pc = (camera_cli_s *)camera;
2989 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2991 if (!pc || !pc->cb_info) {
2992 LOGE("NULL handle");
2993 return CAMERA_ERROR_INVALID_PARAMETER;
2998 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3000 if (ret == CAMERA_ERROR_NONE)
3001 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3003 LOGD("ret : 0x%x", ret);
3008 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3010 int ret = CAMERA_ERROR_NONE;
3011 camera_cli_s *pc = (camera_cli_s *)camera;
3012 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3014 if (!pc || !pc->cb_info) {
3015 LOGE("NULL handle");
3016 return CAMERA_ERROR_INVALID_PARAMETER;
3021 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3023 if (ret == CAMERA_ERROR_NONE) {
3024 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3029 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3032 LOGD("ret : 0x%x", ret);
3037 int camera_stop_face_detection(camera_h camera)
3039 int ret = CAMERA_ERROR_NONE;
3040 camera_cli_s *pc = (camera_cli_s *)camera;
3041 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3043 if (!pc || !pc->cb_info) {
3044 LOGE("NULL handle");
3045 return CAMERA_ERROR_INVALID_PARAMETER;
3050 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3052 if (ret == CAMERA_ERROR_NONE) {
3053 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3055 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3056 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3058 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3061 LOGD("ret : 0x%x", ret);
3066 int camera_get_state(camera_h camera, camera_state_e *state)
3068 int ret = CAMERA_ERROR_NONE;
3069 camera_cli_s *pc = (camera_cli_s *)camera;
3070 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3072 if (!pc || !pc->cb_info || !state) {
3073 LOGE("NULL pointer %p %p", pc, state);
3074 return CAMERA_ERROR_INVALID_PARAMETER;
3079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3081 if (ret == CAMERA_ERROR_NONE)
3082 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3084 LOGD("ret : 0x%x", ret);
3089 int camera_start_focusing(camera_h camera, bool continuous)
3091 int ret = CAMERA_ERROR_NONE;
3092 camera_cli_s *pc = (camera_cli_s *)camera;
3093 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3094 camera_msg_param param;
3095 int is_continuous = (int)continuous;
3097 if (!pc || !pc->cb_info) {
3098 LOGE("NULL handle");
3099 return CAMERA_ERROR_INVALID_PARAMETER;
3104 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3106 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3108 LOGD("ret : 0x%x", ret);
3113 int camera_cancel_focusing(camera_h camera)
3115 int ret = CAMERA_ERROR_NONE;
3116 camera_cli_s *pc = (camera_cli_s *)camera;
3117 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3119 if (!pc || !pc->cb_info) {
3120 LOGE("NULL handle");
3121 return CAMERA_ERROR_INVALID_PARAMETER;
3124 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3126 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3128 LOGD("ret : 0x%x", ret);
3133 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3135 int mm_ret = MM_ERROR_NONE;
3136 int ret = CAMERA_ERROR_NONE;
3137 camera_cli_s *pc = (camera_cli_s *)camera;
3138 camera_cb_info_s *cb_info = NULL;
3139 camera_state_e current_state = CAMERA_STATE_NONE;
3140 camera_msg_param param;
3141 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3142 muse_camera_display_info_s *dp_info = NULL;
3144 if (!pc || !pc->cb_info) {
3145 LOGE("NULL handle");
3146 return CAMERA_ERROR_INVALID_PARAMETER;
3149 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3150 LOGE("invalid type %d", type);
3151 return CAMERA_ERROR_INVALID_PARAMETER;
3154 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3155 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3159 cb_info = (camera_cb_info_s *)pc->cb_info;
3160 dp_info = &cb_info->dp_info;
3162 ret = camera_get_state(camera, ¤t_state);
3163 if (ret != CAMERA_ERROR_NONE) {
3164 LOGE("failed to get current state 0x%x", ret);
3168 if (current_state != CAMERA_STATE_CREATED) {
3169 LOGE("INVALID_STATE : current %d", current_state);
3170 return CAMERA_ERROR_INVALID_STATE;
3173 LOGD("Enter - type : %d, display : %p", type, display);
3175 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3176 /* check display interface handle */
3177 if (!cb_info->dp_interface) {
3178 LOGE("display interface not supported");
3179 return CAMERA_ERROR_NOT_SUPPORTED;
3182 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3183 if (mm_ret != MM_ERROR_NONE) {
3184 LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3185 return CAMERA_ERROR_INVALID_OPERATION;
3188 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3189 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3191 LOGD("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3192 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3193 dp_info->window_rect.width, dp_info->window_rect.height);
3194 } else if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3196 camera_flip_e flip = CAMERA_FLIP_NONE;
3197 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3198 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3205 camera_get_display_flip(camera, &flip);
3206 camera_get_display_mode(camera, &mode);
3207 camera_get_display_rotation(camera, &rotation);
3208 camera_is_display_visible(camera, &visible);
3209 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3211 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3212 flip, mode, rotation, visible, x, y, width, height);
3214 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3215 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3216 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3217 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3219 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3220 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3225 if (mm_ret != MM_ERROR_NONE) {
3226 LOGE("mm_ret 0x%x failed", mm_ret);
3227 return CAMERA_ERROR_INVALID_OPERATION;
3230 dp_info->type = type;
3232 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3234 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3236 if (ret == CAMERA_ERROR_NONE) {
3237 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3238 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3245 int camera_set_preview_resolution(camera_h camera, int width, int height)
3247 int ret = CAMERA_ERROR_NONE;
3248 camera_state_e current_state = CAMERA_STATE_NONE;
3249 camera_cli_s *pc = (camera_cli_s *)camera;
3250 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3251 camera_msg_param param;
3254 if (!pc || !pc->cb_info) {
3255 LOGE("NULL handle");
3256 return CAMERA_ERROR_INVALID_PARAMETER;
3259 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3260 ret = camera_get_state(camera, ¤t_state);
3261 if (ret != CAMERA_ERROR_NONE) {
3262 LOGE("failed to get current state 0x%x", ret);
3266 if (current_state == CAMERA_STATE_PREVIEW) {
3267 ret = _camera_stop_evas_rendering(camera, true);
3268 if (ret != CAMERA_ERROR_NONE)
3273 value = (width << 16) | height;
3274 CAMERA_MSG_PARAM_SET(param, INT, value);
3276 LOGD("%dx%d -> 0x%x", width, height, value);
3278 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3280 LOGD("ret : 0x%x", ret);
3282 if (current_state == CAMERA_STATE_PREVIEW) {
3283 LOGW("restart evas rendering");
3284 _camera_start_evas_rendering(camera);
3291 int camera_set_capture_resolution(camera_h camera, int width, int height)
3293 int ret = CAMERA_ERROR_NONE;
3294 camera_cli_s *pc = (camera_cli_s *)camera;
3295 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3296 camera_msg_param param;
3299 if (!pc || !pc->cb_info) {
3300 LOGE("NULL handle");
3301 return CAMERA_ERROR_INVALID_PARAMETER;
3306 value = (width << 16) | height;
3307 CAMERA_MSG_PARAM_SET(param, INT, value);
3309 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3311 LOGD("ret : 0x%x", ret);
3317 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3319 int ret = CAMERA_ERROR_NONE;
3320 int set_format = (int)format;
3321 camera_cli_s *pc = (camera_cli_s *)camera;
3322 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3323 camera_msg_param param;
3325 if (!pc || !pc->cb_info) {
3326 LOGE("NULL handle");
3327 return CAMERA_ERROR_INVALID_PARAMETER;
3330 LOGD("Enter - format %d", set_format);
3332 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3334 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3336 LOGD("ret : 0x%x", ret);
3342 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3344 int ret = CAMERA_ERROR_NONE;
3345 int set_format = (int)format;
3346 camera_msg_param param;
3347 camera_cli_s *pc = (camera_cli_s *)camera;
3348 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3350 if (!pc || !pc->cb_info) {
3351 LOGE("NULL handle");
3352 return CAMERA_ERROR_INVALID_PARAMETER;
3355 LOGD("Enter - format %d", set_format);
3357 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3359 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3361 if (ret == CAMERA_ERROR_NONE)
3362 pc->cb_info->preview_format = set_format;
3364 LOGD("ret : 0x%x", ret);
3370 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3372 int ret = CAMERA_ERROR_NONE;
3373 camera_cli_s *pc = (camera_cli_s *)camera;
3374 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3376 if (!pc || !pc->cb_info || !width || !height) {
3377 LOGE("NULL pointer %p %p %p", pc, width, height);
3378 return CAMERA_ERROR_INVALID_PARAMETER;
3383 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3385 if (ret == CAMERA_ERROR_NONE) {
3386 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3387 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3390 LOGD("ret : 0x%x", ret);
3396 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3398 int ret = CAMERA_ERROR_NONE;
3399 int set_rotation = (int)rotation;
3400 camera_cli_s *pc = (camera_cli_s *)camera;
3401 camera_msg_param param;
3403 if (!pc || !pc->cb_info) {
3404 LOGE("NULL handle");
3405 return CAMERA_ERROR_INVALID_PARAMETER;
3408 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3409 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3410 if (ret != MM_ERROR_NONE) {
3411 LOGE("failed to set rotation for evas surface 0x%x", ret);
3412 return CAMERA_ERROR_INVALID_OPERATION;
3416 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3418 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3424 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3426 int ret = CAMERA_ERROR_NONE;
3427 camera_cli_s *pc = (camera_cli_s *)camera;
3429 if (!pc || !pc->cb_info || !rotation) {
3430 LOGE("NULL pointer %p %p", pc, rotation);
3431 return CAMERA_ERROR_INVALID_PARAMETER;
3434 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3436 if (ret == CAMERA_ERROR_NONE)
3437 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3443 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3445 int ret = CAMERA_ERROR_NONE;
3446 int set_flip = (int)flip;
3447 camera_cli_s *pc = (camera_cli_s *)camera;
3448 camera_msg_param param;
3450 if (!pc || !pc->cb_info) {
3451 LOGE("NULL handle");
3452 return CAMERA_ERROR_INVALID_PARAMETER;
3455 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3456 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3457 if (ret != MM_ERROR_NONE) {
3458 LOGE("failed to set flip for evas surface 0x%x", ret);
3459 return CAMERA_ERROR_INVALID_OPERATION;
3463 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3465 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3471 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3473 int ret = CAMERA_ERROR_NONE;
3474 camera_cli_s *pc = (camera_cli_s *)camera;
3476 if (!pc || !pc->cb_info || !flip) {
3477 LOGE("NULL pointer %p %p", pc, flip);
3478 return CAMERA_ERROR_INVALID_PARAMETER;
3481 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3483 if (ret == CAMERA_ERROR_NONE)
3484 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3490 int camera_set_display_visible(camera_h camera, bool visible)
3492 int ret = CAMERA_ERROR_NONE;
3493 int set_visible = (int)visible;
3494 camera_cli_s *pc = (camera_cli_s *)camera;
3495 camera_msg_param param;
3497 if (!pc || !pc->cb_info) {
3498 LOGE("NULL handle");
3499 return CAMERA_ERROR_INVALID_PARAMETER;
3502 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3503 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3504 if (ret != MM_ERROR_NONE) {
3505 LOGE("failed to set visible for evas surface 0x%x", ret);
3506 return CAMERA_ERROR_INVALID_OPERATION;
3510 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3512 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3518 int camera_is_display_visible(camera_h camera, bool *visible)
3520 int ret = CAMERA_ERROR_NONE;
3521 camera_cli_s *pc = (camera_cli_s *)camera;
3523 if (!pc || !pc->cb_info || !visible) {
3524 LOGE("NULL pointer %p %p", pc, visible);
3525 return CAMERA_ERROR_INVALID_PARAMETER;
3528 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3530 if (ret == CAMERA_ERROR_NONE)
3531 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3537 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3539 int ret = CAMERA_ERROR_NONE;
3540 int set_mode = (int)mode;
3541 camera_cli_s *pc = (camera_cli_s *)camera;
3542 camera_msg_param param;
3544 if (!pc || !pc->cb_info) {
3545 LOGE("NULL handle");
3546 return CAMERA_ERROR_INVALID_PARAMETER;
3549 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3550 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3551 if (ret != MM_ERROR_NONE) {
3552 LOGE("failed to set geometry for evas surface 0x%x", ret);
3553 return CAMERA_ERROR_INVALID_OPERATION;
3557 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3559 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3565 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3567 int ret = CAMERA_ERROR_NONE;
3568 camera_cli_s *pc = (camera_cli_s *)camera;
3570 if (!pc || !pc->cb_info || !mode) {
3571 LOGE("NULL pointer %p %p", pc, mode);
3572 return CAMERA_ERROR_INVALID_PARAMETER;
3575 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3577 if (ret == CAMERA_ERROR_NONE)
3578 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3584 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3586 int ret = CAMERA_ERROR_NONE;
3587 int set_hint = (int)hint;
3588 camera_cli_s *pc = (camera_cli_s *)camera;
3589 camera_msg_param param;
3591 if (!pc || !pc->cb_info) {
3592 LOGE("NULL handle");
3593 return CAMERA_ERROR_INVALID_PARAMETER;
3596 LOGD("Enter - hint %d", set_hint);
3598 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3600 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3606 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3608 int ret = CAMERA_ERROR_NONE;
3609 camera_cli_s *pc = (camera_cli_s *)camera;
3610 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3612 if (!pc || !pc->cb_info || !hint) {
3613 LOGE("NULL pointer %p %p", pc, hint);
3614 return CAMERA_ERROR_INVALID_PARAMETER;
3617 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3619 if (ret == CAMERA_ERROR_NONE) {
3620 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3621 LOGD("display reuse hint %d", *hint);
3628 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3630 int ret = CAMERA_ERROR_NONE;
3631 camera_cli_s *pc = (camera_cli_s *)camera;
3632 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3634 if (!pc || !pc->cb_info || !width || !height) {
3635 LOGE("NULL pointer %p %p %p", pc, width, height);
3636 return CAMERA_ERROR_INVALID_PARAMETER;
3641 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3643 if (ret == CAMERA_ERROR_NONE) {
3644 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3645 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3648 LOGD("ret : 0x%x", ret);
3654 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3656 int ret = CAMERA_ERROR_NONE;
3657 camera_cli_s *pc = (camera_cli_s *)camera;
3658 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3660 if (!pc || !pc->cb_info || !format) {
3661 LOGE("NULL pointer %p %p", pc, format);
3662 return CAMERA_ERROR_INVALID_PARAMETER;
3667 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3669 if (ret == CAMERA_ERROR_NONE)
3670 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3672 LOGD("ret : 0x%x", ret);
3678 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3680 int ret = CAMERA_ERROR_NONE;
3681 camera_cli_s *pc = (camera_cli_s *)camera;
3682 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3684 if (!pc || !pc->cb_info || !format) {
3685 LOGE("NULL pointer %p %p", pc, format);
3686 return CAMERA_ERROR_INVALID_PARAMETER;
3691 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3693 if (ret == CAMERA_ERROR_NONE)
3694 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3696 LOGD("ret : 0x%x", ret);
3702 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3704 int ret = CAMERA_ERROR_NONE;
3705 camera_cli_s *pc = (camera_cli_s *)camera;
3706 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3708 if (!pc || !pc->cb_info || !facing_direction) {
3709 LOGE("NULL pointer %p %p", pc, facing_direction);
3710 return CAMERA_ERROR_INVALID_PARAMETER;
3715 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3717 if (ret == CAMERA_ERROR_NONE)
3718 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3720 LOGD("ret : 0x%x", ret);
3726 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3728 int ret = CAMERA_ERROR_NONE;
3729 camera_cli_s *pc = (camera_cli_s *)camera;
3730 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3732 if (!pc || !pc->cb_info || !callback) {
3733 LOGE("NULL pointer %p %p", pc, callback);
3734 return CAMERA_ERROR_INVALID_PARAMETER;
3739 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3741 if (ret == CAMERA_ERROR_NONE) {
3742 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3744 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3745 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3747 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3749 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3752 LOGD("ret : 0x%x", ret);
3758 int camera_unset_preview_cb(camera_h camera)
3760 int ret = CAMERA_ERROR_NONE;
3761 camera_cli_s *pc = (camera_cli_s *)camera;
3762 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3764 if (!pc || !pc->cb_info) {
3765 LOGE("NULL handle");
3766 return CAMERA_ERROR_INVALID_PARAMETER;
3771 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3773 if (ret == CAMERA_ERROR_NONE) {
3774 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3776 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3777 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3779 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3781 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3784 LOGD("ret : 0x%x", ret);
3790 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3792 int ret = CAMERA_ERROR_NONE;
3793 camera_cli_s *pc = (camera_cli_s *)camera;
3794 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3796 if (!pc || !pc->cb_info) {
3797 LOGE("NULL handle");
3798 return CAMERA_ERROR_INVALID_PARAMETER;
3801 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3802 LOGE("NOT SUPPORTED");
3803 return CAMERA_ERROR_NOT_SUPPORTED;
3806 if (callback == NULL) {
3807 LOGE("NULL callback");
3808 return CAMERA_ERROR_INVALID_PARAMETER;
3813 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3815 if (ret == CAMERA_ERROR_NONE) {
3816 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3821 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3824 LOGD("ret : 0x%x", ret);
3830 int camera_unset_media_packet_preview_cb(camera_h camera)
3832 int ret = CAMERA_ERROR_NONE;
3833 camera_cli_s *pc = (camera_cli_s *)camera;
3834 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3836 if (!pc || !pc->cb_info) {
3837 LOGE("NULL handle");
3838 return CAMERA_ERROR_INVALID_PARAMETER;
3843 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3845 if (ret == CAMERA_ERROR_NONE) {
3846 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3848 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3849 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3851 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3854 LOGD("ret : 0x%x", ret);
3860 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3862 int ret = CAMERA_ERROR_NONE;
3863 camera_cli_s *pc = (camera_cli_s *)camera;
3864 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3866 if (!pc || !pc->cb_info || !callback) {
3867 LOGE("NULL pointer %p %p", pc, callback);
3868 return CAMERA_ERROR_INVALID_PARAMETER;
3873 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3875 if (ret == CAMERA_ERROR_NONE) {
3876 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3878 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3879 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3881 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3884 LOGD("ret : 0x%x", ret);
3890 int camera_unset_state_changed_cb(camera_h camera)
3892 int ret = CAMERA_ERROR_NONE;
3893 camera_cli_s *pc = (camera_cli_s *)camera;
3894 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3896 if (!pc || !pc->cb_info) {
3897 LOGE("NULL handle");
3898 return CAMERA_ERROR_INVALID_PARAMETER;
3903 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3905 if (ret == CAMERA_ERROR_NONE) {
3906 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3911 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3914 LOGD("ret : 0x%x", ret);
3920 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3922 int ret = CAMERA_ERROR_NONE;
3923 camera_cli_s *pc = (camera_cli_s *)camera;
3924 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3926 if (!pc || !pc->cb_info || !callback) {
3927 LOGE("NULL pointer %p %p", pc, callback);
3928 return CAMERA_ERROR_INVALID_PARAMETER;
3933 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3935 if (ret == CAMERA_ERROR_NONE) {
3936 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3938 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3939 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3941 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3944 LOGD("ret : 0x%x", ret);
3950 int camera_unset_interrupted_cb(camera_h camera)
3952 int ret = CAMERA_ERROR_NONE;
3953 camera_cli_s *pc = (camera_cli_s *)camera;
3954 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3956 if (!pc || !pc->cb_info) {
3957 LOGE("NULL handle");
3958 return CAMERA_ERROR_INVALID_PARAMETER;
3963 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3965 if (ret == CAMERA_ERROR_NONE) {
3966 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3968 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3969 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3971 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3974 LOGD("ret : 0x%x", ret);
3980 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3982 int ret = CAMERA_ERROR_NONE;
3983 camera_cli_s *pc = (camera_cli_s *)camera;
3984 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3986 if (!pc || !pc->cb_info || !callback) {
3987 LOGE("NULL pointer %p %p", pc, callback);
3988 return CAMERA_ERROR_INVALID_PARAMETER;
3993 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3995 if (ret == CAMERA_ERROR_NONE) {
3996 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4001 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4004 LOGD("ret : 0x%x", ret);
4010 int camera_unset_interrupt_started_cb(camera_h camera)
4012 int ret = CAMERA_ERROR_NONE;
4013 camera_cli_s *pc = (camera_cli_s *)camera;
4014 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4016 if (!pc || !pc->cb_info) {
4017 LOGE("NULL handle");
4018 return CAMERA_ERROR_INVALID_PARAMETER;
4023 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4025 if (ret == CAMERA_ERROR_NONE) {
4026 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4028 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4029 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4031 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4034 LOGD("ret : 0x%x", ret);
4040 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4042 int ret = CAMERA_ERROR_NONE;
4043 camera_cli_s *pc = (camera_cli_s *)camera;
4044 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4046 if (!pc || !pc->cb_info || !callback) {
4047 LOGE("NULL pointer %p %p", pc, callback);
4048 return CAMERA_ERROR_INVALID_PARAMETER;
4053 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4055 if (ret == CAMERA_ERROR_NONE) {
4056 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4058 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4059 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4061 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4064 LOGD("ret : 0x%x", ret);
4070 int camera_unset_focus_changed_cb(camera_h camera)
4072 int ret = CAMERA_ERROR_NONE;
4073 camera_cli_s *pc = (camera_cli_s *)camera;
4074 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4076 if (!pc || !pc->cb_info) {
4077 LOGE("NULL handle");
4078 return CAMERA_ERROR_INVALID_PARAMETER;
4083 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4085 if (ret == CAMERA_ERROR_NONE) {
4086 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4088 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4089 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4091 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4094 LOGD("ret : 0x%x", ret);
4100 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4102 int ret = CAMERA_ERROR_NONE;
4103 camera_cli_s *pc = (camera_cli_s *)camera;
4104 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4106 if (!pc || !pc->cb_info || !callback) {
4107 LOGE("NULL pointer %p %p", pc, callback);
4108 return CAMERA_ERROR_INVALID_PARAMETER;
4113 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4115 if (ret == CAMERA_ERROR_NONE) {
4116 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4118 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4119 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4121 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4124 LOGD("ret : 0x%x", ret);
4130 int camera_unset_error_cb(camera_h camera)
4132 int ret = CAMERA_ERROR_NONE;
4133 camera_cli_s *pc = (camera_cli_s *)camera;
4134 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4136 if (!pc || !pc->cb_info) {
4137 LOGE("NULL handle");
4138 return CAMERA_ERROR_INVALID_PARAMETER;
4143 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4145 if (ret == CAMERA_ERROR_NONE) {
4146 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4148 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4149 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4151 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4154 LOGD("ret : 0x%x", ret);
4160 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4162 int ret = CAMERA_ERROR_NONE;
4163 camera_cli_s *pc = (camera_cli_s *)camera;
4164 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4166 if (!pc || !pc->cb_info || !foreach_cb) {
4167 LOGE("NULL pointer %p %p", pc, foreach_cb);
4168 return CAMERA_ERROR_INVALID_PARAMETER;
4173 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4174 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4176 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4178 LOGD("ret : 0x%x", ret);
4184 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4186 int ret = CAMERA_ERROR_NONE;
4187 camera_cli_s *pc = (camera_cli_s *)camera;
4188 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4190 if (!pc || !pc->cb_info || !foreach_cb) {
4191 LOGE("NULL pointer %p %p", pc, foreach_cb);
4192 return CAMERA_ERROR_INVALID_PARAMETER;
4197 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4198 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4200 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4202 LOGD("ret : 0x%x", ret);
4208 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4210 int ret = CAMERA_ERROR_NONE;
4211 camera_cli_s *pc = (camera_cli_s *)camera;
4212 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4214 if (!pc || !pc->cb_info || !foreach_cb) {
4215 LOGE("NULL pointer %p %p", pc, foreach_cb);
4216 return CAMERA_ERROR_INVALID_PARAMETER;
4221 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4222 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4224 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4226 LOGD("ret : 0x%x", ret);
4232 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4234 int ret = CAMERA_ERROR_NONE;
4235 camera_cli_s *pc = (camera_cli_s *)camera;
4236 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4238 if (!pc || !pc->cb_info || !foreach_cb) {
4239 LOGE("NULL pointer %p %p", pc, foreach_cb);
4240 return CAMERA_ERROR_INVALID_PARAMETER;
4245 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4246 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4248 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4250 LOGD("ret : 0x%x", ret);
4256 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4258 int ret = CAMERA_ERROR_NONE;
4259 camera_cli_s *pc = (camera_cli_s *)camera;
4260 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4262 if (!pc || !pc->cb_info || !width || !height) {
4263 LOGE("NULL pointer %p %p %p", pc, width, height);
4264 return CAMERA_ERROR_INVALID_PARAMETER;
4268 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4270 if (ret == CAMERA_ERROR_NONE) {
4271 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4272 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4275 LOGD("ret : 0x%x", ret);
4281 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4283 int ret = CAMERA_ERROR_NONE;
4284 camera_cli_s *pc = (camera_cli_s *)camera;
4285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4287 if (!pc || !pc->cb_info || !angle) {
4288 LOGE("NULL pointer %p %p", pc, angle);
4289 return CAMERA_ERROR_INVALID_PARAMETER;
4294 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4296 if (ret == CAMERA_ERROR_NONE)
4297 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4299 LOGD("ret : 0x%x", ret);
4305 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4307 int ret = CAMERA_ERROR_NONE;
4308 camera_cli_s *pc = (camera_cli_s *)camera;
4309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4310 camera_msg_param param;
4311 int set_mode = (int)mode;
4313 if (!pc || !pc->cb_info) {
4314 LOGE("NULL handle");
4315 return CAMERA_ERROR_INVALID_PARAMETER;
4320 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4322 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4324 LOGD("ret : 0x%x", ret);
4330 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4332 int ret = CAMERA_ERROR_NONE;
4333 camera_cli_s *pc = (camera_cli_s *)camera;
4334 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4336 if (!pc || !pc->cb_info || !mode) {
4337 LOGE("NULL pointer %p %p", pc, mode);
4338 return CAMERA_ERROR_INVALID_PARAMETER;
4343 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4345 if (ret == CAMERA_ERROR_NONE)
4346 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4348 LOGD("ret : 0x%x", ret);
4354 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4356 int ret = CAMERA_ERROR_NONE;
4357 camera_cli_s *pc = (camera_cli_s *)camera;
4358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4360 if (!pc || !pc->cb_info || !foreach_cb) {
4361 LOGE("NULL pointer %p %p", pc, foreach_cb);
4362 return CAMERA_ERROR_INVALID_PARAMETER;
4367 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4368 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4372 LOGD("Finish, return :%x", ret);
4378 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4380 int ret = CAMERA_ERROR_NONE;
4381 camera_cli_s *pc = (camera_cli_s *)camera;
4382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4383 camera_msg_param param;
4384 int set_fps = (int)fps;
4386 if (!pc || !pc->cb_info) {
4387 LOGE("NULL handle");
4388 return CAMERA_ERROR_INVALID_PARAMETER;
4393 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4395 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4397 LOGD("ret : 0x%x", ret);
4403 int camera_attr_set_image_quality(camera_h camera, int quality)
4405 int ret = CAMERA_ERROR_NONE;
4406 camera_cli_s *pc = (camera_cli_s *)camera;
4407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4408 camera_msg_param param;
4410 if (!pc || !pc->cb_info) {
4411 LOGE("NULL handle");
4412 return CAMERA_ERROR_INVALID_PARAMETER;
4417 CAMERA_MSG_PARAM_SET(param, INT, quality);
4419 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4421 LOGD("ret : 0x%x", ret);
4427 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4429 int ret = CAMERA_ERROR_NONE;
4430 camera_cli_s *pc = (camera_cli_s *)camera;
4431 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4433 if (!pc || !pc->cb_info || !fps) {
4434 LOGE("NULL pointer %p %p", pc, fps);
4435 return CAMERA_ERROR_INVALID_PARAMETER;
4440 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4442 if (ret == CAMERA_ERROR_NONE)
4443 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4445 LOGD("ret : 0x%x", ret);
4451 int camera_attr_get_image_quality(camera_h camera, int *quality)
4453 int ret = CAMERA_ERROR_NONE;
4454 camera_cli_s *pc = (camera_cli_s *)camera;
4455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4457 if (!pc || !pc->cb_info || !quality) {
4458 LOGE("NULL pointer %p %p", pc, quality);
4459 return CAMERA_ERROR_INVALID_PARAMETER;
4464 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4466 if (ret == CAMERA_ERROR_NONE)
4467 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4469 LOGD("ret : 0x%x", ret);
4475 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4477 int ret = CAMERA_ERROR_NONE;
4478 camera_cli_s *pc = (camera_cli_s *)camera;
4479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4481 if (!pc || !pc->cb_info || !bitrate) {
4482 LOGE("NULL pointer %p %p", pc, bitrate);
4483 return CAMERA_ERROR_INVALID_PARAMETER;
4488 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4490 if (ret == CAMERA_ERROR_NONE)
4491 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4493 LOGD("ret : 0x%x", ret);
4499 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4501 int ret = CAMERA_ERROR_NONE;
4502 camera_cli_s *pc = (camera_cli_s *)camera;
4503 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4504 camera_msg_param param;
4505 int set_bitrate = bitrate;
4507 if (!pc || !pc->cb_info) {
4508 LOGE("NULL handle");
4509 return CAMERA_ERROR_INVALID_PARAMETER;
4514 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4516 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4518 LOGD("ret : 0x%x", ret);
4524 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4526 int ret = CAMERA_ERROR_NONE;
4527 camera_cli_s *pc = (camera_cli_s *)camera;
4528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4530 if (!pc || !pc->cb_info || !interval) {
4531 LOGE("NULL pointer %p %p", pc, interval);
4532 return CAMERA_ERROR_INVALID_PARAMETER;
4537 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4539 if (ret == CAMERA_ERROR_NONE)
4540 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4542 LOGD("ret : 0x%x", ret);
4548 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4550 int ret = CAMERA_ERROR_NONE;
4551 camera_cli_s *pc = (camera_cli_s *)camera;
4552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4553 camera_msg_param param;
4554 int set_gop_interval = interval;
4556 if (!pc || !pc->cb_info) {
4557 LOGE("NULL handle");
4558 return CAMERA_ERROR_INVALID_PARAMETER;
4563 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4565 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4567 LOGD("ret : 0x%x", ret);
4573 int camera_attr_set_zoom(camera_h camera, int zoom)
4575 int ret = CAMERA_ERROR_NONE;
4576 camera_cli_s *pc = (camera_cli_s *)camera;
4577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4578 camera_msg_param param;
4580 if (!pc || !pc->cb_info) {
4581 LOGE("NULL handle");
4582 return CAMERA_ERROR_INVALID_PARAMETER;
4585 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4587 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4589 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4591 LOGD("ret : 0x%x", ret);
4597 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4599 int ret = CAMERA_ERROR_NONE;
4600 camera_cli_s *pc = (camera_cli_s *)camera;
4601 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4602 camera_msg_param param;
4603 int set_mode = (int)mode;
4605 if (!pc || !pc->cb_info) {
4606 LOGE("NULL handle");
4607 return CAMERA_ERROR_INVALID_PARAMETER;
4610 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4612 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4614 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4620 int camera_attr_set_af_area(camera_h camera, int x, int y)
4622 int ret = CAMERA_ERROR_NONE;
4623 camera_cli_s *pc = (camera_cli_s *)camera;
4624 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4625 camera_msg_param param;
4628 if (!pc || !pc->cb_info) {
4629 LOGE("NULL handle");
4630 return CAMERA_ERROR_INVALID_PARAMETER;
4633 LOGD("Enter - %d,%d", x, y);
4635 value = (x << 16) | y;
4636 CAMERA_MSG_PARAM_SET(param, INT, value);
4638 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4640 LOGD("ret : 0x%x", ret);
4646 int camera_attr_clear_af_area(camera_h camera)
4648 int ret = CAMERA_ERROR_NONE;
4649 camera_cli_s *pc = (camera_cli_s *)camera;
4650 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4652 if (!pc || !pc->cb_info) {
4653 LOGE("NULL handle");
4654 return CAMERA_ERROR_INVALID_PARAMETER;
4659 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4661 LOGD("ret : 0x%x", ret);
4667 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4669 int ret = CAMERA_ERROR_NONE;
4670 camera_cli_s *pc = (camera_cli_s *)camera;
4671 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4672 camera_msg_param param;
4673 int set_mode = (int)mode;
4675 if (!pc || !pc->cb_info) {
4676 LOGE("NULL handle");
4677 return CAMERA_ERROR_INVALID_PARAMETER;
4682 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4684 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4686 LOGD("ret : 0x%x", ret);
4692 int camera_attr_set_exposure(camera_h camera, int value)
4694 int ret = CAMERA_ERROR_NONE;
4695 camera_cli_s *pc = (camera_cli_s *)camera;
4696 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4697 camera_msg_param param;
4699 if (!pc || !pc->cb_info) {
4700 LOGE("NULL handle");
4701 return CAMERA_ERROR_INVALID_PARAMETER;
4706 CAMERA_MSG_PARAM_SET(param, INT, value);
4708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4710 LOGD("ret : 0x%x", ret);
4716 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4718 int ret = CAMERA_ERROR_NONE;
4719 camera_cli_s *pc = (camera_cli_s *)camera;
4720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4721 camera_msg_param param;
4722 int set_iso = (int)iso;
4724 if (!pc || !pc->cb_info) {
4725 LOGE("NULL handle");
4726 return CAMERA_ERROR_INVALID_PARAMETER;
4731 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4733 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4735 LOGD("ret : 0x%x", ret);
4741 int camera_attr_set_brightness(camera_h camera, int level)
4743 int ret = CAMERA_ERROR_NONE;
4744 camera_cli_s *pc = (camera_cli_s *)camera;
4745 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4746 camera_msg_param param;
4748 if (!pc || !pc->cb_info) {
4749 LOGE("NULL handle");
4750 return CAMERA_ERROR_INVALID_PARAMETER;
4755 CAMERA_MSG_PARAM_SET(param, INT, level);
4757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4759 LOGD("ret : 0x%x", ret);
4765 int camera_attr_set_contrast(camera_h camera, int level)
4767 int ret = CAMERA_ERROR_NONE;
4768 camera_cli_s *pc = (camera_cli_s *)camera;
4769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4770 camera_msg_param param;
4772 if (!pc || !pc->cb_info) {
4773 LOGE("NULL handle");
4774 return CAMERA_ERROR_INVALID_PARAMETER;
4779 CAMERA_MSG_PARAM_SET(param, INT, level);
4781 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4783 LOGD("ret : 0x%x", ret);
4789 int camera_attr_set_hue(camera_h camera, int level)
4791 int ret = CAMERA_ERROR_NONE;
4792 camera_cli_s *pc = (camera_cli_s *)camera;
4793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4794 camera_msg_param param;
4796 if (!pc || !pc->cb_info) {
4797 LOGE("NULL handle");
4798 return CAMERA_ERROR_INVALID_PARAMETER;
4803 CAMERA_MSG_PARAM_SET(param, INT, level);
4805 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4807 LOGD("ret : 0x%x", ret);
4813 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4815 int ret = CAMERA_ERROR_NONE;
4816 camera_cli_s *pc = (camera_cli_s *)camera;
4817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4818 camera_msg_param param;
4819 int set_whitebalance = (int)wb;
4821 if (!pc || !pc->cb_info) {
4822 LOGE("NULL handle");
4823 return CAMERA_ERROR_INVALID_PARAMETER;
4828 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4832 LOGD("ret : 0x%x", ret);
4838 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4840 int ret = CAMERA_ERROR_NONE;
4841 camera_cli_s *pc = (camera_cli_s *)camera;
4842 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4843 camera_msg_param param;
4844 int set_effect = (int)effect;
4846 if (!pc || !pc->cb_info) {
4847 LOGE("NULL handle");
4848 return CAMERA_ERROR_INVALID_PARAMETER;
4853 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4855 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4857 LOGD("ret : 0x%x", ret);
4863 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4865 int ret = CAMERA_ERROR_NONE;
4866 camera_cli_s *pc = (camera_cli_s *)camera;
4867 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4868 camera_msg_param param;
4869 int set_mode = (int)mode;
4871 if (!pc || !pc->cb_info) {
4872 LOGE("NULL handle");
4873 return CAMERA_ERROR_INVALID_PARAMETER;
4878 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4880 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4882 LOGD("ret : 0x%x", ret);
4888 int camera_attr_enable_tag(camera_h camera, bool enable)
4890 int ret = CAMERA_ERROR_NONE;
4891 camera_cli_s *pc = (camera_cli_s *)camera;
4892 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4893 camera_msg_param param;
4894 int set_enable = (int)enable;
4896 if (!pc || !pc->cb_info) {
4897 LOGE("NULL handle");
4898 return CAMERA_ERROR_INVALID_PARAMETER;
4903 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4905 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4907 LOGD("ret : 0x%x", ret);
4913 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4915 int ret = CAMERA_ERROR_NONE;
4916 camera_cli_s *pc = (camera_cli_s *)camera;
4917 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4918 camera_msg_param param;
4920 if (!pc || !pc->cb_info || !description) {
4921 LOGE("NULL pointer %p %p", pc, description);
4922 return CAMERA_ERROR_INVALID_PARAMETER;
4927 CAMERA_MSG_PARAM_SET(param, STRING, description);
4929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4931 LOGD("ret : 0x%x", ret);
4937 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4939 int ret = CAMERA_ERROR_NONE;
4940 camera_cli_s *pc = (camera_cli_s *)camera;
4941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4942 camera_msg_param param;
4943 int set_orientation = (int)orientation;
4945 if (!pc || !pc->cb_info) {
4946 LOGE("NULL handle");
4947 return CAMERA_ERROR_INVALID_PARAMETER;
4952 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4954 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4956 LOGD("ret : 0x%x", ret);
4962 int camera_attr_set_tag_software(camera_h camera, const char *software)
4964 int ret = CAMERA_ERROR_NONE;
4965 camera_cli_s *pc = (camera_cli_s *)camera;
4966 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4967 camera_msg_param param;
4969 if (!pc || !pc->cb_info || !software) {
4970 LOGE("NULL pointer %p %p", pc, software);
4971 return CAMERA_ERROR_INVALID_PARAMETER;
4974 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4976 CAMERA_MSG_PARAM_SET(param, STRING, software);
4978 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4980 LOGD("ret : 0x%x", ret);
4986 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4988 int ret = CAMERA_ERROR_NONE;
4989 camera_cli_s *pc = (camera_cli_s *)camera;
4990 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4991 double set_geotag[3] = {latitude, longitude, altitude};
4996 if (!pc || !pc->cb_info) {
4997 LOGE("NULL handle");
4998 return CAMERA_ERROR_INVALID_PARAMETER;
5003 length = sizeof(set_geotag) / sizeof(int) + \
5004 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5006 msg = muse_core_msg_new(api,
5007 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5010 LOGE("msg creation failed: api %d", api);
5011 return CAMERA_ERROR_OUT_OF_MEMORY;
5014 if (pc->cb_info->is_server_connected) {
5015 __camera_update_api_waiting(pc->cb_info, api, 1);
5017 g_mutex_lock(&pc->cb_info->fd_lock);
5018 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5019 g_mutex_unlock(&pc->cb_info->fd_lock);
5023 LOGE("message send failed");
5024 ret = CAMERA_ERROR_INVALID_OPERATION;
5026 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5029 __camera_update_api_waiting(pc->cb_info, api, -1);
5031 muse_core_msg_free(msg);
5033 LOGD("ret : 0x%x", ret);
5039 int camera_attr_remove_geotag(camera_h camera)
5041 int ret = CAMERA_ERROR_NONE;
5042 camera_cli_s *pc = (camera_cli_s *)camera;
5043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5045 if (!pc || !pc->cb_info) {
5046 LOGE("NULL handle");
5047 return CAMERA_ERROR_INVALID_PARAMETER;
5052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5054 LOGD("ret : 0x%x", ret);
5060 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5062 int ret = CAMERA_ERROR_NONE;
5063 camera_cli_s *pc = (camera_cli_s *)camera;
5064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5065 camera_msg_param param;
5066 int set_mode = (int)mode;
5068 if (!pc || !pc->cb_info) {
5069 LOGE("NULL handle");
5070 return CAMERA_ERROR_INVALID_PARAMETER;
5075 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5077 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5079 LOGD("ret : 0x%x", ret);
5085 int camera_attr_get_zoom(camera_h camera, int *zoom)
5087 int ret = CAMERA_ERROR_NONE;
5088 camera_cli_s *pc = (camera_cli_s *)camera;
5089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5091 if (!pc || !pc->cb_info || !zoom) {
5092 LOGE("NULL pointer %p %p", pc, zoom);
5093 return CAMERA_ERROR_INVALID_PARAMETER;
5098 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5100 if (ret == CAMERA_ERROR_NONE)
5101 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5103 LOGD("ret : 0x%x", ret);
5109 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5111 int ret = CAMERA_ERROR_NONE;
5112 camera_cli_s *pc = (camera_cli_s *)camera;
5113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5115 if (!pc || !pc->cb_info || !min || !max) {
5116 LOGE("NULL pointer %p %p %p", pc, min, max);
5117 return CAMERA_ERROR_INVALID_PARAMETER;
5122 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5124 if (ret == CAMERA_ERROR_NONE) {
5125 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5126 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5129 LOGD("ret : 0x%x", ret);
5135 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5137 int ret = CAMERA_ERROR_NONE;
5138 camera_cli_s *pc = (camera_cli_s *)camera;
5139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5141 if (!pc || !pc->cb_info || !mode) {
5142 LOGE("NULL pointer %p %p", pc, mode);
5143 return CAMERA_ERROR_INVALID_PARAMETER;
5148 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5150 if (ret == CAMERA_ERROR_NONE)
5151 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5153 LOGD("ret : 0x%x", ret);
5159 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5165 if (!pc || !pc->cb_info || !mode) {
5166 LOGE("NULL pointer %p %p", pc, mode);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5172 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5177 LOGD("ret : 0x%x", ret);
5183 int camera_attr_get_exposure(camera_h camera, int *value)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5189 if (!pc || !pc->cb_info || !value) {
5190 LOGE("NULL pointer %p %p", pc, value);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE)
5199 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5201 LOGD("ret : 0x%x", ret);
5207 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5209 int ret = CAMERA_ERROR_NONE;
5210 camera_cli_s *pc = (camera_cli_s *)camera;
5211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5213 if (!pc || !pc->cb_info || !min || !max) {
5214 LOGE("NULL pointer %p %p %p", pc, min, max);
5215 return CAMERA_ERROR_INVALID_PARAMETER;
5220 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5222 if (ret == CAMERA_ERROR_NONE) {
5223 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5224 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5227 LOGD("ret : 0x%x", ret);
5233 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5239 if (!pc || !pc->cb_info || !iso) {
5240 LOGE("NULL pointer %p %p", pc, iso);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5246 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE)
5249 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5251 LOGD("ret : 0x%x", ret);
5257 int camera_attr_get_brightness(camera_h camera, int *level)
5259 int ret = CAMERA_ERROR_NONE;
5260 camera_cli_s *pc = (camera_cli_s *)camera;
5261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5263 if (!pc || !pc->cb_info || !level) {
5264 LOGE("NULL pointer %p %p", pc, level);
5265 return CAMERA_ERROR_INVALID_PARAMETER;
5270 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5272 if (ret == CAMERA_ERROR_NONE)
5273 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5275 LOGD("ret : 0x%x", ret);
5281 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5283 int ret = CAMERA_ERROR_NONE;
5284 camera_cli_s *pc = (camera_cli_s *)camera;
5285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5287 if (!pc || !pc->cb_info || !min || !max) {
5288 LOGE("NULL pointer %p %p %p", pc, min, max);
5289 return CAMERA_ERROR_INVALID_PARAMETER;
5294 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5296 if (ret == CAMERA_ERROR_NONE) {
5297 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5298 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5301 LOGD("ret : 0x%x", ret);
5307 int camera_attr_get_contrast(camera_h camera, int *level)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5313 if (!pc || !pc->cb_info || !level) {
5314 LOGE("NULL pointer %p %p", pc, level);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5320 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5325 LOGD("ret : 0x%x", ret);
5331 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5337 if (!pc || !pc->cb_info || !min || !max) {
5338 LOGE("NULL pointer %p %p %p", pc, min, max);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5344 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE) {
5347 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5348 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5349 LOGD("min %d, max %d", *min, *max);
5352 LOGD("ret : 0x%x", ret);
5358 int camera_attr_get_hue(camera_h camera, int *level)
5360 int ret = CAMERA_ERROR_NONE;
5361 camera_cli_s *pc = (camera_cli_s *)camera;
5362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5364 if (!pc || !pc->cb_info || !level) {
5365 LOGE("NULL pointer %p %p", pc, level);
5366 return CAMERA_ERROR_INVALID_PARAMETER;
5371 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5373 if (ret == CAMERA_ERROR_NONE)
5374 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5376 LOGD("ret : 0x%x", ret);
5382 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5384 int ret = CAMERA_ERROR_NONE;
5385 camera_cli_s *pc = (camera_cli_s *)camera;
5386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5388 if (!pc || !pc->cb_info || !min || !max) {
5389 LOGE("NULL pointer %p %p %p", pc, min, max);
5390 return CAMERA_ERROR_INVALID_PARAMETER;
5395 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5397 if (ret == CAMERA_ERROR_NONE) {
5398 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5399 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5400 LOGD("min %d, max %d", *min, *max);
5403 LOGD("ret : 0x%x", ret);
5409 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5411 int ret = CAMERA_ERROR_NONE;
5412 camera_cli_s *pc = (camera_cli_s *)camera;
5413 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5415 if (!pc || !pc->cb_info || !wb) {
5416 LOGE("NULL pointer %p %p", pc, wb);
5417 return CAMERA_ERROR_INVALID_PARAMETER;
5422 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5424 if (ret == CAMERA_ERROR_NONE)
5425 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5427 LOGD("ret : 0x%x", ret);
5433 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5435 int ret = CAMERA_ERROR_NONE;
5436 camera_cli_s *pc = (camera_cli_s *)camera;
5437 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5439 if (!pc || !pc->cb_info || !effect) {
5440 LOGE("NULL pointer %p %p", pc, effect);
5441 return CAMERA_ERROR_INVALID_PARAMETER;
5446 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5448 if (ret == CAMERA_ERROR_NONE)
5449 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5451 LOGD("ret : 0x%x", ret);
5457 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5459 int ret = CAMERA_ERROR_NONE;
5460 camera_cli_s *pc = (camera_cli_s *)camera;
5461 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5463 if (!pc || !pc->cb_info || !mode) {
5464 LOGE("NULL pointer %p %p", pc, mode);
5465 return CAMERA_ERROR_INVALID_PARAMETER;
5470 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5472 if (ret == CAMERA_ERROR_NONE)
5473 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5475 LOGD("ret : 0x%x", ret);
5481 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5483 int ret = CAMERA_ERROR_NONE;
5484 camera_cli_s *pc = (camera_cli_s *)camera;
5485 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5487 if (!pc || !pc->cb_info || !enable) {
5488 LOGE("NULL pointer %p %p", pc, enable);
5489 return CAMERA_ERROR_INVALID_PARAMETER;
5494 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5496 if (ret == CAMERA_ERROR_NONE)
5497 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5499 LOGD("ret : 0x%x", ret);
5505 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5507 int ret = CAMERA_ERROR_NONE;
5508 camera_cli_s *pc = (camera_cli_s *)camera;
5509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5511 if (!pc || !pc->cb_info || !description) {
5512 LOGE("NULL pointer %p %p", pc, description);
5513 return CAMERA_ERROR_INVALID_PARAMETER;
5518 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5520 if (ret == CAMERA_ERROR_NONE)
5521 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5523 LOGD("ret : 0x%x", ret);
5529 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5531 int ret = CAMERA_ERROR_NONE;
5532 camera_cli_s *pc = (camera_cli_s *)camera;
5533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5535 if (!pc || !pc->cb_info || !orientation) {
5536 LOGE("NULL pointer %p %p", pc, orientation);
5537 return CAMERA_ERROR_INVALID_PARAMETER;
5542 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5544 if (ret == CAMERA_ERROR_NONE)
5545 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5547 LOGD("ret : 0x%x", ret);
5553 int camera_attr_get_tag_software(camera_h camera, char **software)
5555 int ret = CAMERA_ERROR_NONE;
5556 camera_cli_s *pc = (camera_cli_s *)camera;
5557 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5559 if (!pc || !pc->cb_info || !software) {
5560 LOGE("NULL pointer %p %p", pc, software);
5561 return CAMERA_ERROR_INVALID_PARAMETER;
5566 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5568 if (ret == CAMERA_ERROR_NONE)
5569 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5571 LOGD("ret : 0x%x", ret);
5577 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5579 int ret = CAMERA_ERROR_NONE;
5580 camera_cli_s *pc = (camera_cli_s *)camera;
5581 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5583 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5584 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5585 return CAMERA_ERROR_INVALID_PARAMETER;
5590 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5592 if (ret == CAMERA_ERROR_NONE) {
5593 *latitude = pc->cb_info->get_geotag[0];
5594 *longitude = pc->cb_info->get_geotag[1];
5595 *altitude = pc->cb_info->get_geotag[2];
5598 LOGD("ret : 0x%x", ret);
5604 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5606 int ret = CAMERA_ERROR_NONE;
5607 camera_cli_s *pc = (camera_cli_s *)camera;
5608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5610 if (!pc || !pc->cb_info || !mode) {
5611 LOGE("NULL pointer %p %p", pc, mode);
5612 return CAMERA_ERROR_INVALID_PARAMETER;
5617 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5619 if (ret == CAMERA_ERROR_NONE)
5620 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5622 LOGD("ret : 0x%x", ret);
5628 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5630 int ret = CAMERA_ERROR_NONE;
5631 int get_flash_state = 0;
5634 LOGE("NULL pointer");
5635 return CAMERA_ERROR_INVALID_PARAMETER;
5638 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5639 (int)device, "get_flash_state", &get_flash_state);
5641 if (ret == CAMERA_ERROR_NONE) {
5642 *state = (camera_flash_state_e)get_flash_state;
5643 LOGD("flash state %d", *state);
5645 LOGE("failed 0x%x", ret);
5652 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5654 int ret = CAMERA_ERROR_NONE;
5655 camera_cli_s *pc = (camera_cli_s *)camera;
5656 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5658 if (!pc || !pc->cb_info || !foreach_cb) {
5659 LOGE("NULL pointer %p %p", pc, foreach_cb);
5660 return CAMERA_ERROR_INVALID_PARAMETER;
5665 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5666 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5668 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5670 LOGD("ret : 0x%x", ret);
5676 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5678 int ret = CAMERA_ERROR_NONE;
5679 camera_cli_s *pc = (camera_cli_s *)camera;
5680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5682 if (!pc || !pc->cb_info || !foreach_cb) {
5683 LOGE("NULL pointer %p %p", pc, foreach_cb);
5684 return CAMERA_ERROR_INVALID_PARAMETER;
5689 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5690 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5692 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5694 LOGD("ret : 0x%x", ret);
5700 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5702 int ret = CAMERA_ERROR_NONE;
5703 camera_cli_s *pc = (camera_cli_s *)camera;
5704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5706 if (!pc || !pc->cb_info || !foreach_cb) {
5707 LOGE("NULL pointer %p %p", pc, foreach_cb);
5708 return CAMERA_ERROR_INVALID_PARAMETER;
5713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5716 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5718 LOGD("ret : 0x%x", ret);
5724 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5726 int ret = CAMERA_ERROR_NONE;
5727 camera_cli_s *pc = (camera_cli_s *)camera;
5728 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5730 if (!pc || !pc->cb_info || !foreach_cb) {
5731 LOGE("NULL pointer %p %p", pc, foreach_cb);
5732 return CAMERA_ERROR_INVALID_PARAMETER;
5737 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5738 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5740 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5742 LOGD("ret : 0x%x", ret);
5748 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5750 int ret = CAMERA_ERROR_NONE;
5751 camera_cli_s *pc = (camera_cli_s *)camera;
5752 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5754 if (!pc || !pc->cb_info || !foreach_cb) {
5755 LOGE("NULL pointer %p %p", pc, foreach_cb);
5756 return CAMERA_ERROR_INVALID_PARAMETER;
5761 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5762 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5764 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5766 LOGD("ret : 0x%x", ret);
5772 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5774 int ret = CAMERA_ERROR_NONE;
5775 camera_cli_s *pc = (camera_cli_s *)camera;
5776 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5778 if (!pc || !pc->cb_info || !foreach_cb) {
5779 LOGE("NULL pointer %p %p", pc, foreach_cb);
5780 return CAMERA_ERROR_INVALID_PARAMETER;
5785 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5786 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5788 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5790 LOGD("ret : 0x%x", ret);
5796 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5798 int ret = CAMERA_ERROR_NONE;
5799 camera_cli_s *pc = (camera_cli_s *)camera;
5800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5802 if (!pc || !pc->cb_info || !foreach_cb) {
5803 LOGE("NULL pointer %p %p", pc, foreach_cb);
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5812 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5814 LOGD("ret : 0x%x", ret);
5820 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5822 int ret = CAMERA_ERROR_NONE;
5823 camera_cli_s *pc = (camera_cli_s *)camera;
5824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5826 if (!pc || !pc->cb_info || !foreach_cb) {
5827 LOGE("NULL pointer %p %p", pc, foreach_cb);
5828 return CAMERA_ERROR_INVALID_PARAMETER;
5833 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5834 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5836 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5838 LOGD("Enter, handle :%td", pc->remote_handle);
5844 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)
5846 int ret = CAMERA_ERROR_NONE;
5847 camera_cli_s *pc = (camera_cli_s *)camera;
5848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5849 camera_msg_param param;
5852 if (!pc || !pc->cb_info || !foreach_cb) {
5853 LOGE("NULL pointer %p %p", pc, foreach_cb);
5854 return CAMERA_ERROR_INVALID_PARAMETER;
5859 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5860 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5862 value = (width << 16) | height;
5863 CAMERA_MSG_PARAM_SET(param, INT, value);
5865 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5867 LOGD("ret : 0x%x", ret);
5873 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5875 int ret = CAMERA_ERROR_NONE;
5876 camera_cli_s *pc = (camera_cli_s *)camera;
5877 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5879 if (!pc || !pc->cb_info || !foreach_cb) {
5880 LOGE("NULL pointer %p %p", pc, foreach_cb);
5881 return CAMERA_ERROR_INVALID_PARAMETER;
5886 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5887 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5889 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5891 LOGD("ret : 0x%x", ret);
5897 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5899 int ret = CAMERA_ERROR_NONE;
5900 camera_cli_s *pc = (camera_cli_s *)camera;
5901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5903 if (!pc || !pc->cb_info || !foreach_cb) {
5904 LOGE("NULL pointer %p %p", pc, foreach_cb);
5905 return CAMERA_ERROR_INVALID_PARAMETER;
5910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5913 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5915 LOGD("ret : 0x%x", ret);
5921 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5923 int ret = CAMERA_ERROR_NONE;
5924 camera_cli_s *pc = (camera_cli_s *)camera;
5925 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5926 camera_msg_param param;
5927 int set_rotation = (int)rotation;
5929 if (!pc || !pc->cb_info) {
5930 LOGE("NULL handle");
5931 return CAMERA_ERROR_INVALID_PARAMETER;
5936 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5938 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5940 LOGD("ret : 0x%x", ret);
5946 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5948 int ret = CAMERA_ERROR_NONE;
5949 camera_cli_s *pc = (camera_cli_s *)camera;
5950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5952 if (!pc || !pc->cb_info || !rotation) {
5953 LOGE("NULL pointer %p %p", pc, rotation);
5954 return CAMERA_ERROR_INVALID_PARAMETER;
5959 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5961 if (ret == CAMERA_ERROR_NONE)
5962 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5964 LOGD("ret : 0x%x", ret);
5970 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5972 int ret = CAMERA_ERROR_NONE;
5973 camera_cli_s *pc = (camera_cli_s *)camera;
5974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5975 camera_msg_param param;
5976 int set_flip = (int)flip;
5978 if (!pc || !pc->cb_info) {
5979 LOGE("NULL handle");
5980 return CAMERA_ERROR_INVALID_PARAMETER;
5985 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5987 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5989 LOGD("ret : 0x%x", ret);
5995 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5997 int ret = CAMERA_ERROR_NONE;
5998 camera_cli_s *pc = (camera_cli_s *)camera;
5999 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6001 if (!pc || !pc->cb_info || !flip) {
6002 LOGE("NULL pointer %p %p", pc, flip);
6003 return CAMERA_ERROR_INVALID_PARAMETER;
6008 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6010 if (ret == CAMERA_ERROR_NONE)
6011 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6013 LOGD("ret : 0x%x", ret);
6018 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6020 int ret = CAMERA_ERROR_NONE;
6021 camera_cli_s *pc = (camera_cli_s *)camera;
6022 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6023 camera_msg_param param;
6024 int set_mode = (int)mode;
6026 if (!pc || !pc->cb_info) {
6027 LOGE("NULL handle");
6028 return CAMERA_ERROR_INVALID_PARAMETER;
6033 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6035 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6037 LOGD("ret : 0x%x", ret);
6043 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6045 int ret = CAMERA_ERROR_NONE;
6046 camera_cli_s *pc = (camera_cli_s *)camera;
6047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6049 if (!pc || !pc->cb_info || !mode) {
6050 LOGE("NULL pointer %p %p", pc, mode);
6051 return CAMERA_ERROR_INVALID_PARAMETER;
6056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6058 if (ret == CAMERA_ERROR_NONE)
6059 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6061 LOGD("ret : 0x%x", ret);
6067 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6069 int ret = CAMERA_ERROR_NONE;
6070 camera_cli_s *pc = (camera_cli_s *)camera;
6071 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6073 if (!pc || !pc->cb_info) {
6074 LOGE("NULL handle");
6075 return CAMERA_ERROR_INVALID_PARAMETER;
6080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6083 LOGE("error is occurred 0x%x", ret);
6087 LOGD("ret : %d", ret);
6093 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6095 int ret = CAMERA_ERROR_NONE;
6096 camera_cli_s *pc = (camera_cli_s *)camera;
6097 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6099 if (!pc || !pc->cb_info) {
6100 LOGE("NULL handle");
6101 return CAMERA_ERROR_INVALID_PARAMETER;
6106 if (!camera_attr_is_supported_hdr_capture(camera)) {
6107 LOGE("HDR not supported");
6108 return CAMERA_ERROR_NOT_SUPPORTED;
6112 LOGE("NULL callback");
6113 return CAMERA_ERROR_INVALID_PARAMETER;
6116 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6118 if (ret == CAMERA_ERROR_NONE) {
6119 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6121 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6122 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6124 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6127 LOGD("ret : 0x%x", ret);
6133 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6135 int ret = CAMERA_ERROR_NONE;
6136 camera_cli_s *pc = (camera_cli_s *)camera;
6137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6139 if (!pc || !pc->cb_info) {
6140 LOGE("NULL handle");
6141 return CAMERA_ERROR_INVALID_PARAMETER;
6146 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6148 if (ret == CAMERA_ERROR_NONE) {
6149 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6151 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6152 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6154 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6157 LOGD("ret : 0x%x", ret);
6163 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6168 camera_msg_param param;
6169 int set_enable = (int)enable;
6171 if (!pc || !pc->cb_info) {
6172 LOGE("NULL handle");
6173 return CAMERA_ERROR_INVALID_PARAMETER;
6178 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6180 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6182 LOGD("ret : 0x%x", ret);
6188 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6194 if (!pc || !pc->cb_info || !enabled) {
6195 LOGE("NULL pointer %p %p", pc, enabled);
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6201 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6203 if (ret == CAMERA_ERROR_NONE)
6204 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6206 LOGD("ret : 0x%x", ret);
6212 bool camera_attr_is_supported_anti_shake(camera_h camera)
6214 int ret = CAMERA_ERROR_NONE;
6215 camera_cli_s *pc = (camera_cli_s *)camera;
6216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6218 if (!pc || !pc->cb_info) {
6219 LOGE("NULL handle");
6220 return CAMERA_ERROR_INVALID_PARAMETER;
6225 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6228 LOGE("error is occurred 0x%x", ret);
6232 LOGD("ret : %d", ret);
6238 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6240 int ret = CAMERA_ERROR_NONE;
6241 camera_cli_s *pc = (camera_cli_s *)camera;
6242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6243 camera_msg_param param;
6244 int set_enable = (int)enable;
6246 if (!pc || !pc->cb_info) {
6247 LOGE("NULL handle");
6248 return CAMERA_ERROR_INVALID_PARAMETER;
6253 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6255 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6257 LOGD("ret : 0x%x", ret);
6263 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6265 int ret = CAMERA_ERROR_NONE;
6266 camera_cli_s *pc = (camera_cli_s *)camera;
6267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6269 if (!pc || !pc->cb_info || !enabled) {
6270 LOGE("NULL pointer %p %p", pc, enabled);
6271 return CAMERA_ERROR_INVALID_PARAMETER;
6276 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6278 if (ret == CAMERA_ERROR_NONE)
6279 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6281 LOGD("ret : 0x%x", ret);
6287 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6289 int ret = CAMERA_ERROR_NONE;
6290 camera_cli_s *pc = (camera_cli_s *)camera;
6291 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6293 if (!pc || !pc->cb_info) {
6294 LOGE("NULL handle");
6295 return CAMERA_ERROR_INVALID_PARAMETER;
6300 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6303 LOGE("error is occurred 0x%x", ret);
6307 LOGD("ret : %d", ret);
6313 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6315 int ret = CAMERA_ERROR_NONE;
6316 camera_cli_s *pc = (camera_cli_s *)camera;
6317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6318 camera_msg_param param;
6319 int set_enable = (int)enable;
6321 if (!pc || !pc->cb_info) {
6322 LOGE("NULL handle");
6323 return CAMERA_ERROR_INVALID_PARAMETER;
6328 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6330 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6332 LOGD("ret : 0x%x", ret);
6338 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6340 int ret = CAMERA_ERROR_NONE;
6341 camera_cli_s *pc = (camera_cli_s *)camera;
6342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6344 if (!pc || !pc->cb_info || !enabled) {
6345 LOGE("NULL pointer %p %p", pc, enabled);
6346 return CAMERA_ERROR_INVALID_PARAMETER;
6351 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6353 if (ret == CAMERA_ERROR_NONE)
6354 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6356 LOGD("ret : 0x%x", ret);
6362 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6364 int ret = CAMERA_ERROR_NONE;
6365 camera_cli_s *pc = (camera_cli_s *)camera;
6366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6368 if (!pc || !pc->cb_info) {
6369 LOGE("NULL handle");
6370 return CAMERA_ERROR_INVALID_PARAMETER;
6375 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6378 LOGE("error is occurred 0x%x", ret);
6382 LOGD("ret : %d", ret);
6388 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6390 int ret = CAMERA_ERROR_NONE;
6391 camera_cli_s *pc = (camera_cli_s *)camera;
6392 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6393 camera_msg_param param;
6394 int set_disable = (int)disable;
6396 if (!pc || !pc->cb_info) {
6397 LOGE("NULL handle");
6398 return CAMERA_ERROR_INVALID_PARAMETER;
6403 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6405 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6407 LOGD("ret : 0x%x", ret);
6413 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6415 int ret = CAMERA_ERROR_NONE;
6416 camera_cli_s *pc = (camera_cli_s *)camera;
6417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6418 camera_msg_param param0;
6419 camera_msg_param param1;
6421 if (!pc || !pc->cb_info) {
6422 LOGE("NULL handle");
6423 return CAMERA_ERROR_INVALID_PARAMETER;
6428 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6429 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6431 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6432 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6434 LOGD("ret : 0x%x", ret);
6440 int camera_attr_get_pan(camera_h camera, int *pan_step)
6442 int ret = CAMERA_ERROR_NONE;
6443 camera_cli_s *pc = (camera_cli_s *)camera;
6444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6446 if (!pc || !pc->cb_info || !pan_step) {
6447 LOGE("NULL pointer %p %p", pc, pan_step);
6448 return CAMERA_ERROR_INVALID_PARAMETER;
6453 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6455 if (ret == CAMERA_ERROR_NONE)
6456 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6458 LOGD("ret : 0x%x", ret);
6464 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6466 int ret = CAMERA_ERROR_NONE;
6467 camera_cli_s *pc = (camera_cli_s *)camera;
6468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6470 if (!pc || !pc->cb_info || !min || !max) {
6471 LOGE("NULL pointer %p %p %p", pc, min, max);
6472 return CAMERA_ERROR_INVALID_PARAMETER;
6477 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6479 if (ret == CAMERA_ERROR_NONE) {
6480 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6481 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6484 LOGD("ret : 0x%x", ret);
6490 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6492 int ret = CAMERA_ERROR_NONE;
6493 camera_cli_s *pc = (camera_cli_s *)camera;
6494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6495 camera_msg_param param0;
6496 camera_msg_param param1;
6498 if (!pc || !pc->cb_info) {
6499 LOGE("NULL handle");
6500 return CAMERA_ERROR_INVALID_PARAMETER;
6505 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6506 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6508 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6509 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6511 LOGD("ret : 0x%x", ret);
6517 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6519 int ret = CAMERA_ERROR_NONE;
6520 camera_cli_s *pc = (camera_cli_s *)camera;
6521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6523 if (!pc || !pc->cb_info || !tilt_step) {
6524 LOGE("NULL pointer %p %p", pc, tilt_step);
6525 return CAMERA_ERROR_INVALID_PARAMETER;
6530 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6532 if (ret == CAMERA_ERROR_NONE)
6533 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6535 LOGD("ret : 0x%x", ret);
6541 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6543 int ret = CAMERA_ERROR_NONE;
6544 camera_cli_s *pc = (camera_cli_s *)camera;
6545 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6547 if (!pc || !pc->cb_info || !min || !max) {
6548 LOGE("NULL pointer %p %p %p", pc, min, max);
6549 return CAMERA_ERROR_INVALID_PARAMETER;
6554 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6556 if (ret == CAMERA_ERROR_NONE) {
6557 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6558 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6561 LOGD("ret : 0x%x", ret);
6567 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6569 int ret = CAMERA_ERROR_NONE;
6570 camera_cli_s *pc = (camera_cli_s *)camera;
6571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6572 camera_msg_param param;
6573 int set_ptz_type = (int)ptz_type;
6575 if (!pc || !pc->cb_info) {
6576 LOGE("NULL handle");
6577 return CAMERA_ERROR_INVALID_PARAMETER;
6582 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6584 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6586 LOGD("ret : 0x%x", ret);
6592 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6594 int ret = CAMERA_ERROR_NONE;
6595 camera_cli_s *pc = (camera_cli_s *)camera;
6596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6598 if (!pc || !pc->cb_info || !foreach_cb) {
6599 LOGE("NULL pointer %p %p", pc, foreach_cb);
6600 return CAMERA_ERROR_INVALID_PARAMETER;
6605 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6606 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6608 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6610 LOGD("ret : 0x%x", ret);
6616 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6618 int ret = CAMERA_ERROR_NONE;
6619 camera_cli_s *pc = (camera_cli_s *)camera;
6620 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6621 int set_display_roi_area[4] = {x, y, width, height};
6626 if (!pc || !pc->cb_info) {
6627 LOGE("NULL handle");
6628 return CAMERA_ERROR_INVALID_PARAMETER;
6633 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6634 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6635 if (ret != MM_ERROR_NONE) {
6636 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6637 return CAMERA_ERROR_INVALID_OPERATION;
6641 length = sizeof(set_display_roi_area) / sizeof(int) + \
6642 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6644 msg = muse_core_msg_new(api,
6645 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6648 LOGE("msg creation failed: api %d", api);
6649 return CAMERA_ERROR_OUT_OF_MEMORY;
6652 if (pc->cb_info->is_server_connected) {
6653 __camera_update_api_waiting(pc->cb_info, api, 1);
6655 g_mutex_lock(&pc->cb_info->fd_lock);
6656 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6657 g_mutex_unlock(&pc->cb_info->fd_lock);
6661 LOGE("message send failed");
6662 ret = CAMERA_ERROR_INVALID_OPERATION;
6664 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6667 __camera_update_api_waiting(pc->cb_info, api, -1);
6669 muse_core_msg_free(msg);
6671 LOGD("ret : 0x%x", ret);
6677 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6679 camera_cli_s *pc = (camera_cli_s *)camera;
6680 int ret = CAMERA_ERROR_NONE;
6681 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6683 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6684 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6685 return CAMERA_ERROR_INVALID_PARAMETER;
6690 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6692 if (ret == CAMERA_ERROR_NONE) {
6693 *x = pc->cb_info->get_display_roi_area[0];
6694 *y = pc->cb_info->get_display_roi_area[1];
6695 *width = pc->cb_info->get_display_roi_area[2];
6696 *height = pc->cb_info->get_display_roi_area[3];
6699 LOGD("ret : 0x%x", ret);
6705 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6707 int ret = CAMERA_ERROR_NONE;
6708 int get_device_state = 0;
6711 LOGE("NULL pointer");
6712 return CAMERA_ERROR_INVALID_PARAMETER;
6715 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6716 (int)device, "get_device_state", &get_device_state);
6718 if (ret == CAMERA_ERROR_NONE) {
6719 *state = (camera_device_state_e)get_device_state;
6720 LOGD("device state %d", *state);
6722 LOGE("failed 0x%x", ret);
6729 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6731 int ret = CAMERA_ERROR_NONE;
6732 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6733 camera_cb_info *info = NULL;
6735 if (!callback || !cb_id) {
6736 LOGE("invalid pointer %p %p", callback, cb_id);
6737 return CAMERA_ERROR_INVALID_PARAMETER;
6740 /* check camera support */
6741 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6742 if (ret != CAMERA_ERROR_NONE) {
6743 LOGE("get device state failed");
6747 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6749 info = g_new0(camera_cb_info, 1);
6751 LOGE("info failed");
6752 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6756 info->id = ++g_cam_dev_state_changed_cb_id;
6757 info->callback = (void *)callback;
6758 info->user_data = user_data;
6762 /* subscribe dbus signal for camera state change */
6763 if (!g_cam_dev_state_changed_cb_conn) {
6764 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6765 if (!g_cam_dev_state_changed_cb_conn) {
6766 LOGE("failed to get gdbus connection");
6767 ret = CAMERA_ERROR_INVALID_OPERATION;
6771 LOGD("subscribe signal %s - %s - %s",
6772 MM_CAMCORDER_DBUS_OBJECT,
6773 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6774 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6776 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6777 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6778 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6779 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6780 LOGE("failed to get gdbus connection");
6781 ret = CAMERA_ERROR_INVALID_OPERATION;
6785 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6788 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6790 LOGD("callback id %d", info->id);
6793 if (ret != CAMERA_ERROR_NONE) {
6799 if (g_cam_dev_state_changed_cb_conn) {
6800 g_object_unref(g_cam_dev_state_changed_cb_conn);
6801 g_cam_dev_state_changed_cb_conn = NULL;
6805 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6811 int camera_remove_device_state_changed_cb(int cb_id)
6813 int ret = CAMERA_ERROR_NONE;
6814 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6815 GList *tmp_list = NULL;
6816 camera_cb_info *info = NULL;
6818 /* check camera support */
6819 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6820 if (ret != CAMERA_ERROR_NONE) {
6821 LOGE("get device state failed");
6825 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6827 if (!g_cam_dev_state_changed_cb_list) {
6828 LOGE("there is no callback info");
6829 ret = CAMERA_ERROR_INVALID_OPERATION;
6833 tmp_list = g_cam_dev_state_changed_cb_list;
6836 info = tmp_list->data;
6837 tmp_list = tmp_list->next;
6844 if (info->id == cb_id) {
6845 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6850 if (!g_cam_dev_state_changed_cb_list) {
6851 /* no remained callback */
6852 if (g_cam_dev_state_changed_cb_conn) {
6853 /* unsubscribe signal */
6854 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6855 g_cam_dev_state_changed_cb_subscribe_id = 0;
6857 /* unref connection */
6858 g_object_unref(g_cam_dev_state_changed_cb_conn);
6859 g_cam_dev_state_changed_cb_conn = NULL;
6863 LOGD("id %d callback removed", cb_id);
6864 ret = CAMERA_ERROR_NONE;
6870 LOGE("id %d callback not found", cb_id);
6871 ret = CAMERA_ERROR_INVALID_PARAMETER;
6874 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);