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)
741 if (!cb_info || !param) {
742 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
745 *ret = CAMERA_ERROR_INVALID_PARAMETER;
750 /*LOGD("type %d, name %s", param->type, param->name);*/
752 switch (param->type) {
754 msg = muse_core_msg_new(api,
755 param->type, param->name, param->value.value_INT,
758 case MUSE_TYPE_STRING:
759 msg = muse_core_msg_new(api,
760 param->type, param->name, param->value.value_STRING,
764 LOGE("unknown type %d", param->type);
769 LOGE("msg failed: api %d", api);
772 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
777 /*LOGD("send msg %s", msg);*/
779 if (cb_info->is_server_connected) {
780 __camera_update_api_waiting(cb_info, api, 1);
782 g_mutex_lock(&cb_info->fd_lock);
783 send_ret = muse_core_msg_send(cb_info->fd, msg);
784 g_mutex_unlock(&cb_info->fd_lock);
788 LOGE("msg send failed");
791 *ret = CAMERA_ERROR_INVALID_OPERATION;
794 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
797 __camera_update_api_waiting(cb_info, api, -1);
799 muse_core_msg_free(msg);
805 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
806 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
808 int func_ret = CAMERA_ERROR_NONE;
812 if (!cb_info || !param0 || !param1) {
813 LOGE("invalid ptr %p %p %p : api %d",
814 cb_info, param0, param1, api);
815 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
816 goto _SEND_PARAM2_INT_DONE;
819 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
821 param0->name, param0->value.value_INT,
822 param1->name, param1->value.value_INT);*/
824 msg = muse_core_msg_new(api,
825 param0->type, param0->name, param0->value.value_INT,
826 param1->type, param1->name, param1->value.value_INT,
829 LOGE("msg failed: api %d", api);
830 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
831 goto _SEND_PARAM2_INT_DONE;
834 /*LOGD("send msg [%s]", msg);*/
836 if (cb_info->is_server_connected) {
837 __camera_update_api_waiting(cb_info, api, 1);
839 g_mutex_lock(&cb_info->fd_lock);
840 send_ret = muse_core_msg_send(cb_info->fd, msg);
841 g_mutex_unlock(&cb_info->fd_lock);
845 LOGE("msg send failed");
847 func_ret = CAMERA_ERROR_INVALID_OPERATION;
849 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
852 __camera_update_api_waiting(cb_info, api, -1);
854 muse_core_msg_free(msg);
856 _SEND_PARAM2_INT_DONE:
864 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
866 camera_msg_param param;
869 LOGW("invalid fd %d", ret_fd);
873 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
875 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
881 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
883 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
884 in_format >= MM_PIXEL_FORMAT_NUM ||
885 out_format == NULL) {
886 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
887 return CAMERA_ERROR_INVALID_PARAMETER;
891 case MM_PIXEL_FORMAT_NV12:
892 case MM_PIXEL_FORMAT_NV12T:
893 *out_format = TBM_FORMAT_NV12;
895 case MM_PIXEL_FORMAT_NV16:
896 *out_format = TBM_FORMAT_NV16;
898 case MM_PIXEL_FORMAT_NV21:
899 *out_format = TBM_FORMAT_NV21;
901 case MM_PIXEL_FORMAT_YUYV:
902 *out_format = TBM_FORMAT_YUYV;
904 case MM_PIXEL_FORMAT_UYVY:
905 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
906 *out_format = TBM_FORMAT_UYVY;
908 case MM_PIXEL_FORMAT_422P:
909 *out_format = TBM_FORMAT_YUV422;
911 case MM_PIXEL_FORMAT_I420:
912 *out_format = TBM_FORMAT_YUV420;
914 case MM_PIXEL_FORMAT_YV12:
915 *out_format = TBM_FORMAT_YVU420;
917 case MM_PIXEL_FORMAT_RGB565:
918 *out_format = TBM_FORMAT_RGB565;
920 case MM_PIXEL_FORMAT_RGB888:
921 *out_format = TBM_FORMAT_RGB888;
923 case MM_PIXEL_FORMAT_RGBA:
924 *out_format = TBM_FORMAT_RGBA8888;
926 case MM_PIXEL_FORMAT_ARGB:
927 *out_format = TBM_FORMAT_ARGB8888;
930 LOGE("invalid in_format %d", in_format);
931 return CAMERA_ERROR_INVALID_PARAMETER;
934 return CAMERA_ERROR_NONE;
938 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
940 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
941 in_format >= MM_PIXEL_FORMAT_NUM ||
943 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
944 return CAMERA_ERROR_INVALID_PARAMETER;
948 case MM_PIXEL_FORMAT_NV12:
949 case MM_PIXEL_FORMAT_NV12T:
950 *mimetype = MEDIA_FORMAT_NV12;
952 case MM_PIXEL_FORMAT_NV16:
953 *mimetype = MEDIA_FORMAT_NV16;
955 case MM_PIXEL_FORMAT_NV21:
956 *mimetype = MEDIA_FORMAT_NV21;
958 case MM_PIXEL_FORMAT_YUYV:
959 *mimetype = MEDIA_FORMAT_YUYV;
961 case MM_PIXEL_FORMAT_UYVY:
962 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
963 *mimetype = MEDIA_FORMAT_UYVY;
965 case MM_PIXEL_FORMAT_422P:
966 *mimetype = MEDIA_FORMAT_422P;
968 case MM_PIXEL_FORMAT_I420:
969 *mimetype = MEDIA_FORMAT_I420;
971 case MM_PIXEL_FORMAT_YV12:
972 *mimetype = MEDIA_FORMAT_YV12;
974 case MM_PIXEL_FORMAT_RGB565:
975 *mimetype = MEDIA_FORMAT_RGB565;
977 case MM_PIXEL_FORMAT_RGB888:
978 *mimetype = MEDIA_FORMAT_RGB888;
980 case MM_PIXEL_FORMAT_RGBA:
981 *mimetype = MEDIA_FORMAT_RGBA;
983 case MM_PIXEL_FORMAT_ARGB:
984 *mimetype = MEDIA_FORMAT_ARGB;
987 LOGE("invalid in_format %d", in_format);
988 return CAMERA_ERROR_INVALID_PARAMETER;
991 return CAMERA_ERROR_NONE;
994 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
995 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
998 unsigned char *buf_pos = NULL;
1000 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1001 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1005 /* set frame info */
1006 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1007 frame->format = MM_PIXEL_FORMAT_UYVY;
1009 frame->format = stream->format;
1011 frame->width = stream->width;
1012 frame->height = stream->height;
1013 frame->timestamp = stream->timestamp;
1014 frame->num_of_planes = stream->num_planes;
1016 if (num_buffer_fd == 0) {
1018 if (!data_bo_handle || !data_bo_handle->ptr) {
1019 LOGE("NULL pointer");
1023 buf_pos = data_bo_handle->ptr;
1025 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1026 frame->data.encoded_plane.data = buf_pos;
1027 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1028 total_size = stream->data.encoded.length_data;
1029 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1030 frame->data.depth_plane.data = buf_pos;
1031 frame->data.depth_plane.size = stream->data.depth.length_data;
1032 total_size = stream->data.depth.length_data;
1033 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1034 stream->format == MM_PIXEL_FORMAT_ARGB) {
1035 frame->data.rgb_plane.data = buf_pos;
1036 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1037 total_size = stream->data.rgb.length_data;
1039 switch (stream->num_planes) {
1041 frame->data.single_plane.yuv = buf_pos;
1042 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1043 total_size = stream->data.yuv420.length_yuv;
1046 frame->data.double_plane.y = buf_pos;
1047 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1048 buf_pos += stream->data.yuv420sp.length_y;
1049 frame->data.double_plane.uv = buf_pos;
1050 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1051 total_size = stream->data.yuv420sp.length_y + \
1052 stream->data.yuv420sp.length_uv;
1055 frame->data.triple_plane.y = buf_pos;
1056 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1057 buf_pos += stream->data.yuv420p.length_y;
1058 frame->data.triple_plane.u = buf_pos;
1059 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1060 buf_pos += stream->data.yuv420p.length_u;
1061 frame->data.triple_plane.v = buf_pos;
1062 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1063 total_size = stream->data.yuv420p.length_y + \
1064 stream->data.yuv420p.length_u + \
1065 stream->data.yuv420p.length_v;
1073 switch (stream->num_planes) {
1075 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1076 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1077 total_size = stream->data.yuv420.length_yuv;
1080 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1081 if (stream->num_planes == (unsigned int)num_buffer_fd)
1082 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1084 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1085 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1086 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1087 total_size = stream->data.yuv420sp.length_y + \
1088 stream->data.yuv420sp.length_uv;
1091 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1092 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1093 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1094 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1096 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1097 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1099 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1100 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1101 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1102 total_size = stream->data.yuv420p.length_y + \
1103 stream->data.yuv420p.length_u + \
1104 stream->data.yuv420p.length_v;
1112 LOGD("format %d, %dx%d, size %d plane num %d",
1113 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1119 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1120 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1123 int ret = CAMERA_ERROR_NONE;
1124 camera_media_packet_data *tmp_mp_data = NULL;
1128 return CAMERA_ERROR_INVALID_PARAMETER;
1131 if (*mp_data == NULL) {
1132 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1134 tmp_mp_data->ret_fd = ret_fd;
1135 tmp_mp_data->fd = tfd[0];
1136 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1137 tmp_mp_data->bo = bo;
1141 tmp_mp_data->data_bo = data_bo;
1142 tmp_mp_data->data_fd = tfd[1];
1145 for (i = 0 ; i < num_buffer_fd ; i++) {
1146 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1147 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1151 tmp_mp_data->ref_cnt++;
1153 *mp_data = tmp_mp_data;
1154 /*LOGD("mp_data %p", tmp_mp_data);*/
1156 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1157 LOGE("failed to alloc media packet data");
1160 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1166 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1170 if (!mp_data || !cb_info) {
1171 LOGE("NULL pointer %p %p", mp_data, cb_info);
1175 if (mp_data->ref_cnt > 1) {
1177 LOGD("ref count %d", mp_data->ref_cnt);
1179 /* release imported bo and close imported fd */
1180 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1181 tbm_bo_unref(mp_data->buffer_bo[i]);
1182 mp_data->buffer_bo[i] = NULL;
1184 close(mp_data->buffer_fd[i]);
1185 mp_data->buffer_fd[i] = -1;
1188 /* unref tbm bo and close imported fd */
1191 _camera_release_imported_bo(&mp_data->bo);
1193 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1194 close(mp_data->data_fd);
1195 mp_data->data_fd = -1;
1197 _camera_release_imported_bo(&mp_data->data_bo);
1200 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1209 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1210 camera_media_packet_data *mp_data, media_packet_h *packet)
1212 media_packet_h pkt = NULL;
1213 bool make_pkt_fmt = false;
1214 tbm_surface_h tsurf = NULL;
1215 tbm_surface_info_s tsurf_info;
1216 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1217 uint32_t bo_format = 0;
1220 int num_buffer_fd = 0;
1221 tbm_bo *buffer_bo = NULL;
1223 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1224 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1225 cb_info, stream, mp_data, packet);
1226 return CAMERA_ERROR_INVALID_PARAMETER;
1229 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1230 buffer_bo = mp_data->buffer_bo;
1231 num_buffer_fd = mp_data->num_buffer_fd;
1233 /* create tbm surface */
1234 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1235 tsurf_info.planes[i].stride = stream->stride[i];
1237 /* get tbm surface format */
1238 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1239 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1241 if (ret == CAMERA_ERROR_NONE) {
1242 tsurf_info.width = stream->width;
1243 tsurf_info.height = stream->height;
1244 tsurf_info.format = bo_format;
1245 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1246 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1248 if (num_buffer_fd > 0) {
1249 switch (bo_format) {
1250 case TBM_FORMAT_NV12:
1251 case TBM_FORMAT_NV21:
1252 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1253 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1254 tsurf_info.planes[0].offset = 0;
1255 if (num_buffer_fd == 1)
1256 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1257 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1259 case TBM_FORMAT_YUV420:
1260 case TBM_FORMAT_YVU420:
1261 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1262 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1263 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1264 tsurf_info.planes[0].offset = 0;
1265 if (num_buffer_fd == 1) {
1266 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1267 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1269 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1271 case TBM_FORMAT_UYVY:
1272 case TBM_FORMAT_YUYV:
1273 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1274 tsurf_info.planes[0].offset = 0;
1275 tsurf_info.size = tsurf_info.planes[0].size;
1281 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1282 } else if (mp_data->data_bo) {
1283 switch (bo_format) {
1284 case TBM_FORMAT_NV12:
1285 case TBM_FORMAT_NV21:
1286 tsurf_info.planes[0].size = stream->width * stream->height;
1287 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1288 tsurf_info.planes[0].offset = 0;
1289 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1290 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1292 case TBM_FORMAT_YUV420:
1293 case TBM_FORMAT_YVU420:
1294 tsurf_info.planes[0].size = stream->width * stream->height;
1295 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1296 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1297 tsurf_info.planes[0].offset = 0;
1298 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1299 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1300 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1302 case TBM_FORMAT_UYVY:
1303 case TBM_FORMAT_YUYV:
1304 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1305 tsurf_info.planes[0].offset = 0;
1306 tsurf_info.size = tsurf_info.planes[0].size;
1312 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1314 /*LOGD("tbm surface %p", tsurf);*/
1318 /* check media packet format */
1319 if (cb_info->pkt_fmt) {
1320 int pkt_fmt_width = 0;
1321 int pkt_fmt_height = 0;
1322 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1324 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1325 if (pkt_fmt_mimetype != mimetype ||
1326 pkt_fmt_width != stream->width ||
1327 pkt_fmt_height != stream->height) {
1328 LOGW("change fmt: current 0x%x, %dx%d",
1329 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1330 media_format_unref(cb_info->pkt_fmt);
1331 cb_info->pkt_fmt = NULL;
1332 make_pkt_fmt = true;
1335 make_pkt_fmt = true;
1338 /* create packet format */
1340 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1341 ret = media_format_create(&cb_info->pkt_fmt);
1342 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1343 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1344 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1345 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1346 LOGW("media_format_set : 0x%x", ret);
1348 LOGW("media_format_create failed 0x%x", ret);
1352 /* create media packet */
1353 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1354 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1355 (void *)cb_info, &pkt);
1356 if (ret != MEDIA_PACKET_ERROR_NONE) {
1357 LOGE("media_packet_create failed 0x%x", ret);
1358 tbm_surface_destroy(tsurf);
1362 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1363 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1367 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1368 /* set media packet data */
1369 ret = media_packet_set_extra(pkt, (void *)mp_data);
1370 if (ret != MEDIA_PACKET_ERROR_NONE) {
1371 LOGE("media_packet_set_extra failed");
1373 _camera_media_packet_data_release(mp_data, cb_info);
1376 media_packet_destroy(pkt);
1379 /* set timestamp : msec -> nsec */
1380 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1381 LOGW("media_packet_set_pts failed");
1390 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1393 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1394 camera_media_packet_data *mp_data = NULL;
1395 tbm_surface_h tsurf = NULL;
1397 if (!pkt || !cb_info) {
1398 LOGE("NULL pointer %p %p", pkt, cb_info);
1399 return MEDIA_PACKET_FINALIZE;
1402 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1403 if (ret != MEDIA_PACKET_ERROR_NONE) {
1404 LOGE("media_packet_get_extra failed 0x%x", ret);
1405 return MEDIA_PACKET_FINALIZE;
1408 /*LOGD("mp_data %p", mp_data);*/
1410 g_mutex_lock(&cb_info->mp_data_mutex);
1412 _camera_media_packet_data_release(mp_data, cb_info);
1415 g_mutex_unlock(&cb_info->mp_data_mutex);
1417 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1418 if (ret != MEDIA_PACKET_ERROR_NONE)
1419 LOGE("get tbm_surface failed 0x%x", ret);
1422 tbm_surface_destroy(tsurf);
1426 return MEDIA_PACKET_FINALIZE;
1429 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1434 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1435 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1439 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1441 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1443 if (cb_info->user_cb[event] == NULL) {
1444 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1445 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1446 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1447 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1448 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1449 LOGW("NULL callback for event %d, return here", event);
1453 /* return buffer message should be sent for some events.
1454 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1455 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1456 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1457 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1462 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1468 muse_camera_msg_get(previous, recv_msg);
1469 muse_camera_msg_get(current, recv_msg);
1470 muse_camera_msg_get(by_policy, recv_msg);
1472 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1473 previous, current, by_policy);
1475 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1476 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1479 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1483 muse_camera_msg_get(state, recv_msg);
1485 LOGD("FOCUS state - %d", state);
1487 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1490 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1491 LOGD("CAPTURE_COMPLETED");
1492 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1494 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1495 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1496 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1498 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1502 muse_camera_msg_get(percent, recv_msg);
1504 LOGD("HDR progress - %d %%", percent);
1506 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1509 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1515 muse_camera_msg_get(policy, recv_msg);
1516 muse_camera_msg_get(previous, recv_msg);
1517 muse_camera_msg_get(current, recv_msg);
1519 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1521 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1522 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1525 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1530 muse_camera_msg_get(policy, recv_msg);
1531 muse_camera_msg_get(state, recv_msg);
1533 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1535 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1536 (camera_state_e)state, cb_info->user_data[event]);
1539 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1540 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1542 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1545 int current_state = 0;
1547 muse_camera_msg_get(error, recv_msg);
1548 muse_camera_msg_get(current_state, recv_msg);
1550 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1552 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1553 (camera_state_e)current_state, cb_info->user_data[event]);
1556 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1558 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1559 muse_camera_msg_get(param1, recv_msg);
1560 muse_camera_msg_get(param2, recv_msg);
1562 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1564 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1565 cb_info->user_cb[event] = NULL;
1566 cb_info->user_data[event] = NULL;
1567 LOGW("stop foreach callback for event %d", event);
1570 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1572 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1574 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1576 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1578 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1582 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1584 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1599 muse_camera_msg_get(param1, recv_msg);
1601 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1603 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1604 cb_info->user_cb[event] = NULL;
1605 cb_info->user_data[event] = NULL;
1606 LOGW("stop foreach callback for event %d", event);
1609 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1610 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1613 LOGW("unhandled event %d", event);
1617 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1622 static gboolean _camera_idle_event_callback(gpointer data)
1624 camera_cb_info_s *cb_info = NULL;
1625 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1627 if (cam_idle_event == NULL) {
1628 LOGE("cam_idle_event is NULL");
1633 g_mutex_lock(&g_cam_idle_event_lock);
1635 cb_info = cam_idle_event->cb_info;
1636 if (cb_info == NULL) {
1637 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1638 g_mutex_unlock(&g_cam_idle_event_lock);
1639 goto IDLE_EVENT_CALLBACK_DONE;
1642 /* remove event from list */
1643 if (cb_info->idle_event_list)
1644 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1646 g_mutex_unlock(&g_cam_idle_event_lock);
1649 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1651 IDLE_EVENT_CALLBACK_DONE:
1653 g_free(cam_idle_event);
1654 cam_idle_event = NULL;
1659 static gpointer _camera_msg_handler_func(gpointer data)
1663 camera_message_s *cam_msg = NULL;
1664 camera_idle_event_s *cam_idle_event = NULL;
1665 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1666 camera_cb_info_s *cb_info = NULL;
1668 if (!handler_info || !handler_info->cb_info) {
1669 LOGE("NULL handler %p", handler_info);
1673 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1674 type = handler_info->type;
1676 LOGD("t:%d start", type);
1678 g_mutex_lock(&handler_info->mutex);
1680 while (g_atomic_int_get(&handler_info->running)) {
1681 if (g_queue_is_empty(handler_info->queue)) {
1682 /*LOGD("t:%d signal wait...", type);*/
1683 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1684 /*LOGD("t:%d signal received", type);*/
1686 if (g_atomic_int_get(&handler_info->running) == 0) {
1687 LOGD("t:%d stop event thread", type);
1692 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1694 g_mutex_unlock(&handler_info->mutex);
1696 if (cam_msg == NULL) {
1697 LOGE("t:%d NULL message", type);
1698 g_mutex_lock(&handler_info->mutex);
1704 if (api < MUSE_CAMERA_API_MAX) {
1707 g_mutex_lock(&cb_info->api_mutex[api]);
1709 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1710 if (cb_info->api_waiting[api] > 0) {
1711 cb_info->api_ret[api] = ret;
1712 cb_info->api_activating[api] = 1;
1714 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1716 g_cond_signal(&cb_info->api_cond[api]);
1718 LOGW("no waiting for this api [%d]", api);
1721 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1724 g_mutex_unlock(&cb_info->api_mutex[api]);
1725 } else if (api == MUSE_CAMERA_CB_EVENT) {
1726 switch (cam_msg->event_class) {
1727 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1728 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1730 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1731 cam_idle_event = g_new0(camera_idle_event_s, 1);
1732 if (cam_idle_event == NULL) {
1733 LOGE("t:%d cam_idle_event alloc failed", type);
1737 cam_idle_event->event = cam_msg->event;
1738 cam_idle_event->cb_info = cb_info;
1740 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1741 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1743 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1745 g_mutex_lock(&g_cam_idle_event_lock);
1746 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1747 g_mutex_unlock(&g_cam_idle_event_lock);
1749 g_idle_add_full(G_PRIORITY_DEFAULT,
1750 (GSourceFunc)_camera_idle_event_callback,
1751 (gpointer)cam_idle_event,
1755 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1759 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1765 g_mutex_lock(&handler_info->mutex);
1768 /* remove remained event */
1769 while (!g_queue_is_empty(handler_info->queue)) {
1770 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1772 LOGD("t:%d remove camera message %p", type, cam_msg);
1776 LOGW("t:%d NULL camera message", type);
1780 g_mutex_unlock(&handler_info->mutex);
1782 LOGD("t:%d return", type);
1788 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1790 camera_idle_event_s *cam_idle_event = NULL;
1793 if (cb_info == NULL) {
1794 LOGE("cb_info is NULL");
1798 g_mutex_lock(&g_cam_idle_event_lock);
1800 if (cb_info->idle_event_list == NULL) {
1801 LOGD("No remained idle event");
1802 g_mutex_unlock(&g_cam_idle_event_lock);
1806 list = cb_info->idle_event_list;
1809 cam_idle_event = list->data;
1810 list = g_list_next(list);
1812 if (!cam_idle_event) {
1813 LOGW("Fail to remove idle event. The event is NULL");
1817 if (g_idle_remove_by_data(cam_idle_event)) {
1818 LOGW("remove idle event %p done", cam_idle_event);
1820 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1822 g_free(cam_idle_event);
1823 cam_idle_event = NULL;
1828 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1829 cam_idle_event, cam_idle_event->event);
1831 cam_idle_event->cb_info = NULL;
1833 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1836 g_list_free(cb_info->idle_event_list);
1837 cb_info->idle_event_list = NULL;
1839 g_mutex_unlock(&g_cam_idle_event_lock);
1845 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1847 camera_message_s *cam_msg = NULL;
1849 if (!cb_info || !msg) {
1850 LOGE("NULL pointer %p %p", cb_info, msg);
1854 cam_msg = g_new0(camera_message_s, 1);
1856 LOGE("failed to alloc cam_msg for [%s]", msg);
1861 cam_msg->event = event;
1862 cam_msg->event_class = event_class;
1864 if (tfd && tfd[0] >= 0)
1865 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1867 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1869 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1871 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1872 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1873 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1874 g_cond_signal(&cb_info->preview_cb_info.cond);
1875 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1876 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1877 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1878 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1879 g_cond_signal(&cb_info->capture_cb_info.cond);
1880 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1882 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1883 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1884 g_cond_signal(&cb_info->msg_handler_info.cond);
1885 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1894 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1896 int ret = CAMERA_ERROR_NONE;
1900 int event_class = -1;
1904 if (!cb_info || !msg) {
1905 LOGE("invalid ptr %p %p", cb_info, msg);
1909 /*LOGD("msg [%s]", msg);*/
1911 if (!muse_camera_msg_get(api, msg)) {
1912 LOGE("failed to get camera api");
1916 if (api == MUSE_CAMERA_CB_EVENT) {
1917 if (!muse_camera_msg_get(event, msg) ||
1918 !muse_camera_msg_get(event_class, msg)) {
1919 LOGE("failed to get camera event or event_class [%s]", msg);
1923 if (!muse_camera_msg_get(api_class, msg)) {
1924 LOGE("failed to get camera api_class [%s]", msg);
1929 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1930 if (api >= MUSE_CAMERA_API_MAX) {
1931 LOGE("invalid api %d", api);
1935 if (!muse_camera_msg_get(ret, msg)) {
1936 LOGE("failed to get camera ret");
1940 g_mutex_lock(&cb_info->api_mutex[api]);
1943 case MUSE_CAMERA_API_CREATE:
1944 if (ret != CAMERA_ERROR_NONE) {
1945 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1946 LOGE("camera create error 0x%x. close client cb handler", ret);
1949 case MUSE_CAMERA_API_DESTROY:
1950 if (ret == CAMERA_ERROR_NONE) {
1951 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1952 LOGD("camera destroy done. close client cb handler");
1956 muse_camera_msg_get(get_type, msg);
1957 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1958 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1959 muse_camera_msg_get(get_index, msg);
1962 case MUSE_CAMERA_GET_TYPE_INT:
1963 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1965 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1966 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1967 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1969 case MUSE_CAMERA_GET_TYPE_ARRAY:
1970 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1971 muse_core_msg_deserialize("get_value",
1972 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1973 LOGD("get display roi %d,%d,%dx%d",
1974 cb_info->get_display_roi_area[0],
1975 cb_info->get_display_roi_area[1],
1976 cb_info->get_display_roi_area[2],
1977 cb_info->get_display_roi_area[3]);
1979 muse_core_msg_deserialize("get_value",
1980 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1981 LOGD("get geotag %lf, %lf, %lf",
1982 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1985 case MUSE_CAMERA_GET_TYPE_STRING:
1986 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1989 LOGW("unknown type %d", get_type);
1996 if (cb_info->api_waiting[api] > 0) {
1997 cb_info->api_ret[api] = ret;
1998 cb_info->api_activating[api] = 1;
2000 g_cond_signal(&cb_info->api_cond[api]);
2002 LOGW("no waiting for this api [%d]", api);
2005 g_mutex_unlock(&cb_info->api_mutex[api]);
2006 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2007 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2009 LOGW("unknown camera api %d, class %d", api, api_class);
2016 static gpointer _camera_msg_recv_func(gpointer data)
2019 int recv_length = 0;
2020 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2021 char *recv_msg = NULL;
2022 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2025 LOGE("cb_info NULL");
2029 LOGD("start - fd : %d", cb_info->fd);
2031 recv_msg = cb_info->recv_msg;
2033 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2034 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2037 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2038 if (recv_length <= 0) {
2039 cb_info->is_server_connected = FALSE;
2040 LOGE("receive msg failed - server disconnected");
2046 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2049 recv_msg[recv_length] = '\0';
2051 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2053 __camera_process_msg(cb_info, recv_msg, tfd);
2056 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2058 if (!cb_info->is_server_connected) {
2059 char *error_msg = NULL;
2061 if (cb_info->bufmgr == NULL) {
2062 LOGE("No need to send error(handle is not created)");
2066 if (cb_info->fd < 0) {
2067 LOGE("fd is closed in client side");
2071 /* send error msg for server disconnection */
2072 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2073 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2074 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2078 LOGE("error_msg failed");
2082 __camera_add_msg_to_queue(cb_info,
2083 MUSE_CAMERA_CB_EVENT,
2084 MUSE_CAMERA_EVENT_TYPE_ERROR,
2085 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2089 muse_core_msg_free(error_msg);
2092 LOGE("add error msg for service disconnection done");
2099 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2100 int type, const char *thread_name, camera_cb_info_s *cb_info)
2102 if (!handler_info || !thread_name || !cb_info) {
2103 LOGE("t:%d NULL %p %p %p",
2104 type, handler_info, thread_name, cb_info);
2110 handler_info->type = type;
2111 handler_info->queue = g_queue_new();
2112 if (handler_info->queue == NULL) {
2113 LOGE("t:%d queue failed", type);
2117 g_mutex_init(&handler_info->mutex);
2118 g_cond_init(&handler_info->cond);
2120 handler_info->cb_info = (void *)cb_info;
2121 g_atomic_int_set(&handler_info->running, 1);
2123 handler_info->thread = g_thread_try_new(thread_name,
2124 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2125 if (handler_info->thread == NULL) {
2126 LOGE("t:%d thread failed", type);
2128 g_mutex_clear(&handler_info->mutex);
2129 g_cond_clear(&handler_info->cond);
2130 g_queue_free(handler_info->queue);
2131 handler_info->queue = NULL;
2136 LOGD("t:%d done", type);
2142 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2146 if (!handler_info) {
2147 LOGE("NULL handler");
2151 if (!handler_info->thread) {
2152 LOGW("thread is not created");
2156 type = handler_info->type;
2158 LOGD("t:%d thread %p", type, handler_info->thread);
2160 g_mutex_lock(&handler_info->mutex);
2161 g_atomic_int_set(&handler_info->running, 0);
2162 g_cond_signal(&handler_info->cond);
2163 g_mutex_unlock(&handler_info->mutex);
2165 g_thread_join(handler_info->thread);
2166 handler_info->thread = NULL;
2168 g_mutex_clear(&handler_info->mutex);
2169 g_cond_clear(&handler_info->cond);
2170 g_queue_free(handler_info->queue);
2171 handler_info->queue = NULL;
2173 LOGD("t:%d done", type);
2179 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2181 camera_cb_info_s *cb_info = NULL;
2184 g_return_val_if_fail(sockfd > 0, NULL);
2186 cb_info = g_new0(camera_cb_info_s, 1);
2187 if (cb_info == NULL) {
2188 LOGE("cb_info failed");
2192 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2194 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2195 g_mutex_init(&cb_info->api_mutex[i]);
2196 g_cond_init(&cb_info->api_cond[i]);
2199 g_mutex_init(&cb_info->fd_lock);
2200 g_mutex_init(&cb_info->mp_data_mutex);
2202 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2203 g_mutex_init(&cb_info->user_cb_mutex[i]);
2205 /* message handler thread */
2206 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2207 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2208 LOGE("msg_handler_info failed");
2212 /* message handler thread for preview callback */
2213 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2214 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2215 LOGE("preview_cb_info failed");
2219 /* message handler thread for capture callback */
2220 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2221 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2222 LOGE("capture_cb_info failed");
2226 cb_info->fd = sockfd;
2227 cb_info->preview_cb_flag = 0;
2229 /* message receive thread */
2230 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2231 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2232 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2233 if (cb_info->msg_recv_thread == NULL) {
2234 LOGE("message receive thread creation failed");
2239 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2240 cb_info->fds[i] = -1;
2242 cb_info->is_server_connected = TRUE;
2248 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2249 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2250 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2252 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2253 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2255 g_mutex_clear(&cb_info->fd_lock);
2256 g_mutex_clear(&cb_info->mp_data_mutex);
2258 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2259 g_mutex_clear(&cb_info->api_mutex[i]);
2260 g_cond_clear(&cb_info->api_cond[i]);
2270 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2274 g_return_if_fail(cb_info != NULL);
2276 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2278 g_thread_join(cb_info->msg_recv_thread);
2279 cb_info->msg_recv_thread = NULL;
2281 LOGD("msg_recv thread removed");
2283 /* destroy msg handler threads */
2284 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2285 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2286 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2288 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2289 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2291 g_mutex_clear(&cb_info->fd_lock);
2292 g_mutex_clear(&cb_info->mp_data_mutex);
2294 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2295 g_mutex_clear(&cb_info->api_mutex[i]);
2296 g_cond_clear(&cb_info->api_cond[i]);
2299 if (cb_info->fd > -1) {
2300 muse_client_close(cb_info->fd);
2304 if (cb_info->bufmgr) {
2305 tbm_bufmgr_deinit(cb_info->bufmgr);
2306 cb_info->bufmgr = NULL;
2308 if (cb_info->pkt_fmt) {
2309 media_format_unref(cb_info->pkt_fmt);
2310 cb_info->pkt_fmt = NULL;
2313 if (cb_info->dp_interface) {
2314 mm_display_interface_deinit(cb_info->dp_interface);
2315 cb_info->dp_interface = NULL;
2318 cb_info->preview_cb_flag = 0;
2327 int _camera_start_evas_rendering(camera_h camera)
2329 camera_cli_s *pc = (camera_cli_s *)camera;
2331 if (!pc || !pc->cb_info) {
2332 LOGE("NULL handle");
2333 return CAMERA_ERROR_INVALID_PARAMETER;
2338 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2339 LOGE("EVAS surface is not set");
2340 return CAMERA_ERROR_NONE;
2343 /* set evas render flag as RUN */
2344 pc->cb_info->run_evas_render = true;
2346 return CAMERA_ERROR_NONE;
2350 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2352 int ret = CAMERA_ERROR_NONE;
2353 camera_cli_s *pc = (camera_cli_s *)camera;
2355 if (!pc || !pc->cb_info) {
2356 LOGE("NULL handle");
2357 return CAMERA_ERROR_INVALID_PARAMETER;
2360 LOGD("stop - keep screen %d", keep_screen);
2362 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2363 LOGE("EVAS surface is not set");
2364 return CAMERA_ERROR_NONE;
2367 /* set evas render flag as STOP and release buffers */
2368 pc->cb_info->run_evas_render = false;
2370 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2371 if (ret == MM_ERROR_NONE) {
2372 ret = CAMERA_ERROR_NONE;
2374 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2375 ret = CAMERA_ERROR_INVALID_OPERATION;
2382 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2384 int ret = CAMERA_ERROR_NONE;
2386 int module_index = -1;
2388 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2390 /* create muse connection */
2391 if (!key || !value) {
2392 LOGE("NULL pointer");
2393 return CAMERA_ERROR_INVALID_PARAMETER;
2396 sock_fd = muse_client_new();
2398 LOGE("muse_client_new failed");
2399 return CAMERA_ERROR_INVALID_OPERATION;
2402 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2403 LOGE("muse client get module index failed");
2404 ret = CAMERA_ERROR_INVALID_OPERATION;
2408 msg = muse_core_msg_new(api,
2409 MUSE_TYPE_INT, "module", module_index,
2410 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2414 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2418 ret = muse_core_msg_send(sock_fd, msg);
2420 muse_core_msg_free(msg);
2424 LOGE("send msg failed");
2425 ret = CAMERA_ERROR_INVALID_OPERATION;
2429 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2431 LOGE("recv msg failed %d", errno);
2432 ret = CAMERA_ERROR_INVALID_OPERATION;
2436 if (!muse_camera_msg_get(ret, recv_msg)) {
2437 LOGE("failed to get return value from msg [%s]", recv_msg);
2438 ret = CAMERA_ERROR_INVALID_OPERATION;
2442 if (ret == CAMERA_ERROR_NONE)
2443 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2445 LOGD("api %d - value %d", api, *value);
2449 muse_client_close(sock_fd);
2457 int camera_create(camera_device_e device, camera_h *camera)
2460 char *send_msg = NULL;
2462 int ret = CAMERA_ERROR_NONE;
2464 camera_cli_s *pc = NULL;
2465 tbm_bufmgr bufmgr = NULL;
2467 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2468 int module_index = -1;
2469 int device_type = (int)device;
2472 LOGE("NULL pointer");
2473 return CAMERA_ERROR_INVALID_PARAMETER;
2476 sock_fd = muse_client_new();
2478 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2479 ret = CAMERA_ERROR_INVALID_OPERATION;
2485 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2486 LOGE("muse client get module index failed");
2487 ret = CAMERA_ERROR_INVALID_OPERATION;
2491 send_msg = muse_core_msg_new(api,
2492 MUSE_TYPE_INT, "module", module_index,
2493 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2494 MUSE_TYPE_INT, "pid", pid,
2499 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2503 send_ret = muse_core_msg_send(sock_fd, send_msg);
2505 muse_core_msg_free(send_msg);
2509 LOGE("send msg failed %d", errno);
2510 ret = CAMERA_ERROR_INVALID_OPERATION;
2514 pc = g_new0(camera_cli_s, 1);
2516 LOGE("camera_cli_s alloc failed");
2517 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2521 bufmgr = tbm_bufmgr_init(-1);
2522 if (bufmgr == NULL) {
2523 LOGE("get tbm bufmgr failed");
2524 ret = CAMERA_ERROR_INVALID_OPERATION;
2528 pc->cb_info = _camera_client_callback_new(sock_fd);
2529 if (pc->cb_info == NULL) {
2530 LOGE("cb_info alloc failed");
2531 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2537 LOGD("cb info : %d", pc->cb_info->fd);
2539 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2541 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2543 if (ret == CAMERA_ERROR_NONE) {
2544 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2545 int user_buffer_supported = 0;
2546 intptr_t handle = 0;
2548 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2550 LOGE("Receiving Handle Failed!!");
2551 ret = CAMERA_ERROR_INVALID_OPERATION;
2555 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2556 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2558 pc->remote_handle = handle;
2559 pc->cb_info->bufmgr = bufmgr;
2560 pc->cb_info->preview_format = preview_format;
2561 pc->cb_info->dp_type = CAMERA_DISPLAY_TYPE_NONE;
2562 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2564 LOGD("default preview format %d, user buffer %d",
2565 preview_format, user_buffer_supported);
2567 *camera = (camera_h)pc;
2569 /* get display interface handle */
2570 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2571 LOGW("display interface init failed");
2580 tbm_bufmgr_deinit(bufmgr);
2585 muse_client_close(sock_fd);
2591 int temp_fd = pc->cb_info->fd;
2593 /* pc->cb_info->fd should be closed,
2594 because g_thread_join for msg_recv_thread is not returned
2595 in _camera_client_callback_destroy. */
2597 pc->cb_info->fd = -1;
2598 muse_client_close(temp_fd);
2601 _camera_client_callback_destroy(pc->cb_info);
2608 LOGE("camera create error : 0x%x", ret);
2614 int camera_change_device(camera_h camera, camera_device_e device)
2617 int ret = CAMERA_ERROR_NONE;
2618 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2619 camera_cli_s *pc = (camera_cli_s *)camera;
2620 camera_msg_param param;
2622 if (!pc || !pc->cb_info) {
2623 LOGE("NULL handle");
2624 return CAMERA_ERROR_INVALID_PARAMETER;
2627 CAMERA_MSG_PARAM_SET(param, INT, device);
2629 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2631 if (ret == CAMERA_ERROR_NONE) {
2632 /* reset callback and user data */
2633 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2634 pc->cb_info->user_cb[i] = NULL;
2635 pc->cb_info->user_data[i] = NULL;
2637 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2644 int camera_destroy(camera_h camera)
2646 int ret = CAMERA_ERROR_NONE;
2647 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2648 camera_cli_s *pc = (camera_cli_s *)camera;
2650 if (!pc || !pc->cb_info) {
2651 LOGE("NULL handle");
2652 return CAMERA_ERROR_INVALID_PARAMETER;
2657 if (pc->cb_info->is_server_connected)
2658 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2660 LOGW("server disconnected. release resource without send message.");
2662 if (ret == CAMERA_ERROR_NONE) {
2663 _camera_deactivate_idle_event_all(pc->cb_info);
2664 _camera_client_callback_destroy(pc->cb_info);
2671 LOGD("ret : 0x%x", ret);
2676 int camera_start_preview(camera_h camera)
2678 int ret = CAMERA_ERROR_NONE;
2679 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2680 camera_cli_s *pc = (camera_cli_s *)camera;
2681 camera_state_e current_state = CAMERA_STATE_NONE;
2683 if (!pc || !pc->cb_info) {
2684 LOGE("NULL handle");
2685 return CAMERA_ERROR_INVALID_PARAMETER;
2688 LOGD("Enter : preview format %d, display type %d",
2689 pc->cb_info->preview_format, pc->cb_info->dp_type);
2691 ret = camera_get_state(camera, ¤t_state);
2692 if (ret != CAMERA_ERROR_NONE) {
2693 LOGE("failed to get current state 0x%x", ret);
2697 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2698 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2699 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2700 pc->cb_info->dp_type);
2701 return CAMERA_ERROR_INVALID_OPERATION;
2704 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2705 if (!_camera_allocate_preview_buffer(camera))
2706 return CAMERA_ERROR_INVALID_OPERATION;
2708 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2713 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2714 ret = _camera_start_evas_rendering(camera);
2715 if (ret != CAMERA_ERROR_NONE) {
2716 LOGE("stop preview because of error");
2717 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2721 LOGD("ret : 0x%x", ret);
2727 int camera_stop_preview(camera_h camera)
2729 int ret = CAMERA_ERROR_NONE;
2730 camera_cli_s *pc = (camera_cli_s *)camera;
2731 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2732 camera_state_e current_state = CAMERA_STATE_NONE;
2734 if (!pc || !pc->cb_info) {
2735 LOGE("NULL handle");
2736 return CAMERA_ERROR_INVALID_PARAMETER;
2741 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2742 ret = camera_get_state(camera, ¤t_state);
2743 if (ret != CAMERA_ERROR_NONE) {
2744 LOGE("failed to get current state 0x%x", ret);
2748 if (current_state == CAMERA_STATE_PREVIEW) {
2749 ret = _camera_stop_evas_rendering(camera, false);
2750 if (ret != CAMERA_ERROR_NONE)
2755 /* send stop preview message */
2756 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2758 if (ret == CAMERA_ERROR_NONE) {
2759 if (pc->cb_info->user_buffer_supported)
2760 _camera_release_preview_buffer(camera);
2761 } else if (current_state == CAMERA_STATE_PREVIEW) {
2762 LOGW("restart evas rendering");
2763 _camera_start_evas_rendering(camera);
2766 LOGD("ret : 0x%x", ret);
2772 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2774 int ret = CAMERA_ERROR_NONE;
2775 camera_cli_s *pc = (camera_cli_s *)camera;
2776 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2778 if (!pc || !pc->cb_info) {
2779 LOGE("NULL handle");
2780 return CAMERA_ERROR_INVALID_PARAMETER;
2785 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2786 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2788 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2789 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2791 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2793 LOGD("ret : 0x%x", ret);
2799 bool camera_is_supported_continuous_capture(camera_h camera)
2801 int ret = CAMERA_ERROR_NONE;
2802 camera_cli_s *pc = (camera_cli_s *)camera;
2803 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2805 if (!pc || !pc->cb_info) {
2806 LOGE("NULL handle");
2807 return CAMERA_ERROR_INVALID_PARAMETER;
2812 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2815 LOGE("error is occurred 0x%x", ret);
2819 LOGD("ret : %d", ret);
2825 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)
2827 int ret = CAMERA_ERROR_NONE;
2828 camera_cli_s *pc = (camera_cli_s *)camera;
2829 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2830 camera_msg_param param;
2833 if (!pc || !pc->cb_info) {
2834 LOGE("NULL handle");
2835 return CAMERA_ERROR_INVALID_PARAMETER;
2840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2846 value = (count << 16) | interval;
2847 CAMERA_MSG_PARAM_SET(param, INT, value);
2849 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2851 LOGD("ret : 0x%x", ret);
2857 int camera_stop_continuous_capture(camera_h camera)
2859 int ret = CAMERA_ERROR_NONE;
2860 camera_cli_s *pc = (camera_cli_s *)camera;
2861 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2863 if (!pc || !pc->cb_info) {
2864 LOGE("NULL handle");
2865 return CAMERA_ERROR_INVALID_PARAMETER;
2870 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2872 LOGD("ret : 0x%x", ret);
2878 bool camera_is_supported_face_detection(camera_h camera)
2880 int ret = CAMERA_ERROR_NONE;
2881 camera_cli_s *pc = (camera_cli_s *)camera;
2882 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2884 if (!pc || !pc->cb_info) {
2885 LOGE("NULL handle");
2886 return CAMERA_ERROR_INVALID_PARAMETER;
2891 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2894 LOGE("error is occurred 0x%x", ret);
2898 LOGD("ret : %d", ret);
2904 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2906 int ret = CAMERA_ERROR_NONE;
2907 camera_cli_s *pc = (camera_cli_s *)camera;
2908 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2910 if (!pc || !pc->cb_info) {
2911 LOGE("NULL handle");
2912 return CAMERA_ERROR_INVALID_PARAMETER;
2917 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2920 LOGE("error is occurred 0x%x", ret);
2924 LOGD("ret : %d", ret);
2930 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2932 int ret = CAMERA_ERROR_NONE;
2933 camera_cli_s *pc = (camera_cli_s *)camera;
2934 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2936 if (!pc || !pc->cb_info) {
2937 LOGE("NULL handle");
2938 return CAMERA_ERROR_INVALID_PARAMETER;
2943 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2946 LOGE("error is occurred 0x%x", ret);
2950 LOGD("ret : %d", ret);
2955 int camera_get_device_count(camera_h camera, int *device_count)
2957 int ret = CAMERA_ERROR_NONE;
2958 camera_cli_s *pc = (camera_cli_s *)camera;
2959 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2961 if (!pc || !pc->cb_info) {
2962 LOGE("NULL handle");
2963 return CAMERA_ERROR_INVALID_PARAMETER;
2968 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2970 if (ret == CAMERA_ERROR_NONE)
2971 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2973 LOGD("ret : 0x%x", ret);
2978 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2980 int ret = CAMERA_ERROR_NONE;
2981 camera_cli_s *pc = (camera_cli_s *)camera;
2982 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2984 if (!pc || !pc->cb_info) {
2985 LOGE("NULL handle");
2986 return CAMERA_ERROR_INVALID_PARAMETER;
2991 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2993 if (ret == CAMERA_ERROR_NONE) {
2994 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2996 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2997 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2999 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3002 LOGD("ret : 0x%x", ret);
3007 int camera_stop_face_detection(camera_h camera)
3009 int ret = CAMERA_ERROR_NONE;
3010 camera_cli_s *pc = (camera_cli_s *)camera;
3011 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3013 if (!pc || !pc->cb_info) {
3014 LOGE("NULL handle");
3015 return CAMERA_ERROR_INVALID_PARAMETER;
3020 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3022 if (ret == CAMERA_ERROR_NONE) {
3023 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3028 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3031 LOGD("ret : 0x%x", ret);
3036 int camera_get_state(camera_h camera, camera_state_e *state)
3038 int ret = CAMERA_ERROR_NONE;
3039 camera_cli_s *pc = (camera_cli_s *)camera;
3040 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3042 if (!pc || !pc->cb_info || !state) {
3043 LOGE("NULL pointer %p %p", pc, state);
3044 return CAMERA_ERROR_INVALID_PARAMETER;
3049 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3051 if (ret == CAMERA_ERROR_NONE)
3052 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3054 LOGD("ret : 0x%x", ret);
3059 int camera_start_focusing(camera_h camera, bool continuous)
3061 int ret = CAMERA_ERROR_NONE;
3062 camera_cli_s *pc = (camera_cli_s *)camera;
3063 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3064 camera_msg_param param;
3065 int is_continuous = (int)continuous;
3067 if (!pc || !pc->cb_info) {
3068 LOGE("NULL handle");
3069 return CAMERA_ERROR_INVALID_PARAMETER;
3074 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3076 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3078 LOGD("ret : 0x%x", ret);
3083 int camera_cancel_focusing(camera_h camera)
3085 int ret = CAMERA_ERROR_NONE;
3086 camera_cli_s *pc = (camera_cli_s *)camera;
3087 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3089 if (!pc || !pc->cb_info) {
3090 LOGE("NULL handle");
3091 return CAMERA_ERROR_INVALID_PARAMETER;
3094 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3096 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3098 LOGD("ret : 0x%x", ret);
3103 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3105 int ret = CAMERA_ERROR_NONE;
3107 camera_cli_s *pc = (camera_cli_s *)camera;
3108 camera_cb_info_s *cb_info = NULL;
3109 camera_state_e current_state = CAMERA_STATE_NONE;
3110 camera_msg_param param0;
3111 camera_msg_param param1;
3112 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3114 if (!pc || !pc->cb_info) {
3115 LOGE("NULL handle");
3116 return CAMERA_ERROR_INVALID_PARAMETER;
3119 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3120 LOGE("invalid type %d", type);
3121 return CAMERA_ERROR_INVALID_PARAMETER;
3124 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3125 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3126 return CAMERA_ERROR_INVALID_PARAMETER;
3129 cb_info = (camera_cb_info_s *)pc->cb_info;
3131 ret = camera_get_state(camera, ¤t_state);
3132 if (ret != CAMERA_ERROR_NONE) {
3133 LOGE("failed to get current state 0x%x", ret);
3137 if (current_state != CAMERA_STATE_CREATED) {
3138 LOGE("INVALID_STATE : current %d", current_state);
3139 return CAMERA_ERROR_INVALID_STATE;
3142 LOGD("Enter - type : %d, display : %p", type, display);
3144 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3145 /* check display interface handle */
3146 if (!cb_info->dp_interface) {
3147 LOGE("display interface not supported");
3148 return CAMERA_ERROR_NOT_SUPPORTED;
3151 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3152 if (ret != MM_ERROR_NONE) {
3153 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3154 return CAMERA_ERROR_INVALID_OPERATION;
3157 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3158 camera_flip_e flip = CAMERA_FLIP_NONE;
3159 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3160 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3167 camera_get_display_flip(camera, &flip);
3168 camera_get_display_mode(camera, &mode);
3169 camera_get_display_rotation(camera, &rotation);
3170 camera_is_display_visible(camera, &visible);
3171 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3173 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3174 flip, mode, rotation, visible, x, y, width, height);
3176 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3177 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3178 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3179 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3181 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3182 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3186 CAMERA_MSG_PARAM_SET(param0, INT, type);
3187 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3189 _camera_msg_send_param2_int(api, cb_info, &ret,
3190 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3192 if (ret == CAMERA_ERROR_NONE) {
3193 pc->cb_info->dp_type = type;
3195 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3196 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3203 int camera_set_preview_resolution(camera_h camera, int width, int height)
3205 int ret = CAMERA_ERROR_NONE;
3206 camera_state_e current_state = CAMERA_STATE_NONE;
3207 camera_cli_s *pc = (camera_cli_s *)camera;
3208 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3209 camera_msg_param param;
3212 if (!pc || !pc->cb_info) {
3213 LOGE("NULL handle");
3214 return CAMERA_ERROR_INVALID_PARAMETER;
3217 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3218 ret = camera_get_state(camera, ¤t_state);
3219 if (ret != CAMERA_ERROR_NONE) {
3220 LOGE("failed to get current state 0x%x", ret);
3224 if (current_state == CAMERA_STATE_PREVIEW) {
3225 ret = _camera_stop_evas_rendering(camera, true);
3226 if (ret != CAMERA_ERROR_NONE)
3231 value = (width << 16) | height;
3232 CAMERA_MSG_PARAM_SET(param, INT, value);
3234 LOGD("%dx%d -> 0x%x", width, height, value);
3236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3238 LOGD("ret : 0x%x", ret);
3240 if (current_state == CAMERA_STATE_PREVIEW) {
3241 LOGW("restart evas rendering");
3242 _camera_start_evas_rendering(camera);
3249 int camera_set_capture_resolution(camera_h camera, int width, int height)
3251 int ret = CAMERA_ERROR_NONE;
3252 camera_cli_s *pc = (camera_cli_s *)camera;
3253 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3254 camera_msg_param param;
3257 if (!pc || !pc->cb_info) {
3258 LOGE("NULL handle");
3259 return CAMERA_ERROR_INVALID_PARAMETER;
3264 value = (width << 16) | height;
3265 CAMERA_MSG_PARAM_SET(param, INT, value);
3267 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3269 LOGD("ret : 0x%x", ret);
3275 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3277 int ret = CAMERA_ERROR_NONE;
3278 int set_format = (int)format;
3279 camera_cli_s *pc = (camera_cli_s *)camera;
3280 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3281 camera_msg_param param;
3283 if (!pc || !pc->cb_info) {
3284 LOGE("NULL handle");
3285 return CAMERA_ERROR_INVALID_PARAMETER;
3288 LOGD("Enter - format %d", set_format);
3290 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3292 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3294 LOGD("ret : 0x%x", ret);
3300 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3302 int ret = CAMERA_ERROR_NONE;
3303 int set_format = (int)format;
3304 camera_msg_param param;
3305 camera_cli_s *pc = (camera_cli_s *)camera;
3306 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3308 if (!pc || !pc->cb_info) {
3309 LOGE("NULL handle");
3310 return CAMERA_ERROR_INVALID_PARAMETER;
3313 LOGD("Enter - format %d", set_format);
3315 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3317 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3319 if (ret == CAMERA_ERROR_NONE)
3320 pc->cb_info->preview_format = set_format;
3322 LOGD("ret : 0x%x", ret);
3328 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3330 int ret = CAMERA_ERROR_NONE;
3331 camera_cli_s *pc = (camera_cli_s *)camera;
3332 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3334 if (!pc || !pc->cb_info || !width || !height) {
3335 LOGE("NULL pointer %p %p %p", pc, width, height);
3336 return CAMERA_ERROR_INVALID_PARAMETER;
3341 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3343 if (ret == CAMERA_ERROR_NONE) {
3344 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3345 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3348 LOGD("ret : 0x%x", ret);
3354 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3356 int ret = CAMERA_ERROR_NONE;
3357 int set_rotation = (int)rotation;
3358 camera_cli_s *pc = (camera_cli_s *)camera;
3359 camera_msg_param param;
3361 if (!pc || !pc->cb_info) {
3362 LOGE("NULL handle");
3363 return CAMERA_ERROR_INVALID_PARAMETER;
3366 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3367 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3368 if (ret != MM_ERROR_NONE) {
3369 LOGE("failed to set rotation for evas surface 0x%x", ret);
3370 return CAMERA_ERROR_INVALID_OPERATION;
3374 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3376 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3382 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3384 int ret = CAMERA_ERROR_NONE;
3385 camera_cli_s *pc = (camera_cli_s *)camera;
3387 if (!pc || !pc->cb_info || !rotation) {
3388 LOGE("NULL pointer %p %p", pc, rotation);
3389 return CAMERA_ERROR_INVALID_PARAMETER;
3392 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3394 if (ret == CAMERA_ERROR_NONE)
3395 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3401 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3403 int ret = CAMERA_ERROR_NONE;
3404 int set_flip = (int)flip;
3405 camera_cli_s *pc = (camera_cli_s *)camera;
3406 camera_msg_param param;
3408 if (!pc || !pc->cb_info) {
3409 LOGE("NULL handle");
3410 return CAMERA_ERROR_INVALID_PARAMETER;
3413 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3414 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3415 if (ret != MM_ERROR_NONE) {
3416 LOGE("failed to set flip for evas surface 0x%x", ret);
3417 return CAMERA_ERROR_INVALID_OPERATION;
3421 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3423 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3429 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3431 int ret = CAMERA_ERROR_NONE;
3432 camera_cli_s *pc = (camera_cli_s *)camera;
3434 if (!pc || !pc->cb_info || !flip) {
3435 LOGE("NULL pointer %p %p", pc, flip);
3436 return CAMERA_ERROR_INVALID_PARAMETER;
3439 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3441 if (ret == CAMERA_ERROR_NONE)
3442 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3448 int camera_set_display_visible(camera_h camera, bool visible)
3450 int ret = CAMERA_ERROR_NONE;
3451 int set_visible = (int)visible;
3452 camera_cli_s *pc = (camera_cli_s *)camera;
3453 camera_msg_param param;
3455 if (!pc || !pc->cb_info) {
3456 LOGE("NULL handle");
3457 return CAMERA_ERROR_INVALID_PARAMETER;
3460 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3461 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3462 if (ret != MM_ERROR_NONE) {
3463 LOGE("failed to set visible for evas surface 0x%x", ret);
3464 return CAMERA_ERROR_INVALID_OPERATION;
3468 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3470 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3476 int camera_is_display_visible(camera_h camera, bool *visible)
3478 int ret = CAMERA_ERROR_NONE;
3479 camera_cli_s *pc = (camera_cli_s *)camera;
3481 if (!pc || !pc->cb_info || !visible) {
3482 LOGE("NULL pointer %p %p", pc, visible);
3483 return CAMERA_ERROR_INVALID_PARAMETER;
3486 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3488 if (ret == CAMERA_ERROR_NONE)
3489 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3495 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3497 int ret = CAMERA_ERROR_NONE;
3498 int set_mode = (int)mode;
3499 camera_cli_s *pc = (camera_cli_s *)camera;
3500 camera_msg_param param;
3502 if (!pc || !pc->cb_info) {
3503 LOGE("NULL handle");
3504 return CAMERA_ERROR_INVALID_PARAMETER;
3507 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3508 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3509 if (ret != MM_ERROR_NONE) {
3510 LOGE("failed to set geometry for evas surface 0x%x", ret);
3511 return CAMERA_ERROR_INVALID_OPERATION;
3515 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3517 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3523 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3525 int ret = CAMERA_ERROR_NONE;
3526 camera_cli_s *pc = (camera_cli_s *)camera;
3528 if (!pc || !pc->cb_info || !mode) {
3529 LOGE("NULL pointer %p %p", pc, mode);
3530 return CAMERA_ERROR_INVALID_PARAMETER;
3533 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3535 if (ret == CAMERA_ERROR_NONE)
3536 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3542 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3544 int ret = CAMERA_ERROR_NONE;
3545 int set_hint = (int)hint;
3546 camera_cli_s *pc = (camera_cli_s *)camera;
3547 camera_msg_param param;
3549 if (!pc || !pc->cb_info) {
3550 LOGE("NULL handle");
3551 return CAMERA_ERROR_INVALID_PARAMETER;
3554 LOGD("Enter - hint %d", set_hint);
3556 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3558 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3564 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3566 int ret = CAMERA_ERROR_NONE;
3567 camera_cli_s *pc = (camera_cli_s *)camera;
3568 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3570 if (!pc || !pc->cb_info || !hint) {
3571 LOGE("NULL pointer %p %p", pc, hint);
3572 return CAMERA_ERROR_INVALID_PARAMETER;
3575 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3577 if (ret == CAMERA_ERROR_NONE) {
3578 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3579 LOGD("display reuse hint %d", *hint);
3586 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3588 int ret = CAMERA_ERROR_NONE;
3589 camera_cli_s *pc = (camera_cli_s *)camera;
3590 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3592 if (!pc || !pc->cb_info || !width || !height) {
3593 LOGE("NULL pointer %p %p %p", pc, width, height);
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3599 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3601 if (ret == CAMERA_ERROR_NONE) {
3602 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3603 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3606 LOGD("ret : 0x%x", ret);
3612 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3614 int ret = CAMERA_ERROR_NONE;
3615 camera_cli_s *pc = (camera_cli_s *)camera;
3616 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3618 if (!pc || !pc->cb_info || !format) {
3619 LOGE("NULL pointer %p %p", pc, format);
3620 return CAMERA_ERROR_INVALID_PARAMETER;
3625 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3627 if (ret == CAMERA_ERROR_NONE)
3628 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3630 LOGD("ret : 0x%x", ret);
3636 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3638 int ret = CAMERA_ERROR_NONE;
3639 camera_cli_s *pc = (camera_cli_s *)camera;
3640 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3642 if (!pc || !pc->cb_info || !format) {
3643 LOGE("NULL pointer %p %p", pc, format);
3644 return CAMERA_ERROR_INVALID_PARAMETER;
3649 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3651 if (ret == CAMERA_ERROR_NONE)
3652 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3654 LOGD("ret : 0x%x", ret);
3660 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3662 int ret = CAMERA_ERROR_NONE;
3663 camera_cli_s *pc = (camera_cli_s *)camera;
3664 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3666 if (!pc || !pc->cb_info || !facing_direction) {
3667 LOGE("NULL pointer %p %p", pc, facing_direction);
3668 return CAMERA_ERROR_INVALID_PARAMETER;
3673 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3675 if (ret == CAMERA_ERROR_NONE)
3676 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3678 LOGD("ret : 0x%x", ret);
3684 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3690 if (!pc || !pc->cb_info || !callback) {
3691 LOGE("NULL pointer %p %p", pc, callback);
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE) {
3700 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3705 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3707 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3710 LOGD("ret : 0x%x", ret);
3716 int camera_unset_preview_cb(camera_h camera)
3718 int ret = CAMERA_ERROR_NONE;
3719 camera_cli_s *pc = (camera_cli_s *)camera;
3720 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3722 if (!pc || !pc->cb_info) {
3723 LOGE("NULL handle");
3724 return CAMERA_ERROR_INVALID_PARAMETER;
3729 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3731 if (ret == CAMERA_ERROR_NONE) {
3732 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3737 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3739 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3742 LOGD("ret : 0x%x", ret);
3748 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3750 int ret = CAMERA_ERROR_NONE;
3751 camera_cli_s *pc = (camera_cli_s *)camera;
3752 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3754 if (!pc || !pc->cb_info) {
3755 LOGE("NULL handle");
3756 return CAMERA_ERROR_INVALID_PARAMETER;
3759 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3760 LOGE("NOT SUPPORTED");
3761 return CAMERA_ERROR_NOT_SUPPORTED;
3764 if (callback == NULL) {
3765 LOGE("NULL callback");
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_MEDIA_PACKET_PREVIEW]);
3776 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3777 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3779 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3782 LOGD("ret : 0x%x", ret);
3788 int camera_unset_media_packet_preview_cb(camera_h camera)
3790 int ret = CAMERA_ERROR_NONE;
3791 camera_cli_s *pc = (camera_cli_s *)camera;
3792 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3794 if (!pc || !pc->cb_info) {
3795 LOGE("NULL handle");
3796 return CAMERA_ERROR_INVALID_PARAMETER;
3801 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3803 if (ret == CAMERA_ERROR_NONE) {
3804 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3806 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3807 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3809 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3812 LOGD("ret : 0x%x", ret);
3818 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3820 int ret = CAMERA_ERROR_NONE;
3821 camera_cli_s *pc = (camera_cli_s *)camera;
3822 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3824 if (!pc || !pc->cb_info || !callback) {
3825 LOGE("NULL pointer %p %p", pc, callback);
3826 return CAMERA_ERROR_INVALID_PARAMETER;
3831 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3833 if (ret == CAMERA_ERROR_NONE) {
3834 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3839 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3842 LOGD("ret : 0x%x", ret);
3848 int camera_unset_state_changed_cb(camera_h camera)
3850 int ret = CAMERA_ERROR_NONE;
3851 camera_cli_s *pc = (camera_cli_s *)camera;
3852 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3854 if (!pc || !pc->cb_info) {
3855 LOGE("NULL handle");
3856 return CAMERA_ERROR_INVALID_PARAMETER;
3861 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3863 if (ret == CAMERA_ERROR_NONE) {
3864 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3866 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3867 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3869 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3872 LOGD("ret : 0x%x", ret);
3878 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3880 int ret = CAMERA_ERROR_NONE;
3881 camera_cli_s *pc = (camera_cli_s *)camera;
3882 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3884 if (!pc || !pc->cb_info || !callback) {
3885 LOGE("NULL pointer %p %p", pc, callback);
3886 return CAMERA_ERROR_INVALID_PARAMETER;
3891 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3893 if (ret == CAMERA_ERROR_NONE) {
3894 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3896 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3897 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3899 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3902 LOGD("ret : 0x%x", ret);
3908 int camera_unset_interrupted_cb(camera_h camera)
3910 int ret = CAMERA_ERROR_NONE;
3911 camera_cli_s *pc = (camera_cli_s *)camera;
3912 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3914 if (!pc || !pc->cb_info) {
3915 LOGE("NULL handle");
3916 return CAMERA_ERROR_INVALID_PARAMETER;
3921 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3923 if (ret == CAMERA_ERROR_NONE) {
3924 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3926 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3927 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3929 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3932 LOGD("ret : 0x%x", ret);
3938 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3940 int ret = CAMERA_ERROR_NONE;
3941 camera_cli_s *pc = (camera_cli_s *)camera;
3942 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3944 if (!pc || !pc->cb_info || !callback) {
3945 LOGE("NULL pointer %p %p", pc, callback);
3946 return CAMERA_ERROR_INVALID_PARAMETER;
3951 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3953 if (ret == CAMERA_ERROR_NONE) {
3954 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3956 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3957 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3959 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3962 LOGD("ret : 0x%x", ret);
3968 int camera_unset_interrupt_started_cb(camera_h camera)
3970 int ret = CAMERA_ERROR_NONE;
3971 camera_cli_s *pc = (camera_cli_s *)camera;
3972 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3974 if (!pc || !pc->cb_info) {
3975 LOGE("NULL handle");
3976 return CAMERA_ERROR_INVALID_PARAMETER;
3981 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3983 if (ret == CAMERA_ERROR_NONE) {
3984 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3986 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3987 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3989 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3992 LOGD("ret : 0x%x", ret);
3998 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4000 int ret = CAMERA_ERROR_NONE;
4001 camera_cli_s *pc = (camera_cli_s *)camera;
4002 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4004 if (!pc || !pc->cb_info || !callback) {
4005 LOGE("NULL pointer %p %p", pc, callback);
4006 return CAMERA_ERROR_INVALID_PARAMETER;
4011 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4013 if (ret == CAMERA_ERROR_NONE) {
4014 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4016 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4017 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4019 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4022 LOGD("ret : 0x%x", ret);
4028 int camera_unset_focus_changed_cb(camera_h camera)
4030 int ret = CAMERA_ERROR_NONE;
4031 camera_cli_s *pc = (camera_cli_s *)camera;
4032 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4034 if (!pc || !pc->cb_info) {
4035 LOGE("NULL handle");
4036 return CAMERA_ERROR_INVALID_PARAMETER;
4041 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4043 if (ret == CAMERA_ERROR_NONE) {
4044 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4049 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4052 LOGD("ret : 0x%x", ret);
4058 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4060 int ret = CAMERA_ERROR_NONE;
4061 camera_cli_s *pc = (camera_cli_s *)camera;
4062 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4064 if (!pc || !pc->cb_info || !callback) {
4065 LOGE("NULL pointer %p %p", pc, callback);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4071 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4073 if (ret == CAMERA_ERROR_NONE) {
4074 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4076 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4077 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4079 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4082 LOGD("ret : 0x%x", ret);
4088 int camera_unset_error_cb(camera_h camera)
4090 int ret = CAMERA_ERROR_NONE;
4091 camera_cli_s *pc = (camera_cli_s *)camera;
4092 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4094 if (!pc || !pc->cb_info) {
4095 LOGE("NULL handle");
4096 return CAMERA_ERROR_INVALID_PARAMETER;
4101 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4103 if (ret == CAMERA_ERROR_NONE) {
4104 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4106 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4107 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4109 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4112 LOGD("ret : 0x%x", ret);
4118 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4120 int ret = CAMERA_ERROR_NONE;
4121 camera_cli_s *pc = (camera_cli_s *)camera;
4122 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4124 if (!pc || !pc->cb_info || !foreach_cb) {
4125 LOGE("NULL pointer %p %p", pc, foreach_cb);
4126 return CAMERA_ERROR_INVALID_PARAMETER;
4131 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4132 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4134 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4136 LOGD("ret : 0x%x", ret);
4142 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4144 int ret = CAMERA_ERROR_NONE;
4145 camera_cli_s *pc = (camera_cli_s *)camera;
4146 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4148 if (!pc || !pc->cb_info || !foreach_cb) {
4149 LOGE("NULL pointer %p %p", pc, foreach_cb);
4150 return CAMERA_ERROR_INVALID_PARAMETER;
4155 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4156 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4158 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4160 LOGD("ret : 0x%x", ret);
4166 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4168 int ret = CAMERA_ERROR_NONE;
4169 camera_cli_s *pc = (camera_cli_s *)camera;
4170 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4172 if (!pc || !pc->cb_info || !foreach_cb) {
4173 LOGE("NULL pointer %p %p", pc, foreach_cb);
4174 return CAMERA_ERROR_INVALID_PARAMETER;
4179 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4180 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4184 LOGD("ret : 0x%x", ret);
4190 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4192 int ret = CAMERA_ERROR_NONE;
4193 camera_cli_s *pc = (camera_cli_s *)camera;
4194 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4196 if (!pc || !pc->cb_info || !foreach_cb) {
4197 LOGE("NULL pointer %p %p", pc, foreach_cb);
4198 return CAMERA_ERROR_INVALID_PARAMETER;
4203 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4204 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4206 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4208 LOGD("ret : 0x%x", ret);
4214 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4216 int ret = CAMERA_ERROR_NONE;
4217 camera_cli_s *pc = (camera_cli_s *)camera;
4218 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4220 if (!pc || !pc->cb_info || !width || !height) {
4221 LOGE("NULL pointer %p %p %p", pc, width, height);
4222 return CAMERA_ERROR_INVALID_PARAMETER;
4226 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4228 if (ret == CAMERA_ERROR_NONE) {
4229 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4230 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4233 LOGD("ret : 0x%x", ret);
4239 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4241 int ret = CAMERA_ERROR_NONE;
4242 camera_cli_s *pc = (camera_cli_s *)camera;
4243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4245 if (!pc || !pc->cb_info || !angle) {
4246 LOGE("NULL pointer %p %p", pc, angle);
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4252 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4254 if (ret == CAMERA_ERROR_NONE)
4255 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4257 LOGD("ret : 0x%x", ret);
4263 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4265 int ret = CAMERA_ERROR_NONE;
4266 camera_cli_s *pc = (camera_cli_s *)camera;
4267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4268 camera_msg_param param;
4269 int set_mode = (int)mode;
4271 if (!pc || !pc->cb_info) {
4272 LOGE("NULL handle");
4273 return CAMERA_ERROR_INVALID_PARAMETER;
4278 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4280 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4282 LOGD("ret : 0x%x", ret);
4288 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4290 int ret = CAMERA_ERROR_NONE;
4291 camera_cli_s *pc = (camera_cli_s *)camera;
4292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4294 if (!pc || !pc->cb_info || !mode) {
4295 LOGE("NULL pointer %p %p", pc, mode);
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4301 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4303 if (ret == CAMERA_ERROR_NONE)
4304 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4306 LOGD("ret : 0x%x", ret);
4312 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4314 int ret = CAMERA_ERROR_NONE;
4315 camera_cli_s *pc = (camera_cli_s *)camera;
4316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4318 if (!pc || !pc->cb_info || !foreach_cb) {
4319 LOGE("NULL pointer %p %p", pc, foreach_cb);
4320 return CAMERA_ERROR_INVALID_PARAMETER;
4325 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4326 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4328 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4330 LOGD("Finish, return :%x", ret);
4336 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4338 int ret = CAMERA_ERROR_NONE;
4339 camera_cli_s *pc = (camera_cli_s *)camera;
4340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4341 camera_msg_param param;
4342 int set_fps = (int)fps;
4344 if (!pc || !pc->cb_info) {
4345 LOGE("NULL handle");
4346 return CAMERA_ERROR_INVALID_PARAMETER;
4351 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4353 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4355 LOGD("ret : 0x%x", ret);
4361 int camera_attr_set_image_quality(camera_h camera, int quality)
4363 int ret = CAMERA_ERROR_NONE;
4364 camera_cli_s *pc = (camera_cli_s *)camera;
4365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4366 camera_msg_param param;
4368 if (!pc || !pc->cb_info) {
4369 LOGE("NULL handle");
4370 return CAMERA_ERROR_INVALID_PARAMETER;
4375 CAMERA_MSG_PARAM_SET(param, INT, quality);
4377 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4379 LOGD("ret : 0x%x", ret);
4385 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4387 int ret = CAMERA_ERROR_NONE;
4388 camera_cli_s *pc = (camera_cli_s *)camera;
4389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4391 if (!pc || !pc->cb_info || !fps) {
4392 LOGE("NULL pointer %p %p", pc, fps);
4393 return CAMERA_ERROR_INVALID_PARAMETER;
4398 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4400 if (ret == CAMERA_ERROR_NONE)
4401 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4403 LOGD("ret : 0x%x", ret);
4409 int camera_attr_get_image_quality(camera_h camera, int *quality)
4411 int ret = CAMERA_ERROR_NONE;
4412 camera_cli_s *pc = (camera_cli_s *)camera;
4413 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4415 if (!pc || !pc->cb_info || !quality) {
4416 LOGE("NULL pointer %p %p", pc, quality);
4417 return CAMERA_ERROR_INVALID_PARAMETER;
4422 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4424 if (ret == CAMERA_ERROR_NONE)
4425 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4427 LOGD("ret : 0x%x", ret);
4433 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4435 int ret = CAMERA_ERROR_NONE;
4436 camera_cli_s *pc = (camera_cli_s *)camera;
4437 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4439 if (!pc || !pc->cb_info || !bitrate) {
4440 LOGE("NULL pointer %p %p", pc, bitrate);
4441 return CAMERA_ERROR_INVALID_PARAMETER;
4446 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4448 if (ret == CAMERA_ERROR_NONE)
4449 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4451 LOGD("ret : 0x%x", ret);
4457 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4459 int ret = CAMERA_ERROR_NONE;
4460 camera_cli_s *pc = (camera_cli_s *)camera;
4461 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4462 camera_msg_param param;
4463 int set_bitrate = bitrate;
4465 if (!pc || !pc->cb_info) {
4466 LOGE("NULL handle");
4467 return CAMERA_ERROR_INVALID_PARAMETER;
4472 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4474 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4476 LOGD("ret : 0x%x", ret);
4482 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4484 int ret = CAMERA_ERROR_NONE;
4485 camera_cli_s *pc = (camera_cli_s *)camera;
4486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4488 if (!pc || !pc->cb_info || !interval) {
4489 LOGE("NULL pointer %p %p", pc, interval);
4490 return CAMERA_ERROR_INVALID_PARAMETER;
4495 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4497 if (ret == CAMERA_ERROR_NONE)
4498 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4500 LOGD("ret : 0x%x", ret);
4506 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4508 int ret = CAMERA_ERROR_NONE;
4509 camera_cli_s *pc = (camera_cli_s *)camera;
4510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4511 camera_msg_param param;
4512 int set_gop_interval = interval;
4514 if (!pc || !pc->cb_info) {
4515 LOGE("NULL handle");
4516 return CAMERA_ERROR_INVALID_PARAMETER;
4521 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4523 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4525 LOGD("ret : 0x%x", ret);
4531 int camera_attr_set_zoom(camera_h camera, int zoom)
4533 int ret = CAMERA_ERROR_NONE;
4534 camera_cli_s *pc = (camera_cli_s *)camera;
4535 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4536 camera_msg_param param;
4538 if (!pc || !pc->cb_info) {
4539 LOGE("NULL handle");
4540 return CAMERA_ERROR_INVALID_PARAMETER;
4543 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4545 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4547 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4549 LOGD("ret : 0x%x", ret);
4555 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4557 int ret = CAMERA_ERROR_NONE;
4558 camera_cli_s *pc = (camera_cli_s *)camera;
4559 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4560 camera_msg_param param;
4561 int set_mode = (int)mode;
4563 if (!pc || !pc->cb_info) {
4564 LOGE("NULL handle");
4565 return CAMERA_ERROR_INVALID_PARAMETER;
4568 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4570 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4572 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4578 int camera_attr_set_af_area(camera_h camera, int x, int y)
4580 int ret = CAMERA_ERROR_NONE;
4581 camera_cli_s *pc = (camera_cli_s *)camera;
4582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4583 camera_msg_param param;
4586 if (!pc || !pc->cb_info) {
4587 LOGE("NULL handle");
4588 return CAMERA_ERROR_INVALID_PARAMETER;
4591 LOGD("Enter - %d,%d", x, y);
4593 value = (x << 16) | y;
4594 CAMERA_MSG_PARAM_SET(param, INT, value);
4596 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4598 LOGD("ret : 0x%x", ret);
4604 int camera_attr_clear_af_area(camera_h camera)
4606 int ret = CAMERA_ERROR_NONE;
4607 camera_cli_s *pc = (camera_cli_s *)camera;
4608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4610 if (!pc || !pc->cb_info) {
4611 LOGE("NULL handle");
4612 return CAMERA_ERROR_INVALID_PARAMETER;
4617 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4619 LOGD("ret : 0x%x", ret);
4625 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4627 int ret = CAMERA_ERROR_NONE;
4628 camera_cli_s *pc = (camera_cli_s *)camera;
4629 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4630 camera_msg_param param;
4631 int set_mode = (int)mode;
4633 if (!pc || !pc->cb_info) {
4634 LOGE("NULL handle");
4635 return CAMERA_ERROR_INVALID_PARAMETER;
4640 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4642 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4644 LOGD("ret : 0x%x", ret);
4650 int camera_attr_set_exposure(camera_h camera, int value)
4652 int ret = CAMERA_ERROR_NONE;
4653 camera_cli_s *pc = (camera_cli_s *)camera;
4654 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4655 camera_msg_param param;
4657 if (!pc || !pc->cb_info) {
4658 LOGE("NULL handle");
4659 return CAMERA_ERROR_INVALID_PARAMETER;
4664 CAMERA_MSG_PARAM_SET(param, INT, value);
4666 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4668 LOGD("ret : 0x%x", ret);
4674 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4676 int ret = CAMERA_ERROR_NONE;
4677 camera_cli_s *pc = (camera_cli_s *)camera;
4678 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4679 camera_msg_param param;
4680 int set_iso = (int)iso;
4682 if (!pc || !pc->cb_info) {
4683 LOGE("NULL handle");
4684 return CAMERA_ERROR_INVALID_PARAMETER;
4689 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4691 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4693 LOGD("ret : 0x%x", ret);
4699 int camera_attr_set_brightness(camera_h camera, int level)
4701 int ret = CAMERA_ERROR_NONE;
4702 camera_cli_s *pc = (camera_cli_s *)camera;
4703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4704 camera_msg_param param;
4706 if (!pc || !pc->cb_info) {
4707 LOGE("NULL handle");
4708 return CAMERA_ERROR_INVALID_PARAMETER;
4713 CAMERA_MSG_PARAM_SET(param, INT, level);
4715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4717 LOGD("ret : 0x%x", ret);
4723 int camera_attr_set_contrast(camera_h camera, int level)
4725 int ret = CAMERA_ERROR_NONE;
4726 camera_cli_s *pc = (camera_cli_s *)camera;
4727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4728 camera_msg_param param;
4730 if (!pc || !pc->cb_info) {
4731 LOGE("NULL handle");
4732 return CAMERA_ERROR_INVALID_PARAMETER;
4737 CAMERA_MSG_PARAM_SET(param, INT, level);
4739 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4741 LOGD("ret : 0x%x", ret);
4747 int camera_attr_set_hue(camera_h camera, int level)
4749 int ret = CAMERA_ERROR_NONE;
4750 camera_cli_s *pc = (camera_cli_s *)camera;
4751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4752 camera_msg_param param;
4754 if (!pc || !pc->cb_info) {
4755 LOGE("NULL handle");
4756 return CAMERA_ERROR_INVALID_PARAMETER;
4761 CAMERA_MSG_PARAM_SET(param, INT, level);
4763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4765 LOGD("ret : 0x%x", ret);
4771 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4773 int ret = CAMERA_ERROR_NONE;
4774 camera_cli_s *pc = (camera_cli_s *)camera;
4775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4776 camera_msg_param param;
4777 int set_whitebalance = (int)wb;
4779 if (!pc || !pc->cb_info) {
4780 LOGE("NULL handle");
4781 return CAMERA_ERROR_INVALID_PARAMETER;
4786 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4790 LOGD("ret : 0x%x", ret);
4796 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4798 int ret = CAMERA_ERROR_NONE;
4799 camera_cli_s *pc = (camera_cli_s *)camera;
4800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4801 camera_msg_param param;
4802 int set_effect = (int)effect;
4804 if (!pc || !pc->cb_info) {
4805 LOGE("NULL handle");
4806 return CAMERA_ERROR_INVALID_PARAMETER;
4811 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4815 LOGD("ret : 0x%x", ret);
4821 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4823 int ret = CAMERA_ERROR_NONE;
4824 camera_cli_s *pc = (camera_cli_s *)camera;
4825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4826 camera_msg_param param;
4827 int set_mode = (int)mode;
4829 if (!pc || !pc->cb_info) {
4830 LOGE("NULL handle");
4831 return CAMERA_ERROR_INVALID_PARAMETER;
4836 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4838 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4840 LOGD("ret : 0x%x", ret);
4846 int camera_attr_enable_tag(camera_h camera, bool enable)
4848 int ret = CAMERA_ERROR_NONE;
4849 camera_cli_s *pc = (camera_cli_s *)camera;
4850 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4851 camera_msg_param param;
4852 int set_enable = (int)enable;
4854 if (!pc || !pc->cb_info) {
4855 LOGE("NULL handle");
4856 return CAMERA_ERROR_INVALID_PARAMETER;
4861 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4863 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4876 camera_msg_param param;
4878 if (!pc || !pc->cb_info || !description) {
4879 LOGE("NULL pointer %p %p", pc, description);
4880 return CAMERA_ERROR_INVALID_PARAMETER;
4885 CAMERA_MSG_PARAM_SET(param, STRING, description);
4887 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4889 LOGD("ret : 0x%x", ret);
4895 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4897 int ret = CAMERA_ERROR_NONE;
4898 camera_cli_s *pc = (camera_cli_s *)camera;
4899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4900 camera_msg_param param;
4901 int set_orientation = (int)orientation;
4903 if (!pc || !pc->cb_info) {
4904 LOGE("NULL handle");
4905 return CAMERA_ERROR_INVALID_PARAMETER;
4910 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4912 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4914 LOGD("ret : 0x%x", ret);
4920 int camera_attr_set_tag_software(camera_h camera, const char *software)
4922 int ret = CAMERA_ERROR_NONE;
4923 camera_cli_s *pc = (camera_cli_s *)camera;
4924 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4925 camera_msg_param param;
4927 if (!pc || !pc->cb_info || !software) {
4928 LOGE("NULL pointer %p %p", pc, software);
4929 return CAMERA_ERROR_INVALID_PARAMETER;
4932 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4934 CAMERA_MSG_PARAM_SET(param, STRING, software);
4936 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4938 LOGD("ret : 0x%x", ret);
4944 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4946 int ret = CAMERA_ERROR_NONE;
4947 camera_cli_s *pc = (camera_cli_s *)camera;
4948 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4949 double set_geotag[3] = {latitude, longitude, altitude};
4954 if (!pc || !pc->cb_info) {
4955 LOGE("NULL handle");
4956 return CAMERA_ERROR_INVALID_PARAMETER;
4961 length = sizeof(set_geotag) / sizeof(int) + \
4962 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4964 msg = muse_core_msg_new(api,
4965 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4968 LOGE("msg creation failed: api %d", api);
4969 return CAMERA_ERROR_OUT_OF_MEMORY;
4972 if (pc->cb_info->is_server_connected) {
4973 __camera_update_api_waiting(pc->cb_info, api, 1);
4975 g_mutex_lock(&pc->cb_info->fd_lock);
4976 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4977 g_mutex_unlock(&pc->cb_info->fd_lock);
4981 LOGE("message send failed");
4982 ret = CAMERA_ERROR_INVALID_OPERATION;
4984 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4987 __camera_update_api_waiting(pc->cb_info, api, -1);
4989 muse_core_msg_free(msg);
4991 LOGD("ret : 0x%x", ret);
4997 int camera_attr_remove_geotag(camera_h camera)
4999 int ret = CAMERA_ERROR_NONE;
5000 camera_cli_s *pc = (camera_cli_s *)camera;
5001 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5003 if (!pc || !pc->cb_info) {
5004 LOGE("NULL handle");
5005 return CAMERA_ERROR_INVALID_PARAMETER;
5010 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5012 LOGD("ret : 0x%x", ret);
5018 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5020 int ret = CAMERA_ERROR_NONE;
5021 camera_cli_s *pc = (camera_cli_s *)camera;
5022 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5023 camera_msg_param param;
5024 int set_mode = (int)mode;
5026 if (!pc || !pc->cb_info) {
5027 LOGE("NULL handle");
5028 return CAMERA_ERROR_INVALID_PARAMETER;
5033 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5035 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5037 LOGD("ret : 0x%x", ret);
5043 int camera_attr_get_zoom(camera_h camera, int *zoom)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5049 if (!pc || !pc->cb_info || !zoom) {
5050 LOGE("NULL pointer %p %p", pc, zoom);
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5058 if (ret == CAMERA_ERROR_NONE)
5059 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5061 LOGD("ret : 0x%x", ret);
5067 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5069 int ret = CAMERA_ERROR_NONE;
5070 camera_cli_s *pc = (camera_cli_s *)camera;
5071 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5073 if (!pc || !pc->cb_info || !min || !max) {
5074 LOGE("NULL pointer %p %p %p", pc, min, max);
5075 return CAMERA_ERROR_INVALID_PARAMETER;
5080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5082 if (ret == CAMERA_ERROR_NONE) {
5083 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5084 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5087 LOGD("ret : 0x%x", ret);
5093 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5095 int ret = CAMERA_ERROR_NONE;
5096 camera_cli_s *pc = (camera_cli_s *)camera;
5097 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5099 if (!pc || !pc->cb_info || !mode) {
5100 LOGE("NULL pointer %p %p", pc, mode);
5101 return CAMERA_ERROR_INVALID_PARAMETER;
5106 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5108 if (ret == CAMERA_ERROR_NONE)
5109 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5111 LOGD("ret : 0x%x", ret);
5117 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5119 int ret = CAMERA_ERROR_NONE;
5120 camera_cli_s *pc = (camera_cli_s *)camera;
5121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5123 if (!pc || !pc->cb_info || !mode) {
5124 LOGE("NULL pointer %p %p", pc, mode);
5125 return CAMERA_ERROR_INVALID_PARAMETER;
5130 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5132 if (ret == CAMERA_ERROR_NONE)
5133 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5135 LOGD("ret : 0x%x", ret);
5141 int camera_attr_get_exposure(camera_h camera, int *value)
5143 int ret = CAMERA_ERROR_NONE;
5144 camera_cli_s *pc = (camera_cli_s *)camera;
5145 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5147 if (!pc || !pc->cb_info || !value) {
5148 LOGE("NULL pointer %p %p", pc, value);
5149 return CAMERA_ERROR_INVALID_PARAMETER;
5154 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5156 if (ret == CAMERA_ERROR_NONE)
5157 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5159 LOGD("ret : 0x%x", ret);
5165 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5167 int ret = CAMERA_ERROR_NONE;
5168 camera_cli_s *pc = (camera_cli_s *)camera;
5169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5171 if (!pc || !pc->cb_info || !min || !max) {
5172 LOGE("NULL pointer %p %p %p", pc, min, max);
5173 return CAMERA_ERROR_INVALID_PARAMETER;
5178 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5180 if (ret == CAMERA_ERROR_NONE) {
5181 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5182 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5185 LOGD("ret : 0x%x", ret);
5191 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5193 int ret = CAMERA_ERROR_NONE;
5194 camera_cli_s *pc = (camera_cli_s *)camera;
5195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5197 if (!pc || !pc->cb_info || !iso) {
5198 LOGE("NULL pointer %p %p", pc, iso);
5199 return CAMERA_ERROR_INVALID_PARAMETER;
5204 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5206 if (ret == CAMERA_ERROR_NONE)
5207 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5209 LOGD("ret : 0x%x", ret);
5215 int camera_attr_get_brightness(camera_h camera, int *level)
5217 int ret = CAMERA_ERROR_NONE;
5218 camera_cli_s *pc = (camera_cli_s *)camera;
5219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5221 if (!pc || !pc->cb_info || !level) {
5222 LOGE("NULL pointer %p %p", pc, level);
5223 return CAMERA_ERROR_INVALID_PARAMETER;
5228 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5230 if (ret == CAMERA_ERROR_NONE)
5231 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5233 LOGD("ret : 0x%x", ret);
5239 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5241 int ret = CAMERA_ERROR_NONE;
5242 camera_cli_s *pc = (camera_cli_s *)camera;
5243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5245 if (!pc || !pc->cb_info || !min || !max) {
5246 LOGE("NULL pointer %p %p %p", pc, min, max);
5247 return CAMERA_ERROR_INVALID_PARAMETER;
5252 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5254 if (ret == CAMERA_ERROR_NONE) {
5255 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5256 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5259 LOGD("ret : 0x%x", ret);
5265 int camera_attr_get_contrast(camera_h camera, int *level)
5267 int ret = CAMERA_ERROR_NONE;
5268 camera_cli_s *pc = (camera_cli_s *)camera;
5269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5271 if (!pc || !pc->cb_info || !level) {
5272 LOGE("NULL pointer %p %p", pc, level);
5273 return CAMERA_ERROR_INVALID_PARAMETER;
5278 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 if (ret == CAMERA_ERROR_NONE)
5281 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5283 LOGD("ret : 0x%x", ret);
5289 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5295 if (!pc || !pc->cb_info || !min || !max) {
5296 LOGE("NULL pointer %p %p %p", pc, min, max);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5302 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE) {
5305 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5306 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5307 LOGD("min %d, max %d", *min, *max);
5310 LOGD("ret : 0x%x", ret);
5316 int camera_attr_get_hue(camera_h camera, int *level)
5318 int ret = CAMERA_ERROR_NONE;
5319 camera_cli_s *pc = (camera_cli_s *)camera;
5320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5322 if (!pc || !pc->cb_info || !level) {
5323 LOGE("NULL pointer %p %p", pc, level);
5324 return CAMERA_ERROR_INVALID_PARAMETER;
5329 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5331 if (ret == CAMERA_ERROR_NONE)
5332 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5334 LOGD("ret : 0x%x", ret);
5340 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5342 int ret = CAMERA_ERROR_NONE;
5343 camera_cli_s *pc = (camera_cli_s *)camera;
5344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5346 if (!pc || !pc->cb_info || !min || !max) {
5347 LOGE("NULL pointer %p %p %p", pc, min, max);
5348 return CAMERA_ERROR_INVALID_PARAMETER;
5353 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5355 if (ret == CAMERA_ERROR_NONE) {
5356 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5357 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5358 LOGD("min %d, max %d", *min, *max);
5361 LOGD("ret : 0x%x", ret);
5367 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5369 int ret = CAMERA_ERROR_NONE;
5370 camera_cli_s *pc = (camera_cli_s *)camera;
5371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5373 if (!pc || !pc->cb_info || !wb) {
5374 LOGE("NULL pointer %p %p", pc, wb);
5375 return CAMERA_ERROR_INVALID_PARAMETER;
5380 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5382 if (ret == CAMERA_ERROR_NONE)
5383 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5385 LOGD("ret : 0x%x", ret);
5391 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5393 int ret = CAMERA_ERROR_NONE;
5394 camera_cli_s *pc = (camera_cli_s *)camera;
5395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5397 if (!pc || !pc->cb_info || !effect) {
5398 LOGE("NULL pointer %p %p", pc, effect);
5399 return CAMERA_ERROR_INVALID_PARAMETER;
5404 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5406 if (ret == CAMERA_ERROR_NONE)
5407 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5409 LOGD("ret : 0x%x", ret);
5415 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5417 int ret = CAMERA_ERROR_NONE;
5418 camera_cli_s *pc = (camera_cli_s *)camera;
5419 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5421 if (!pc || !pc->cb_info || !mode) {
5422 LOGE("NULL pointer %p %p", pc, mode);
5423 return CAMERA_ERROR_INVALID_PARAMETER;
5428 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5430 if (ret == CAMERA_ERROR_NONE)
5431 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5433 LOGD("ret : 0x%x", ret);
5439 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5441 int ret = CAMERA_ERROR_NONE;
5442 camera_cli_s *pc = (camera_cli_s *)camera;
5443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5445 if (!pc || !pc->cb_info || !enable) {
5446 LOGE("NULL pointer %p %p", pc, enable);
5447 return CAMERA_ERROR_INVALID_PARAMETER;
5452 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5454 if (ret == CAMERA_ERROR_NONE)
5455 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5457 LOGD("ret : 0x%x", ret);
5463 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5465 int ret = CAMERA_ERROR_NONE;
5466 camera_cli_s *pc = (camera_cli_s *)camera;
5467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5469 if (!pc || !pc->cb_info || !description) {
5470 LOGE("NULL pointer %p %p", pc, description);
5471 return CAMERA_ERROR_INVALID_PARAMETER;
5476 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5478 if (ret == CAMERA_ERROR_NONE)
5479 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5481 LOGD("ret : 0x%x", ret);
5487 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5489 int ret = CAMERA_ERROR_NONE;
5490 camera_cli_s *pc = (camera_cli_s *)camera;
5491 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5493 if (!pc || !pc->cb_info || !orientation) {
5494 LOGE("NULL pointer %p %p", pc, orientation);
5495 return CAMERA_ERROR_INVALID_PARAMETER;
5500 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5502 if (ret == CAMERA_ERROR_NONE)
5503 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5505 LOGD("ret : 0x%x", ret);
5511 int camera_attr_get_tag_software(camera_h camera, char **software)
5513 int ret = CAMERA_ERROR_NONE;
5514 camera_cli_s *pc = (camera_cli_s *)camera;
5515 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5517 if (!pc || !pc->cb_info || !software) {
5518 LOGE("NULL pointer %p %p", pc, software);
5519 return CAMERA_ERROR_INVALID_PARAMETER;
5524 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5526 if (ret == CAMERA_ERROR_NONE)
5527 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5529 LOGD("ret : 0x%x", ret);
5535 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5537 int ret = CAMERA_ERROR_NONE;
5538 camera_cli_s *pc = (camera_cli_s *)camera;
5539 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5541 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5542 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5543 return CAMERA_ERROR_INVALID_PARAMETER;
5548 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5550 if (ret == CAMERA_ERROR_NONE) {
5551 *latitude = pc->cb_info->get_geotag[0];
5552 *longitude = pc->cb_info->get_geotag[1];
5553 *altitude = pc->cb_info->get_geotag[2];
5556 LOGD("ret : 0x%x", ret);
5562 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5564 int ret = CAMERA_ERROR_NONE;
5565 camera_cli_s *pc = (camera_cli_s *)camera;
5566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5568 if (!pc || !pc->cb_info || !mode) {
5569 LOGE("NULL pointer %p %p", pc, mode);
5570 return CAMERA_ERROR_INVALID_PARAMETER;
5575 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5577 if (ret == CAMERA_ERROR_NONE)
5578 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5580 LOGD("ret : 0x%x", ret);
5586 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5588 int ret = CAMERA_ERROR_NONE;
5589 int get_flash_state = 0;
5592 LOGE("NULL pointer");
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5596 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5597 (int)device, "get_flash_state", &get_flash_state);
5599 if (ret == CAMERA_ERROR_NONE) {
5600 *state = (camera_flash_state_e)get_flash_state;
5601 LOGD("flash state %d", *state);
5603 LOGE("failed 0x%x", ret);
5610 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5612 int ret = CAMERA_ERROR_NONE;
5613 camera_cli_s *pc = (camera_cli_s *)camera;
5614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5616 if (!pc || !pc->cb_info || !foreach_cb) {
5617 LOGE("NULL pointer %p %p", pc, foreach_cb);
5618 return CAMERA_ERROR_INVALID_PARAMETER;
5623 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5624 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5626 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5628 LOGD("ret : 0x%x", ret);
5634 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5636 int ret = CAMERA_ERROR_NONE;
5637 camera_cli_s *pc = (camera_cli_s *)camera;
5638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5640 if (!pc || !pc->cb_info || !foreach_cb) {
5641 LOGE("NULL pointer %p %p", pc, foreach_cb);
5642 return CAMERA_ERROR_INVALID_PARAMETER;
5647 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5648 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5650 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5652 LOGD("ret : 0x%x", ret);
5658 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5660 int ret = CAMERA_ERROR_NONE;
5661 camera_cli_s *pc = (camera_cli_s *)camera;
5662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5664 if (!pc || !pc->cb_info || !foreach_cb) {
5665 LOGE("NULL pointer %p %p", pc, foreach_cb);
5666 return CAMERA_ERROR_INVALID_PARAMETER;
5671 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5672 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5674 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5676 LOGD("ret : 0x%x", ret);
5682 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5684 int ret = CAMERA_ERROR_NONE;
5685 camera_cli_s *pc = (camera_cli_s *)camera;
5686 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5688 if (!pc || !pc->cb_info || !foreach_cb) {
5689 LOGE("NULL pointer %p %p", pc, foreach_cb);
5690 return CAMERA_ERROR_INVALID_PARAMETER;
5695 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5696 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5698 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5700 LOGD("ret : 0x%x", ret);
5706 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5708 int ret = CAMERA_ERROR_NONE;
5709 camera_cli_s *pc = (camera_cli_s *)camera;
5710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5712 if (!pc || !pc->cb_info || !foreach_cb) {
5713 LOGE("NULL pointer %p %p", pc, foreach_cb);
5714 return CAMERA_ERROR_INVALID_PARAMETER;
5719 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5720 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5722 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5724 LOGD("ret : 0x%x", ret);
5730 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5732 int ret = CAMERA_ERROR_NONE;
5733 camera_cli_s *pc = (camera_cli_s *)camera;
5734 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5736 if (!pc || !pc->cb_info || !foreach_cb) {
5737 LOGE("NULL pointer %p %p", pc, foreach_cb);
5738 return CAMERA_ERROR_INVALID_PARAMETER;
5743 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5744 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5746 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5748 LOGD("ret : 0x%x", ret);
5754 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5760 if (!pc || !pc->cb_info || !foreach_cb) {
5761 LOGE("NULL pointer %p %p", pc, foreach_cb);
5762 return CAMERA_ERROR_INVALID_PARAMETER;
5767 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5768 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5770 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5772 LOGD("ret : 0x%x", ret);
5778 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5780 int ret = CAMERA_ERROR_NONE;
5781 camera_cli_s *pc = (camera_cli_s *)camera;
5782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5784 if (!pc || !pc->cb_info || !foreach_cb) {
5785 LOGE("NULL pointer %p %p", pc, foreach_cb);
5786 return CAMERA_ERROR_INVALID_PARAMETER;
5791 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5792 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5794 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5796 LOGD("Enter, handle :%td", pc->remote_handle);
5802 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)
5804 int ret = CAMERA_ERROR_NONE;
5805 camera_cli_s *pc = (camera_cli_s *)camera;
5806 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5807 camera_msg_param param;
5810 if (!pc || !pc->cb_info || !foreach_cb) {
5811 LOGE("NULL pointer %p %p", pc, foreach_cb);
5812 return CAMERA_ERROR_INVALID_PARAMETER;
5817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5820 value = (width << 16) | height;
5821 CAMERA_MSG_PARAM_SET(param, INT, value);
5823 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5825 LOGD("ret : 0x%x", ret);
5831 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5833 int ret = CAMERA_ERROR_NONE;
5834 camera_cli_s *pc = (camera_cli_s *)camera;
5835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5837 if (!pc || !pc->cb_info || !foreach_cb) {
5838 LOGE("NULL pointer %p %p", pc, foreach_cb);
5839 return CAMERA_ERROR_INVALID_PARAMETER;
5844 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5847 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5849 LOGD("ret : 0x%x", ret);
5855 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5857 int ret = CAMERA_ERROR_NONE;
5858 camera_cli_s *pc = (camera_cli_s *)camera;
5859 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5861 if (!pc || !pc->cb_info || !foreach_cb) {
5862 LOGE("NULL pointer %p %p", pc, foreach_cb);
5863 return CAMERA_ERROR_INVALID_PARAMETER;
5868 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5869 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5871 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5873 LOGD("ret : 0x%x", ret);
5879 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5881 int ret = CAMERA_ERROR_NONE;
5882 camera_cli_s *pc = (camera_cli_s *)camera;
5883 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5884 camera_msg_param param;
5885 int set_rotation = (int)rotation;
5887 if (!pc || !pc->cb_info) {
5888 LOGE("NULL handle");
5889 return CAMERA_ERROR_INVALID_PARAMETER;
5894 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5896 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5898 LOGD("ret : 0x%x", ret);
5904 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5906 int ret = CAMERA_ERROR_NONE;
5907 camera_cli_s *pc = (camera_cli_s *)camera;
5908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5910 if (!pc || !pc->cb_info || !rotation) {
5911 LOGE("NULL pointer %p %p", pc, rotation);
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5917 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5919 if (ret == CAMERA_ERROR_NONE)
5920 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5922 LOGD("ret : 0x%x", ret);
5928 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5930 int ret = CAMERA_ERROR_NONE;
5931 camera_cli_s *pc = (camera_cli_s *)camera;
5932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5933 camera_msg_param param;
5934 int set_flip = (int)flip;
5936 if (!pc || !pc->cb_info) {
5937 LOGE("NULL handle");
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5943 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5945 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5947 LOGD("ret : 0x%x", ret);
5953 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5955 int ret = CAMERA_ERROR_NONE;
5956 camera_cli_s *pc = (camera_cli_s *)camera;
5957 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5959 if (!pc || !pc->cb_info || !flip) {
5960 LOGE("NULL pointer %p %p", pc, flip);
5961 return CAMERA_ERROR_INVALID_PARAMETER;
5966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5968 if (ret == CAMERA_ERROR_NONE)
5969 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5971 LOGD("ret : 0x%x", ret);
5976 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5981 camera_msg_param param;
5982 int set_mode = (int)mode;
5984 if (!pc || !pc->cb_info) {
5985 LOGE("NULL handle");
5986 return CAMERA_ERROR_INVALID_PARAMETER;
5991 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5993 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5995 LOGD("ret : 0x%x", ret);
6001 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6003 int ret = CAMERA_ERROR_NONE;
6004 camera_cli_s *pc = (camera_cli_s *)camera;
6005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6007 if (!pc || !pc->cb_info || !mode) {
6008 LOGE("NULL pointer %p %p", pc, mode);
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6014 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6016 if (ret == CAMERA_ERROR_NONE)
6017 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6019 LOGD("ret : 0x%x", ret);
6025 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6027 int ret = CAMERA_ERROR_NONE;
6028 camera_cli_s *pc = (camera_cli_s *)camera;
6029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6031 if (!pc || !pc->cb_info) {
6032 LOGE("NULL handle");
6033 return CAMERA_ERROR_INVALID_PARAMETER;
6038 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6041 LOGE("error is occurred 0x%x", ret);
6045 LOGD("ret : %d", ret);
6051 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6053 int ret = CAMERA_ERROR_NONE;
6054 camera_cli_s *pc = (camera_cli_s *)camera;
6055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6057 if (!pc || !pc->cb_info) {
6058 LOGE("NULL handle");
6059 return CAMERA_ERROR_INVALID_PARAMETER;
6064 if (!camera_attr_is_supported_hdr_capture(camera)) {
6065 LOGE("HDR not supported");
6066 return CAMERA_ERROR_NOT_SUPPORTED;
6070 LOGE("NULL callback");
6071 return CAMERA_ERROR_INVALID_PARAMETER;
6074 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6076 if (ret == CAMERA_ERROR_NONE) {
6077 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6082 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6085 LOGD("ret : 0x%x", ret);
6091 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6093 int ret = CAMERA_ERROR_NONE;
6094 camera_cli_s *pc = (camera_cli_s *)camera;
6095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6097 if (!pc || !pc->cb_info) {
6098 LOGE("NULL handle");
6099 return CAMERA_ERROR_INVALID_PARAMETER;
6104 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6106 if (ret == CAMERA_ERROR_NONE) {
6107 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6109 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6110 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6112 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6115 LOGD("ret : 0x%x", ret);
6121 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6123 int ret = CAMERA_ERROR_NONE;
6124 camera_cli_s *pc = (camera_cli_s *)camera;
6125 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6126 camera_msg_param param;
6127 int set_enable = (int)enable;
6129 if (!pc || !pc->cb_info) {
6130 LOGE("NULL handle");
6131 return CAMERA_ERROR_INVALID_PARAMETER;
6136 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6138 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6140 LOGD("ret : 0x%x", ret);
6146 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6148 int ret = CAMERA_ERROR_NONE;
6149 camera_cli_s *pc = (camera_cli_s *)camera;
6150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6152 if (!pc || !pc->cb_info || !enabled) {
6153 LOGE("NULL pointer %p %p", pc, enabled);
6154 return CAMERA_ERROR_INVALID_PARAMETER;
6159 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6161 if (ret == CAMERA_ERROR_NONE)
6162 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6164 LOGD("ret : 0x%x", ret);
6170 bool camera_attr_is_supported_anti_shake(camera_h camera)
6172 int ret = CAMERA_ERROR_NONE;
6173 camera_cli_s *pc = (camera_cli_s *)camera;
6174 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6176 if (!pc || !pc->cb_info) {
6177 LOGE("NULL handle");
6178 return CAMERA_ERROR_INVALID_PARAMETER;
6183 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6186 LOGE("error is occurred 0x%x", ret);
6190 LOGD("ret : %d", ret);
6196 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6198 int ret = CAMERA_ERROR_NONE;
6199 camera_cli_s *pc = (camera_cli_s *)camera;
6200 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6201 camera_msg_param param;
6202 int set_enable = (int)enable;
6204 if (!pc || !pc->cb_info) {
6205 LOGE("NULL handle");
6206 return CAMERA_ERROR_INVALID_PARAMETER;
6211 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6213 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6215 LOGD("ret : 0x%x", ret);
6221 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6223 int ret = CAMERA_ERROR_NONE;
6224 camera_cli_s *pc = (camera_cli_s *)camera;
6225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6227 if (!pc || !pc->cb_info || !enabled) {
6228 LOGE("NULL pointer %p %p", pc, enabled);
6229 return CAMERA_ERROR_INVALID_PARAMETER;
6234 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6236 if (ret == CAMERA_ERROR_NONE)
6237 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6239 LOGD("ret : 0x%x", ret);
6245 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6247 int ret = CAMERA_ERROR_NONE;
6248 camera_cli_s *pc = (camera_cli_s *)camera;
6249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6251 if (!pc || !pc->cb_info) {
6252 LOGE("NULL handle");
6253 return CAMERA_ERROR_INVALID_PARAMETER;
6258 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6261 LOGE("error is occurred 0x%x", ret);
6265 LOGD("ret : %d", ret);
6271 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6273 int ret = CAMERA_ERROR_NONE;
6274 camera_cli_s *pc = (camera_cli_s *)camera;
6275 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6276 camera_msg_param param;
6277 int set_enable = (int)enable;
6279 if (!pc || !pc->cb_info) {
6280 LOGE("NULL handle");
6281 return CAMERA_ERROR_INVALID_PARAMETER;
6286 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6288 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6290 LOGD("ret : 0x%x", ret);
6296 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6298 int ret = CAMERA_ERROR_NONE;
6299 camera_cli_s *pc = (camera_cli_s *)camera;
6300 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6302 if (!pc || !pc->cb_info || !enabled) {
6303 LOGE("NULL pointer %p %p", pc, enabled);
6304 return CAMERA_ERROR_INVALID_PARAMETER;
6309 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6311 if (ret == CAMERA_ERROR_NONE)
6312 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6314 LOGD("ret : 0x%x", ret);
6320 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6322 int ret = CAMERA_ERROR_NONE;
6323 camera_cli_s *pc = (camera_cli_s *)camera;
6324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6326 if (!pc || !pc->cb_info) {
6327 LOGE("NULL handle");
6328 return CAMERA_ERROR_INVALID_PARAMETER;
6333 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6336 LOGE("error is occurred 0x%x", ret);
6340 LOGD("ret : %d", ret);
6346 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6348 int ret = CAMERA_ERROR_NONE;
6349 camera_cli_s *pc = (camera_cli_s *)camera;
6350 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6351 camera_msg_param param;
6352 int set_disable = (int)disable;
6354 if (!pc || !pc->cb_info) {
6355 LOGE("NULL handle");
6356 return CAMERA_ERROR_INVALID_PARAMETER;
6361 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6363 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6365 LOGD("ret : 0x%x", ret);
6371 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6373 int ret = CAMERA_ERROR_NONE;
6374 camera_cli_s *pc = (camera_cli_s *)camera;
6375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6376 camera_msg_param param0;
6377 camera_msg_param param1;
6379 if (!pc || !pc->cb_info) {
6380 LOGE("NULL handle");
6381 return CAMERA_ERROR_INVALID_PARAMETER;
6386 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6387 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6389 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6390 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6392 LOGD("ret : 0x%x", ret);
6398 int camera_attr_get_pan(camera_h camera, int *pan_step)
6400 int ret = CAMERA_ERROR_NONE;
6401 camera_cli_s *pc = (camera_cli_s *)camera;
6402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6404 if (!pc || !pc->cb_info || !pan_step) {
6405 LOGE("NULL pointer %p %p", pc, pan_step);
6406 return CAMERA_ERROR_INVALID_PARAMETER;
6411 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6413 if (ret == CAMERA_ERROR_NONE)
6414 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6416 LOGD("ret : 0x%x", ret);
6422 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6424 int ret = CAMERA_ERROR_NONE;
6425 camera_cli_s *pc = (camera_cli_s *)camera;
6426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6428 if (!pc || !pc->cb_info || !min || !max) {
6429 LOGE("NULL pointer %p %p %p", pc, min, max);
6430 return CAMERA_ERROR_INVALID_PARAMETER;
6435 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6437 if (ret == CAMERA_ERROR_NONE) {
6438 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6439 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6442 LOGD("ret : 0x%x", ret);
6448 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6450 int ret = CAMERA_ERROR_NONE;
6451 camera_cli_s *pc = (camera_cli_s *)camera;
6452 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6453 camera_msg_param param0;
6454 camera_msg_param param1;
6456 if (!pc || !pc->cb_info) {
6457 LOGE("NULL handle");
6458 return CAMERA_ERROR_INVALID_PARAMETER;
6463 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6464 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6466 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6467 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6469 LOGD("ret : 0x%x", ret);
6475 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6477 int ret = CAMERA_ERROR_NONE;
6478 camera_cli_s *pc = (camera_cli_s *)camera;
6479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6481 if (!pc || !pc->cb_info || !tilt_step) {
6482 LOGE("NULL pointer %p %p", pc, tilt_step);
6483 return CAMERA_ERROR_INVALID_PARAMETER;
6488 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6490 if (ret == CAMERA_ERROR_NONE)
6491 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6493 LOGD("ret : 0x%x", ret);
6499 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6501 int ret = CAMERA_ERROR_NONE;
6502 camera_cli_s *pc = (camera_cli_s *)camera;
6503 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6505 if (!pc || !pc->cb_info || !min || !max) {
6506 LOGE("NULL pointer %p %p %p", pc, min, max);
6507 return CAMERA_ERROR_INVALID_PARAMETER;
6512 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6514 if (ret == CAMERA_ERROR_NONE) {
6515 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6516 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6519 LOGD("ret : 0x%x", ret);
6525 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6527 int ret = CAMERA_ERROR_NONE;
6528 camera_cli_s *pc = (camera_cli_s *)camera;
6529 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6530 camera_msg_param param;
6531 int set_ptz_type = (int)ptz_type;
6533 if (!pc || !pc->cb_info) {
6534 LOGE("NULL handle");
6535 return CAMERA_ERROR_INVALID_PARAMETER;
6540 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6542 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6544 LOGD("ret : 0x%x", ret);
6550 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6552 int ret = CAMERA_ERROR_NONE;
6553 camera_cli_s *pc = (camera_cli_s *)camera;
6554 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6556 if (!pc || !pc->cb_info || !foreach_cb) {
6557 LOGE("NULL pointer %p %p", pc, foreach_cb);
6558 return CAMERA_ERROR_INVALID_PARAMETER;
6563 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6564 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6566 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6568 LOGD("ret : 0x%x", ret);
6574 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6576 int ret = CAMERA_ERROR_NONE;
6577 camera_cli_s *pc = (camera_cli_s *)camera;
6578 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6579 int set_display_roi_area[4] = {x, y, width, height};
6584 if (!pc || !pc->cb_info) {
6585 LOGE("NULL handle");
6586 return CAMERA_ERROR_INVALID_PARAMETER;
6591 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6592 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6593 if (ret != MM_ERROR_NONE) {
6594 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6595 return CAMERA_ERROR_INVALID_OPERATION;
6599 length = sizeof(set_display_roi_area) / sizeof(int) + \
6600 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6602 msg = muse_core_msg_new(api,
6603 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6606 LOGE("msg creation failed: api %d", api);
6607 return CAMERA_ERROR_OUT_OF_MEMORY;
6610 if (pc->cb_info->is_server_connected) {
6611 __camera_update_api_waiting(pc->cb_info, api, 1);
6613 g_mutex_lock(&pc->cb_info->fd_lock);
6614 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6615 g_mutex_unlock(&pc->cb_info->fd_lock);
6619 LOGE("message send failed");
6620 ret = CAMERA_ERROR_INVALID_OPERATION;
6622 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6625 __camera_update_api_waiting(pc->cb_info, api, -1);
6627 muse_core_msg_free(msg);
6629 LOGD("ret : 0x%x", ret);
6635 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6637 camera_cli_s *pc = (camera_cli_s *)camera;
6638 int ret = CAMERA_ERROR_NONE;
6639 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6641 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6642 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6643 return CAMERA_ERROR_INVALID_PARAMETER;
6648 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6650 if (ret == CAMERA_ERROR_NONE) {
6651 *x = pc->cb_info->get_display_roi_area[0];
6652 *y = pc->cb_info->get_display_roi_area[1];
6653 *width = pc->cb_info->get_display_roi_area[2];
6654 *height = pc->cb_info->get_display_roi_area[3];
6657 LOGD("ret : 0x%x", ret);
6663 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6665 int ret = CAMERA_ERROR_NONE;
6666 int get_device_state = 0;
6669 LOGE("NULL pointer");
6670 return CAMERA_ERROR_INVALID_PARAMETER;
6673 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6674 (int)device, "get_device_state", &get_device_state);
6676 if (ret == CAMERA_ERROR_NONE) {
6677 *state = (camera_device_state_e)get_device_state;
6678 LOGD("device state %d", *state);
6680 LOGE("failed 0x%x", ret);
6687 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6689 int ret = CAMERA_ERROR_NONE;
6690 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6691 camera_cb_info *info = NULL;
6693 if (!callback || !cb_id) {
6694 LOGE("invalid pointer %p %p", callback, cb_id);
6695 return CAMERA_ERROR_INVALID_PARAMETER;
6698 /* check camera support */
6699 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6700 if (ret != CAMERA_ERROR_NONE) {
6701 LOGE("get device state failed");
6705 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6707 info = g_new0(camera_cb_info, 1);
6709 LOGE("info failed");
6710 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6714 info->id = ++g_cam_dev_state_changed_cb_id;
6715 info->callback = (void *)callback;
6716 info->user_data = user_data;
6720 /* subscribe dbus signal for camera state change */
6721 if (!g_cam_dev_state_changed_cb_conn) {
6722 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6723 if (!g_cam_dev_state_changed_cb_conn) {
6724 LOGE("failed to get gdbus connection");
6725 ret = CAMERA_ERROR_INVALID_OPERATION;
6729 LOGD("subscribe signal %s - %s - %s",
6730 MM_CAMCORDER_DBUS_OBJECT,
6731 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6732 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6734 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6735 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6736 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6737 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6738 LOGE("failed to get gdbus connection");
6739 ret = CAMERA_ERROR_INVALID_OPERATION;
6743 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6746 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6748 LOGD("callback id %d", info->id);
6751 if (ret != CAMERA_ERROR_NONE) {
6757 if (g_cam_dev_state_changed_cb_conn) {
6758 g_object_unref(g_cam_dev_state_changed_cb_conn);
6759 g_cam_dev_state_changed_cb_conn = NULL;
6763 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6769 int camera_remove_device_state_changed_cb(int cb_id)
6771 int ret = CAMERA_ERROR_NONE;
6772 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6773 GList *tmp_list = NULL;
6774 camera_cb_info *info = NULL;
6776 /* check camera support */
6777 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6778 if (ret != CAMERA_ERROR_NONE) {
6779 LOGE("get device state failed");
6783 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6785 if (!g_cam_dev_state_changed_cb_list) {
6786 LOGE("there is no callback info");
6787 ret = CAMERA_ERROR_INVALID_OPERATION;
6791 tmp_list = g_cam_dev_state_changed_cb_list;
6794 info = tmp_list->data;
6795 tmp_list = tmp_list->next;
6802 if (info->id == cb_id) {
6803 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6808 if (!g_cam_dev_state_changed_cb_list) {
6809 /* no remained callback */
6810 if (g_cam_dev_state_changed_cb_conn) {
6811 /* unsubscribe signal */
6812 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6813 g_cam_dev_state_changed_cb_subscribe_id = 0;
6815 /* unref connection */
6816 g_object_unref(g_cam_dev_state_changed_cb_conn);
6817 g_cam_dev_state_changed_cb_conn = NULL;
6821 LOGD("id %d callback removed", cb_id);
6822 ret = CAMERA_ERROR_NONE;
6828 LOGE("id %d callback not found", cb_id);
6829 ret = CAMERA_ERROR_INVALID_PARAMETER;
6832 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);