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;
896 case MM_PIXEL_FORMAT_NV16:
897 *out_format = TBM_FORMAT_NV16;
899 case MM_PIXEL_FORMAT_NV21:
900 *out_format = TBM_FORMAT_NV21;
902 case MM_PIXEL_FORMAT_YUYV:
903 *out_format = TBM_FORMAT_YUYV;
905 case MM_PIXEL_FORMAT_UYVY:
906 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
907 *out_format = TBM_FORMAT_UYVY;
909 case MM_PIXEL_FORMAT_422P:
910 *out_format = TBM_FORMAT_YUV422;
912 case MM_PIXEL_FORMAT_I420:
913 *out_format = TBM_FORMAT_YUV420;
915 case MM_PIXEL_FORMAT_YV12:
916 *out_format = TBM_FORMAT_YVU420;
918 case MM_PIXEL_FORMAT_RGB565:
919 *out_format = TBM_FORMAT_RGB565;
921 case MM_PIXEL_FORMAT_RGB888:
922 *out_format = TBM_FORMAT_RGB888;
924 case MM_PIXEL_FORMAT_RGBA:
925 *out_format = TBM_FORMAT_RGBA8888;
927 case MM_PIXEL_FORMAT_ARGB:
928 *out_format = TBM_FORMAT_ARGB8888;
931 LOGE("invalid in_format %d", in_format);
932 return CAMERA_ERROR_INVALID_PARAMETER;
936 return CAMERA_ERROR_NONE;
940 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
942 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
943 in_format >= MM_PIXEL_FORMAT_NUM ||
945 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
946 return CAMERA_ERROR_INVALID_PARAMETER;
950 case MM_PIXEL_FORMAT_NV12:
951 case MM_PIXEL_FORMAT_NV12T:
952 *mimetype = MEDIA_FORMAT_NV12;
955 case MM_PIXEL_FORMAT_NV16:
956 *mimetype = MEDIA_FORMAT_NV16;
958 case MM_PIXEL_FORMAT_NV21:
959 *mimetype = MEDIA_FORMAT_NV21;
961 case MM_PIXEL_FORMAT_YUYV:
962 *mimetype = MEDIA_FORMAT_YUYV;
964 case MM_PIXEL_FORMAT_UYVY:
965 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
966 *mimetype = MEDIA_FORMAT_UYVY;
968 case MM_PIXEL_FORMAT_422P:
969 *mimetype = MEDIA_FORMAT_422P;
971 case MM_PIXEL_FORMAT_I420:
972 *mimetype = MEDIA_FORMAT_I420;
974 case MM_PIXEL_FORMAT_YV12:
975 *mimetype = MEDIA_FORMAT_YV12;
977 case MM_PIXEL_FORMAT_RGB565:
978 *mimetype = MEDIA_FORMAT_RGB565;
980 case MM_PIXEL_FORMAT_RGB888:
981 *mimetype = MEDIA_FORMAT_RGB888;
983 case MM_PIXEL_FORMAT_RGBA:
984 *mimetype = MEDIA_FORMAT_RGBA;
986 case MM_PIXEL_FORMAT_ARGB:
987 *mimetype = MEDIA_FORMAT_ARGB;
990 LOGE("invalid in_format %d", in_format);
991 return CAMERA_ERROR_INVALID_PARAMETER;
995 return CAMERA_ERROR_NONE;
998 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
999 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1002 unsigned char *buf_pos = NULL;
1004 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1005 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1009 /* set frame info */
1010 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1011 frame->format = MM_PIXEL_FORMAT_UYVY;
1013 frame->format = stream->format;
1015 frame->width = stream->width;
1016 frame->height = stream->height;
1017 frame->timestamp = stream->timestamp;
1018 frame->num_of_planes = stream->num_planes;
1020 if (num_buffer_fd == 0) {
1023 if (!data_bo_handle || !data_bo_handle->ptr) {
1024 LOGE("NULL pointer");
1028 buf_pos = data_bo_handle->ptr;
1030 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1031 frame->data.encoded_plane.data = buf_pos;
1032 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1033 total_size = stream->data.encoded.length_data;
1034 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1035 frame->data.depth_plane.data = buf_pos;
1036 frame->data.depth_plane.size = stream->data.depth.length_data;
1037 total_size = stream->data.depth.length_data;
1038 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1039 stream->format == MM_PIXEL_FORMAT_ARGB) {
1040 frame->data.rgb_plane.data = buf_pos;
1041 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1042 total_size = stream->data.rgb.length_data;
1044 switch (stream->num_planes) {
1046 frame->data.single_plane.yuv = buf_pos;
1047 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1048 total_size = stream->data.yuv420.length_yuv;
1051 frame->data.double_plane.y = buf_pos;
1052 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1053 buf_pos += stream->data.yuv420sp.length_y;
1054 frame->data.double_plane.uv = buf_pos;
1055 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1056 total_size = stream->data.yuv420sp.length_y + \
1057 stream->data.yuv420sp.length_uv;
1060 frame->data.triple_plane.y = buf_pos;
1061 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1062 buf_pos += stream->data.yuv420p.length_y;
1063 frame->data.triple_plane.u = buf_pos;
1064 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1065 buf_pos += stream->data.yuv420p.length_u;
1066 frame->data.triple_plane.v = buf_pos;
1067 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1068 total_size = stream->data.yuv420p.length_y + \
1069 stream->data.yuv420p.length_u + \
1070 stream->data.yuv420p.length_v;
1079 switch (stream->num_planes) {
1082 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1083 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1084 total_size = stream->data.yuv420.length_yuv;
1088 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1089 if (stream->num_planes == (unsigned int)num_buffer_fd)
1090 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1092 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1093 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1094 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1095 total_size = stream->data.yuv420sp.length_y + \
1096 stream->data.yuv420sp.length_uv;
1100 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1101 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1102 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1103 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1105 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1106 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1108 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1109 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1110 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1111 total_size = stream->data.yuv420p.length_y + \
1112 stream->data.yuv420p.length_u + \
1113 stream->data.yuv420p.length_v;
1122 LOGD("format %d, %dx%d, size %d plane num %d",
1123 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1129 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1130 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1133 int ret = CAMERA_ERROR_NONE;
1134 camera_media_packet_data *tmp_mp_data = NULL;
1138 return CAMERA_ERROR_INVALID_PARAMETER;
1141 if (*mp_data == NULL) {
1142 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1144 tmp_mp_data->ret_fd = ret_fd;
1145 tmp_mp_data->fd = tfd[0];
1146 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1147 tmp_mp_data->bo = bo;
1151 tmp_mp_data->data_bo = data_bo;
1152 tmp_mp_data->data_fd = tfd[1];
1155 for (i = 0 ; i < num_buffer_fd ; i++) {
1156 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1157 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1161 tmp_mp_data->ref_cnt++;
1163 *mp_data = tmp_mp_data;
1164 /*LOGD("mp_data %p", tmp_mp_data);*/
1166 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1167 LOGE("failed to alloc media packet data");
1170 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1176 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1180 if (!mp_data || !cb_info) {
1181 LOGE("NULL pointer %p %p", mp_data, cb_info);
1185 if (mp_data->ref_cnt > 1) {
1187 LOGD("ref count %d", mp_data->ref_cnt);
1189 /* release imported bo and close imported fd */
1190 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1191 tbm_bo_unref(mp_data->buffer_bo[i]);
1192 mp_data->buffer_bo[i] = NULL;
1194 close(mp_data->buffer_fd[i]);
1195 mp_data->buffer_fd[i] = -1;
1198 /* unref tbm bo and close imported fd */
1201 _camera_release_imported_bo(&mp_data->bo);
1203 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1204 close(mp_data->data_fd);
1205 mp_data->data_fd = -1;
1207 _camera_release_imported_bo(&mp_data->data_bo);
1210 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1219 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1220 camera_media_packet_data *mp_data, media_packet_h *packet)
1222 media_packet_h pkt = NULL;
1223 bool make_pkt_fmt = false;
1224 tbm_surface_h tsurf = NULL;
1225 tbm_surface_info_s tsurf_info;
1226 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1227 uint32_t bo_format = 0;
1230 int num_buffer_fd = 0;
1231 tbm_bo *buffer_bo = NULL;
1233 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1234 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1235 cb_info, stream, mp_data, packet);
1236 return CAMERA_ERROR_INVALID_PARAMETER;
1239 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1240 buffer_bo = mp_data->buffer_bo;
1241 num_buffer_fd = mp_data->num_buffer_fd;
1243 /* create tbm surface */
1244 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1245 tsurf_info.planes[i].stride = stream->stride[i];
1247 /* get tbm surface format */
1248 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1249 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1251 if (ret == CAMERA_ERROR_NONE) {
1252 tsurf_info.width = stream->width;
1253 tsurf_info.height = stream->height;
1254 tsurf_info.format = bo_format;
1255 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1256 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1258 if (num_buffer_fd > 0) {
1259 switch (bo_format) {
1260 case TBM_FORMAT_NV12:
1261 case TBM_FORMAT_NV21:
1262 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1263 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
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.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1270 case TBM_FORMAT_YUV420:
1271 case TBM_FORMAT_YVU420:
1272 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1273 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1274 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1275 tsurf_info.planes[0].offset = 0;
1276 if (num_buffer_fd == 1) {
1277 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1278 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1280 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1282 case TBM_FORMAT_UYVY:
1283 case TBM_FORMAT_YUYV:
1284 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1285 tsurf_info.planes[0].offset = 0;
1286 tsurf_info.size = tsurf_info.planes[0].size;
1293 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1294 } else if (mp_data->data_bo) {
1296 switch (bo_format) {
1297 case TBM_FORMAT_NV12:
1298 case TBM_FORMAT_NV21:
1299 tsurf_info.planes[0].size = stream->width * stream->height;
1300 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1301 tsurf_info.planes[0].offset = 0;
1302 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1303 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1305 case TBM_FORMAT_YUV420:
1306 case TBM_FORMAT_YVU420:
1307 tsurf_info.planes[0].size = stream->width * stream->height;
1308 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1309 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1310 tsurf_info.planes[0].offset = 0;
1311 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1312 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1313 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1315 case TBM_FORMAT_UYVY:
1316 case TBM_FORMAT_YUYV:
1317 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1318 tsurf_info.planes[0].offset = 0;
1319 tsurf_info.size = tsurf_info.planes[0].size;
1325 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1328 /*LOGD("tbm surface %p", tsurf);*/
1332 /* check media packet format */
1333 if (cb_info->pkt_fmt) {
1334 int pkt_fmt_width = 0;
1335 int pkt_fmt_height = 0;
1336 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1338 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1339 if (pkt_fmt_mimetype != mimetype ||
1340 pkt_fmt_width != stream->width ||
1341 pkt_fmt_height != stream->height) {
1342 LOGW("change fmt: current 0x%x, %dx%d",
1343 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1344 media_format_unref(cb_info->pkt_fmt);
1345 cb_info->pkt_fmt = NULL;
1346 make_pkt_fmt = true;
1349 make_pkt_fmt = true;
1352 /* create packet format */
1354 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1355 ret = media_format_create(&cb_info->pkt_fmt);
1356 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1357 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1358 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1359 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1360 LOGW("media_format_set : 0x%x", ret);
1362 LOGW("media_format_create failed 0x%x", ret);
1366 /* create media packet */
1367 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1368 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1369 (void *)cb_info, &pkt);
1370 if (ret != MEDIA_PACKET_ERROR_NONE) {
1371 LOGE("media_packet_create failed 0x%x", ret);
1372 tbm_surface_destroy(tsurf);
1376 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1377 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1381 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1382 /* set media packet data */
1383 ret = media_packet_set_extra(pkt, (void *)mp_data);
1384 if (ret != MEDIA_PACKET_ERROR_NONE) {
1385 LOGE("media_packet_set_extra failed");
1387 _camera_media_packet_data_release(mp_data, cb_info);
1390 media_packet_destroy(pkt);
1393 /* set timestamp : msec -> nsec */
1394 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1395 LOGW("media_packet_set_pts failed");
1404 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1407 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1408 camera_media_packet_data *mp_data = NULL;
1409 tbm_surface_h tsurf = NULL;
1411 if (!pkt || !cb_info) {
1412 LOGE("NULL pointer %p %p", pkt, cb_info);
1413 return MEDIA_PACKET_FINALIZE;
1416 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1417 if (ret != MEDIA_PACKET_ERROR_NONE) {
1418 LOGE("media_packet_get_extra failed 0x%x", ret);
1419 return MEDIA_PACKET_FINALIZE;
1422 /*LOGD("mp_data %p", mp_data);*/
1424 g_mutex_lock(&cb_info->mp_data_mutex);
1426 _camera_media_packet_data_release(mp_data, cb_info);
1429 g_mutex_unlock(&cb_info->mp_data_mutex);
1431 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1432 if (ret != MEDIA_PACKET_ERROR_NONE)
1433 LOGE("get tbm_surface failed 0x%x", ret);
1436 tbm_surface_destroy(tsurf);
1440 return MEDIA_PACKET_FINALIZE;
1443 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1448 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1449 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1453 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1455 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1457 if (cb_info->user_cb[event] == NULL) {
1458 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1459 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1460 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1461 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1462 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1463 LOGW("NULL callback for event %d, return here", event);
1467 /* return buffer message should be sent for some events.
1468 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1469 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1470 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1471 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1476 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1482 muse_camera_msg_get(previous, recv_msg);
1483 muse_camera_msg_get(current, recv_msg);
1484 muse_camera_msg_get(by_policy, recv_msg);
1486 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1487 previous, current, by_policy);
1489 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1490 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1493 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1497 muse_camera_msg_get(state, recv_msg);
1499 LOGD("FOCUS state - %d", state);
1501 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1504 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1505 LOGD("CAPTURE_COMPLETED");
1506 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1508 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1509 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1510 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1513 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1517 muse_camera_msg_get(percent, recv_msg);
1519 LOGD("HDR progress - %d %%", percent);
1521 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1524 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1530 muse_camera_msg_get(policy, recv_msg);
1531 muse_camera_msg_get(previous, recv_msg);
1532 muse_camera_msg_get(current, recv_msg);
1534 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1536 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1537 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1540 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1545 muse_camera_msg_get(policy, recv_msg);
1546 muse_camera_msg_get(state, recv_msg);
1548 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1550 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1551 (camera_state_e)state, cb_info->user_data[event]);
1554 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1555 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1557 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1560 int current_state = 0;
1562 muse_camera_msg_get(error, recv_msg);
1563 muse_camera_msg_get(current_state, recv_msg);
1565 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1567 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1568 (camera_state_e)current_state, cb_info->user_data[event]);
1572 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1574 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1575 muse_camera_msg_get(param1, recv_msg);
1576 muse_camera_msg_get(param2, recv_msg);
1578 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1580 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1581 cb_info->user_cb[event] = NULL;
1582 cb_info->user_data[event] = NULL;
1583 LOGW("stop foreach callback for event %d", event);
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1604 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1606 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1608 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1610 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1613 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1615 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1616 muse_camera_msg_get(param1, recv_msg);
1618 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1620 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1621 cb_info->user_cb[event] = NULL;
1622 cb_info->user_data[event] = NULL;
1623 LOGW("stop foreach callback for event %d", event);
1627 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1628 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1631 LOGW("unhandled event %d", event);
1635 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1640 static gboolean _camera_idle_event_callback(gpointer data)
1642 camera_cb_info_s *cb_info = NULL;
1643 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1645 if (cam_idle_event == NULL) {
1646 LOGE("cam_idle_event is NULL");
1651 g_mutex_lock(&g_cam_idle_event_lock);
1653 cb_info = cam_idle_event->cb_info;
1654 if (cb_info == NULL) {
1655 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1656 g_mutex_unlock(&g_cam_idle_event_lock);
1657 goto IDLE_EVENT_CALLBACK_DONE;
1660 /* remove event from list */
1661 if (cb_info->idle_event_list)
1662 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1664 g_mutex_unlock(&g_cam_idle_event_lock);
1667 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1669 IDLE_EVENT_CALLBACK_DONE:
1671 g_free(cam_idle_event);
1672 cam_idle_event = NULL;
1677 static gpointer _camera_msg_handler_func(gpointer data)
1681 camera_message_s *cam_msg = NULL;
1682 camera_idle_event_s *cam_idle_event = NULL;
1683 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1684 camera_cb_info_s *cb_info = NULL;
1686 if (!handler_info || !handler_info->cb_info) {
1687 LOGE("NULL handler %p", handler_info);
1691 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1692 type = handler_info->type;
1694 LOGD("t:%d start", type);
1696 g_mutex_lock(&handler_info->mutex);
1698 while (g_atomic_int_get(&handler_info->running)) {
1699 if (g_queue_is_empty(handler_info->queue)) {
1700 /*LOGD("t:%d signal wait...", type);*/
1701 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1702 /*LOGD("t:%d signal received", type);*/
1704 if (g_atomic_int_get(&handler_info->running) == 0) {
1705 LOGD("t:%d stop event thread", type);
1710 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1712 g_mutex_unlock(&handler_info->mutex);
1714 if (cam_msg == NULL) {
1715 LOGE("t:%d NULL message", type);
1716 g_mutex_lock(&handler_info->mutex);
1722 if (api < MUSE_CAMERA_API_MAX) {
1725 g_mutex_lock(&cb_info->api_mutex[api]);
1727 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1728 if (cb_info->api_waiting[api] > 0) {
1729 cb_info->api_ret[api] = ret;
1730 cb_info->api_activating[api] = 1;
1732 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1734 g_cond_signal(&cb_info->api_cond[api]);
1736 LOGW("no waiting for this api [%d]", api);
1739 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1742 g_mutex_unlock(&cb_info->api_mutex[api]);
1743 } else if (api == MUSE_CAMERA_CB_EVENT) {
1744 switch (cam_msg->event_class) {
1745 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1746 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1748 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1749 cam_idle_event = g_new0(camera_idle_event_s, 1);
1750 if (cam_idle_event == NULL) {
1751 LOGE("t:%d cam_idle_event alloc failed", type);
1755 cam_idle_event->event = cam_msg->event;
1756 cam_idle_event->cb_info = cb_info;
1758 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1759 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1761 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1763 g_mutex_lock(&g_cam_idle_event_lock);
1764 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1765 g_mutex_unlock(&g_cam_idle_event_lock);
1767 g_idle_add_full(G_PRIORITY_DEFAULT,
1768 (GSourceFunc)_camera_idle_event_callback,
1769 (gpointer)cam_idle_event,
1773 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1777 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1783 g_mutex_lock(&handler_info->mutex);
1786 /* remove remained event */
1787 while (!g_queue_is_empty(handler_info->queue)) {
1788 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1790 LOGD("t:%d remove camera message %p", type, cam_msg);
1794 LOGW("t:%d NULL camera message", type);
1798 g_mutex_unlock(&handler_info->mutex);
1800 LOGD("t:%d return", type);
1806 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1808 camera_idle_event_s *cam_idle_event = NULL;
1811 if (cb_info == NULL) {
1812 LOGE("cb_info is NULL");
1816 g_mutex_lock(&g_cam_idle_event_lock);
1818 if (cb_info->idle_event_list == NULL) {
1819 LOGD("No remained idle event");
1820 g_mutex_unlock(&g_cam_idle_event_lock);
1824 list = cb_info->idle_event_list;
1827 cam_idle_event = list->data;
1828 list = g_list_next(list);
1830 if (!cam_idle_event) {
1831 LOGW("Fail to remove idle event. The event is NULL");
1835 if (g_idle_remove_by_data(cam_idle_event)) {
1836 LOGW("remove idle event %p done", cam_idle_event);
1838 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1840 g_free(cam_idle_event);
1841 cam_idle_event = NULL;
1846 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1847 cam_idle_event, cam_idle_event->event);
1849 cam_idle_event->cb_info = NULL;
1851 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1854 g_list_free(cb_info->idle_event_list);
1855 cb_info->idle_event_list = NULL;
1857 g_mutex_unlock(&g_cam_idle_event_lock);
1863 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1865 camera_message_s *cam_msg = NULL;
1867 if (!cb_info || !msg) {
1868 LOGE("NULL pointer %p %p", cb_info, msg);
1872 cam_msg = g_new0(camera_message_s, 1);
1874 LOGE("failed to alloc cam_msg for [%s]", msg);
1879 cam_msg->event = event;
1880 cam_msg->event_class = event_class;
1882 if (tfd && tfd[0] >= 0)
1883 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1885 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1887 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1889 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1890 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1891 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1892 g_cond_signal(&cb_info->preview_cb_info.cond);
1893 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1894 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1895 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1896 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1897 g_cond_signal(&cb_info->capture_cb_info.cond);
1898 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1900 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1901 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1902 g_cond_signal(&cb_info->msg_handler_info.cond);
1903 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1912 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1914 int ret = CAMERA_ERROR_NONE;
1918 int event_class = -1;
1922 if (!cb_info || !msg) {
1923 LOGE("invalid ptr %p %p", cb_info, msg);
1927 /*LOGD("msg [%s]", msg);*/
1929 if (!muse_camera_msg_get(api, msg)) {
1930 LOGE("failed to get camera api");
1934 if (api == MUSE_CAMERA_CB_EVENT) {
1935 if (!muse_camera_msg_get(event, msg) ||
1936 !muse_camera_msg_get(event_class, msg)) {
1937 LOGE("failed to get camera event or event_class [%s]", msg);
1941 if (!muse_camera_msg_get(api_class, msg)) {
1942 LOGE("failed to get camera api_class [%s]", msg);
1947 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1948 if (api >= MUSE_CAMERA_API_MAX) {
1949 LOGE("invalid api %d", api);
1953 if (!muse_camera_msg_get(ret, msg)) {
1954 LOGE("failed to get camera ret");
1958 g_mutex_lock(&cb_info->api_mutex[api]);
1961 case MUSE_CAMERA_API_CREATE:
1962 if (ret != CAMERA_ERROR_NONE) {
1963 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1964 LOGE("camera create error 0x%x. close client cb handler", ret);
1967 case MUSE_CAMERA_API_DESTROY:
1968 if (ret == CAMERA_ERROR_NONE) {
1969 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1970 LOGD("camera destroy done. close client cb handler");
1974 muse_camera_msg_get(get_type, msg);
1975 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1976 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1977 muse_camera_msg_get(get_index, msg);
1980 case MUSE_CAMERA_GET_TYPE_INT:
1981 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1983 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1984 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1985 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1987 case MUSE_CAMERA_GET_TYPE_ARRAY:
1988 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1989 muse_core_msg_deserialize("get_value",
1990 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1991 LOGD("get display roi %d,%d,%dx%d",
1992 cb_info->get_display_roi_area[0],
1993 cb_info->get_display_roi_area[1],
1994 cb_info->get_display_roi_area[2],
1995 cb_info->get_display_roi_area[3]);
1997 muse_core_msg_deserialize("get_value",
1998 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1999 LOGD("get geotag %lf, %lf, %lf",
2000 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2003 case MUSE_CAMERA_GET_TYPE_STRING:
2004 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2007 LOGW("unknown type %d", get_type);
2014 if (cb_info->api_waiting[api] > 0) {
2015 cb_info->api_ret[api] = ret;
2016 cb_info->api_activating[api] = 1;
2018 g_cond_signal(&cb_info->api_cond[api]);
2020 LOGW("no waiting for this api [%d]", api);
2023 g_mutex_unlock(&cb_info->api_mutex[api]);
2024 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2025 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2027 LOGW("unknown camera api %d, class %d", api, api_class);
2034 static gpointer _camera_msg_recv_func(gpointer data)
2037 int recv_length = 0;
2038 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2039 char *recv_msg = NULL;
2040 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2043 LOGE("cb_info NULL");
2047 LOGD("start - fd : %d", cb_info->fd);
2049 recv_msg = cb_info->recv_msg;
2051 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2052 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2055 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2056 if (recv_length <= 0) {
2057 cb_info->is_server_connected = FALSE;
2058 LOGE("receive msg failed - server disconnected");
2064 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2067 recv_msg[recv_length] = '\0';
2069 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2071 __camera_process_msg(cb_info, recv_msg, tfd);
2074 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2076 if (!cb_info->is_server_connected) {
2077 char *error_msg = NULL;
2079 if (cb_info->bufmgr == NULL) {
2080 LOGE("No need to send error(handle is not created)");
2084 if (cb_info->fd < 0) {
2085 LOGE("fd is closed in client side");
2089 /* send error msg for server disconnection */
2090 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2091 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2092 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2096 LOGE("error_msg failed");
2100 __camera_add_msg_to_queue(cb_info,
2101 MUSE_CAMERA_CB_EVENT,
2102 MUSE_CAMERA_EVENT_TYPE_ERROR,
2103 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2107 muse_core_msg_free(error_msg);
2110 LOGE("add error msg for service disconnection done");
2117 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2118 int type, const char *thread_name, camera_cb_info_s *cb_info)
2120 if (!handler_info || !thread_name || !cb_info) {
2121 LOGE("t:%d NULL %p %p %p",
2122 type, handler_info, thread_name, cb_info);
2128 handler_info->type = type;
2129 handler_info->queue = g_queue_new();
2130 if (handler_info->queue == NULL) {
2131 LOGE("t:%d queue failed", type);
2135 g_mutex_init(&handler_info->mutex);
2136 g_cond_init(&handler_info->cond);
2138 handler_info->cb_info = (void *)cb_info;
2139 g_atomic_int_set(&handler_info->running, 1);
2141 handler_info->thread = g_thread_try_new(thread_name,
2142 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2143 if (handler_info->thread == NULL) {
2144 LOGE("t:%d thread failed", type);
2146 g_mutex_clear(&handler_info->mutex);
2147 g_cond_clear(&handler_info->cond);
2148 g_queue_free(handler_info->queue);
2149 handler_info->queue = NULL;
2154 LOGD("t:%d done", type);
2160 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2164 if (!handler_info) {
2165 LOGE("NULL handler");
2169 if (!handler_info->thread) {
2170 LOGW("thread is not created");
2174 type = handler_info->type;
2176 LOGD("t:%d thread %p", type, handler_info->thread);
2178 g_mutex_lock(&handler_info->mutex);
2179 g_atomic_int_set(&handler_info->running, 0);
2180 g_cond_signal(&handler_info->cond);
2181 g_mutex_unlock(&handler_info->mutex);
2183 g_thread_join(handler_info->thread);
2184 handler_info->thread = NULL;
2186 g_mutex_clear(&handler_info->mutex);
2187 g_cond_clear(&handler_info->cond);
2188 g_queue_free(handler_info->queue);
2189 handler_info->queue = NULL;
2191 LOGD("t:%d done", type);
2197 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2199 camera_cb_info_s *cb_info = NULL;
2202 g_return_val_if_fail(sockfd > 0, NULL);
2204 cb_info = g_new0(camera_cb_info_s, 1);
2205 if (cb_info == NULL) {
2206 LOGE("cb_info failed");
2210 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2212 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2213 g_mutex_init(&cb_info->api_mutex[i]);
2214 g_cond_init(&cb_info->api_cond[i]);
2217 g_mutex_init(&cb_info->fd_lock);
2218 g_mutex_init(&cb_info->mp_data_mutex);
2220 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2221 g_mutex_init(&cb_info->user_cb_mutex[i]);
2223 /* message handler thread */
2224 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2225 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2226 LOGE("msg_handler_info failed");
2230 /* message handler thread for preview callback */
2231 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2232 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2233 LOGE("preview_cb_info failed");
2237 /* message handler thread for capture callback */
2238 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2239 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2240 LOGE("capture_cb_info failed");
2244 cb_info->fd = sockfd;
2245 cb_info->preview_cb_flag = 0;
2247 /* message receive thread */
2248 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2249 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2250 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2251 if (cb_info->msg_recv_thread == NULL) {
2252 LOGE("message receive thread creation failed");
2257 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2258 cb_info->fds[i] = -1;
2260 cb_info->is_server_connected = TRUE;
2266 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2267 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2268 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2270 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2271 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2273 g_mutex_clear(&cb_info->fd_lock);
2274 g_mutex_clear(&cb_info->mp_data_mutex);
2276 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2277 g_mutex_clear(&cb_info->api_mutex[i]);
2278 g_cond_clear(&cb_info->api_cond[i]);
2289 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2293 g_return_if_fail(cb_info != NULL);
2295 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2297 g_thread_join(cb_info->msg_recv_thread);
2298 cb_info->msg_recv_thread = NULL;
2300 LOGD("msg_recv thread removed");
2302 /* destroy msg handler threads */
2303 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2304 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2305 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2307 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2308 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2310 g_mutex_clear(&cb_info->fd_lock);
2311 g_mutex_clear(&cb_info->mp_data_mutex);
2313 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2314 g_mutex_clear(&cb_info->api_mutex[i]);
2315 g_cond_clear(&cb_info->api_cond[i]);
2318 if (cb_info->fd > -1) {
2319 muse_client_close(cb_info->fd);
2323 if (cb_info->bufmgr) {
2324 tbm_bufmgr_deinit(cb_info->bufmgr);
2325 cb_info->bufmgr = NULL;
2327 if (cb_info->pkt_fmt) {
2328 media_format_unref(cb_info->pkt_fmt);
2329 cb_info->pkt_fmt = NULL;
2332 if (cb_info->dp_interface) {
2333 mm_display_interface_deinit(cb_info->dp_interface);
2334 cb_info->dp_interface = NULL;
2337 cb_info->preview_cb_flag = 0;
2346 int _camera_start_evas_rendering(camera_h camera)
2348 camera_cli_s *pc = (camera_cli_s *)camera;
2350 if (!pc || !pc->cb_info) {
2351 LOGE("NULL handle");
2352 return CAMERA_ERROR_INVALID_PARAMETER;
2357 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2358 LOGE("EVAS surface is not set");
2359 return CAMERA_ERROR_NONE;
2362 /* set evas render flag as RUN */
2363 pc->cb_info->run_evas_render = true;
2365 return CAMERA_ERROR_NONE;
2369 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2371 int ret = CAMERA_ERROR_NONE;
2372 camera_cli_s *pc = (camera_cli_s *)camera;
2374 if (!pc || !pc->cb_info) {
2375 LOGE("NULL handle");
2376 return CAMERA_ERROR_INVALID_PARAMETER;
2379 LOGD("stop - keep screen %d", keep_screen);
2381 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2382 LOGE("EVAS surface is not set");
2383 return CAMERA_ERROR_NONE;
2386 /* set evas render flag as STOP and release buffers */
2387 pc->cb_info->run_evas_render = false;
2389 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2390 if (ret == MM_ERROR_NONE) {
2391 ret = CAMERA_ERROR_NONE;
2393 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2394 ret = CAMERA_ERROR_INVALID_OPERATION;
2401 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2403 int ret = CAMERA_ERROR_NONE;
2405 int module_index = -1;
2407 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2409 /* create muse connection */
2410 if (!key || !value) {
2411 LOGE("NULL pointer");
2412 return CAMERA_ERROR_INVALID_PARAMETER;
2415 sock_fd = muse_client_new();
2417 LOGE("muse_client_new failed");
2418 return CAMERA_ERROR_INVALID_OPERATION;
2421 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2422 LOGE("muse client get module index failed");
2423 ret = CAMERA_ERROR_INVALID_OPERATION;
2427 msg = muse_core_msg_new(api,
2428 MUSE_TYPE_INT, "module", module_index,
2429 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2433 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2437 ret = muse_core_msg_send(sock_fd, msg);
2439 muse_core_msg_free(msg);
2443 LOGE("send msg failed");
2444 ret = CAMERA_ERROR_INVALID_OPERATION;
2448 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2450 LOGE("recv msg failed %d", errno);
2451 ret = CAMERA_ERROR_INVALID_OPERATION;
2455 if (!muse_camera_msg_get(ret, recv_msg)) {
2456 LOGE("failed to get return value from msg [%s]", recv_msg);
2457 ret = CAMERA_ERROR_INVALID_OPERATION;
2461 if (ret == CAMERA_ERROR_NONE)
2462 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2464 LOGD("api %d - value %d", api, *value);
2468 muse_client_close(sock_fd);
2476 int camera_create(camera_device_e device, camera_h *camera)
2479 char *send_msg = NULL;
2481 int ret = CAMERA_ERROR_NONE;
2483 camera_cli_s *pc = NULL;
2484 tbm_bufmgr bufmgr = NULL;
2486 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2487 int module_index = -1;
2488 int device_type = (int)device;
2491 LOGE("NULL pointer");
2492 return CAMERA_ERROR_INVALID_PARAMETER;
2495 sock_fd = muse_client_new();
2497 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2498 ret = CAMERA_ERROR_INVALID_OPERATION;
2504 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2505 LOGE("muse client get module index failed");
2506 ret = CAMERA_ERROR_INVALID_OPERATION;
2510 send_msg = muse_core_msg_new(api,
2511 MUSE_TYPE_INT, "module", module_index,
2512 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2513 MUSE_TYPE_INT, "pid", pid,
2518 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2522 send_ret = muse_core_msg_send(sock_fd, send_msg);
2524 muse_core_msg_free(send_msg);
2528 LOGE("send msg failed %d", errno);
2529 ret = CAMERA_ERROR_INVALID_OPERATION;
2533 pc = g_new0(camera_cli_s, 1);
2535 LOGE("camera_cli_s alloc failed");
2536 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2540 bufmgr = tbm_bufmgr_init(-1);
2541 if (bufmgr == NULL) {
2542 LOGE("get tbm bufmgr failed");
2543 ret = CAMERA_ERROR_INVALID_OPERATION;
2547 pc->cb_info = _camera_client_callback_new(sock_fd);
2548 if (pc->cb_info == NULL) {
2549 LOGE("cb_info alloc failed");
2550 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2556 LOGD("cb info : %d", pc->cb_info->fd);
2558 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2560 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2562 if (ret == CAMERA_ERROR_NONE) {
2563 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2564 int user_buffer_supported = 0;
2565 intptr_t handle = 0;
2567 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2569 LOGE("Receiving Handle Failed!!");
2570 ret = CAMERA_ERROR_INVALID_OPERATION;
2574 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2575 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2577 pc->remote_handle = handle;
2578 pc->cb_info->bufmgr = bufmgr;
2579 pc->cb_info->preview_format = preview_format;
2580 pc->cb_info->dp_type = CAMERA_DISPLAY_TYPE_NONE;
2581 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2583 LOGD("default preview format %d, user buffer %d",
2584 preview_format, user_buffer_supported);
2586 *camera = (camera_h)pc;
2588 /* get display interface handle */
2589 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2590 LOGW("display interface init failed");
2599 tbm_bufmgr_deinit(bufmgr);
2604 muse_client_close(sock_fd);
2610 int temp_fd = pc->cb_info->fd;
2612 /* pc->cb_info->fd should be closed,
2613 because g_thread_join for msg_recv_thread is not returned
2614 in _camera_client_callback_destroy. */
2616 pc->cb_info->fd = -1;
2617 muse_client_close(temp_fd);
2620 _camera_client_callback_destroy(pc->cb_info);
2627 LOGE("camera create error : 0x%x", ret);
2634 int camera_change_device(camera_h camera, camera_device_e device)
2637 int ret = CAMERA_ERROR_NONE;
2638 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2639 camera_cli_s *pc = (camera_cli_s *)camera;
2640 camera_msg_param param;
2642 if (!pc || !pc->cb_info) {
2643 LOGE("NULL handle");
2644 return CAMERA_ERROR_INVALID_PARAMETER;
2647 CAMERA_MSG_PARAM_SET(param, INT, device);
2649 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2651 if (ret == CAMERA_ERROR_NONE) {
2652 /* reset callback and user data */
2653 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2654 pc->cb_info->user_cb[i] = NULL;
2655 pc->cb_info->user_data[i] = NULL;
2657 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2664 int camera_destroy(camera_h camera)
2666 int ret = CAMERA_ERROR_NONE;
2667 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2668 camera_cli_s *pc = (camera_cli_s *)camera;
2670 if (!pc || !pc->cb_info) {
2671 LOGE("NULL handle");
2672 return CAMERA_ERROR_INVALID_PARAMETER;
2677 if (pc->cb_info->is_server_connected)
2678 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2680 LOGW("server disconnected. release resource without send message.");
2682 if (ret == CAMERA_ERROR_NONE) {
2683 _camera_deactivate_idle_event_all(pc->cb_info);
2684 _camera_client_callback_destroy(pc->cb_info);
2691 LOGD("ret : 0x%x", ret);
2696 int camera_start_preview(camera_h camera)
2698 int ret = CAMERA_ERROR_NONE;
2699 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2700 camera_cli_s *pc = (camera_cli_s *)camera;
2701 camera_state_e current_state = CAMERA_STATE_NONE;
2703 if (!pc || !pc->cb_info) {
2704 LOGE("NULL handle");
2705 return CAMERA_ERROR_INVALID_PARAMETER;
2708 LOGD("Enter : preview format %d, display type %d",
2709 pc->cb_info->preview_format, pc->cb_info->dp_type);
2711 ret = camera_get_state(camera, ¤t_state);
2712 if (ret != CAMERA_ERROR_NONE) {
2713 LOGE("failed to get current state 0x%x", ret);
2717 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2718 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2719 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2720 pc->cb_info->dp_type);
2721 return CAMERA_ERROR_INVALID_OPERATION;
2724 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2725 if (!_camera_allocate_preview_buffer(camera))
2726 return CAMERA_ERROR_INVALID_OPERATION;
2728 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2730 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2733 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2734 ret = _camera_start_evas_rendering(camera);
2735 if (ret != CAMERA_ERROR_NONE) {
2736 LOGE("stop preview because of error");
2737 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2741 LOGD("ret : 0x%x", ret);
2747 int camera_stop_preview(camera_h camera)
2749 int ret = CAMERA_ERROR_NONE;
2750 camera_cli_s *pc = (camera_cli_s *)camera;
2751 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2752 camera_state_e current_state = CAMERA_STATE_NONE;
2754 if (!pc || !pc->cb_info) {
2755 LOGE("NULL handle");
2756 return CAMERA_ERROR_INVALID_PARAMETER;
2762 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2763 ret = camera_get_state(camera, ¤t_state);
2764 if (ret != CAMERA_ERROR_NONE) {
2765 LOGE("failed to get current state 0x%x", ret);
2769 if (current_state == CAMERA_STATE_PREVIEW) {
2770 ret = _camera_stop_evas_rendering(camera, false);
2771 if (ret != CAMERA_ERROR_NONE)
2776 /* send stop preview message */
2777 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2779 if (ret == CAMERA_ERROR_NONE) {
2780 if (pc->cb_info->user_buffer_supported)
2781 _camera_release_preview_buffer(camera);
2782 } else if (current_state == CAMERA_STATE_PREVIEW) {
2783 LOGW("restart evas rendering");
2784 _camera_start_evas_rendering(camera);
2787 LOGD("ret : 0x%x", ret);
2793 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2795 int ret = CAMERA_ERROR_NONE;
2796 camera_cli_s *pc = (camera_cli_s *)camera;
2797 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2799 if (!pc || !pc->cb_info) {
2800 LOGE("NULL handle");
2801 return CAMERA_ERROR_INVALID_PARAMETER;
2806 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2807 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2812 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2814 LOGD("ret : 0x%x", ret);
2820 bool camera_is_supported_continuous_capture(camera_h camera)
2822 int ret = CAMERA_ERROR_NONE;
2823 camera_cli_s *pc = (camera_cli_s *)camera;
2824 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2826 if (!pc || !pc->cb_info) {
2827 LOGE("NULL handle");
2828 return CAMERA_ERROR_INVALID_PARAMETER;
2833 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2836 LOGE("error is occurred 0x%x", ret);
2840 LOGD("ret : %d", ret);
2846 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)
2848 int ret = CAMERA_ERROR_NONE;
2849 camera_cli_s *pc = (camera_cli_s *)camera;
2850 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2851 camera_msg_param param;
2854 if (!pc || !pc->cb_info) {
2855 LOGE("NULL handle");
2856 return CAMERA_ERROR_INVALID_PARAMETER;
2861 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2862 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2867 value = (count << 16) | interval;
2868 CAMERA_MSG_PARAM_SET(param, INT, value);
2870 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2872 LOGD("ret : 0x%x", ret);
2878 int camera_stop_continuous_capture(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_STOP_CONTINUOUS_CAPTURE;
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);
2893 LOGD("ret : 0x%x", ret);
2899 bool camera_is_supported_face_detection(camera_h camera)
2901 int ret = CAMERA_ERROR_NONE;
2902 camera_cli_s *pc = (camera_cli_s *)camera;
2903 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2905 if (!pc || !pc->cb_info) {
2906 LOGE("NULL handle");
2907 return CAMERA_ERROR_INVALID_PARAMETER;
2912 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2915 LOGE("error is occurred 0x%x", ret);
2919 LOGD("ret : %d", ret);
2925 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2927 int ret = CAMERA_ERROR_NONE;
2928 camera_cli_s *pc = (camera_cli_s *)camera;
2929 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2931 if (!pc || !pc->cb_info) {
2932 LOGE("NULL handle");
2933 return CAMERA_ERROR_INVALID_PARAMETER;
2938 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2941 LOGE("error is occurred 0x%x", ret);
2945 LOGD("ret : %d", ret);
2951 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2953 int ret = CAMERA_ERROR_NONE;
2954 camera_cli_s *pc = (camera_cli_s *)camera;
2955 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2957 if (!pc || !pc->cb_info) {
2958 LOGE("NULL handle");
2959 return CAMERA_ERROR_INVALID_PARAMETER;
2964 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2967 LOGE("error is occurred 0x%x", ret);
2971 LOGD("ret : %d", ret);
2976 int camera_get_device_count(camera_h camera, int *device_count)
2978 int ret = CAMERA_ERROR_NONE;
2979 camera_cli_s *pc = (camera_cli_s *)camera;
2980 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2982 if (!pc || !pc->cb_info) {
2983 LOGE("NULL handle");
2984 return CAMERA_ERROR_INVALID_PARAMETER;
2989 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2991 if (ret == CAMERA_ERROR_NONE)
2992 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2994 LOGD("ret : 0x%x", ret);
2999 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3001 int ret = CAMERA_ERROR_NONE;
3002 camera_cli_s *pc = (camera_cli_s *)camera;
3003 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3005 if (!pc || !pc->cb_info) {
3006 LOGE("NULL handle");
3007 return CAMERA_ERROR_INVALID_PARAMETER;
3012 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3014 if (ret == CAMERA_ERROR_NONE) {
3015 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3017 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3018 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3020 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3023 LOGD("ret : 0x%x", ret);
3028 int camera_stop_face_detection(camera_h camera)
3030 int ret = CAMERA_ERROR_NONE;
3031 camera_cli_s *pc = (camera_cli_s *)camera;
3032 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3034 if (!pc || !pc->cb_info) {
3035 LOGE("NULL handle");
3036 return CAMERA_ERROR_INVALID_PARAMETER;
3041 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3043 if (ret == CAMERA_ERROR_NONE) {
3044 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3049 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3052 LOGD("ret : 0x%x", ret);
3057 int camera_get_state(camera_h camera, camera_state_e *state)
3059 int ret = CAMERA_ERROR_NONE;
3060 camera_cli_s *pc = (camera_cli_s *)camera;
3061 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3063 if (!pc || !pc->cb_info || !state) {
3064 LOGE("NULL pointer %p %p", pc, state);
3065 return CAMERA_ERROR_INVALID_PARAMETER;
3070 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3072 if (ret == CAMERA_ERROR_NONE)
3073 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3075 LOGD("ret : 0x%x", ret);
3080 int camera_start_focusing(camera_h camera, bool continuous)
3082 int ret = CAMERA_ERROR_NONE;
3083 camera_cli_s *pc = (camera_cli_s *)camera;
3084 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3085 camera_msg_param param;
3086 int is_continuous = (int)continuous;
3088 if (!pc || !pc->cb_info) {
3089 LOGE("NULL handle");
3090 return CAMERA_ERROR_INVALID_PARAMETER;
3095 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3097 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3099 LOGD("ret : 0x%x", ret);
3104 int camera_cancel_focusing(camera_h camera)
3106 int ret = CAMERA_ERROR_NONE;
3107 camera_cli_s *pc = (camera_cli_s *)camera;
3108 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3110 if (!pc || !pc->cb_info) {
3111 LOGE("NULL handle");
3112 return CAMERA_ERROR_INVALID_PARAMETER;
3115 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3117 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3119 LOGD("ret : 0x%x", ret);
3124 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3126 int ret = CAMERA_ERROR_NONE;
3128 camera_cli_s *pc = (camera_cli_s *)camera;
3129 camera_cb_info_s *cb_info = NULL;
3130 camera_state_e current_state = CAMERA_STATE_NONE;
3131 camera_msg_param param0;
3132 camera_msg_param param1;
3133 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3135 if (!pc || !pc->cb_info) {
3136 LOGE("NULL handle");
3137 return CAMERA_ERROR_INVALID_PARAMETER;
3140 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3141 LOGE("invalid type %d", type);
3142 return CAMERA_ERROR_INVALID_PARAMETER;
3145 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3146 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3147 return CAMERA_ERROR_INVALID_PARAMETER;
3150 cb_info = (camera_cb_info_s *)pc->cb_info;
3152 ret = camera_get_state(camera, ¤t_state);
3153 if (ret != CAMERA_ERROR_NONE) {
3154 LOGE("failed to get current state 0x%x", ret);
3158 if (current_state != CAMERA_STATE_CREATED) {
3159 LOGE("INVALID_STATE : current %d", current_state);
3160 return CAMERA_ERROR_INVALID_STATE;
3163 LOGD("Enter - type : %d, display : %p", type, display);
3165 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3166 /* check display interface handle */
3167 if (!cb_info->dp_interface) {
3168 LOGE("display interface not supported");
3169 return CAMERA_ERROR_NOT_SUPPORTED;
3172 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3173 if (ret != MM_ERROR_NONE) {
3174 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3175 return CAMERA_ERROR_INVALID_OPERATION;
3178 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3180 camera_flip_e flip = CAMERA_FLIP_NONE;
3181 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3182 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3189 camera_get_display_flip(camera, &flip);
3190 camera_get_display_mode(camera, &mode);
3191 camera_get_display_rotation(camera, &rotation);
3192 camera_is_display_visible(camera, &visible);
3193 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3195 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3196 flip, mode, rotation, visible, x, y, width, height);
3198 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3199 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3200 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3201 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3203 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3204 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3209 CAMERA_MSG_PARAM_SET(param0, INT, type);
3210 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3212 _camera_msg_send_param2_int(api, cb_info, &ret,
3213 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3215 if (ret == CAMERA_ERROR_NONE) {
3216 pc->cb_info->dp_type = type;
3218 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3219 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3226 int camera_set_preview_resolution(camera_h camera, int width, int height)
3228 int ret = CAMERA_ERROR_NONE;
3229 camera_state_e current_state = CAMERA_STATE_NONE;
3230 camera_cli_s *pc = (camera_cli_s *)camera;
3231 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3232 camera_msg_param param;
3235 if (!pc || !pc->cb_info) {
3236 LOGE("NULL handle");
3237 return CAMERA_ERROR_INVALID_PARAMETER;
3240 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3241 ret = camera_get_state(camera, ¤t_state);
3242 if (ret != CAMERA_ERROR_NONE) {
3243 LOGE("failed to get current state 0x%x", ret);
3247 if (current_state == CAMERA_STATE_PREVIEW) {
3248 ret = _camera_stop_evas_rendering(camera, true);
3249 if (ret != CAMERA_ERROR_NONE)
3254 value = (width << 16) | height;
3255 CAMERA_MSG_PARAM_SET(param, INT, value);
3257 LOGD("%dx%d -> 0x%x", width, height, value);
3259 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3261 LOGD("ret : 0x%x", ret);
3263 if (current_state == CAMERA_STATE_PREVIEW) {
3264 LOGW("restart evas rendering");
3265 _camera_start_evas_rendering(camera);
3272 int camera_set_capture_resolution(camera_h camera, int width, int height)
3274 int ret = CAMERA_ERROR_NONE;
3275 camera_cli_s *pc = (camera_cli_s *)camera;
3276 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3277 camera_msg_param param;
3280 if (!pc || !pc->cb_info) {
3281 LOGE("NULL handle");
3282 return CAMERA_ERROR_INVALID_PARAMETER;
3287 value = (width << 16) | height;
3288 CAMERA_MSG_PARAM_SET(param, INT, value);
3290 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3292 LOGD("ret : 0x%x", ret);
3298 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3300 int ret = CAMERA_ERROR_NONE;
3301 int set_format = (int)format;
3302 camera_cli_s *pc = (camera_cli_s *)camera;
3303 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3304 camera_msg_param param;
3306 if (!pc || !pc->cb_info) {
3307 LOGE("NULL handle");
3308 return CAMERA_ERROR_INVALID_PARAMETER;
3311 LOGD("Enter - format %d", set_format);
3313 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3315 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3317 LOGD("ret : 0x%x", ret);
3323 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3325 int ret = CAMERA_ERROR_NONE;
3326 int set_format = (int)format;
3327 camera_msg_param param;
3328 camera_cli_s *pc = (camera_cli_s *)camera;
3329 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3331 if (!pc || !pc->cb_info) {
3332 LOGE("NULL handle");
3333 return CAMERA_ERROR_INVALID_PARAMETER;
3336 LOGD("Enter - format %d", set_format);
3338 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3340 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3342 if (ret == CAMERA_ERROR_NONE)
3343 pc->cb_info->preview_format = set_format;
3345 LOGD("ret : 0x%x", ret);
3351 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3353 int ret = CAMERA_ERROR_NONE;
3354 camera_cli_s *pc = (camera_cli_s *)camera;
3355 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3357 if (!pc || !pc->cb_info || !width || !height) {
3358 LOGE("NULL pointer %p %p %p", pc, width, height);
3359 return CAMERA_ERROR_INVALID_PARAMETER;
3364 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3366 if (ret == CAMERA_ERROR_NONE) {
3367 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3368 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3371 LOGD("ret : 0x%x", ret);
3377 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3379 int ret = CAMERA_ERROR_NONE;
3380 int set_rotation = (int)rotation;
3381 camera_cli_s *pc = (camera_cli_s *)camera;
3382 camera_msg_param param;
3384 if (!pc || !pc->cb_info) {
3385 LOGE("NULL handle");
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3389 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3390 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3391 if (ret != MM_ERROR_NONE) {
3392 LOGE("failed to set rotation for evas surface 0x%x", ret);
3393 return CAMERA_ERROR_INVALID_OPERATION;
3397 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3399 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3405 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3407 int ret = CAMERA_ERROR_NONE;
3408 camera_cli_s *pc = (camera_cli_s *)camera;
3410 if (!pc || !pc->cb_info || !rotation) {
3411 LOGE("NULL pointer %p %p", pc, rotation);
3412 return CAMERA_ERROR_INVALID_PARAMETER;
3415 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3417 if (ret == CAMERA_ERROR_NONE)
3418 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3424 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3426 int ret = CAMERA_ERROR_NONE;
3427 int set_flip = (int)flip;
3428 camera_cli_s *pc = (camera_cli_s *)camera;
3429 camera_msg_param param;
3431 if (!pc || !pc->cb_info) {
3432 LOGE("NULL handle");
3433 return CAMERA_ERROR_INVALID_PARAMETER;
3436 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3437 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3438 if (ret != MM_ERROR_NONE) {
3439 LOGE("failed to set flip for evas surface 0x%x", ret);
3440 return CAMERA_ERROR_INVALID_OPERATION;
3444 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3446 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3452 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3454 int ret = CAMERA_ERROR_NONE;
3455 camera_cli_s *pc = (camera_cli_s *)camera;
3457 if (!pc || !pc->cb_info || !flip) {
3458 LOGE("NULL pointer %p %p", pc, flip);
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3464 if (ret == CAMERA_ERROR_NONE)
3465 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3471 int camera_set_display_visible(camera_h camera, bool visible)
3473 int ret = CAMERA_ERROR_NONE;
3474 int set_visible = (int)visible;
3475 camera_cli_s *pc = (camera_cli_s *)camera;
3476 camera_msg_param param;
3478 if (!pc || !pc->cb_info) {
3479 LOGE("NULL handle");
3480 return CAMERA_ERROR_INVALID_PARAMETER;
3483 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3484 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3485 if (ret != MM_ERROR_NONE) {
3486 LOGE("failed to set visible for evas surface 0x%x", ret);
3487 return CAMERA_ERROR_INVALID_OPERATION;
3491 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3493 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3499 int camera_is_display_visible(camera_h camera, bool *visible)
3501 int ret = CAMERA_ERROR_NONE;
3502 camera_cli_s *pc = (camera_cli_s *)camera;
3504 if (!pc || !pc->cb_info || !visible) {
3505 LOGE("NULL pointer %p %p", pc, visible);
3506 return CAMERA_ERROR_INVALID_PARAMETER;
3509 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3511 if (ret == CAMERA_ERROR_NONE)
3512 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3518 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3520 int ret = CAMERA_ERROR_NONE;
3521 int set_mode = (int)mode;
3522 camera_cli_s *pc = (camera_cli_s *)camera;
3523 camera_msg_param param;
3525 if (!pc || !pc->cb_info) {
3526 LOGE("NULL handle");
3527 return CAMERA_ERROR_INVALID_PARAMETER;
3530 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3531 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3532 if (ret != MM_ERROR_NONE) {
3533 LOGE("failed to set geometry for evas surface 0x%x", ret);
3534 return CAMERA_ERROR_INVALID_OPERATION;
3538 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3540 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3546 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3548 int ret = CAMERA_ERROR_NONE;
3549 camera_cli_s *pc = (camera_cli_s *)camera;
3551 if (!pc || !pc->cb_info || !mode) {
3552 LOGE("NULL pointer %p %p", pc, mode);
3553 return CAMERA_ERROR_INVALID_PARAMETER;
3556 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3558 if (ret == CAMERA_ERROR_NONE)
3559 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3565 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3567 int ret = CAMERA_ERROR_NONE;
3568 int set_hint = (int)hint;
3569 camera_cli_s *pc = (camera_cli_s *)camera;
3570 camera_msg_param param;
3572 if (!pc || !pc->cb_info) {
3573 LOGE("NULL handle");
3574 return CAMERA_ERROR_INVALID_PARAMETER;
3577 LOGD("Enter - hint %d", set_hint);
3579 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3581 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3587 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3589 int ret = CAMERA_ERROR_NONE;
3590 camera_cli_s *pc = (camera_cli_s *)camera;
3591 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3593 if (!pc || !pc->cb_info || !hint) {
3594 LOGE("NULL pointer %p %p", pc, hint);
3595 return CAMERA_ERROR_INVALID_PARAMETER;
3598 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3600 if (ret == CAMERA_ERROR_NONE) {
3601 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3602 LOGD("display reuse hint %d", *hint);
3609 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3611 int ret = CAMERA_ERROR_NONE;
3612 camera_cli_s *pc = (camera_cli_s *)camera;
3613 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3615 if (!pc || !pc->cb_info || !width || !height) {
3616 LOGE("NULL pointer %p %p %p", pc, width, height);
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3622 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3624 if (ret == CAMERA_ERROR_NONE) {
3625 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3626 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3629 LOGD("ret : 0x%x", ret);
3635 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3637 int ret = CAMERA_ERROR_NONE;
3638 camera_cli_s *pc = (camera_cli_s *)camera;
3639 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3641 if (!pc || !pc->cb_info || !format) {
3642 LOGE("NULL pointer %p %p", pc, format);
3643 return CAMERA_ERROR_INVALID_PARAMETER;
3648 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3650 if (ret == CAMERA_ERROR_NONE)
3651 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3653 LOGD("ret : 0x%x", ret);
3659 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3661 int ret = CAMERA_ERROR_NONE;
3662 camera_cli_s *pc = (camera_cli_s *)camera;
3663 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3665 if (!pc || !pc->cb_info || !format) {
3666 LOGE("NULL pointer %p %p", pc, format);
3667 return CAMERA_ERROR_INVALID_PARAMETER;
3672 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3674 if (ret == CAMERA_ERROR_NONE)
3675 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3677 LOGD("ret : 0x%x", ret);
3683 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3685 int ret = CAMERA_ERROR_NONE;
3686 camera_cli_s *pc = (camera_cli_s *)camera;
3687 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3689 if (!pc || !pc->cb_info || !facing_direction) {
3690 LOGE("NULL pointer %p %p", pc, facing_direction);
3691 return CAMERA_ERROR_INVALID_PARAMETER;
3696 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3698 if (ret == CAMERA_ERROR_NONE)
3699 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3701 LOGD("ret : 0x%x", ret);
3707 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3709 int ret = CAMERA_ERROR_NONE;
3710 camera_cli_s *pc = (camera_cli_s *)camera;
3711 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3713 if (!pc || !pc->cb_info || !callback) {
3714 LOGE("NULL pointer %p %p", pc, callback);
3715 return CAMERA_ERROR_INVALID_PARAMETER;
3720 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3722 if (ret == CAMERA_ERROR_NONE) {
3723 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3728 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3730 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3733 LOGD("ret : 0x%x", ret);
3739 int camera_unset_preview_cb(camera_h camera)
3741 int ret = CAMERA_ERROR_NONE;
3742 camera_cli_s *pc = (camera_cli_s *)camera;
3743 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3745 if (!pc || !pc->cb_info) {
3746 LOGE("NULL handle");
3747 return CAMERA_ERROR_INVALID_PARAMETER;
3752 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3754 if (ret == CAMERA_ERROR_NONE) {
3755 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3757 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3758 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3760 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3762 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3765 LOGD("ret : 0x%x", ret);
3771 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3773 int ret = CAMERA_ERROR_NONE;
3774 camera_cli_s *pc = (camera_cli_s *)camera;
3775 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3777 if (!pc || !pc->cb_info) {
3778 LOGE("NULL handle");
3779 return CAMERA_ERROR_INVALID_PARAMETER;
3782 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3783 LOGE("NOT SUPPORTED");
3784 return CAMERA_ERROR_NOT_SUPPORTED;
3787 if (callback == NULL) {
3788 LOGE("NULL callback");
3789 return CAMERA_ERROR_INVALID_PARAMETER;
3794 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3796 if (ret == CAMERA_ERROR_NONE) {
3797 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3799 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3800 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3802 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3805 LOGD("ret : 0x%x", ret);
3811 int camera_unset_media_packet_preview_cb(camera_h camera)
3813 int ret = CAMERA_ERROR_NONE;
3814 camera_cli_s *pc = (camera_cli_s *)camera;
3815 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3817 if (!pc || !pc->cb_info) {
3818 LOGE("NULL handle");
3819 return CAMERA_ERROR_INVALID_PARAMETER;
3824 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3826 if (ret == CAMERA_ERROR_NONE) {
3827 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3829 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3830 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3832 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3835 LOGD("ret : 0x%x", ret);
3841 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3843 int ret = CAMERA_ERROR_NONE;
3844 camera_cli_s *pc = (camera_cli_s *)camera;
3845 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3847 if (!pc || !pc->cb_info || !callback) {
3848 LOGE("NULL pointer %p %p", pc, callback);
3849 return CAMERA_ERROR_INVALID_PARAMETER;
3854 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3856 if (ret == CAMERA_ERROR_NONE) {
3857 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3859 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3860 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3862 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3865 LOGD("ret : 0x%x", ret);
3871 int camera_unset_state_changed_cb(camera_h camera)
3873 int ret = CAMERA_ERROR_NONE;
3874 camera_cli_s *pc = (camera_cli_s *)camera;
3875 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3877 if (!pc || !pc->cb_info) {
3878 LOGE("NULL handle");
3879 return CAMERA_ERROR_INVALID_PARAMETER;
3884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3886 if (ret == CAMERA_ERROR_NONE) {
3887 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3889 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3890 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3892 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3895 LOGD("ret : 0x%x", ret);
3901 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3903 int ret = CAMERA_ERROR_NONE;
3904 camera_cli_s *pc = (camera_cli_s *)camera;
3905 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3907 if (!pc || !pc->cb_info || !callback) {
3908 LOGE("NULL pointer %p %p", pc, callback);
3909 return CAMERA_ERROR_INVALID_PARAMETER;
3914 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3916 if (ret == CAMERA_ERROR_NONE) {
3917 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3919 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3920 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3922 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3925 LOGD("ret : 0x%x", ret);
3931 int camera_unset_interrupted_cb(camera_h camera)
3933 int ret = CAMERA_ERROR_NONE;
3934 camera_cli_s *pc = (camera_cli_s *)camera;
3935 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3937 if (!pc || !pc->cb_info) {
3938 LOGE("NULL handle");
3939 return CAMERA_ERROR_INVALID_PARAMETER;
3944 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3946 if (ret == CAMERA_ERROR_NONE) {
3947 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3949 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3950 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3952 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3955 LOGD("ret : 0x%x", ret);
3961 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3963 int ret = CAMERA_ERROR_NONE;
3964 camera_cli_s *pc = (camera_cli_s *)camera;
3965 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3967 if (!pc || !pc->cb_info || !callback) {
3968 LOGE("NULL pointer %p %p", pc, callback);
3969 return CAMERA_ERROR_INVALID_PARAMETER;
3974 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3976 if (ret == CAMERA_ERROR_NONE) {
3977 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3979 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3980 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3982 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3985 LOGD("ret : 0x%x", ret);
3991 int camera_unset_interrupt_started_cb(camera_h camera)
3993 int ret = CAMERA_ERROR_NONE;
3994 camera_cli_s *pc = (camera_cli_s *)camera;
3995 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3997 if (!pc || !pc->cb_info) {
3998 LOGE("NULL handle");
3999 return CAMERA_ERROR_INVALID_PARAMETER;
4004 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4006 if (ret == CAMERA_ERROR_NONE) {
4007 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4009 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4010 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4012 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4015 LOGD("ret : 0x%x", ret);
4021 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4023 int ret = CAMERA_ERROR_NONE;
4024 camera_cli_s *pc = (camera_cli_s *)camera;
4025 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4027 if (!pc || !pc->cb_info || !callback) {
4028 LOGE("NULL pointer %p %p", pc, callback);
4029 return CAMERA_ERROR_INVALID_PARAMETER;
4034 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4036 if (ret == CAMERA_ERROR_NONE) {
4037 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4039 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4040 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4042 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4045 LOGD("ret : 0x%x", ret);
4051 int camera_unset_focus_changed_cb(camera_h camera)
4053 int ret = CAMERA_ERROR_NONE;
4054 camera_cli_s *pc = (camera_cli_s *)camera;
4055 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4057 if (!pc || !pc->cb_info) {
4058 LOGE("NULL handle");
4059 return CAMERA_ERROR_INVALID_PARAMETER;
4064 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4066 if (ret == CAMERA_ERROR_NONE) {
4067 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4069 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4070 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4072 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4075 LOGD("ret : 0x%x", ret);
4081 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4083 int ret = CAMERA_ERROR_NONE;
4084 camera_cli_s *pc = (camera_cli_s *)camera;
4085 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4087 if (!pc || !pc->cb_info || !callback) {
4088 LOGE("NULL pointer %p %p", pc, callback);
4089 return CAMERA_ERROR_INVALID_PARAMETER;
4094 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4096 if (ret == CAMERA_ERROR_NONE) {
4097 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4099 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4100 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4102 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4105 LOGD("ret : 0x%x", ret);
4111 int camera_unset_error_cb(camera_h camera)
4113 int ret = CAMERA_ERROR_NONE;
4114 camera_cli_s *pc = (camera_cli_s *)camera;
4115 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4117 if (!pc || !pc->cb_info) {
4118 LOGE("NULL handle");
4119 return CAMERA_ERROR_INVALID_PARAMETER;
4124 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4126 if (ret == CAMERA_ERROR_NONE) {
4127 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4129 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4130 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4132 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4135 LOGD("ret : 0x%x", ret);
4141 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4143 int ret = CAMERA_ERROR_NONE;
4144 camera_cli_s *pc = (camera_cli_s *)camera;
4145 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4147 if (!pc || !pc->cb_info || !foreach_cb) {
4148 LOGE("NULL pointer %p %p", pc, foreach_cb);
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4154 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4155 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4157 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4159 LOGD("ret : 0x%x", ret);
4165 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4167 int ret = CAMERA_ERROR_NONE;
4168 camera_cli_s *pc = (camera_cli_s *)camera;
4169 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4171 if (!pc || !pc->cb_info || !foreach_cb) {
4172 LOGE("NULL pointer %p %p", pc, foreach_cb);
4173 return CAMERA_ERROR_INVALID_PARAMETER;
4178 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4179 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4181 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4183 LOGD("ret : 0x%x", ret);
4189 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4191 int ret = CAMERA_ERROR_NONE;
4192 camera_cli_s *pc = (camera_cli_s *)camera;
4193 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4195 if (!pc || !pc->cb_info || !foreach_cb) {
4196 LOGE("NULL pointer %p %p", pc, foreach_cb);
4197 return CAMERA_ERROR_INVALID_PARAMETER;
4202 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4203 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4205 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4207 LOGD("ret : 0x%x", ret);
4213 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4215 int ret = CAMERA_ERROR_NONE;
4216 camera_cli_s *pc = (camera_cli_s *)camera;
4217 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4219 if (!pc || !pc->cb_info || !foreach_cb) {
4220 LOGE("NULL pointer %p %p", pc, foreach_cb);
4221 return CAMERA_ERROR_INVALID_PARAMETER;
4226 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4227 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4229 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4231 LOGD("ret : 0x%x", ret);
4237 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4239 int ret = CAMERA_ERROR_NONE;
4240 camera_cli_s *pc = (camera_cli_s *)camera;
4241 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4243 if (!pc || !pc->cb_info || !width || !height) {
4244 LOGE("NULL pointer %p %p %p", pc, width, height);
4245 return CAMERA_ERROR_INVALID_PARAMETER;
4249 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4251 if (ret == CAMERA_ERROR_NONE) {
4252 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4253 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4256 LOGD("ret : 0x%x", ret);
4262 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4264 int ret = CAMERA_ERROR_NONE;
4265 camera_cli_s *pc = (camera_cli_s *)camera;
4266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4268 if (!pc || !pc->cb_info || !angle) {
4269 LOGE("NULL pointer %p %p", pc, angle);
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4277 if (ret == CAMERA_ERROR_NONE)
4278 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4280 LOGD("ret : 0x%x", ret);
4286 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4288 int ret = CAMERA_ERROR_NONE;
4289 camera_cli_s *pc = (camera_cli_s *)camera;
4290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4291 camera_msg_param param;
4292 int set_mode = (int)mode;
4294 if (!pc || !pc->cb_info) {
4295 LOGE("NULL handle");
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4301 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4303 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4305 LOGD("ret : 0x%x", ret);
4311 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4313 int ret = CAMERA_ERROR_NONE;
4314 camera_cli_s *pc = (camera_cli_s *)camera;
4315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4317 if (!pc || !pc->cb_info || !mode) {
4318 LOGE("NULL pointer %p %p", pc, mode);
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4324 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4326 if (ret == CAMERA_ERROR_NONE)
4327 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4329 LOGD("ret : 0x%x", ret);
4335 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4337 int ret = CAMERA_ERROR_NONE;
4338 camera_cli_s *pc = (camera_cli_s *)camera;
4339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4341 if (!pc || !pc->cb_info || !foreach_cb) {
4342 LOGE("NULL pointer %p %p", pc, foreach_cb);
4343 return CAMERA_ERROR_INVALID_PARAMETER;
4348 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4349 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4351 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4353 LOGD("Finish, return :%x", ret);
4359 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4361 int ret = CAMERA_ERROR_NONE;
4362 camera_cli_s *pc = (camera_cli_s *)camera;
4363 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4364 camera_msg_param param;
4365 int set_fps = (int)fps;
4367 if (!pc || !pc->cb_info) {
4368 LOGE("NULL handle");
4369 return CAMERA_ERROR_INVALID_PARAMETER;
4374 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4376 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4378 LOGD("ret : 0x%x", ret);
4384 int camera_attr_set_image_quality(camera_h camera, int quality)
4386 int ret = CAMERA_ERROR_NONE;
4387 camera_cli_s *pc = (camera_cli_s *)camera;
4388 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4389 camera_msg_param param;
4391 if (!pc || !pc->cb_info) {
4392 LOGE("NULL handle");
4393 return CAMERA_ERROR_INVALID_PARAMETER;
4398 CAMERA_MSG_PARAM_SET(param, INT, quality);
4400 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4402 LOGD("ret : 0x%x", ret);
4408 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4410 int ret = CAMERA_ERROR_NONE;
4411 camera_cli_s *pc = (camera_cli_s *)camera;
4412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4414 if (!pc || !pc->cb_info || !fps) {
4415 LOGE("NULL pointer %p %p", pc, fps);
4416 return CAMERA_ERROR_INVALID_PARAMETER;
4421 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4423 if (ret == CAMERA_ERROR_NONE)
4424 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4426 LOGD("ret : 0x%x", ret);
4432 int camera_attr_get_image_quality(camera_h camera, int *quality)
4434 int ret = CAMERA_ERROR_NONE;
4435 camera_cli_s *pc = (camera_cli_s *)camera;
4436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4438 if (!pc || !pc->cb_info || !quality) {
4439 LOGE("NULL pointer %p %p", pc, quality);
4440 return CAMERA_ERROR_INVALID_PARAMETER;
4445 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4447 if (ret == CAMERA_ERROR_NONE)
4448 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4450 LOGD("ret : 0x%x", ret);
4456 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4458 int ret = CAMERA_ERROR_NONE;
4459 camera_cli_s *pc = (camera_cli_s *)camera;
4460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4462 if (!pc || !pc->cb_info || !bitrate) {
4463 LOGE("NULL pointer %p %p", pc, bitrate);
4464 return CAMERA_ERROR_INVALID_PARAMETER;
4469 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4471 if (ret == CAMERA_ERROR_NONE)
4472 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4474 LOGD("ret : 0x%x", ret);
4480 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4482 int ret = CAMERA_ERROR_NONE;
4483 camera_cli_s *pc = (camera_cli_s *)camera;
4484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4485 camera_msg_param param;
4486 int set_bitrate = bitrate;
4488 if (!pc || !pc->cb_info) {
4489 LOGE("NULL handle");
4490 return CAMERA_ERROR_INVALID_PARAMETER;
4495 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4497 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4499 LOGD("ret : 0x%x", ret);
4505 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4511 if (!pc || !pc->cb_info || !interval) {
4512 LOGE("NULL pointer %p %p", pc, interval);
4513 return CAMERA_ERROR_INVALID_PARAMETER;
4518 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4520 if (ret == CAMERA_ERROR_NONE)
4521 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4523 LOGD("ret : 0x%x", ret);
4529 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4534 camera_msg_param param;
4535 int set_gop_interval = interval;
4537 if (!pc || !pc->cb_info) {
4538 LOGE("NULL handle");
4539 return CAMERA_ERROR_INVALID_PARAMETER;
4544 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4546 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4548 LOGD("ret : 0x%x", ret);
4554 int camera_attr_set_zoom(camera_h camera, int zoom)
4556 int ret = CAMERA_ERROR_NONE;
4557 camera_cli_s *pc = (camera_cli_s *)camera;
4558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4559 camera_msg_param param;
4561 if (!pc || !pc->cb_info) {
4562 LOGE("NULL handle");
4563 return CAMERA_ERROR_INVALID_PARAMETER;
4566 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4568 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4570 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4572 LOGD("ret : 0x%x", ret);
4578 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
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_MODE;
4583 camera_msg_param param;
4584 int set_mode = (int)mode;
4586 if (!pc || !pc->cb_info) {
4587 LOGE("NULL handle");
4588 return CAMERA_ERROR_INVALID_PARAMETER;
4591 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4593 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4601 int camera_attr_set_af_area(camera_h camera, int x, int y)
4603 int ret = CAMERA_ERROR_NONE;
4604 camera_cli_s *pc = (camera_cli_s *)camera;
4605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4606 camera_msg_param param;
4609 if (!pc || !pc->cb_info) {
4610 LOGE("NULL handle");
4611 return CAMERA_ERROR_INVALID_PARAMETER;
4614 LOGD("Enter - %d,%d", x, y);
4616 value = (x << 16) | y;
4617 CAMERA_MSG_PARAM_SET(param, INT, value);
4619 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4621 LOGD("ret : 0x%x", ret);
4627 int camera_attr_clear_af_area(camera_h camera)
4629 int ret = CAMERA_ERROR_NONE;
4630 camera_cli_s *pc = (camera_cli_s *)camera;
4631 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4633 if (!pc || !pc->cb_info) {
4634 LOGE("NULL handle");
4635 return CAMERA_ERROR_INVALID_PARAMETER;
4640 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4642 LOGD("ret : 0x%x", ret);
4648 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4653 camera_msg_param param;
4654 int set_mode = (int)mode;
4656 if (!pc || !pc->cb_info) {
4657 LOGE("NULL handle");
4658 return CAMERA_ERROR_INVALID_PARAMETER;
4663 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4665 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4667 LOGD("ret : 0x%x", ret);
4673 int camera_attr_set_exposure(camera_h camera, int value)
4675 int ret = CAMERA_ERROR_NONE;
4676 camera_cli_s *pc = (camera_cli_s *)camera;
4677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4678 camera_msg_param param;
4680 if (!pc || !pc->cb_info) {
4681 LOGE("NULL handle");
4682 return CAMERA_ERROR_INVALID_PARAMETER;
4687 CAMERA_MSG_PARAM_SET(param, INT, value);
4689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4691 LOGD("ret : 0x%x", ret);
4697 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4699 int ret = CAMERA_ERROR_NONE;
4700 camera_cli_s *pc = (camera_cli_s *)camera;
4701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4702 camera_msg_param param;
4703 int set_iso = (int)iso;
4705 if (!pc || !pc->cb_info) {
4706 LOGE("NULL handle");
4707 return CAMERA_ERROR_INVALID_PARAMETER;
4712 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4714 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4716 LOGD("ret : 0x%x", ret);
4722 int camera_attr_set_brightness(camera_h camera, int level)
4724 int ret = CAMERA_ERROR_NONE;
4725 camera_cli_s *pc = (camera_cli_s *)camera;
4726 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4727 camera_msg_param param;
4729 if (!pc || !pc->cb_info) {
4730 LOGE("NULL handle");
4731 return CAMERA_ERROR_INVALID_PARAMETER;
4736 CAMERA_MSG_PARAM_SET(param, INT, level);
4738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4740 LOGD("ret : 0x%x", ret);
4746 int camera_attr_set_contrast(camera_h camera, int level)
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4751 camera_msg_param param;
4753 if (!pc || !pc->cb_info) {
4754 LOGE("NULL handle");
4755 return CAMERA_ERROR_INVALID_PARAMETER;
4760 CAMERA_MSG_PARAM_SET(param, INT, level);
4762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4764 LOGD("ret : 0x%x", ret);
4770 int camera_attr_set_hue(camera_h camera, int level)
4772 int ret = CAMERA_ERROR_NONE;
4773 camera_cli_s *pc = (camera_cli_s *)camera;
4774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4775 camera_msg_param param;
4777 if (!pc || !pc->cb_info) {
4778 LOGE("NULL handle");
4779 return CAMERA_ERROR_INVALID_PARAMETER;
4784 CAMERA_MSG_PARAM_SET(param, INT, level);
4786 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4788 LOGD("ret : 0x%x", ret);
4794 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4796 int ret = CAMERA_ERROR_NONE;
4797 camera_cli_s *pc = (camera_cli_s *)camera;
4798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4799 camera_msg_param param;
4800 int set_whitebalance = (int)wb;
4802 if (!pc || !pc->cb_info) {
4803 LOGE("NULL handle");
4804 return CAMERA_ERROR_INVALID_PARAMETER;
4809 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4813 LOGD("ret : 0x%x", ret);
4819 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4821 int ret = CAMERA_ERROR_NONE;
4822 camera_cli_s *pc = (camera_cli_s *)camera;
4823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4824 camera_msg_param param;
4825 int set_effect = (int)effect;
4827 if (!pc || !pc->cb_info) {
4828 LOGE("NULL handle");
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4834 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4838 LOGD("ret : 0x%x", ret);
4844 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4846 int ret = CAMERA_ERROR_NONE;
4847 camera_cli_s *pc = (camera_cli_s *)camera;
4848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4849 camera_msg_param param;
4850 int set_mode = (int)mode;
4852 if (!pc || !pc->cb_info) {
4853 LOGE("NULL handle");
4854 return CAMERA_ERROR_INVALID_PARAMETER;
4859 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4863 LOGD("ret : 0x%x", ret);
4869 int camera_attr_enable_tag(camera_h camera, bool enable)
4871 int ret = CAMERA_ERROR_NONE;
4872 camera_cli_s *pc = (camera_cli_s *)camera;
4873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4874 camera_msg_param param;
4875 int set_enable = (int)enable;
4877 if (!pc || !pc->cb_info) {
4878 LOGE("NULL handle");
4879 return CAMERA_ERROR_INVALID_PARAMETER;
4884 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4886 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4888 LOGD("ret : 0x%x", ret);
4894 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4896 int ret = CAMERA_ERROR_NONE;
4897 camera_cli_s *pc = (camera_cli_s *)camera;
4898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4899 camera_msg_param param;
4901 if (!pc || !pc->cb_info || !description) {
4902 LOGE("NULL pointer %p %p", pc, description);
4903 return CAMERA_ERROR_INVALID_PARAMETER;
4908 CAMERA_MSG_PARAM_SET(param, STRING, description);
4910 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4912 LOGD("ret : 0x%x", ret);
4918 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4920 int ret = CAMERA_ERROR_NONE;
4921 camera_cli_s *pc = (camera_cli_s *)camera;
4922 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4923 camera_msg_param param;
4924 int set_orientation = (int)orientation;
4926 if (!pc || !pc->cb_info) {
4927 LOGE("NULL handle");
4928 return CAMERA_ERROR_INVALID_PARAMETER;
4933 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4935 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4937 LOGD("ret : 0x%x", ret);
4943 int camera_attr_set_tag_software(camera_h camera, const char *software)
4945 int ret = CAMERA_ERROR_NONE;
4946 camera_cli_s *pc = (camera_cli_s *)camera;
4947 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4948 camera_msg_param param;
4950 if (!pc || !pc->cb_info || !software) {
4951 LOGE("NULL pointer %p %p", pc, software);
4952 return CAMERA_ERROR_INVALID_PARAMETER;
4955 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4957 CAMERA_MSG_PARAM_SET(param, STRING, software);
4959 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4961 LOGD("ret : 0x%x", ret);
4967 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4969 int ret = CAMERA_ERROR_NONE;
4970 camera_cli_s *pc = (camera_cli_s *)camera;
4971 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4972 double set_geotag[3] = {latitude, longitude, altitude};
4977 if (!pc || !pc->cb_info) {
4978 LOGE("NULL handle");
4979 return CAMERA_ERROR_INVALID_PARAMETER;
4984 length = sizeof(set_geotag) / sizeof(int) + \
4985 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4987 msg = muse_core_msg_new(api,
4988 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4991 LOGE("msg creation failed: api %d", api);
4992 return CAMERA_ERROR_OUT_OF_MEMORY;
4995 if (pc->cb_info->is_server_connected) {
4996 __camera_update_api_waiting(pc->cb_info, api, 1);
4998 g_mutex_lock(&pc->cb_info->fd_lock);
4999 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5000 g_mutex_unlock(&pc->cb_info->fd_lock);
5004 LOGE("message send failed");
5005 ret = CAMERA_ERROR_INVALID_OPERATION;
5007 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5010 __camera_update_api_waiting(pc->cb_info, api, -1);
5012 muse_core_msg_free(msg);
5014 LOGD("ret : 0x%x", ret);
5020 int camera_attr_remove_geotag(camera_h camera)
5022 int ret = CAMERA_ERROR_NONE;
5023 camera_cli_s *pc = (camera_cli_s *)camera;
5024 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5026 if (!pc || !pc->cb_info) {
5027 LOGE("NULL handle");
5028 return CAMERA_ERROR_INVALID_PARAMETER;
5033 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5035 LOGD("ret : 0x%x", ret);
5041 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5043 int ret = CAMERA_ERROR_NONE;
5044 camera_cli_s *pc = (camera_cli_s *)camera;
5045 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5046 camera_msg_param param;
5047 int set_mode = (int)mode;
5049 if (!pc || !pc->cb_info) {
5050 LOGE("NULL handle");
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5056 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5058 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5060 LOGD("ret : 0x%x", ret);
5066 int camera_attr_get_zoom(camera_h camera, int *zoom)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5072 if (!pc || !pc->cb_info || !zoom) {
5073 LOGE("NULL pointer %p %p", pc, zoom);
5074 return CAMERA_ERROR_INVALID_PARAMETER;
5079 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5081 if (ret == CAMERA_ERROR_NONE)
5082 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5084 LOGD("ret : 0x%x", ret);
5090 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5096 if (!pc || !pc->cb_info || !min || !max) {
5097 LOGE("NULL pointer %p %p %p", pc, min, max);
5098 return CAMERA_ERROR_INVALID_PARAMETER;
5103 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5105 if (ret == CAMERA_ERROR_NONE) {
5106 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5107 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5110 LOGD("ret : 0x%x", ret);
5116 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5118 int ret = CAMERA_ERROR_NONE;
5119 camera_cli_s *pc = (camera_cli_s *)camera;
5120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5122 if (!pc || !pc->cb_info || !mode) {
5123 LOGE("NULL pointer %p %p", pc, mode);
5124 return CAMERA_ERROR_INVALID_PARAMETER;
5129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5131 if (ret == CAMERA_ERROR_NONE)
5132 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5134 LOGD("ret : 0x%x", ret);
5140 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5142 int ret = CAMERA_ERROR_NONE;
5143 camera_cli_s *pc = (camera_cli_s *)camera;
5144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5146 if (!pc || !pc->cb_info || !mode) {
5147 LOGE("NULL pointer %p %p", pc, mode);
5148 return CAMERA_ERROR_INVALID_PARAMETER;
5153 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5155 if (ret == CAMERA_ERROR_NONE)
5156 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5158 LOGD("ret : 0x%x", ret);
5164 int camera_attr_get_exposure(camera_h camera, int *value)
5166 int ret = CAMERA_ERROR_NONE;
5167 camera_cli_s *pc = (camera_cli_s *)camera;
5168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5170 if (!pc || !pc->cb_info || !value) {
5171 LOGE("NULL pointer %p %p", pc, value);
5172 return CAMERA_ERROR_INVALID_PARAMETER;
5177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5179 if (ret == CAMERA_ERROR_NONE)
5180 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5182 LOGD("ret : 0x%x", ret);
5188 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5190 int ret = CAMERA_ERROR_NONE;
5191 camera_cli_s *pc = (camera_cli_s *)camera;
5192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5194 if (!pc || !pc->cb_info || !min || !max) {
5195 LOGE("NULL pointer %p %p %p", pc, min, max);
5196 return CAMERA_ERROR_INVALID_PARAMETER;
5201 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5203 if (ret == CAMERA_ERROR_NONE) {
5204 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5205 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5208 LOGD("ret : 0x%x", ret);
5214 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5216 int ret = CAMERA_ERROR_NONE;
5217 camera_cli_s *pc = (camera_cli_s *)camera;
5218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5220 if (!pc || !pc->cb_info || !iso) {
5221 LOGE("NULL pointer %p %p", pc, iso);
5222 return CAMERA_ERROR_INVALID_PARAMETER;
5227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5229 if (ret == CAMERA_ERROR_NONE)
5230 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5232 LOGD("ret : 0x%x", ret);
5238 int camera_attr_get_brightness(camera_h camera, int *level)
5240 int ret = CAMERA_ERROR_NONE;
5241 camera_cli_s *pc = (camera_cli_s *)camera;
5242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5244 if (!pc || !pc->cb_info || !level) {
5245 LOGE("NULL pointer %p %p", pc, level);
5246 return CAMERA_ERROR_INVALID_PARAMETER;
5251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5253 if (ret == CAMERA_ERROR_NONE)
5254 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5256 LOGD("ret : 0x%x", ret);
5262 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5264 int ret = CAMERA_ERROR_NONE;
5265 camera_cli_s *pc = (camera_cli_s *)camera;
5266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5268 if (!pc || !pc->cb_info || !min || !max) {
5269 LOGE("NULL pointer %p %p %p", pc, min, max);
5270 return CAMERA_ERROR_INVALID_PARAMETER;
5275 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5277 if (ret == CAMERA_ERROR_NONE) {
5278 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5279 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5282 LOGD("ret : 0x%x", ret);
5288 int camera_attr_get_contrast(camera_h camera, int *level)
5290 int ret = CAMERA_ERROR_NONE;
5291 camera_cli_s *pc = (camera_cli_s *)camera;
5292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5294 if (!pc || !pc->cb_info || !level) {
5295 LOGE("NULL pointer %p %p", pc, level);
5296 return CAMERA_ERROR_INVALID_PARAMETER;
5301 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5303 if (ret == CAMERA_ERROR_NONE)
5304 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5306 LOGD("ret : 0x%x", ret);
5312 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5314 int ret = CAMERA_ERROR_NONE;
5315 camera_cli_s *pc = (camera_cli_s *)camera;
5316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5318 if (!pc || !pc->cb_info || !min || !max) {
5319 LOGE("NULL pointer %p %p %p", pc, min, max);
5320 return CAMERA_ERROR_INVALID_PARAMETER;
5325 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5327 if (ret == CAMERA_ERROR_NONE) {
5328 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5329 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5330 LOGD("min %d, max %d", *min, *max);
5333 LOGD("ret : 0x%x", ret);
5339 int camera_attr_get_hue(camera_h camera, int *level)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5345 if (!pc || !pc->cb_info || !level) {
5346 LOGE("NULL pointer %p %p", pc, level);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5352 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE)
5355 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5357 LOGD("ret : 0x%x", ret);
5363 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5365 int ret = CAMERA_ERROR_NONE;
5366 camera_cli_s *pc = (camera_cli_s *)camera;
5367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5369 if (!pc || !pc->cb_info || !min || !max) {
5370 LOGE("NULL pointer %p %p %p", pc, min, max);
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5376 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5378 if (ret == CAMERA_ERROR_NONE) {
5379 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5380 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5381 LOGD("min %d, max %d", *min, *max);
5384 LOGD("ret : 0x%x", ret);
5390 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5392 int ret = CAMERA_ERROR_NONE;
5393 camera_cli_s *pc = (camera_cli_s *)camera;
5394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5396 if (!pc || !pc->cb_info || !wb) {
5397 LOGE("NULL pointer %p %p", pc, wb);
5398 return CAMERA_ERROR_INVALID_PARAMETER;
5403 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5405 if (ret == CAMERA_ERROR_NONE)
5406 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5408 LOGD("ret : 0x%x", ret);
5414 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5416 int ret = CAMERA_ERROR_NONE;
5417 camera_cli_s *pc = (camera_cli_s *)camera;
5418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5420 if (!pc || !pc->cb_info || !effect) {
5421 LOGE("NULL pointer %p %p", pc, effect);
5422 return CAMERA_ERROR_INVALID_PARAMETER;
5427 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5429 if (ret == CAMERA_ERROR_NONE)
5430 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5432 LOGD("ret : 0x%x", ret);
5438 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5440 int ret = CAMERA_ERROR_NONE;
5441 camera_cli_s *pc = (camera_cli_s *)camera;
5442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5444 if (!pc || !pc->cb_info || !mode) {
5445 LOGE("NULL pointer %p %p", pc, mode);
5446 return CAMERA_ERROR_INVALID_PARAMETER;
5451 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5453 if (ret == CAMERA_ERROR_NONE)
5454 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5456 LOGD("ret : 0x%x", ret);
5462 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5464 int ret = CAMERA_ERROR_NONE;
5465 camera_cli_s *pc = (camera_cli_s *)camera;
5466 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5468 if (!pc || !pc->cb_info || !enable) {
5469 LOGE("NULL pointer %p %p", pc, enable);
5470 return CAMERA_ERROR_INVALID_PARAMETER;
5475 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5477 if (ret == CAMERA_ERROR_NONE)
5478 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5480 LOGD("ret : 0x%x", ret);
5486 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5488 int ret = CAMERA_ERROR_NONE;
5489 camera_cli_s *pc = (camera_cli_s *)camera;
5490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5492 if (!pc || !pc->cb_info || !description) {
5493 LOGE("NULL pointer %p %p", pc, description);
5494 return CAMERA_ERROR_INVALID_PARAMETER;
5499 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5501 if (ret == CAMERA_ERROR_NONE)
5502 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5504 LOGD("ret : 0x%x", ret);
5510 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5512 int ret = CAMERA_ERROR_NONE;
5513 camera_cli_s *pc = (camera_cli_s *)camera;
5514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5516 if (!pc || !pc->cb_info || !orientation) {
5517 LOGE("NULL pointer %p %p", pc, orientation);
5518 return CAMERA_ERROR_INVALID_PARAMETER;
5523 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5525 if (ret == CAMERA_ERROR_NONE)
5526 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5528 LOGD("ret : 0x%x", ret);
5534 int camera_attr_get_tag_software(camera_h camera, char **software)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5540 if (!pc || !pc->cb_info || !software) {
5541 LOGE("NULL pointer %p %p", pc, software);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5547 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5549 if (ret == CAMERA_ERROR_NONE)
5550 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5552 LOGD("ret : 0x%x", ret);
5558 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5560 int ret = CAMERA_ERROR_NONE;
5561 camera_cli_s *pc = (camera_cli_s *)camera;
5562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5564 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5565 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5566 return CAMERA_ERROR_INVALID_PARAMETER;
5571 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5573 if (ret == CAMERA_ERROR_NONE) {
5574 *latitude = pc->cb_info->get_geotag[0];
5575 *longitude = pc->cb_info->get_geotag[1];
5576 *altitude = pc->cb_info->get_geotag[2];
5579 LOGD("ret : 0x%x", ret);
5585 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5587 int ret = CAMERA_ERROR_NONE;
5588 camera_cli_s *pc = (camera_cli_s *)camera;
5589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5591 if (!pc || !pc->cb_info || !mode) {
5592 LOGE("NULL pointer %p %p", pc, mode);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5598 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 if (ret == CAMERA_ERROR_NONE)
5601 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5603 LOGD("ret : 0x%x", ret);
5609 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5611 int ret = CAMERA_ERROR_NONE;
5612 int get_flash_state = 0;
5615 LOGE("NULL pointer");
5616 return CAMERA_ERROR_INVALID_PARAMETER;
5619 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5620 (int)device, "get_flash_state", &get_flash_state);
5622 if (ret == CAMERA_ERROR_NONE) {
5623 *state = (camera_flash_state_e)get_flash_state;
5624 LOGD("flash state %d", *state);
5626 LOGE("failed 0x%x", ret);
5633 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5635 int ret = CAMERA_ERROR_NONE;
5636 camera_cli_s *pc = (camera_cli_s *)camera;
5637 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5639 if (!pc || !pc->cb_info || !foreach_cb) {
5640 LOGE("NULL pointer %p %p", pc, foreach_cb);
5641 return CAMERA_ERROR_INVALID_PARAMETER;
5646 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5649 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5651 LOGD("ret : 0x%x", ret);
5657 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5659 int ret = CAMERA_ERROR_NONE;
5660 camera_cli_s *pc = (camera_cli_s *)camera;
5661 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5663 if (!pc || !pc->cb_info || !foreach_cb) {
5664 LOGE("NULL pointer %p %p", pc, foreach_cb);
5665 return CAMERA_ERROR_INVALID_PARAMETER;
5670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5673 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5675 LOGD("ret : 0x%x", ret);
5681 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5683 int ret = CAMERA_ERROR_NONE;
5684 camera_cli_s *pc = (camera_cli_s *)camera;
5685 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5687 if (!pc || !pc->cb_info || !foreach_cb) {
5688 LOGE("NULL pointer %p %p", pc, foreach_cb);
5689 return CAMERA_ERROR_INVALID_PARAMETER;
5694 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5697 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5699 LOGD("ret : 0x%x", ret);
5705 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5707 int ret = CAMERA_ERROR_NONE;
5708 camera_cli_s *pc = (camera_cli_s *)camera;
5709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5711 if (!pc || !pc->cb_info || !foreach_cb) {
5712 LOGE("NULL pointer %p %p", pc, foreach_cb);
5713 return CAMERA_ERROR_INVALID_PARAMETER;
5718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5721 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5723 LOGD("ret : 0x%x", ret);
5729 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5735 if (!pc || !pc->cb_info || !foreach_cb) {
5736 LOGE("NULL pointer %p %p", pc, foreach_cb);
5737 return CAMERA_ERROR_INVALID_PARAMETER;
5742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5745 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5747 LOGD("ret : 0x%x", ret);
5753 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5755 int ret = CAMERA_ERROR_NONE;
5756 camera_cli_s *pc = (camera_cli_s *)camera;
5757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5759 if (!pc || !pc->cb_info || !foreach_cb) {
5760 LOGE("NULL pointer %p %p", pc, foreach_cb);
5761 return CAMERA_ERROR_INVALID_PARAMETER;
5766 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5769 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5771 LOGD("ret : 0x%x", ret);
5777 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5779 int ret = CAMERA_ERROR_NONE;
5780 camera_cli_s *pc = (camera_cli_s *)camera;
5781 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5783 if (!pc || !pc->cb_info || !foreach_cb) {
5784 LOGE("NULL pointer %p %p", pc, foreach_cb);
5785 return CAMERA_ERROR_INVALID_PARAMETER;
5790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5793 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5795 LOGD("ret : 0x%x", ret);
5801 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5803 int ret = CAMERA_ERROR_NONE;
5804 camera_cli_s *pc = (camera_cli_s *)camera;
5805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5807 if (!pc || !pc->cb_info || !foreach_cb) {
5808 LOGE("NULL pointer %p %p", pc, foreach_cb);
5809 return CAMERA_ERROR_INVALID_PARAMETER;
5814 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5815 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5817 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5819 LOGD("Enter, handle :%td", pc->remote_handle);
5825 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)
5827 int ret = CAMERA_ERROR_NONE;
5828 camera_cli_s *pc = (camera_cli_s *)camera;
5829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5830 camera_msg_param param;
5833 if (!pc || !pc->cb_info || !foreach_cb) {
5834 LOGE("NULL pointer %p %p", pc, foreach_cb);
5835 return CAMERA_ERROR_INVALID_PARAMETER;
5840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5843 value = (width << 16) | height;
5844 CAMERA_MSG_PARAM_SET(param, INT, value);
5846 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5848 LOGD("ret : 0x%x", ret);
5854 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5856 int ret = CAMERA_ERROR_NONE;
5857 camera_cli_s *pc = (camera_cli_s *)camera;
5858 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5860 if (!pc || !pc->cb_info || !foreach_cb) {
5861 LOGE("NULL pointer %p %p", pc, foreach_cb);
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5867 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5868 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5870 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5872 LOGD("ret : 0x%x", ret);
5878 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5880 int ret = CAMERA_ERROR_NONE;
5881 camera_cli_s *pc = (camera_cli_s *)camera;
5882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5884 if (!pc || !pc->cb_info || !foreach_cb) {
5885 LOGE("NULL pointer %p %p", pc, foreach_cb);
5886 return CAMERA_ERROR_INVALID_PARAMETER;
5891 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5892 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5894 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5896 LOGD("ret : 0x%x", ret);
5902 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5904 int ret = CAMERA_ERROR_NONE;
5905 camera_cli_s *pc = (camera_cli_s *)camera;
5906 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5907 camera_msg_param param;
5908 int set_rotation = (int)rotation;
5910 if (!pc || !pc->cb_info) {
5911 LOGE("NULL handle");
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5917 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5919 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5921 LOGD("ret : 0x%x", ret);
5927 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5933 if (!pc || !pc->cb_info || !rotation) {
5934 LOGE("NULL pointer %p %p", pc, rotation);
5935 return CAMERA_ERROR_INVALID_PARAMETER;
5940 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5942 if (ret == CAMERA_ERROR_NONE)
5943 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5945 LOGD("ret : 0x%x", ret);
5951 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5953 int ret = CAMERA_ERROR_NONE;
5954 camera_cli_s *pc = (camera_cli_s *)camera;
5955 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5956 camera_msg_param param;
5957 int set_flip = (int)flip;
5959 if (!pc || !pc->cb_info) {
5960 LOGE("NULL handle");
5961 return CAMERA_ERROR_INVALID_PARAMETER;
5966 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5968 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5970 LOGD("ret : 0x%x", ret);
5976 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
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_GET_STREAM_FLIP;
5982 if (!pc || !pc->cb_info || !flip) {
5983 LOGE("NULL pointer %p %p", pc, flip);
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5991 if (ret == CAMERA_ERROR_NONE)
5992 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5994 LOGD("ret : 0x%x", ret);
5999 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6001 int ret = CAMERA_ERROR_NONE;
6002 camera_cli_s *pc = (camera_cli_s *)camera;
6003 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6004 camera_msg_param param;
6005 int set_mode = (int)mode;
6007 if (!pc || !pc->cb_info) {
6008 LOGE("NULL handle");
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6014 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6016 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6018 LOGD("ret : 0x%x", ret);
6024 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6026 int ret = CAMERA_ERROR_NONE;
6027 camera_cli_s *pc = (camera_cli_s *)camera;
6028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6030 if (!pc || !pc->cb_info || !mode) {
6031 LOGE("NULL pointer %p %p", pc, mode);
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6039 if (ret == CAMERA_ERROR_NONE)
6040 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6042 LOGD("ret : 0x%x", ret);
6048 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6050 int ret = CAMERA_ERROR_NONE;
6051 camera_cli_s *pc = (camera_cli_s *)camera;
6052 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6054 if (!pc || !pc->cb_info) {
6055 LOGE("NULL handle");
6056 return CAMERA_ERROR_INVALID_PARAMETER;
6061 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6064 LOGE("error is occurred 0x%x", ret);
6068 LOGD("ret : %d", ret);
6074 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6076 int ret = CAMERA_ERROR_NONE;
6077 camera_cli_s *pc = (camera_cli_s *)camera;
6078 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6080 if (!pc || !pc->cb_info) {
6081 LOGE("NULL handle");
6082 return CAMERA_ERROR_INVALID_PARAMETER;
6087 if (!camera_attr_is_supported_hdr_capture(camera)) {
6088 LOGE("HDR not supported");
6089 return CAMERA_ERROR_NOT_SUPPORTED;
6093 LOGE("NULL callback");
6094 return CAMERA_ERROR_INVALID_PARAMETER;
6097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6099 if (ret == CAMERA_ERROR_NONE) {
6100 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6102 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6103 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6105 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6108 LOGD("ret : 0x%x", ret);
6114 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6120 if (!pc || !pc->cb_info) {
6121 LOGE("NULL handle");
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6127 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6129 if (ret == CAMERA_ERROR_NONE) {
6130 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6132 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6133 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6135 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6138 LOGD("ret : 0x%x", ret);
6144 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6146 int ret = CAMERA_ERROR_NONE;
6147 camera_cli_s *pc = (camera_cli_s *)camera;
6148 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6149 camera_msg_param param;
6150 int set_enable = (int)enable;
6152 if (!pc || !pc->cb_info) {
6153 LOGE("NULL handle");
6154 return CAMERA_ERROR_INVALID_PARAMETER;
6159 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6161 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6163 LOGD("ret : 0x%x", ret);
6169 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6171 int ret = CAMERA_ERROR_NONE;
6172 camera_cli_s *pc = (camera_cli_s *)camera;
6173 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6175 if (!pc || !pc->cb_info || !enabled) {
6176 LOGE("NULL pointer %p %p", pc, enabled);
6177 return CAMERA_ERROR_INVALID_PARAMETER;
6182 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6184 if (ret == CAMERA_ERROR_NONE)
6185 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6187 LOGD("ret : 0x%x", ret);
6193 bool camera_attr_is_supported_anti_shake(camera_h camera)
6195 int ret = CAMERA_ERROR_NONE;
6196 camera_cli_s *pc = (camera_cli_s *)camera;
6197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6199 if (!pc || !pc->cb_info) {
6200 LOGE("NULL handle");
6201 return CAMERA_ERROR_INVALID_PARAMETER;
6206 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6209 LOGE("error is occurred 0x%x", ret);
6213 LOGD("ret : %d", ret);
6219 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6221 int ret = CAMERA_ERROR_NONE;
6222 camera_cli_s *pc = (camera_cli_s *)camera;
6223 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6224 camera_msg_param param;
6225 int set_enable = (int)enable;
6227 if (!pc || !pc->cb_info) {
6228 LOGE("NULL handle");
6229 return CAMERA_ERROR_INVALID_PARAMETER;
6234 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6238 LOGD("ret : 0x%x", ret);
6244 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6246 int ret = CAMERA_ERROR_NONE;
6247 camera_cli_s *pc = (camera_cli_s *)camera;
6248 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6250 if (!pc || !pc->cb_info || !enabled) {
6251 LOGE("NULL pointer %p %p", pc, enabled);
6252 return CAMERA_ERROR_INVALID_PARAMETER;
6257 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6259 if (ret == CAMERA_ERROR_NONE)
6260 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6262 LOGD("ret : 0x%x", ret);
6268 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6270 int ret = CAMERA_ERROR_NONE;
6271 camera_cli_s *pc = (camera_cli_s *)camera;
6272 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6274 if (!pc || !pc->cb_info) {
6275 LOGE("NULL handle");
6276 return CAMERA_ERROR_INVALID_PARAMETER;
6281 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6284 LOGE("error is occurred 0x%x", ret);
6288 LOGD("ret : %d", ret);
6294 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6296 int ret = CAMERA_ERROR_NONE;
6297 camera_cli_s *pc = (camera_cli_s *)camera;
6298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6299 camera_msg_param param;
6300 int set_enable = (int)enable;
6302 if (!pc || !pc->cb_info) {
6303 LOGE("NULL handle");
6304 return CAMERA_ERROR_INVALID_PARAMETER;
6309 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6311 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6313 LOGD("ret : 0x%x", ret);
6319 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6321 int ret = CAMERA_ERROR_NONE;
6322 camera_cli_s *pc = (camera_cli_s *)camera;
6323 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6325 if (!pc || !pc->cb_info || !enabled) {
6326 LOGE("NULL pointer %p %p", pc, enabled);
6327 return CAMERA_ERROR_INVALID_PARAMETER;
6332 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6334 if (ret == CAMERA_ERROR_NONE)
6335 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6337 LOGD("ret : 0x%x", ret);
6343 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6345 int ret = CAMERA_ERROR_NONE;
6346 camera_cli_s *pc = (camera_cli_s *)camera;
6347 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6349 if (!pc || !pc->cb_info) {
6350 LOGE("NULL handle");
6351 return CAMERA_ERROR_INVALID_PARAMETER;
6356 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6359 LOGE("error is occurred 0x%x", ret);
6363 LOGD("ret : %d", ret);
6369 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6371 int ret = CAMERA_ERROR_NONE;
6372 camera_cli_s *pc = (camera_cli_s *)camera;
6373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6374 camera_msg_param param;
6375 int set_disable = (int)disable;
6377 if (!pc || !pc->cb_info) {
6378 LOGE("NULL handle");
6379 return CAMERA_ERROR_INVALID_PARAMETER;
6384 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6386 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6388 LOGD("ret : 0x%x", ret);
6394 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6396 int ret = CAMERA_ERROR_NONE;
6397 camera_cli_s *pc = (camera_cli_s *)camera;
6398 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6399 camera_msg_param param;
6400 int set_move_type = (int)move_type;
6403 if (!pc || !pc->cb_info) {
6404 LOGE("NULL handle");
6405 return CAMERA_ERROR_INVALID_PARAMETER;
6410 value = (set_move_type << 16) | pan_step;
6411 CAMERA_MSG_PARAM_SET(param, INT, value);
6413 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6415 LOGD("ret : 0x%x", ret);
6421 int camera_attr_get_pan(camera_h camera, int *pan_step)
6423 int ret = CAMERA_ERROR_NONE;
6424 camera_cli_s *pc = (camera_cli_s *)camera;
6425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6427 if (!pc || !pc->cb_info || !pan_step) {
6428 LOGE("NULL pointer %p %p", pc, pan_step);
6429 return CAMERA_ERROR_INVALID_PARAMETER;
6434 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6436 if (ret == CAMERA_ERROR_NONE)
6437 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6439 LOGD("ret : 0x%x", ret);
6445 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6447 int ret = CAMERA_ERROR_NONE;
6448 camera_cli_s *pc = (camera_cli_s *)camera;
6449 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6451 if (!pc || !pc->cb_info || !min || !max) {
6452 LOGE("NULL pointer %p %p %p", pc, min, max);
6453 return CAMERA_ERROR_INVALID_PARAMETER;
6458 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6460 if (ret == CAMERA_ERROR_NONE) {
6461 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6462 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6465 LOGD("ret : 0x%x", ret);
6471 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6473 int ret = CAMERA_ERROR_NONE;
6474 camera_cli_s *pc = (camera_cli_s *)camera;
6475 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6476 camera_msg_param param;
6477 int set_move_type = (int)move_type;
6480 if (!pc || !pc->cb_info) {
6481 LOGE("NULL handle");
6482 return CAMERA_ERROR_INVALID_PARAMETER;
6487 value = (set_move_type << 16) | tilt_step;
6488 CAMERA_MSG_PARAM_SET(param, INT, value);
6490 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6492 LOGD("ret : 0x%x", ret);
6498 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6500 int ret = CAMERA_ERROR_NONE;
6501 camera_cli_s *pc = (camera_cli_s *)camera;
6502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6504 if (!pc || !pc->cb_info || !tilt_step) {
6505 LOGE("NULL pointer %p %p", pc, tilt_step);
6506 return CAMERA_ERROR_INVALID_PARAMETER;
6511 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6513 if (ret == CAMERA_ERROR_NONE)
6514 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6516 LOGD("ret : 0x%x", ret);
6522 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6524 int ret = CAMERA_ERROR_NONE;
6525 camera_cli_s *pc = (camera_cli_s *)camera;
6526 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6528 if (!pc || !pc->cb_info || !min || !max) {
6529 LOGE("NULL pointer %p %p %p", pc, min, max);
6530 return CAMERA_ERROR_INVALID_PARAMETER;
6535 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6537 if (ret == CAMERA_ERROR_NONE) {
6538 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6539 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6542 LOGD("ret : 0x%x", ret);
6548 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6550 int ret = CAMERA_ERROR_NONE;
6551 camera_cli_s *pc = (camera_cli_s *)camera;
6552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6553 camera_msg_param param;
6554 int set_ptz_type = (int)ptz_type;
6556 if (!pc || !pc->cb_info) {
6557 LOGE("NULL handle");
6558 return CAMERA_ERROR_INVALID_PARAMETER;
6563 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6565 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6567 LOGD("ret : 0x%x", ret);
6573 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6575 int ret = CAMERA_ERROR_NONE;
6576 camera_cli_s *pc = (camera_cli_s *)camera;
6577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6579 if (!pc || !pc->cb_info || !foreach_cb) {
6580 LOGE("NULL pointer %p %p", pc, foreach_cb);
6581 return CAMERA_ERROR_INVALID_PARAMETER;
6586 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6587 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6589 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6591 LOGD("ret : 0x%x", ret);
6597 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6599 int ret = CAMERA_ERROR_NONE;
6600 camera_cli_s *pc = (camera_cli_s *)camera;
6601 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6602 int set_display_roi_area[4] = {x, y, width, height};
6607 if (!pc || !pc->cb_info) {
6608 LOGE("NULL handle");
6609 return CAMERA_ERROR_INVALID_PARAMETER;
6614 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6615 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6616 if (ret != MM_ERROR_NONE) {
6617 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6618 return CAMERA_ERROR_INVALID_OPERATION;
6622 length = sizeof(set_display_roi_area) / sizeof(int) + \
6623 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6625 msg = muse_core_msg_new(api,
6626 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6629 LOGE("msg creation failed: api %d", api);
6630 return CAMERA_ERROR_OUT_OF_MEMORY;
6633 if (pc->cb_info->is_server_connected) {
6634 __camera_update_api_waiting(pc->cb_info, api, 1);
6636 g_mutex_lock(&pc->cb_info->fd_lock);
6637 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6638 g_mutex_unlock(&pc->cb_info->fd_lock);
6642 LOGE("message send failed");
6643 ret = CAMERA_ERROR_INVALID_OPERATION;
6645 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6648 __camera_update_api_waiting(pc->cb_info, api, -1);
6650 muse_core_msg_free(msg);
6652 LOGD("ret : 0x%x", ret);
6658 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6660 camera_cli_s *pc = (camera_cli_s *)camera;
6661 int ret = CAMERA_ERROR_NONE;
6662 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6664 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6665 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6666 return CAMERA_ERROR_INVALID_PARAMETER;
6671 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6673 if (ret == CAMERA_ERROR_NONE) {
6674 *x = pc->cb_info->get_display_roi_area[0];
6675 *y = pc->cb_info->get_display_roi_area[1];
6676 *width = pc->cb_info->get_display_roi_area[2];
6677 *height = pc->cb_info->get_display_roi_area[3];
6680 LOGD("ret : 0x%x", ret);
6686 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6688 int ret = CAMERA_ERROR_NONE;
6689 int get_device_state = 0;
6692 LOGE("NULL pointer");
6693 return CAMERA_ERROR_INVALID_PARAMETER;
6696 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6697 (int)device, "get_device_state", &get_device_state);
6699 if (ret == CAMERA_ERROR_NONE) {
6700 *state = (camera_device_state_e)get_device_state;
6701 LOGD("device state %d", *state);
6703 LOGE("failed 0x%x", ret);
6710 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6712 int ret = CAMERA_ERROR_NONE;
6713 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6714 camera_cb_info *info = NULL;
6716 if (!callback || !cb_id) {
6717 LOGE("invalid pointer %p %p", callback, cb_id);
6718 return CAMERA_ERROR_INVALID_PARAMETER;
6721 /* check camera support */
6722 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6723 if (ret != CAMERA_ERROR_NONE) {
6724 LOGE("get device state failed");
6728 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6730 info = g_new0(camera_cb_info, 1);
6732 LOGE("info failed");
6733 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6737 info->id = ++g_cam_dev_state_changed_cb_id;
6738 info->callback = (void *)callback;
6739 info->user_data = user_data;
6743 /* subscribe dbus signal for camera state change */
6744 if (!g_cam_dev_state_changed_cb_conn) {
6745 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6746 if (!g_cam_dev_state_changed_cb_conn) {
6747 LOGE("failed to get gdbus connection");
6748 ret = CAMERA_ERROR_INVALID_OPERATION;
6752 LOGD("subscribe signal %s - %s - %s",
6753 MM_CAMCORDER_DBUS_OBJECT,
6754 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6755 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6757 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6758 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6759 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6760 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6761 LOGE("failed to get gdbus connection");
6762 ret = CAMERA_ERROR_INVALID_OPERATION;
6766 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6769 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6771 LOGD("callback id %d", info->id);
6774 if (ret != CAMERA_ERROR_NONE) {
6780 if (g_cam_dev_state_changed_cb_conn) {
6781 g_object_unref(g_cam_dev_state_changed_cb_conn);
6782 g_cam_dev_state_changed_cb_conn = NULL;
6786 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6792 int camera_remove_device_state_changed_cb(int cb_id)
6794 int ret = CAMERA_ERROR_NONE;
6795 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6796 GList *tmp_list = NULL;
6797 camera_cb_info *info = NULL;
6799 /* check camera support */
6800 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6801 if (ret != CAMERA_ERROR_NONE) {
6802 LOGE("get device state failed");
6806 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6808 if (!g_cam_dev_state_changed_cb_list) {
6809 LOGE("there is no callback info");
6810 ret = CAMERA_ERROR_INVALID_OPERATION;
6814 tmp_list = g_cam_dev_state_changed_cb_list;
6817 info = tmp_list->data;
6818 tmp_list = tmp_list->next;
6825 if (info->id == cb_id) {
6826 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6831 if (!g_cam_dev_state_changed_cb_list) {
6832 /* no remained callback */
6833 if (g_cam_dev_state_changed_cb_conn) {
6834 /* unsubscribe signal */
6835 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6836 g_cam_dev_state_changed_cb_subscribe_id = 0;
6838 /* unref connection */
6839 g_object_unref(g_cam_dev_state_changed_cb_conn);
6840 g_cam_dev_state_changed_cb_conn = NULL;
6844 LOGD("id %d callback removed", cb_id);
6845 ret = CAMERA_ERROR_NONE;
6851 LOGE("id %d callback not found", cb_id);
6852 ret = CAMERA_ERROR_INVALID_PARAMETER;
6855 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);