2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
37 #define MODULE_NAME "camera"
39 /* for device changed callback */
40 static GMutex g_cam_dev_state_changed_cb_lock;
41 static GList *g_cam_dev_state_changed_cb_list;
42 static int g_cam_dev_state_changed_cb_id;
43 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
44 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static GMutex g_cam_idle_event_lock;
47 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
48 int *ret, int timeout);
49 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param, int timeout);
51 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
52 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
53 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
54 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
55 static void _camera_release_imported_bo(tbm_bo *bo);
56 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
57 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
58 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
59 camera_media_packet_data *mp_data, media_packet_h *packet);
60 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
61 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
62 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
63 static gboolean _camera_allocate_preview_buffer(camera_h camera);
64 static void _camera_release_preview_buffer(camera_h camera);
67 static gboolean _camera_allocate_preview_buffer(camera_h camera)
70 int ret = CAMERA_ERROR_NONE;
71 int format = CAMERA_PIXEL_FORMAT_INVALID;
75 camera_cli_s *pc = (camera_cli_s *)camera;
76 camera_cb_info_s *cb_info = NULL;
78 if (!pc || !pc->cb_info) {
79 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
83 cb_info = pc->cb_info;
87 /* get preview info and calculate size */
88 ret = camera_get_preview_format(camera, &format);
89 if (ret != CAMERA_ERROR_NONE) {
90 LOGE("get preview format failed 0x%x", ret);
94 ret = camera_get_preview_resolution(camera, &width, &height);
95 if (ret != CAMERA_ERROR_NONE) {
96 LOGE("get preview resolution failed 0x%x", ret);
100 LOGD("preview %dx%d, format %d", width, height, format);
103 case CAMERA_PIXEL_FORMAT_INVZ:
104 buffer_size = width * height;
106 case CAMERA_PIXEL_FORMAT_NV12:
107 case CAMERA_PIXEL_FORMAT_I420:
108 buffer_size = (width * height * 3) >> 1;
110 case CAMERA_PIXEL_FORMAT_YUYV:
111 case CAMERA_PIXEL_FORMAT_UYVY:
112 buffer_size = width * height * 2;
115 LOGE("unhandled format %d", format);
116 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
119 LOGD("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
121 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
122 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
123 if (!cb_info->bos[i]) {
124 LOGE("bo alloc failed [%d,i:%d]", buffer_size, i);
125 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
128 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
129 if (cb_info->fds[i] < 0) {
130 LOGE("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
131 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
134 LOGD("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
141 _ALLOCATE_PREVIEW_BUFFER_FAILED:
142 _camera_release_preview_buffer(camera);
147 static void _camera_release_preview_buffer(camera_h camera)
150 camera_cli_s *pc = (camera_cli_s *)camera;
151 camera_cb_info_s *cb_info = NULL;
153 if (!pc || !pc->cb_info) {
154 LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
160 cb_info = pc->cb_info;
162 /* close exported fd and bos */
163 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
164 LOGD("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
166 if (cb_info->bos[i]) {
167 tbm_bo_unref(cb_info->bos[i]);
168 cb_info->bos[i] = NULL;
173 if (cb_info->fds[i] >= 0) {
174 close(cb_info->fds[i]);
175 cb_info->fds[i] = -1;
185 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
188 api < 0 || api >= MUSE_CAMERA_API_MAX) {
189 LOGE("invalid param %p %d", cb_info, api);
193 g_mutex_lock(&(cb_info->api_mutex[api]));
194 cb_info->api_waiting[api] += value;
195 g_mutex_unlock(&(cb_info->api_mutex[api]));
197 /*LOGD("api %d, value %d, waiting %d",
198 api, value, cb_info->api_waiting[api]);*/
204 static void __camera_device_state_changed_cb(GDBusConnection *connection,
205 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
206 const gchar *signal_name, GVariant *param, gpointer user_data)
209 camera_device_e device = CAMERA_DEVICE_CAMERA0;
210 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
211 GList *tmp_list = NULL;
212 camera_cb_info *info = NULL;
214 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
216 if (!g_cam_dev_state_changed_cb_list || !param) {
217 LOGW("no callback or NULL param %p", param);
221 /* get device and state */
222 g_variant_get(param, "(i)", &value);
224 device = value >> 16;
225 state = 0x0000ffff & value;
227 LOGD("device %d, state %d", device, state);
229 tmp_list = g_cam_dev_state_changed_cb_list;
232 info = (camera_cb_info *)tmp_list->data;
235 if (info->callback) {
236 LOGD("start id[%d] callback", info->id);
237 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
238 LOGD("returned id[%d] callback", info->id);
240 LOGW("NULL callback for id %d", info->id);
244 tmp_list = tmp_list->next;
248 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
254 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
260 int num_buffer_fd = 0;
261 unsigned char *buf_pos = NULL;
264 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
265 tbm_bo_handle bo_handle = {.ptr = NULL};
266 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
267 tbm_bo data_bo = NULL;
268 tbm_bo_handle data_bo_handle = {.ptr = NULL};
270 camera_msg_param param;
271 camera_preview_data_s frame;
272 camera_stream_data_s *stream = NULL;
273 camera_media_packet_data *mp_data = NULL;
274 media_packet_h pkt = NULL;
275 media_packet_h pkt_evas = NULL;
277 /* tfd[0]: MMCamcorderVideoStreamDataType
278 tfd[1]: data_bo or zero copy bo[0]
279 tfd[2]: zero copy bo[1]
280 tfd[3]: zero copy bo[2] */
282 if (!cb_info || !recv_msg || !tfd) {
283 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
287 muse_camera_msg_get(preview_fd, recv_msg);
288 muse_camera_msg_get(num_buffer_fd, recv_msg);
290 /*LOGD("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);*/
292 memset(&frame, 0x0, sizeof(camera_preview_data_s));
295 LOGE("invalid fd %d", tfd[0]);
300 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
302 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
303 LOGE("invalid num buffer fd %d", num_buffer_fd);
304 goto _PREVIEW_CB_HANDLER_DONE;
307 if (num_buffer_fd == 0 && tfd[1] >= 0) {
308 /* import tbm data_bo and get virtual address */
309 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
310 LOGE("failed to import data fd %d", tfd[1]);
311 goto _PREVIEW_CB_HANDLER_DONE;
315 /* import tbm bo and get virtual address */
316 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
317 LOGE("failed to import fd %d", tfd[0]);
318 goto _PREVIEW_CB_HANDLER_DONE;
321 buf_pos = (unsigned char *)bo_handle.ptr;
323 /* get stream info */
324 stream = (camera_stream_data_s *)buf_pos;
326 for (i = 0 ; i < num_buffer_fd ; i++) {
327 /* import buffer bo and get virtual address */
328 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
329 LOGE("failed to import buffer fd %d", tfd[i + 1]);
330 goto _PREVIEW_CB_HANDLER_DONE;
334 /* call preview callback */
335 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
336 _camera_preview_frame_create(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
338 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
339 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
342 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
343 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
345 if (ret == CAMERA_ERROR_NONE) {
346 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
347 if (ret != CAMERA_ERROR_NONE) {
348 LOGE("create pkt for evas failed");
349 _camera_media_packet_data_release(mp_data, cb_info);
355 /* call media packet callback */
356 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
357 ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
359 if (ret == CAMERA_ERROR_NONE) {
360 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
362 if (ret == CAMERA_ERROR_NONE) {
363 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
364 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
366 _camera_media_packet_data_release(mp_data, cb_info);
372 /* call evas renderer */
374 if (cb_info->run_evas_render) {
375 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
377 LOGW("evas renderer is stopped, skip this buffer...");
378 media_packet_destroy(pkt_evas);
383 /* send message for preview callback return */
384 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
385 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
387 _PREVIEW_CB_HANDLER_DONE:
388 if (mp_data == NULL) {
389 /* release imported bo */
390 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
391 _camera_release_imported_bo(&buffer_bo[i]);
393 /* unmap and unref tbm bo */
394 _camera_release_imported_bo(&data_bo);
395 _camera_release_imported_bo(&bo);
397 /* close imported fd */
398 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
408 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
410 /*LOGD("return buffer Done");*/
417 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
421 int capture_fd_main = 0;
422 int capture_fd_post = 0;
423 int capture_fd_thumb = 0;
424 unsigned char *buf_pos = NULL;
426 camera_image_data_s *rImage = NULL;
427 camera_image_data_s *rPostview = NULL;
428 camera_image_data_s *rThumbnail = NULL;
430 tbm_bo bo_main = NULL;
431 tbm_bo bo_post = NULL;
432 tbm_bo bo_thumb = NULL;
433 tbm_bo_handle bo_main_handle = {.ptr = NULL};
434 tbm_bo_handle bo_post_handle = {.ptr = NULL};
435 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
437 if (!cb_info || !recv_msg || !tfd) {
438 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
442 muse_camera_msg_get(capture_fd_main, recv_msg);
443 muse_camera_msg_get(capture_fd_post, recv_msg);
444 muse_camera_msg_get(capture_fd_thumb, recv_msg);
446 LOGD("capture fd %d %d %d, received fd %d %d %d",
447 capture_fd_main, capture_fd_post, capture_fd_thumb,
448 tfd[0], tfd[1], tfd[2]);
450 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
451 LOGE("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
452 goto _CAPTURE_CB_HANDLER_DONE;
455 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
456 LOGW("NULL callback");
457 goto _CAPTURE_CB_HANDLER_DONE;
460 /* import tbm bo and get virtual address */
461 if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
462 LOGE("failed to import fd [%d] for main", tfd[tfd_index]);
463 goto _CAPTURE_CB_HANDLER_DONE;
466 buf_pos = (unsigned char *)bo_main_handle.ptr;
467 rImage = (camera_image_data_s *)buf_pos;
468 rImage->data = buf_pos + sizeof(camera_image_data_s);
469 if (rImage->exif && rImage->exif_size > 0) {
470 rImage->exif = rImage->data + rImage->size;
473 rImage->exif_size = 0;
476 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
477 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
479 if (capture_fd_post >= 0) {
480 /* import tbm bo and get virtual address */
482 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
483 buf_pos = (unsigned char *)bo_post_handle.ptr;
484 rPostview = (camera_image_data_s *)buf_pos;
485 LOGD("rPostview->size : %d", rPostview->size);
486 rPostview->data = buf_pos + sizeof(camera_image_data_s);
488 LOGE("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
492 if (capture_fd_thumb >= 0) {
493 /* import tbm bo and get virtual address */
495 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
496 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
497 rThumbnail = (camera_image_data_s *)buf_pos;
498 LOGD("rThumbnail->size : %d", rThumbnail->size);
499 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
501 LOGE("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
505 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
506 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
508 _CAPTURE_CB_HANDLER_DONE:
510 if (capture_fd_main >= 0) {
511 _camera_release_imported_bo(&bo_main);
512 _camera_msg_return_buffer(capture_fd_main, cb_info);
515 if (capture_fd_post >= 0) {
516 _camera_release_imported_bo(&bo_post);
517 _camera_msg_return_buffer(capture_fd_post, cb_info);
520 if (capture_fd_thumb >= 0) {
521 _camera_release_imported_bo(&bo_thumb);
522 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
525 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
527 LOGD("close %d", tfd[i]);
535 LOGD("return buffer done");
541 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
545 camera_detected_face_s *faces = NULL;
548 tbm_bo_handle bo_handle = {.ptr = NULL};
550 if (!cb_info || !recv_msg || !tfd) {
551 LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
555 muse_camera_msg_get(count, recv_msg);
556 muse_camera_msg_get(face_fd, recv_msg);
558 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
559 LOGD("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
562 if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
564 faces = bo_handle.ptr;
571 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
572 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
575 _camera_release_imported_bo(&bo);
577 LOGW("skip face detection message [count %d, fd %d, cb %p]",
578 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
582 _camera_msg_return_buffer(face_fd, cb_info);
588 static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
590 tbm_bo tmp_bo = NULL;
591 tbm_bo_handle tmp_bo_handle = {NULL, };
593 if (!bufmgr || !bo || !bo_handle || fd < 0) {
594 LOGE("invalid parameter - %p %p %p, fd %d",
595 bufmgr, bo, bo_handle, fd);
599 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
600 if (tmp_bo == NULL) {
601 LOGE("import failed - fd %d", fd);
605 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
606 if (tmp_bo_handle.ptr == NULL) {
607 LOGE("map failed %p", tmp_bo);
608 tbm_bo_unref(tmp_bo);
613 tbm_bo_unmap(tmp_bo);
615 /* set bo and bo_handle */
617 *bo_handle = tmp_bo_handle;
622 static void _camera_release_imported_bo(tbm_bo *bo)
635 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
637 int ret = CAMERA_ERROR_NONE;
640 /*LOGD("Enter api : %d", api);*/
642 if (!cb_info->is_server_connected) {
643 LOGE("server is disconnected");
644 return CAMERA_ERROR_SERVICE_DISCONNECTED;
647 g_mutex_lock(&(cb_info->api_mutex[api]));
649 if (cb_info->api_activating[api] == 0) {
650 if (time_out == CAMERA_CB_NO_TIMEOUT) {
651 LOGW("wait for api %d", api);
652 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
653 ret = cb_info->api_ret[api];
654 cb_info->api_activating[api] = 0;
655 LOGW("api %d returned 0x%x", api, ret);
657 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
658 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
659 ret = cb_info->api_ret[api];
660 cb_info->api_activating[api] = 0;
661 /*LOGD("return value : 0x%x", ret);*/
663 ret = CAMERA_ERROR_INVALID_OPERATION;
664 LOGE("api %d was TIMED OUT!", api);
668 ret = cb_info->api_ret[api];
669 cb_info->api_activating[api] = 0;
671 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
674 g_mutex_unlock(&(cb_info->api_mutex[api]));
676 if (ret != CAMERA_ERROR_NONE)
677 LOGE("api %d : error 0x%x", api, ret);
683 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
684 int *ret, int timeout)
690 LOGE("NULL info - api %d", api);
693 *ret = CAMERA_ERROR_INVALID_PARAMETER;
698 msg = muse_core_msg_new(api, NULL);
700 LOGE("msg failed: api %d", api);
703 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
708 /*LOGD("send msg %s", msg);*/
710 if (cb_info->is_server_connected) {
711 __camera_update_api_waiting(cb_info, api, 1);
713 g_mutex_lock(&cb_info->fd_lock);
714 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
715 g_mutex_unlock(&cb_info->fd_lock);
719 LOGE("msg send failed");
721 *ret = CAMERA_ERROR_INVALID_OPERATION;
724 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
727 __camera_update_api_waiting(cb_info, api, -1);
729 muse_core_msg_free(msg);
735 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
736 int *ret, camera_msg_param *param, int timeout)
741 if (!cb_info || !param) {
742 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
745 *ret = CAMERA_ERROR_INVALID_PARAMETER;
750 /*LOGD("type %d, name %s", param->type, param->name);*/
752 switch (param->type) {
754 msg = muse_core_msg_new(api,
755 param->type, param->name, param->value.value_INT,
758 case MUSE_TYPE_STRING:
759 msg = muse_core_msg_new(api,
760 param->type, param->name, param->value.value_STRING,
764 LOGE("unknown type %d", param->type);
769 LOGE("msg failed: api %d", api);
772 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
777 /*LOGD("send msg %s", msg);*/
779 if (cb_info->is_server_connected) {
780 __camera_update_api_waiting(cb_info, api, 1);
782 g_mutex_lock(&cb_info->fd_lock);
783 send_ret = muse_core_msg_send(cb_info->fd, msg);
784 g_mutex_unlock(&cb_info->fd_lock);
788 LOGE("msg send failed");
791 *ret = CAMERA_ERROR_INVALID_OPERATION;
794 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
797 __camera_update_api_waiting(cb_info, api, -1);
799 muse_core_msg_free(msg);
805 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
806 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
808 int func_ret = CAMERA_ERROR_NONE;
812 if (!cb_info || !param0 || !param1) {
813 LOGE("invalid ptr %p %p %p : api %d",
814 cb_info, param0, param1, api);
815 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
816 goto _SEND_PARAM2_INT_DONE;
819 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
821 param0->name, param0->value.value_INT,
822 param1->name, param1->value.value_INT);*/
824 msg = muse_core_msg_new(api,
825 param0->type, param0->name, param0->value.value_INT,
826 param1->type, param1->name, param1->value.value_INT,
829 LOGE("msg failed: api %d", api);
830 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
831 goto _SEND_PARAM2_INT_DONE;
834 /*LOGD("send msg [%s]", msg);*/
836 if (cb_info->is_server_connected) {
837 __camera_update_api_waiting(cb_info, api, 1);
839 g_mutex_lock(&cb_info->fd_lock);
840 send_ret = muse_core_msg_send(cb_info->fd, msg);
841 g_mutex_unlock(&cb_info->fd_lock);
845 LOGE("msg send failed");
847 func_ret = CAMERA_ERROR_INVALID_OPERATION;
849 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
852 __camera_update_api_waiting(cb_info, api, -1);
854 muse_core_msg_free(msg);
856 _SEND_PARAM2_INT_DONE:
864 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
866 camera_msg_param param;
869 LOGW("invalid fd %d", ret_fd);
873 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
875 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
881 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
883 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
884 in_format >= MM_PIXEL_FORMAT_NUM ||
885 out_format == NULL) {
886 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
887 return CAMERA_ERROR_INVALID_PARAMETER;
891 case MM_PIXEL_FORMAT_NV12:
892 case MM_PIXEL_FORMAT_NV12T:
893 *out_format = TBM_FORMAT_NV12;
895 case MM_PIXEL_FORMAT_NV16:
896 *out_format = TBM_FORMAT_NV16;
898 case MM_PIXEL_FORMAT_NV21:
899 *out_format = TBM_FORMAT_NV21;
901 case MM_PIXEL_FORMAT_YUYV:
902 *out_format = TBM_FORMAT_YUYV;
904 case MM_PIXEL_FORMAT_UYVY:
905 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
906 *out_format = TBM_FORMAT_UYVY;
908 case MM_PIXEL_FORMAT_422P:
909 *out_format = TBM_FORMAT_YUV422;
911 case MM_PIXEL_FORMAT_I420:
912 *out_format = TBM_FORMAT_YUV420;
914 case MM_PIXEL_FORMAT_YV12:
915 *out_format = TBM_FORMAT_YVU420;
917 case MM_PIXEL_FORMAT_RGB565:
918 *out_format = TBM_FORMAT_RGB565;
920 case MM_PIXEL_FORMAT_RGB888:
921 *out_format = TBM_FORMAT_RGB888;
923 case MM_PIXEL_FORMAT_RGBA:
924 *out_format = TBM_FORMAT_RGBA8888;
926 case MM_PIXEL_FORMAT_ARGB:
927 *out_format = TBM_FORMAT_ARGB8888;
930 LOGE("invalid in_format %d", in_format);
931 return CAMERA_ERROR_INVALID_PARAMETER;
934 return CAMERA_ERROR_NONE;
938 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
940 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
941 in_format >= MM_PIXEL_FORMAT_NUM ||
943 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
944 return CAMERA_ERROR_INVALID_PARAMETER;
948 case MM_PIXEL_FORMAT_NV12:
949 case MM_PIXEL_FORMAT_NV12T:
950 *mimetype = MEDIA_FORMAT_NV12;
952 case MM_PIXEL_FORMAT_NV16:
953 *mimetype = MEDIA_FORMAT_NV16;
955 case MM_PIXEL_FORMAT_NV21:
956 *mimetype = MEDIA_FORMAT_NV21;
958 case MM_PIXEL_FORMAT_YUYV:
959 *mimetype = MEDIA_FORMAT_YUYV;
961 case MM_PIXEL_FORMAT_UYVY:
962 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
963 *mimetype = MEDIA_FORMAT_UYVY;
965 case MM_PIXEL_FORMAT_422P:
966 *mimetype = MEDIA_FORMAT_422P;
968 case MM_PIXEL_FORMAT_I420:
969 *mimetype = MEDIA_FORMAT_I420;
971 case MM_PIXEL_FORMAT_YV12:
972 *mimetype = MEDIA_FORMAT_YV12;
974 case MM_PIXEL_FORMAT_RGB565:
975 *mimetype = MEDIA_FORMAT_RGB565;
977 case MM_PIXEL_FORMAT_RGB888:
978 *mimetype = MEDIA_FORMAT_RGB888;
980 case MM_PIXEL_FORMAT_RGBA:
981 *mimetype = MEDIA_FORMAT_RGBA;
983 case MM_PIXEL_FORMAT_ARGB:
984 *mimetype = MEDIA_FORMAT_ARGB;
987 LOGE("invalid in_format %d", in_format);
988 return CAMERA_ERROR_INVALID_PARAMETER;
991 return CAMERA_ERROR_NONE;
994 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
995 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
998 unsigned char *buf_pos = NULL;
1000 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1001 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1005 /* set frame info */
1006 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1007 frame->format = MM_PIXEL_FORMAT_UYVY;
1009 frame->format = stream->format;
1011 frame->width = stream->width;
1012 frame->height = stream->height;
1013 frame->timestamp = stream->timestamp;
1014 frame->num_of_planes = stream->num_planes;
1016 if (num_buffer_fd == 0) {
1018 if (!data_bo_handle || !data_bo_handle->ptr) {
1019 LOGE("NULL pointer");
1023 buf_pos = data_bo_handle->ptr;
1025 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1026 frame->data.encoded_plane.data = buf_pos;
1027 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1028 total_size = stream->data.encoded.length_data;
1029 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1030 frame->data.depth_plane.data = buf_pos;
1031 frame->data.depth_plane.size = stream->data.depth.length_data;
1032 total_size = stream->data.depth.length_data;
1033 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1034 stream->format == MM_PIXEL_FORMAT_ARGB) {
1035 frame->data.rgb_plane.data = buf_pos;
1036 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1037 total_size = stream->data.rgb.length_data;
1039 switch (stream->num_planes) {
1041 frame->data.single_plane.yuv = buf_pos;
1042 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1043 total_size = stream->data.yuv420.length_yuv;
1046 frame->data.double_plane.y = buf_pos;
1047 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1048 buf_pos += stream->data.yuv420sp.length_y;
1049 frame->data.double_plane.uv = buf_pos;
1050 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1051 total_size = stream->data.yuv420sp.length_y + \
1052 stream->data.yuv420sp.length_uv;
1055 frame->data.triple_plane.y = buf_pos;
1056 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1057 buf_pos += stream->data.yuv420p.length_y;
1058 frame->data.triple_plane.u = buf_pos;
1059 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1060 buf_pos += stream->data.yuv420p.length_u;
1061 frame->data.triple_plane.v = buf_pos;
1062 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1063 total_size = stream->data.yuv420p.length_y + \
1064 stream->data.yuv420p.length_u + \
1065 stream->data.yuv420p.length_v;
1073 switch (stream->num_planes) {
1075 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1076 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1077 total_size = stream->data.yuv420.length_yuv;
1080 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1081 if (stream->num_planes == (unsigned int)num_buffer_fd)
1082 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1084 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1085 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1086 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1087 total_size = stream->data.yuv420sp.length_y + \
1088 stream->data.yuv420sp.length_uv;
1091 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1092 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1093 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1094 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1096 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1097 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1099 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1100 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1101 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1102 total_size = stream->data.yuv420p.length_y + \
1103 stream->data.yuv420p.length_u + \
1104 stream->data.yuv420p.length_v;
1112 LOGD("format %d, %dx%d, size %d plane num %d",
1113 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1119 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1120 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1123 int ret = CAMERA_ERROR_NONE;
1124 camera_media_packet_data *tmp_mp_data = NULL;
1128 return CAMERA_ERROR_INVALID_PARAMETER;
1131 if (*mp_data == NULL) {
1132 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1134 tmp_mp_data->ret_fd = ret_fd;
1135 tmp_mp_data->fd = tfd[0];
1136 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1137 tmp_mp_data->bo = bo;
1141 tmp_mp_data->data_bo = data_bo;
1142 tmp_mp_data->data_fd = tfd[1];
1145 for (i = 0 ; i < num_buffer_fd ; i++) {
1146 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1147 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1151 tmp_mp_data->ref_cnt++;
1153 *mp_data = tmp_mp_data;
1154 /*LOGD("mp_data %p", tmp_mp_data);*/
1156 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1157 LOGE("failed to alloc media packet data");
1160 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1166 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1170 if (!mp_data || !cb_info) {
1171 LOGE("NULL pointer %p %p", mp_data, cb_info);
1175 if (mp_data->ref_cnt > 1) {
1177 LOGD("ref count %d", mp_data->ref_cnt);
1179 /* release imported bo and close imported fd */
1180 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1181 tbm_bo_unref(mp_data->buffer_bo[i]);
1182 mp_data->buffer_bo[i] = NULL;
1184 close(mp_data->buffer_fd[i]);
1185 mp_data->buffer_fd[i] = -1;
1188 /* unref tbm bo and close imported fd */
1191 _camera_release_imported_bo(&mp_data->bo);
1193 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1194 close(mp_data->data_fd);
1195 mp_data->data_fd = -1;
1197 _camera_release_imported_bo(&mp_data->data_bo);
1200 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1209 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1210 camera_media_packet_data *mp_data, media_packet_h *packet)
1212 media_packet_h pkt = NULL;
1213 bool make_pkt_fmt = false;
1214 tbm_surface_h tsurf = NULL;
1215 tbm_surface_info_s tsurf_info;
1216 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1217 uint32_t bo_format = 0;
1220 int num_buffer_fd = 0;
1221 tbm_bo *buffer_bo = NULL;
1223 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1224 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1225 cb_info, stream, mp_data, packet);
1226 return CAMERA_ERROR_INVALID_PARAMETER;
1229 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1230 buffer_bo = mp_data->buffer_bo;
1231 num_buffer_fd = mp_data->num_buffer_fd;
1233 /* create tbm surface */
1234 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1235 tsurf_info.planes[i].stride = stream->stride[i];
1237 /* get tbm surface format */
1238 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1239 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1241 if (ret == CAMERA_ERROR_NONE) {
1242 tsurf_info.width = stream->width;
1243 tsurf_info.height = stream->height;
1244 tsurf_info.format = bo_format;
1245 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1246 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1248 if (num_buffer_fd > 0) {
1249 switch (bo_format) {
1250 case TBM_FORMAT_NV12:
1251 case TBM_FORMAT_NV21:
1252 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1253 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1254 tsurf_info.planes[0].offset = 0;
1255 if (num_buffer_fd == 1)
1256 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1257 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1259 case TBM_FORMAT_YUV420:
1260 case TBM_FORMAT_YVU420:
1261 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1262 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1263 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1264 tsurf_info.planes[0].offset = 0;
1265 if (num_buffer_fd == 1) {
1266 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1267 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1269 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1271 case TBM_FORMAT_UYVY:
1272 case TBM_FORMAT_YUYV:
1273 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1274 tsurf_info.planes[0].offset = 0;
1275 tsurf_info.size = tsurf_info.planes[0].size;
1281 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1282 } else if (mp_data->data_bo) {
1283 switch (bo_format) {
1284 case TBM_FORMAT_NV12:
1285 case TBM_FORMAT_NV21:
1286 tsurf_info.planes[0].size = stream->width * stream->height;
1287 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1288 tsurf_info.planes[0].offset = 0;
1289 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1290 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1292 case TBM_FORMAT_YUV420:
1293 case TBM_FORMAT_YVU420:
1294 tsurf_info.planes[0].size = stream->width * stream->height;
1295 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1296 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1297 tsurf_info.planes[0].offset = 0;
1298 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1299 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1300 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1302 case TBM_FORMAT_UYVY:
1303 case TBM_FORMAT_YUYV:
1304 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1305 tsurf_info.planes[0].offset = 0;
1306 tsurf_info.size = tsurf_info.planes[0].size;
1312 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1314 /*LOGD("tbm surface %p", tsurf);*/
1318 /* check media packet format */
1319 if (cb_info->pkt_fmt) {
1320 int pkt_fmt_width = 0;
1321 int pkt_fmt_height = 0;
1322 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1324 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1325 if (pkt_fmt_mimetype != mimetype ||
1326 pkt_fmt_width != stream->width ||
1327 pkt_fmt_height != stream->height) {
1328 LOGW("change fmt: current 0x%x, %dx%d",
1329 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1330 media_format_unref(cb_info->pkt_fmt);
1331 cb_info->pkt_fmt = NULL;
1332 make_pkt_fmt = true;
1335 make_pkt_fmt = true;
1338 /* create packet format */
1340 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1341 ret = media_format_create(&cb_info->pkt_fmt);
1342 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1343 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1344 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1345 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1346 LOGW("media_format_set : 0x%x", ret);
1348 LOGW("media_format_create failed 0x%x", ret);
1352 /* create media packet */
1353 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1354 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1355 (void *)cb_info, &pkt);
1356 if (ret != MEDIA_PACKET_ERROR_NONE) {
1357 LOGE("media_packet_create failed 0x%x", ret);
1358 tbm_surface_destroy(tsurf);
1362 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1363 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1367 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1368 /* set media packet data */
1369 ret = media_packet_set_extra(pkt, (void *)mp_data);
1370 if (ret != MEDIA_PACKET_ERROR_NONE) {
1371 LOGE("media_packet_set_extra failed");
1373 _camera_media_packet_data_release(mp_data, cb_info);
1376 media_packet_destroy(pkt);
1379 /* set timestamp : msec -> nsec */
1380 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1381 LOGW("media_packet_set_pts failed");
1390 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1393 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1394 camera_media_packet_data *mp_data = NULL;
1395 tbm_surface_h tsurf = NULL;
1397 if (!pkt || !cb_info) {
1398 LOGE("NULL pointer %p %p", pkt, cb_info);
1399 return MEDIA_PACKET_FINALIZE;
1402 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1403 if (ret != MEDIA_PACKET_ERROR_NONE) {
1404 LOGE("media_packet_get_extra failed 0x%x", ret);
1405 return MEDIA_PACKET_FINALIZE;
1408 /*LOGD("mp_data %p", mp_data);*/
1410 g_mutex_lock(&cb_info->mp_data_mutex);
1412 _camera_media_packet_data_release(mp_data, cb_info);
1415 g_mutex_unlock(&cb_info->mp_data_mutex);
1417 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1418 if (ret != MEDIA_PACKET_ERROR_NONE)
1419 LOGE("get tbm_surface failed 0x%x", ret);
1422 tbm_surface_destroy(tsurf);
1426 return MEDIA_PACKET_FINALIZE;
1429 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1434 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1435 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1439 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1441 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1443 if (cb_info->user_cb[event] == NULL) {
1444 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1445 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1446 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1447 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1448 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1449 LOGW("NULL callback for event %d, return here", event);
1453 /* return buffer message should be sent for some events.
1454 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1455 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1456 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1457 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1462 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1468 muse_camera_msg_get(previous, recv_msg);
1469 muse_camera_msg_get(current, recv_msg);
1470 muse_camera_msg_get(by_policy, recv_msg);
1472 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1473 previous, current, by_policy);
1475 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1476 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1479 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1483 muse_camera_msg_get(state, recv_msg);
1485 LOGD("FOCUS state - %d", state);
1487 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1490 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1491 LOGD("CAPTURE_COMPLETED");
1492 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1494 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1495 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1496 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1498 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1502 muse_camera_msg_get(percent, recv_msg);
1504 LOGD("HDR progress - %d %%", percent);
1506 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1509 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1515 muse_camera_msg_get(policy, recv_msg);
1516 muse_camera_msg_get(previous, recv_msg);
1517 muse_camera_msg_get(current, recv_msg);
1519 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1521 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1522 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1525 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1530 muse_camera_msg_get(policy, recv_msg);
1531 muse_camera_msg_get(state, recv_msg);
1533 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1535 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1536 (camera_state_e)state, cb_info->user_data[event]);
1539 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1540 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1542 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1545 int current_state = 0;
1547 muse_camera_msg_get(error, recv_msg);
1548 muse_camera_msg_get(current_state, recv_msg);
1550 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1552 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1553 (camera_state_e)current_state, cb_info->user_data[event]);
1556 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1558 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1559 muse_camera_msg_get(param1, recv_msg);
1560 muse_camera_msg_get(param2, recv_msg);
1562 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1564 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1565 cb_info->user_cb[event] = NULL;
1566 cb_info->user_data[event] = NULL;
1567 LOGW("stop foreach callback for event %d", event);
1570 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1572 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1574 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1576 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1578 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1582 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1584 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1586 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1588 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1590 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1599 muse_camera_msg_get(param1, recv_msg);
1601 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1603 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1604 cb_info->user_cb[event] = NULL;
1605 cb_info->user_data[event] = NULL;
1606 LOGW("stop foreach callback for event %d", event);
1609 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1610 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1613 LOGW("unhandled event %d", event);
1617 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1622 static gboolean _camera_idle_event_callback(gpointer data)
1624 camera_cb_info_s *cb_info = NULL;
1625 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1627 if (cam_idle_event == NULL) {
1628 LOGE("cam_idle_event is NULL");
1633 g_mutex_lock(&g_cam_idle_event_lock);
1635 cb_info = cam_idle_event->cb_info;
1636 if (cb_info == NULL) {
1637 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1638 g_mutex_unlock(&g_cam_idle_event_lock);
1639 goto IDLE_EVENT_CALLBACK_DONE;
1642 /* remove event from list */
1643 if (cb_info->idle_event_list)
1644 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1646 g_mutex_unlock(&g_cam_idle_event_lock);
1649 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1651 IDLE_EVENT_CALLBACK_DONE:
1653 g_free(cam_idle_event);
1654 cam_idle_event = NULL;
1659 static void *_camera_msg_handler_func(gpointer data)
1663 camera_message_s *cam_msg = NULL;
1664 camera_idle_event_s *cam_idle_event = NULL;
1665 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1666 camera_cb_info_s *cb_info = NULL;
1668 if (!handler_info || !handler_info->cb_info) {
1669 LOGE("NULL handler %p", handler_info);
1673 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1674 type = handler_info->type;
1676 LOGD("t:%d start", type);
1678 g_mutex_lock(&handler_info->mutex);
1680 while (g_atomic_int_get(&handler_info->running)) {
1681 if (g_queue_is_empty(handler_info->queue)) {
1682 /*LOGD("t:%d signal wait...", type);*/
1683 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1684 /*LOGD("t:%d signal received", type);*/
1686 if (g_atomic_int_get(&handler_info->running) == 0) {
1687 LOGD("t:%d stop event thread", type);
1692 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1694 g_mutex_unlock(&handler_info->mutex);
1696 if (cam_msg == NULL) {
1697 LOGE("t:%d NULL message", type);
1698 g_mutex_lock(&handler_info->mutex);
1704 if (api < MUSE_CAMERA_API_MAX) {
1707 g_mutex_lock(&cb_info->api_mutex[api]);
1709 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1710 if (cb_info->api_waiting[api] > 0) {
1711 cb_info->api_ret[api] = ret;
1712 cb_info->api_activating[api] = 1;
1714 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1716 g_cond_signal(&cb_info->api_cond[api]);
1718 LOGW("no waiting for this api [%d]", api);
1721 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1724 g_mutex_unlock(&cb_info->api_mutex[api]);
1725 } else if (api == MUSE_CAMERA_CB_EVENT) {
1726 switch (cam_msg->event_class) {
1727 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1728 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1730 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1731 cam_idle_event = g_new0(camera_idle_event_s, 1);
1732 if (cam_idle_event == NULL) {
1733 LOGE("t:%d cam_idle_event alloc failed", type);
1737 cam_idle_event->event = cam_msg->event;
1738 cam_idle_event->cb_info = cb_info;
1740 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1741 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1743 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1745 g_mutex_lock(&g_cam_idle_event_lock);
1746 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1747 g_mutex_unlock(&g_cam_idle_event_lock);
1749 g_idle_add_full(G_PRIORITY_DEFAULT,
1750 (GSourceFunc)_camera_idle_event_callback,
1751 (gpointer)cam_idle_event,
1755 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1759 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1765 g_mutex_lock(&handler_info->mutex);
1768 /* remove remained event */
1769 while (!g_queue_is_empty(handler_info->queue)) {
1770 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1772 LOGD("t:%d remove camera message %p", type, cam_msg);
1776 LOGW("t:%d NULL camera message", type);
1780 g_mutex_unlock(&handler_info->mutex);
1782 LOGD("t:%d return", type);
1788 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1790 camera_idle_event_s *cam_idle_event = NULL;
1793 if (cb_info == NULL) {
1794 LOGE("cb_info is NULL");
1798 g_mutex_lock(&g_cam_idle_event_lock);
1800 if (cb_info->idle_event_list == NULL) {
1801 LOGD("No remained idle event");
1802 g_mutex_unlock(&g_cam_idle_event_lock);
1806 list = cb_info->idle_event_list;
1809 cam_idle_event = list->data;
1810 list = g_list_next(list);
1812 if (!cam_idle_event) {
1813 LOGW("Fail to remove idle event. The event is NULL");
1817 if (g_idle_remove_by_data(cam_idle_event)) {
1818 LOGW("remove idle event %p done", cam_idle_event);
1820 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1822 g_free(cam_idle_event);
1823 cam_idle_event = NULL;
1828 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1829 cam_idle_event, cam_idle_event->event);
1831 cam_idle_event->cb_info = NULL;
1833 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1836 g_list_free(cb_info->idle_event_list);
1837 cb_info->idle_event_list = NULL;
1839 g_mutex_unlock(&g_cam_idle_event_lock);
1845 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1847 camera_message_s *cam_msg = NULL;
1849 if (!cb_info || !msg) {
1850 LOGE("NULL pointer %p %p", cb_info, msg);
1854 cam_msg = g_new0(camera_message_s, 1);
1856 LOGE("failed to alloc cam_msg for [%s]", msg);
1861 cam_msg->event = event;
1862 cam_msg->event_class = event_class;
1864 if (tfd && tfd[0] >= 0)
1865 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1867 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1869 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1871 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1872 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1873 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1874 g_cond_signal(&cb_info->preview_cb_info.cond);
1875 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1876 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1877 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1878 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1879 g_cond_signal(&cb_info->capture_cb_info.cond);
1880 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1882 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1883 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1884 g_cond_signal(&cb_info->msg_handler_info.cond);
1885 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1894 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1896 int ret = CAMERA_ERROR_NONE;
1900 int event_class = -1;
1904 if (!cb_info || !msg) {
1905 LOGE("invalid ptr %p %p", cb_info, msg);
1909 /*LOGD("msg [%s]", msg);*/
1911 if (!muse_camera_msg_get(api, msg)) {
1912 LOGE("failed to get camera api");
1916 if (api == MUSE_CAMERA_CB_EVENT) {
1917 if (!muse_camera_msg_get(event, msg) ||
1918 !muse_camera_msg_get(event_class, msg)) {
1919 LOGE("failed to get camera event or event_class [%s]", msg);
1923 if (!muse_camera_msg_get(api_class, msg)) {
1924 LOGE("failed to get camera api_class [%s]", msg);
1929 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1930 if (api >= MUSE_CAMERA_API_MAX) {
1931 LOGE("invalid api %d", api);
1935 if (!muse_camera_msg_get(ret, msg)) {
1936 LOGE("failed to get camera ret");
1940 g_mutex_lock(&cb_info->api_mutex[api]);
1943 case MUSE_CAMERA_API_CREATE:
1944 if (ret != CAMERA_ERROR_NONE) {
1945 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1946 LOGE("camera create error 0x%x. close client cb handler", ret);
1949 case MUSE_CAMERA_API_DESTROY:
1950 if (ret == CAMERA_ERROR_NONE) {
1951 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1952 LOGD("camera destroy done. close client cb handler");
1956 muse_camera_msg_get(get_type, msg);
1957 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1958 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1959 muse_camera_msg_get(get_index, msg);
1962 case MUSE_CAMERA_GET_TYPE_INT:
1963 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1965 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1966 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1967 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1969 case MUSE_CAMERA_GET_TYPE_ARRAY:
1970 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1971 muse_core_msg_deserialize("get_value",
1972 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1973 LOGD("get display roi %d,%d,%dx%d",
1974 cb_info->get_display_roi_area[0],
1975 cb_info->get_display_roi_area[1],
1976 cb_info->get_display_roi_area[2],
1977 cb_info->get_display_roi_area[3]);
1979 muse_core_msg_deserialize("get_value",
1980 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1981 LOGD("get geotag %lf, %lf, %lf",
1982 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1985 case MUSE_CAMERA_GET_TYPE_STRING:
1986 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1989 LOGW("unknown type %d", get_type);
1996 if (cb_info->api_waiting[api] > 0) {
1997 cb_info->api_ret[api] = ret;
1998 cb_info->api_activating[api] = 1;
2000 g_cond_signal(&cb_info->api_cond[api]);
2002 LOGW("no waiting for this api [%d]", api);
2005 g_mutex_unlock(&cb_info->api_mutex[api]);
2006 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2007 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2009 LOGW("unknown camera api %d, class %d", api, api_class);
2016 static void *_camera_msg_recv_func(gpointer data)
2019 int recv_length = 0;
2020 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2021 char *recv_msg = NULL;
2022 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2025 LOGE("cb_info NULL");
2029 LOGD("start - fd : %d", cb_info->fd);
2031 recv_msg = cb_info->recv_msg;
2033 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2034 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2037 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2038 if (recv_length <= 0) {
2039 cb_info->is_server_connected = FALSE;
2040 LOGE("receive msg failed - server disconnected");
2046 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2049 recv_msg[recv_length] = '\0';
2051 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2053 __camera_process_msg(cb_info, recv_msg, tfd);
2056 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2058 if (!cb_info->is_server_connected) {
2059 char *error_msg = NULL;
2061 if (cb_info->fd < 0) {
2062 LOGE("fd is closed in client side");
2063 goto CB_HANDLER_EXIT;
2066 /* send error msg for server disconnection */
2067 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2068 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2069 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2073 LOGE("error_msg failed");
2074 goto CB_HANDLER_EXIT;
2077 __camera_add_msg_to_queue(cb_info,
2078 MUSE_CAMERA_CB_EVENT,
2079 MUSE_CAMERA_EVENT_TYPE_ERROR,
2080 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2084 muse_core_msg_free(error_msg);
2087 LOGE("add error msg for service disconnection done");
2095 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2096 int type, const char *thread_name, camera_cb_info_s *cb_info)
2098 if (!handler_info || !thread_name || !cb_info) {
2099 LOGE("t:%d NULL %p %p %p",
2100 type, handler_info, thread_name, cb_info);
2106 handler_info->type = type;
2107 handler_info->queue = g_queue_new();
2108 if (handler_info->queue == NULL) {
2109 LOGE("t:%d queue failed", type);
2113 g_mutex_init(&handler_info->mutex);
2114 g_cond_init(&handler_info->cond);
2116 handler_info->cb_info = (void *)cb_info;
2117 g_atomic_int_set(&handler_info->running, 1);
2119 handler_info->thread = g_thread_try_new(thread_name,
2120 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2121 if (handler_info->thread == NULL) {
2122 LOGE("t:%d thread failed", type);
2124 g_mutex_clear(&handler_info->mutex);
2125 g_cond_clear(&handler_info->cond);
2126 g_queue_free(handler_info->queue);
2127 handler_info->queue = NULL;
2132 LOGD("t:%d done", type);
2138 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2142 if (!handler_info) {
2143 LOGE("NULL handler");
2147 if (!handler_info->thread) {
2148 LOGW("thread is not created");
2152 type = handler_info->type;
2154 LOGD("t:%d thread %p", type, handler_info->thread);
2156 g_mutex_lock(&handler_info->mutex);
2157 g_atomic_int_set(&handler_info->running, 0);
2158 g_cond_signal(&handler_info->cond);
2159 g_mutex_unlock(&handler_info->mutex);
2161 g_thread_join(handler_info->thread);
2162 handler_info->thread = NULL;
2164 g_mutex_clear(&handler_info->mutex);
2165 g_cond_clear(&handler_info->cond);
2166 g_queue_free(handler_info->queue);
2167 handler_info->queue = NULL;
2169 LOGD("t:%d done", type);
2175 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2177 camera_cb_info_s *cb_info = NULL;
2180 g_return_val_if_fail(sockfd > 0, NULL);
2182 cb_info = g_new0(camera_cb_info_s, 1);
2183 if (cb_info == NULL) {
2184 LOGE("cb_info failed");
2188 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2190 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2191 g_mutex_init(&cb_info->api_mutex[i]);
2192 g_cond_init(&cb_info->api_cond[i]);
2195 g_mutex_init(&cb_info->fd_lock);
2196 g_mutex_init(&cb_info->mp_data_mutex);
2198 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2199 g_mutex_init(&cb_info->user_cb_mutex[i]);
2201 /* message handler thread */
2202 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2203 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2204 LOGE("msg_handler_info failed");
2208 /* message handler thread for preview callback */
2209 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2210 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2211 LOGE("preview_cb_info failed");
2215 /* message handler thread for capture callback */
2216 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2217 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2218 LOGE("capture_cb_info failed");
2222 cb_info->fd = sockfd;
2223 cb_info->preview_cb_flag = 0;
2225 /* message receive thread */
2226 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2227 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2228 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2229 if (cb_info->msg_recv_thread == NULL) {
2230 LOGE("message receive thread creation failed");
2235 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2236 cb_info->fds[i] = -1;
2238 cb_info->is_server_connected = TRUE;
2244 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2245 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2246 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2248 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2249 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2251 g_mutex_clear(&cb_info->fd_lock);
2252 g_mutex_clear(&cb_info->mp_data_mutex);
2254 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2255 g_mutex_clear(&cb_info->api_mutex[i]);
2256 g_cond_clear(&cb_info->api_cond[i]);
2266 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2270 g_return_if_fail(cb_info != NULL);
2272 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2274 g_thread_join(cb_info->msg_recv_thread);
2275 cb_info->msg_recv_thread = NULL;
2277 LOGD("msg_recv thread removed");
2279 /* destroy msg handler threads */
2280 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2281 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2282 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2284 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2285 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2287 g_mutex_clear(&cb_info->fd_lock);
2288 g_mutex_clear(&cb_info->mp_data_mutex);
2290 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2291 g_mutex_clear(&cb_info->api_mutex[i]);
2292 g_cond_clear(&cb_info->api_cond[i]);
2295 if (cb_info->fd > -1) {
2296 muse_client_close(cb_info->fd);
2300 if (cb_info->bufmgr) {
2301 tbm_bufmgr_deinit(cb_info->bufmgr);
2302 cb_info->bufmgr = NULL;
2304 if (cb_info->pkt_fmt) {
2305 media_format_unref(cb_info->pkt_fmt);
2306 cb_info->pkt_fmt = NULL;
2309 if (cb_info->dp_interface) {
2310 mm_display_interface_deinit(cb_info->dp_interface);
2311 cb_info->dp_interface = NULL;
2314 cb_info->preview_cb_flag = 0;
2323 int _camera_start_evas_rendering(camera_h camera)
2325 camera_cli_s *pc = (camera_cli_s *)camera;
2327 if (!pc || !pc->cb_info) {
2328 LOGE("NULL handle");
2329 return CAMERA_ERROR_INVALID_PARAMETER;
2334 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2335 LOGE("EVAS surface is not set");
2336 return CAMERA_ERROR_NONE;
2339 /* set evas render flag as RUN */
2340 pc->cb_info->run_evas_render = true;
2342 return CAMERA_ERROR_NONE;
2346 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2348 int ret = CAMERA_ERROR_NONE;
2349 camera_cli_s *pc = (camera_cli_s *)camera;
2351 if (!pc || !pc->cb_info) {
2352 LOGE("NULL handle");
2353 return CAMERA_ERROR_INVALID_PARAMETER;
2356 LOGD("stop - keep screen %d", keep_screen);
2358 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2359 LOGE("EVAS surface is not set");
2360 return CAMERA_ERROR_NONE;
2363 /* set evas render flag as STOP and release buffers */
2364 pc->cb_info->run_evas_render = false;
2366 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2367 if (ret == MM_ERROR_NONE) {
2368 ret = CAMERA_ERROR_NONE;
2370 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2371 ret = CAMERA_ERROR_INVALID_OPERATION;
2378 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2380 int ret = CAMERA_ERROR_NONE;
2382 int module_index = -1;
2384 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2386 /* create muse connection */
2387 if (!key || !value) {
2388 LOGE("NULL pointer");
2389 return CAMERA_ERROR_INVALID_PARAMETER;
2392 sock_fd = muse_client_new();
2394 LOGE("muse_client_new failed");
2395 return CAMERA_ERROR_INVALID_OPERATION;
2398 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2399 LOGE("muse client get module index failed");
2400 ret = CAMERA_ERROR_INVALID_OPERATION;
2404 msg = muse_core_msg_new(api,
2405 MUSE_TYPE_INT, "module", module_index,
2406 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2410 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2414 ret = muse_core_msg_send(sock_fd, msg);
2416 muse_core_msg_free(msg);
2420 LOGE("send msg failed");
2421 ret = CAMERA_ERROR_INVALID_OPERATION;
2425 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2427 LOGE("recv msg failed %d", errno);
2428 ret = CAMERA_ERROR_INVALID_OPERATION;
2432 if (!muse_camera_msg_get(ret, recv_msg)) {
2433 LOGE("failed to get return value from msg [%s]", recv_msg);
2434 ret = CAMERA_ERROR_INVALID_OPERATION;
2438 if (ret == CAMERA_ERROR_NONE)
2439 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2441 LOGD("api %d - value %d", api, *value);
2445 muse_client_close(sock_fd);
2453 int camera_create(camera_device_e device, camera_h *camera)
2456 char *send_msg = NULL;
2458 int ret = CAMERA_ERROR_NONE;
2460 camera_cli_s *pc = NULL;
2461 tbm_bufmgr bufmgr = NULL;
2463 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2464 int module_index = -1;
2465 int device_type = (int)device;
2468 LOGE("NULL pointer");
2469 return CAMERA_ERROR_INVALID_PARAMETER;
2472 sock_fd = muse_client_new();
2474 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2475 ret = CAMERA_ERROR_INVALID_OPERATION;
2481 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2482 LOGE("muse client get module index failed");
2483 ret = CAMERA_ERROR_INVALID_OPERATION;
2487 send_msg = muse_core_msg_new(api,
2488 MUSE_TYPE_INT, "module", module_index,
2489 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2490 MUSE_TYPE_INT, "pid", pid,
2495 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2499 send_ret = muse_core_msg_send(sock_fd, send_msg);
2501 muse_core_msg_free(send_msg);
2505 LOGE("send msg failed %d", errno);
2506 ret = CAMERA_ERROR_INVALID_OPERATION;
2510 pc = g_new0(camera_cli_s, 1);
2512 LOGE("camera_cli_s alloc failed");
2513 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2517 bufmgr = tbm_bufmgr_init(-1);
2518 if (bufmgr == NULL) {
2519 LOGE("get tbm bufmgr failed");
2520 ret = CAMERA_ERROR_INVALID_OPERATION;
2524 pc->cb_info = _camera_client_callback_new(sock_fd);
2525 if (pc->cb_info == NULL) {
2526 LOGE("cb_info alloc failed");
2527 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2533 LOGD("cb info : %d", pc->cb_info->fd);
2535 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2537 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2539 if (ret == CAMERA_ERROR_NONE) {
2540 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2541 int user_buffer_supported = 0;
2542 intptr_t handle = 0;
2544 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2546 LOGE("Receiving Handle Failed!!");
2547 ret = CAMERA_ERROR_INVALID_OPERATION;
2551 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2552 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2554 pc->remote_handle = handle;
2555 pc->cb_info->bufmgr = bufmgr;
2556 pc->cb_info->preview_format = preview_format;
2557 pc->cb_info->dp_type = CAMERA_DISPLAY_TYPE_NONE;
2558 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2560 LOGD("default preview format %d, user buffer %d",
2561 preview_format, user_buffer_supported);
2563 *camera = (camera_h)pc;
2565 /* get display interface handle */
2566 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2567 LOGW("display interface init failed");
2576 tbm_bufmgr_deinit(bufmgr);
2581 muse_client_close(sock_fd);
2587 int temp_fd = pc->cb_info->fd;
2589 /* pc->cb_info->fd should be closed,
2590 because g_thread_join for msg_recv_thread is not returned
2591 in _camera_client_callback_destroy. */
2593 pc->cb_info->fd = -1;
2594 muse_client_close(temp_fd);
2597 _camera_client_callback_destroy(pc->cb_info);
2604 LOGE("camera create error : 0x%x", ret);
2610 int camera_change_device(camera_h camera, camera_device_e device)
2613 int ret = CAMERA_ERROR_NONE;
2614 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2615 camera_cli_s *pc = (camera_cli_s *)camera;
2616 camera_msg_param param;
2618 if (!pc || !pc->cb_info) {
2619 LOGE("NULL handle");
2620 return CAMERA_ERROR_INVALID_PARAMETER;
2623 CAMERA_MSG_PARAM_SET(param, INT, device);
2625 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2627 if (ret == CAMERA_ERROR_NONE) {
2628 /* reset callback and user data */
2629 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2630 pc->cb_info->user_cb[i] = NULL;
2631 pc->cb_info->user_data[i] = NULL;
2633 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2640 int camera_destroy(camera_h camera)
2642 int ret = CAMERA_ERROR_NONE;
2643 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2644 camera_cli_s *pc = (camera_cli_s *)camera;
2646 if (!pc || !pc->cb_info) {
2647 LOGE("NULL handle");
2648 return CAMERA_ERROR_INVALID_PARAMETER;
2653 if (pc->cb_info->is_server_connected)
2654 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2656 LOGW("server disconnected. release resource without send message.");
2658 if (ret == CAMERA_ERROR_NONE) {
2659 _camera_deactivate_idle_event_all(pc->cb_info);
2660 _camera_client_callback_destroy(pc->cb_info);
2667 LOGD("ret : 0x%x", ret);
2672 int camera_start_preview(camera_h camera)
2674 int ret = CAMERA_ERROR_NONE;
2675 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2676 camera_cli_s *pc = (camera_cli_s *)camera;
2677 camera_state_e current_state = CAMERA_STATE_NONE;
2679 if (!pc || !pc->cb_info) {
2680 LOGE("NULL handle");
2681 return CAMERA_ERROR_INVALID_PARAMETER;
2684 LOGD("Enter : preview format %d, display type %d",
2685 pc->cb_info->preview_format, pc->cb_info->dp_type);
2687 ret = camera_get_state(camera, ¤t_state);
2688 if (ret != CAMERA_ERROR_NONE) {
2689 LOGE("failed to get current state 0x%x", ret);
2693 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2694 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2695 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2696 pc->cb_info->dp_type);
2697 return CAMERA_ERROR_INVALID_OPERATION;
2700 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2701 if (!_camera_allocate_preview_buffer(camera))
2702 return CAMERA_ERROR_INVALID_OPERATION;
2704 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2706 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2709 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2710 ret = _camera_start_evas_rendering(camera);
2711 if (ret != CAMERA_ERROR_NONE) {
2712 LOGE("stop preview because of error");
2713 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2717 LOGD("ret : 0x%x", ret);
2723 int camera_stop_preview(camera_h camera)
2725 int ret = CAMERA_ERROR_NONE;
2726 camera_cli_s *pc = (camera_cli_s *)camera;
2727 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2728 camera_state_e current_state = CAMERA_STATE_NONE;
2730 if (!pc || !pc->cb_info) {
2731 LOGE("NULL handle");
2732 return CAMERA_ERROR_INVALID_PARAMETER;
2737 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2738 ret = camera_get_state(camera, ¤t_state);
2739 if (ret != CAMERA_ERROR_NONE) {
2740 LOGE("failed to get current state 0x%x", ret);
2744 if (current_state == CAMERA_STATE_PREVIEW) {
2745 ret = _camera_stop_evas_rendering(camera, false);
2746 if (ret != CAMERA_ERROR_NONE)
2751 /* send stop preview message */
2752 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2754 if (ret == CAMERA_ERROR_NONE) {
2755 if (pc->cb_info->user_buffer_supported)
2756 _camera_release_preview_buffer(camera);
2757 } else if (current_state == CAMERA_STATE_PREVIEW) {
2758 LOGW("restart evas rendering");
2759 _camera_start_evas_rendering(camera);
2762 LOGD("ret : 0x%x", ret);
2768 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2770 int ret = CAMERA_ERROR_NONE;
2771 camera_cli_s *pc = (camera_cli_s *)camera;
2772 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2774 if (!pc || !pc->cb_info) {
2775 LOGE("NULL handle");
2776 return CAMERA_ERROR_INVALID_PARAMETER;
2781 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2782 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2784 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2785 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2787 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2789 LOGD("ret : 0x%x", ret);
2795 bool camera_is_supported_continuous_capture(camera_h camera)
2797 int ret = CAMERA_ERROR_NONE;
2798 camera_cli_s *pc = (camera_cli_s *)camera;
2799 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2801 if (!pc || !pc->cb_info) {
2802 LOGE("NULL handle");
2803 return CAMERA_ERROR_INVALID_PARAMETER;
2808 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2811 LOGE("error is occurred 0x%x", ret);
2815 LOGD("ret : %d", ret);
2821 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)
2823 int ret = CAMERA_ERROR_NONE;
2824 camera_cli_s *pc = (camera_cli_s *)camera;
2825 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2826 camera_msg_param param;
2829 if (!pc || !pc->cb_info) {
2830 LOGE("NULL handle");
2831 return CAMERA_ERROR_INVALID_PARAMETER;
2836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2839 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2840 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2842 value = (count << 16) | interval;
2843 CAMERA_MSG_PARAM_SET(param, INT, value);
2845 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2847 LOGD("ret : 0x%x", ret);
2853 int camera_stop_continuous_capture(camera_h camera)
2855 int ret = CAMERA_ERROR_NONE;
2856 camera_cli_s *pc = (camera_cli_s *)camera;
2857 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2859 if (!pc || !pc->cb_info) {
2860 LOGE("NULL handle");
2861 return CAMERA_ERROR_INVALID_PARAMETER;
2866 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2868 LOGD("ret : 0x%x", ret);
2874 bool camera_is_supported_face_detection(camera_h camera)
2876 int ret = CAMERA_ERROR_NONE;
2877 camera_cli_s *pc = (camera_cli_s *)camera;
2878 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2880 if (!pc || !pc->cb_info) {
2881 LOGE("NULL handle");
2882 return CAMERA_ERROR_INVALID_PARAMETER;
2887 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2890 LOGE("error is occurred 0x%x", ret);
2894 LOGD("ret : %d", ret);
2900 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2902 int ret = CAMERA_ERROR_NONE;
2903 camera_cli_s *pc = (camera_cli_s *)camera;
2904 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2906 if (!pc || !pc->cb_info) {
2907 LOGE("NULL handle");
2908 return CAMERA_ERROR_INVALID_PARAMETER;
2913 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2916 LOGE("error is occurred 0x%x", ret);
2920 LOGD("ret : %d", ret);
2926 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2928 int ret = CAMERA_ERROR_NONE;
2929 camera_cli_s *pc = (camera_cli_s *)camera;
2930 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2932 if (!pc || !pc->cb_info) {
2933 LOGE("NULL handle");
2934 return CAMERA_ERROR_INVALID_PARAMETER;
2939 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2942 LOGE("error is occurred 0x%x", ret);
2946 LOGD("ret : %d", ret);
2951 int camera_get_device_count(camera_h camera, int *device_count)
2953 int ret = CAMERA_ERROR_NONE;
2954 camera_cli_s *pc = (camera_cli_s *)camera;
2955 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
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);
2966 if (ret == CAMERA_ERROR_NONE)
2967 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2969 LOGD("ret : 0x%x", ret);
2974 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2976 int ret = CAMERA_ERROR_NONE;
2977 camera_cli_s *pc = (camera_cli_s *)camera;
2978 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2980 if (!pc || !pc->cb_info) {
2981 LOGE("NULL handle");
2982 return CAMERA_ERROR_INVALID_PARAMETER;
2987 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2989 if (ret == CAMERA_ERROR_NONE) {
2990 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2995 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2998 LOGD("ret : 0x%x", ret);
3003 int camera_stop_face_detection(camera_h camera)
3005 int ret = CAMERA_ERROR_NONE;
3006 camera_cli_s *pc = (camera_cli_s *)camera;
3007 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3009 if (!pc || !pc->cb_info) {
3010 LOGE("NULL handle");
3011 return CAMERA_ERROR_INVALID_PARAMETER;
3016 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3018 if (ret == CAMERA_ERROR_NONE) {
3019 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3021 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3022 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3024 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3027 LOGD("ret : 0x%x", ret);
3032 int camera_get_state(camera_h camera, camera_state_e *state)
3034 int ret = CAMERA_ERROR_NONE;
3035 camera_cli_s *pc = (camera_cli_s *)camera;
3036 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3038 if (!pc || !pc->cb_info || !state) {
3039 LOGE("NULL pointer %p %p", pc, state);
3040 return CAMERA_ERROR_INVALID_PARAMETER;
3045 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3047 if (ret == CAMERA_ERROR_NONE)
3048 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3050 LOGD("ret : 0x%x", ret);
3055 int camera_start_focusing(camera_h camera, bool continuous)
3057 int ret = CAMERA_ERROR_NONE;
3058 camera_cli_s *pc = (camera_cli_s *)camera;
3059 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3060 camera_msg_param param;
3061 int is_continuous = (int)continuous;
3063 if (!pc || !pc->cb_info) {
3064 LOGE("NULL handle");
3065 return CAMERA_ERROR_INVALID_PARAMETER;
3070 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3072 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3074 LOGD("ret : 0x%x", ret);
3079 int camera_cancel_focusing(camera_h camera)
3081 int ret = CAMERA_ERROR_NONE;
3082 camera_cli_s *pc = (camera_cli_s *)camera;
3083 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3085 if (!pc || !pc->cb_info) {
3086 LOGE("NULL handle");
3087 return CAMERA_ERROR_INVALID_PARAMETER;
3090 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3092 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3094 LOGD("ret : 0x%x", ret);
3099 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3101 int ret = CAMERA_ERROR_NONE;
3103 camera_cli_s *pc = (camera_cli_s *)camera;
3104 camera_cb_info_s *cb_info = NULL;
3105 camera_state_e current_state = CAMERA_STATE_NONE;
3106 camera_msg_param param0;
3107 camera_msg_param param1;
3108 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3110 if (!pc || !pc->cb_info) {
3111 LOGE("NULL handle");
3112 return CAMERA_ERROR_INVALID_PARAMETER;
3115 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3116 LOGE("invalid type %d", type);
3117 return CAMERA_ERROR_INVALID_PARAMETER;
3120 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3121 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3122 return CAMERA_ERROR_INVALID_PARAMETER;
3125 cb_info = (camera_cb_info_s *)pc->cb_info;
3127 ret = camera_get_state(camera, ¤t_state);
3128 if (ret != CAMERA_ERROR_NONE) {
3129 LOGE("failed to get current state 0x%x", ret);
3133 if (current_state != CAMERA_STATE_CREATED) {
3134 LOGE("INVALID_STATE : current %d", current_state);
3135 return CAMERA_ERROR_INVALID_STATE;
3138 LOGD("Enter - type : %d, display : %p", type, display);
3140 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3141 /* check display interface handle */
3142 if (!cb_info->dp_interface) {
3143 LOGE("display interface not supported");
3144 return CAMERA_ERROR_NOT_SUPPORTED;
3147 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3148 if (ret != MM_ERROR_NONE) {
3149 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3150 return CAMERA_ERROR_INVALID_OPERATION;
3153 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3154 camera_flip_e flip = CAMERA_FLIP_NONE;
3155 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3156 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3163 camera_get_display_flip(camera, &flip);
3164 camera_get_display_mode(camera, &mode);
3165 camera_get_display_rotation(camera, &rotation);
3166 camera_is_display_visible(camera, &visible);
3167 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3169 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3170 flip, mode, rotation, visible, x, y, width, height);
3172 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3173 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3174 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3175 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3177 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3178 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3182 CAMERA_MSG_PARAM_SET(param0, INT, type);
3183 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3185 _camera_msg_send_param2_int(api, cb_info, &ret,
3186 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3188 if (ret == CAMERA_ERROR_NONE) {
3189 pc->cb_info->dp_type = type;
3191 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3192 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3199 int camera_set_preview_resolution(camera_h camera, int width, int height)
3201 int ret = CAMERA_ERROR_NONE;
3202 camera_state_e current_state = CAMERA_STATE_NONE;
3203 camera_cli_s *pc = (camera_cli_s *)camera;
3204 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3205 camera_msg_param param;
3208 if (!pc || !pc->cb_info) {
3209 LOGE("NULL handle");
3210 return CAMERA_ERROR_INVALID_PARAMETER;
3213 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3214 ret = camera_get_state(camera, ¤t_state);
3215 if (ret != CAMERA_ERROR_NONE) {
3216 LOGE("failed to get current state 0x%x", ret);
3220 if (current_state == CAMERA_STATE_PREVIEW) {
3221 ret = _camera_stop_evas_rendering(camera, true);
3222 if (ret != CAMERA_ERROR_NONE)
3227 value = (width << 16) | height;
3228 CAMERA_MSG_PARAM_SET(param, INT, value);
3230 LOGD("%dx%d -> 0x%x", width, height, value);
3232 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3234 LOGD("ret : 0x%x", ret);
3236 if (current_state == CAMERA_STATE_PREVIEW) {
3237 LOGW("restart evas rendering");
3238 _camera_start_evas_rendering(camera);
3245 int camera_set_capture_resolution(camera_h camera, int width, int height)
3247 int ret = CAMERA_ERROR_NONE;
3248 camera_cli_s *pc = (camera_cli_s *)camera;
3249 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3250 camera_msg_param param;
3253 if (!pc || !pc->cb_info) {
3254 LOGE("NULL handle");
3255 return CAMERA_ERROR_INVALID_PARAMETER;
3260 value = (width << 16) | height;
3261 CAMERA_MSG_PARAM_SET(param, INT, value);
3263 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3265 LOGD("ret : 0x%x", ret);
3271 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3273 int ret = CAMERA_ERROR_NONE;
3274 int set_format = (int)format;
3275 camera_cli_s *pc = (camera_cli_s *)camera;
3276 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3277 camera_msg_param param;
3279 if (!pc || !pc->cb_info) {
3280 LOGE("NULL handle");
3281 return CAMERA_ERROR_INVALID_PARAMETER;
3284 LOGD("Enter - format %d", set_format);
3286 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3288 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3290 LOGD("ret : 0x%x", ret);
3296 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3298 int ret = CAMERA_ERROR_NONE;
3299 int set_format = (int)format;
3300 camera_msg_param param;
3301 camera_cli_s *pc = (camera_cli_s *)camera;
3302 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3304 if (!pc || !pc->cb_info) {
3305 LOGE("NULL handle");
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3309 LOGD("Enter - format %d", set_format);
3311 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3313 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3315 if (ret == CAMERA_ERROR_NONE)
3316 pc->cb_info->preview_format = set_format;
3318 LOGD("ret : 0x%x", ret);
3324 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3326 int ret = CAMERA_ERROR_NONE;
3327 camera_cli_s *pc = (camera_cli_s *)camera;
3328 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3330 if (!pc || !pc->cb_info || !width || !height) {
3331 LOGE("NULL pointer %p %p %p", pc, width, height);
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3337 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3339 if (ret == CAMERA_ERROR_NONE) {
3340 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3341 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3344 LOGD("ret : 0x%x", ret);
3350 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3352 int ret = CAMERA_ERROR_NONE;
3353 int set_rotation = (int)rotation;
3354 camera_cli_s *pc = (camera_cli_s *)camera;
3355 camera_msg_param param;
3357 if (!pc || !pc->cb_info) {
3358 LOGE("NULL handle");
3359 return CAMERA_ERROR_INVALID_PARAMETER;
3362 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3363 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3364 if (ret != MM_ERROR_NONE) {
3365 LOGE("failed to set rotation for evas surface 0x%x", ret);
3366 return CAMERA_ERROR_INVALID_OPERATION;
3370 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3372 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3378 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3380 int ret = CAMERA_ERROR_NONE;
3381 camera_cli_s *pc = (camera_cli_s *)camera;
3383 if (!pc || !pc->cb_info || !rotation) {
3384 LOGE("NULL pointer %p %p", pc, rotation);
3385 return CAMERA_ERROR_INVALID_PARAMETER;
3388 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3390 if (ret == CAMERA_ERROR_NONE)
3391 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3397 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3399 int ret = CAMERA_ERROR_NONE;
3400 int set_flip = (int)flip;
3401 camera_cli_s *pc = (camera_cli_s *)camera;
3402 camera_msg_param param;
3404 if (!pc || !pc->cb_info) {
3405 LOGE("NULL handle");
3406 return CAMERA_ERROR_INVALID_PARAMETER;
3409 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3410 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3411 if (ret != MM_ERROR_NONE) {
3412 LOGE("failed to set flip for evas surface 0x%x", ret);
3413 return CAMERA_ERROR_INVALID_OPERATION;
3417 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3419 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3425 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3427 int ret = CAMERA_ERROR_NONE;
3428 camera_cli_s *pc = (camera_cli_s *)camera;
3430 if (!pc || !pc->cb_info || !flip) {
3431 LOGE("NULL pointer %p %p", pc, flip);
3432 return CAMERA_ERROR_INVALID_PARAMETER;
3435 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3437 if (ret == CAMERA_ERROR_NONE)
3438 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3444 int camera_set_display_visible(camera_h camera, bool visible)
3446 int ret = CAMERA_ERROR_NONE;
3447 int set_visible = (int)visible;
3448 camera_cli_s *pc = (camera_cli_s *)camera;
3449 camera_msg_param param;
3451 if (!pc || !pc->cb_info) {
3452 LOGE("NULL handle");
3453 return CAMERA_ERROR_INVALID_PARAMETER;
3456 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3457 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3458 if (ret != MM_ERROR_NONE) {
3459 LOGE("failed to set visible for evas surface 0x%x", ret);
3460 return CAMERA_ERROR_INVALID_OPERATION;
3464 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3466 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3472 int camera_is_display_visible(camera_h camera, bool *visible)
3474 int ret = CAMERA_ERROR_NONE;
3475 camera_cli_s *pc = (camera_cli_s *)camera;
3477 if (!pc || !pc->cb_info || !visible) {
3478 LOGE("NULL pointer %p %p", pc, visible);
3479 return CAMERA_ERROR_INVALID_PARAMETER;
3482 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3484 if (ret == CAMERA_ERROR_NONE)
3485 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3491 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3493 int ret = CAMERA_ERROR_NONE;
3494 int set_mode = (int)mode;
3495 camera_cli_s *pc = (camera_cli_s *)camera;
3496 camera_msg_param param;
3498 if (!pc || !pc->cb_info) {
3499 LOGE("NULL handle");
3500 return CAMERA_ERROR_INVALID_PARAMETER;
3503 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3504 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3505 if (ret != MM_ERROR_NONE) {
3506 LOGE("failed to set geometry for evas surface 0x%x", ret);
3507 return CAMERA_ERROR_INVALID_OPERATION;
3511 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3513 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3519 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3521 int ret = CAMERA_ERROR_NONE;
3522 camera_cli_s *pc = (camera_cli_s *)camera;
3524 if (!pc || !pc->cb_info || !mode) {
3525 LOGE("NULL pointer %p %p", pc, mode);
3526 return CAMERA_ERROR_INVALID_PARAMETER;
3529 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3531 if (ret == CAMERA_ERROR_NONE)
3532 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3538 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3540 int ret = CAMERA_ERROR_NONE;
3541 int set_hint = (int)hint;
3542 camera_cli_s *pc = (camera_cli_s *)camera;
3543 camera_msg_param param;
3545 if (!pc || !pc->cb_info) {
3546 LOGE("NULL handle");
3547 return CAMERA_ERROR_INVALID_PARAMETER;
3550 LOGD("Enter - hint %d", set_hint);
3552 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3554 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3560 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3562 int ret = CAMERA_ERROR_NONE;
3563 camera_cli_s *pc = (camera_cli_s *)camera;
3564 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3566 if (!pc || !pc->cb_info || !hint) {
3567 LOGE("NULL pointer %p %p", pc, hint);
3568 return CAMERA_ERROR_INVALID_PARAMETER;
3571 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3573 if (ret == CAMERA_ERROR_NONE) {
3574 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3575 LOGD("display reuse hint %d", *hint);
3582 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3586 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3588 if (!pc || !pc->cb_info || !width || !height) {
3589 LOGE("NULL pointer %p %p %p", pc, width, height);
3590 return CAMERA_ERROR_INVALID_PARAMETER;
3595 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3597 if (ret == CAMERA_ERROR_NONE) {
3598 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3599 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3602 LOGD("ret : 0x%x", ret);
3608 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3610 int ret = CAMERA_ERROR_NONE;
3611 camera_cli_s *pc = (camera_cli_s *)camera;
3612 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3614 if (!pc || !pc->cb_info || !format) {
3615 LOGE("NULL pointer %p %p", pc, format);
3616 return CAMERA_ERROR_INVALID_PARAMETER;
3621 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3623 if (ret == CAMERA_ERROR_NONE)
3624 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3626 LOGD("ret : 0x%x", ret);
3632 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3634 int ret = CAMERA_ERROR_NONE;
3635 camera_cli_s *pc = (camera_cli_s *)camera;
3636 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3638 if (!pc || !pc->cb_info || !format) {
3639 LOGE("NULL pointer %p %p", pc, format);
3640 return CAMERA_ERROR_INVALID_PARAMETER;
3645 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3647 if (ret == CAMERA_ERROR_NONE)
3648 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3650 LOGD("ret : 0x%x", ret);
3656 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3658 int ret = CAMERA_ERROR_NONE;
3659 camera_cli_s *pc = (camera_cli_s *)camera;
3660 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3662 if (!pc || !pc->cb_info || !facing_direction) {
3663 LOGE("NULL pointer %p %p", pc, facing_direction);
3664 return CAMERA_ERROR_INVALID_PARAMETER;
3669 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3671 if (ret == CAMERA_ERROR_NONE)
3672 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3674 LOGD("ret : 0x%x", ret);
3680 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3682 int ret = CAMERA_ERROR_NONE;
3683 camera_cli_s *pc = (camera_cli_s *)camera;
3684 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3686 if (!pc || !pc->cb_info || !callback) {
3687 LOGE("NULL pointer %p %p", pc, callback);
3688 return CAMERA_ERROR_INVALID_PARAMETER;
3693 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3695 if (ret == CAMERA_ERROR_NONE) {
3696 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3698 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3699 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3701 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3703 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3706 LOGD("ret : 0x%x", ret);
3712 int camera_unset_preview_cb(camera_h camera)
3714 int ret = CAMERA_ERROR_NONE;
3715 camera_cli_s *pc = (camera_cli_s *)camera;
3716 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3718 if (!pc || !pc->cb_info) {
3719 LOGE("NULL handle");
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3725 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3727 if (ret == CAMERA_ERROR_NONE) {
3728 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3733 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3735 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3738 LOGD("ret : 0x%x", ret);
3744 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3746 int ret = CAMERA_ERROR_NONE;
3747 camera_cli_s *pc = (camera_cli_s *)camera;
3748 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3750 if (!pc || !pc->cb_info) {
3751 LOGE("NULL handle");
3752 return CAMERA_ERROR_INVALID_PARAMETER;
3755 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3756 LOGE("NOT SUPPORTED");
3757 return CAMERA_ERROR_NOT_SUPPORTED;
3760 if (callback == NULL) {
3761 LOGE("NULL callback");
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3767 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3769 if (ret == CAMERA_ERROR_NONE) {
3770 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3772 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3773 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3775 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3778 LOGD("ret : 0x%x", ret);
3784 int camera_unset_media_packet_preview_cb(camera_h camera)
3786 int ret = CAMERA_ERROR_NONE;
3787 camera_cli_s *pc = (camera_cli_s *)camera;
3788 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3790 if (!pc || !pc->cb_info) {
3791 LOGE("NULL handle");
3792 return CAMERA_ERROR_INVALID_PARAMETER;
3797 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3799 if (ret == CAMERA_ERROR_NONE) {
3800 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3802 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3803 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3805 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3808 LOGD("ret : 0x%x", ret);
3814 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3816 int ret = CAMERA_ERROR_NONE;
3817 camera_cli_s *pc = (camera_cli_s *)camera;
3818 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3820 if (!pc || !pc->cb_info || !callback) {
3821 LOGE("NULL pointer %p %p", pc, callback);
3822 return CAMERA_ERROR_INVALID_PARAMETER;
3827 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3829 if (ret == CAMERA_ERROR_NONE) {
3830 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3832 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3833 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3835 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3838 LOGD("ret : 0x%x", ret);
3844 int camera_unset_state_changed_cb(camera_h camera)
3846 int ret = CAMERA_ERROR_NONE;
3847 camera_cli_s *pc = (camera_cli_s *)camera;
3848 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3850 if (!pc || !pc->cb_info) {
3851 LOGE("NULL handle");
3852 return CAMERA_ERROR_INVALID_PARAMETER;
3857 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3859 if (ret == CAMERA_ERROR_NONE) {
3860 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3862 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3863 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3865 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3868 LOGD("ret : 0x%x", ret);
3874 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3876 int ret = CAMERA_ERROR_NONE;
3877 camera_cli_s *pc = (camera_cli_s *)camera;
3878 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3880 if (!pc || !pc->cb_info || !callback) {
3881 LOGE("NULL pointer %p %p", pc, callback);
3882 return CAMERA_ERROR_INVALID_PARAMETER;
3887 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3889 if (ret == CAMERA_ERROR_NONE) {
3890 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3895 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3898 LOGD("ret : 0x%x", ret);
3904 int camera_unset_interrupted_cb(camera_h camera)
3906 int ret = CAMERA_ERROR_NONE;
3907 camera_cli_s *pc = (camera_cli_s *)camera;
3908 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3910 if (!pc || !pc->cb_info) {
3911 LOGE("NULL handle");
3912 return CAMERA_ERROR_INVALID_PARAMETER;
3917 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3919 if (ret == CAMERA_ERROR_NONE) {
3920 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3922 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3923 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3925 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3928 LOGD("ret : 0x%x", ret);
3934 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3936 int ret = CAMERA_ERROR_NONE;
3937 camera_cli_s *pc = (camera_cli_s *)camera;
3938 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3940 if (!pc || !pc->cb_info || !callback) {
3941 LOGE("NULL pointer %p %p", pc, callback);
3942 return CAMERA_ERROR_INVALID_PARAMETER;
3947 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3949 if (ret == CAMERA_ERROR_NONE) {
3950 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3952 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3953 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3955 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3958 LOGD("ret : 0x%x", ret);
3964 int camera_unset_interrupt_started_cb(camera_h camera)
3966 int ret = CAMERA_ERROR_NONE;
3967 camera_cli_s *pc = (camera_cli_s *)camera;
3968 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3970 if (!pc || !pc->cb_info) {
3971 LOGE("NULL handle");
3972 return CAMERA_ERROR_INVALID_PARAMETER;
3977 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3979 if (ret == CAMERA_ERROR_NONE) {
3980 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3982 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3983 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3985 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3988 LOGD("ret : 0x%x", ret);
3994 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3996 int ret = CAMERA_ERROR_NONE;
3997 camera_cli_s *pc = (camera_cli_s *)camera;
3998 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4000 if (!pc || !pc->cb_info || !callback) {
4001 LOGE("NULL pointer %p %p", pc, callback);
4002 return CAMERA_ERROR_INVALID_PARAMETER;
4007 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4009 if (ret == CAMERA_ERROR_NONE) {
4010 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4012 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4013 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4015 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4018 LOGD("ret : 0x%x", ret);
4024 int camera_unset_focus_changed_cb(camera_h camera)
4026 int ret = CAMERA_ERROR_NONE;
4027 camera_cli_s *pc = (camera_cli_s *)camera;
4028 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4030 if (!pc || !pc->cb_info) {
4031 LOGE("NULL handle");
4032 return CAMERA_ERROR_INVALID_PARAMETER;
4037 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4039 if (ret == CAMERA_ERROR_NONE) {
4040 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4042 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4043 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4045 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4048 LOGD("ret : 0x%x", ret);
4054 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4056 int ret = CAMERA_ERROR_NONE;
4057 camera_cli_s *pc = (camera_cli_s *)camera;
4058 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4060 if (!pc || !pc->cb_info || !callback) {
4061 LOGE("NULL pointer %p %p", pc, callback);
4062 return CAMERA_ERROR_INVALID_PARAMETER;
4067 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4069 if (ret == CAMERA_ERROR_NONE) {
4070 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4072 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4073 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4075 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4078 LOGD("ret : 0x%x", ret);
4084 int camera_unset_error_cb(camera_h camera)
4086 int ret = CAMERA_ERROR_NONE;
4087 camera_cli_s *pc = (camera_cli_s *)camera;
4088 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4090 if (!pc || !pc->cb_info) {
4091 LOGE("NULL handle");
4092 return CAMERA_ERROR_INVALID_PARAMETER;
4097 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4099 if (ret == CAMERA_ERROR_NONE) {
4100 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4102 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4103 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4105 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4108 LOGD("ret : 0x%x", ret);
4114 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4116 int ret = CAMERA_ERROR_NONE;
4117 camera_cli_s *pc = (camera_cli_s *)camera;
4118 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4120 if (!pc || !pc->cb_info || !foreach_cb) {
4121 LOGE("NULL pointer %p %p", pc, foreach_cb);
4122 return CAMERA_ERROR_INVALID_PARAMETER;
4127 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4128 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4130 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4132 LOGD("ret : 0x%x", ret);
4138 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4140 int ret = CAMERA_ERROR_NONE;
4141 camera_cli_s *pc = (camera_cli_s *)camera;
4142 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4144 if (!pc || !pc->cb_info || !foreach_cb) {
4145 LOGE("NULL pointer %p %p", pc, foreach_cb);
4146 return CAMERA_ERROR_INVALID_PARAMETER;
4151 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4152 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4154 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4156 LOGD("ret : 0x%x", ret);
4162 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4164 int ret = CAMERA_ERROR_NONE;
4165 camera_cli_s *pc = (camera_cli_s *)camera;
4166 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4168 if (!pc || !pc->cb_info || !foreach_cb) {
4169 LOGE("NULL pointer %p %p", pc, foreach_cb);
4170 return CAMERA_ERROR_INVALID_PARAMETER;
4175 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4176 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4178 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4180 LOGD("ret : 0x%x", ret);
4186 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4188 int ret = CAMERA_ERROR_NONE;
4189 camera_cli_s *pc = (camera_cli_s *)camera;
4190 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4192 if (!pc || !pc->cb_info || !foreach_cb) {
4193 LOGE("NULL pointer %p %p", pc, foreach_cb);
4194 return CAMERA_ERROR_INVALID_PARAMETER;
4199 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4200 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4202 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4204 LOGD("ret : 0x%x", ret);
4210 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4212 int ret = CAMERA_ERROR_NONE;
4213 camera_cli_s *pc = (camera_cli_s *)camera;
4214 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4216 if (!pc || !pc->cb_info || !width || !height) {
4217 LOGE("NULL pointer %p %p %p", pc, width, height);
4218 return CAMERA_ERROR_INVALID_PARAMETER;
4222 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4224 if (ret == CAMERA_ERROR_NONE) {
4225 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4226 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4229 LOGD("ret : 0x%x", ret);
4235 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4237 int ret = CAMERA_ERROR_NONE;
4238 camera_cli_s *pc = (camera_cli_s *)camera;
4239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4241 if (!pc || !pc->cb_info || !angle) {
4242 LOGE("NULL pointer %p %p", pc, angle);
4243 return CAMERA_ERROR_INVALID_PARAMETER;
4248 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4250 if (ret == CAMERA_ERROR_NONE)
4251 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4253 LOGD("ret : 0x%x", ret);
4259 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4261 int ret = CAMERA_ERROR_NONE;
4262 camera_cli_s *pc = (camera_cli_s *)camera;
4263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4264 camera_msg_param param;
4265 int set_mode = (int)mode;
4267 if (!pc || !pc->cb_info) {
4268 LOGE("NULL handle");
4269 return CAMERA_ERROR_INVALID_PARAMETER;
4274 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4276 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4278 LOGD("ret : 0x%x", ret);
4284 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4286 int ret = CAMERA_ERROR_NONE;
4287 camera_cli_s *pc = (camera_cli_s *)camera;
4288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4290 if (!pc || !pc->cb_info || !mode) {
4291 LOGE("NULL pointer %p %p", pc, mode);
4292 return CAMERA_ERROR_INVALID_PARAMETER;
4297 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4299 if (ret == CAMERA_ERROR_NONE)
4300 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4302 LOGD("ret : 0x%x", ret);
4308 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4310 int ret = CAMERA_ERROR_NONE;
4311 camera_cli_s *pc = (camera_cli_s *)camera;
4312 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4314 if (!pc || !pc->cb_info || !foreach_cb) {
4315 LOGE("NULL pointer %p %p", pc, foreach_cb);
4316 return CAMERA_ERROR_INVALID_PARAMETER;
4321 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4322 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4324 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4326 LOGD("Finish, return :%x", ret);
4332 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4334 int ret = CAMERA_ERROR_NONE;
4335 camera_cli_s *pc = (camera_cli_s *)camera;
4336 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4337 camera_msg_param param;
4338 int set_fps = (int)fps;
4340 if (!pc || !pc->cb_info) {
4341 LOGE("NULL handle");
4342 return CAMERA_ERROR_INVALID_PARAMETER;
4347 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4349 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4351 LOGD("ret : 0x%x", ret);
4357 int camera_attr_set_image_quality(camera_h camera, int quality)
4359 int ret = CAMERA_ERROR_NONE;
4360 camera_cli_s *pc = (camera_cli_s *)camera;
4361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4362 camera_msg_param param;
4364 if (!pc || !pc->cb_info) {
4365 LOGE("NULL handle");
4366 return CAMERA_ERROR_INVALID_PARAMETER;
4371 CAMERA_MSG_PARAM_SET(param, INT, quality);
4373 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4375 LOGD("ret : 0x%x", ret);
4381 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4387 if (!pc || !pc->cb_info || !fps) {
4388 LOGE("NULL pointer %p %p", pc, fps);
4389 return CAMERA_ERROR_INVALID_PARAMETER;
4394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4396 if (ret == CAMERA_ERROR_NONE)
4397 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4399 LOGD("ret : 0x%x", ret);
4405 int camera_attr_get_image_quality(camera_h camera, int *quality)
4407 int ret = CAMERA_ERROR_NONE;
4408 camera_cli_s *pc = (camera_cli_s *)camera;
4409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4411 if (!pc || !pc->cb_info || !quality) {
4412 LOGE("NULL pointer %p %p", pc, quality);
4413 return CAMERA_ERROR_INVALID_PARAMETER;
4418 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4420 if (ret == CAMERA_ERROR_NONE)
4421 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4423 LOGD("ret : 0x%x", ret);
4429 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4431 int ret = CAMERA_ERROR_NONE;
4432 camera_cli_s *pc = (camera_cli_s *)camera;
4433 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4435 if (!pc || !pc->cb_info || !bitrate) {
4436 LOGE("NULL pointer %p %p", pc, bitrate);
4437 return CAMERA_ERROR_INVALID_PARAMETER;
4442 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4444 if (ret == CAMERA_ERROR_NONE)
4445 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4447 LOGD("ret : 0x%x", ret);
4453 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4455 int ret = CAMERA_ERROR_NONE;
4456 camera_cli_s *pc = (camera_cli_s *)camera;
4457 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4458 camera_msg_param param;
4459 int set_bitrate = bitrate;
4461 if (!pc || !pc->cb_info) {
4462 LOGE("NULL handle");
4463 return CAMERA_ERROR_INVALID_PARAMETER;
4468 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4470 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4472 LOGD("ret : 0x%x", ret);
4478 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4480 int ret = CAMERA_ERROR_NONE;
4481 camera_cli_s *pc = (camera_cli_s *)camera;
4482 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4484 if (!pc || !pc->cb_info || !interval) {
4485 LOGE("NULL pointer %p %p", pc, interval);
4486 return CAMERA_ERROR_INVALID_PARAMETER;
4491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4493 if (ret == CAMERA_ERROR_NONE)
4494 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4496 LOGD("ret : 0x%x", ret);
4502 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4504 int ret = CAMERA_ERROR_NONE;
4505 camera_cli_s *pc = (camera_cli_s *)camera;
4506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4507 camera_msg_param param;
4508 int set_gop_interval = interval;
4510 if (!pc || !pc->cb_info) {
4511 LOGE("NULL handle");
4512 return CAMERA_ERROR_INVALID_PARAMETER;
4517 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4519 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4521 LOGD("ret : 0x%x", ret);
4527 int camera_attr_set_zoom(camera_h camera, int zoom)
4529 int ret = CAMERA_ERROR_NONE;
4530 camera_cli_s *pc = (camera_cli_s *)camera;
4531 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4532 camera_msg_param param;
4534 if (!pc || !pc->cb_info) {
4535 LOGE("NULL handle");
4536 return CAMERA_ERROR_INVALID_PARAMETER;
4539 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4541 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4543 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4545 LOGD("ret : 0x%x", ret);
4551 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4553 int ret = CAMERA_ERROR_NONE;
4554 camera_cli_s *pc = (camera_cli_s *)camera;
4555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4556 camera_msg_param param;
4557 int set_mode = (int)mode;
4559 if (!pc || !pc->cb_info) {
4560 LOGE("NULL handle");
4561 return CAMERA_ERROR_INVALID_PARAMETER;
4564 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4566 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4568 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4574 int camera_attr_set_af_area(camera_h camera, int x, int y)
4576 int ret = CAMERA_ERROR_NONE;
4577 camera_cli_s *pc = (camera_cli_s *)camera;
4578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4579 camera_msg_param param;
4582 if (!pc || !pc->cb_info) {
4583 LOGE("NULL handle");
4584 return CAMERA_ERROR_INVALID_PARAMETER;
4587 LOGD("Enter - %d,%d", x, y);
4589 value = (x << 16) | y;
4590 CAMERA_MSG_PARAM_SET(param, INT, value);
4592 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4594 LOGD("ret : 0x%x", ret);
4600 int camera_attr_clear_af_area(camera_h camera)
4602 int ret = CAMERA_ERROR_NONE;
4603 camera_cli_s *pc = (camera_cli_s *)camera;
4604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4606 if (!pc || !pc->cb_info) {
4607 LOGE("NULL handle");
4608 return CAMERA_ERROR_INVALID_PARAMETER;
4613 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4615 LOGD("ret : 0x%x", ret);
4621 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4623 int ret = CAMERA_ERROR_NONE;
4624 camera_cli_s *pc = (camera_cli_s *)camera;
4625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4626 camera_msg_param param;
4627 int set_mode = (int)mode;
4629 if (!pc || !pc->cb_info) {
4630 LOGE("NULL handle");
4631 return CAMERA_ERROR_INVALID_PARAMETER;
4636 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4638 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4640 LOGD("ret : 0x%x", ret);
4646 int camera_attr_set_exposure(camera_h camera, int value)
4648 int ret = CAMERA_ERROR_NONE;
4649 camera_cli_s *pc = (camera_cli_s *)camera;
4650 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4651 camera_msg_param param;
4653 if (!pc || !pc->cb_info) {
4654 LOGE("NULL handle");
4655 return CAMERA_ERROR_INVALID_PARAMETER;
4660 CAMERA_MSG_PARAM_SET(param, INT, value);
4662 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4664 LOGD("ret : 0x%x", ret);
4670 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4672 int ret = CAMERA_ERROR_NONE;
4673 camera_cli_s *pc = (camera_cli_s *)camera;
4674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4675 camera_msg_param param;
4676 int set_iso = (int)iso;
4678 if (!pc || !pc->cb_info) {
4679 LOGE("NULL handle");
4680 return CAMERA_ERROR_INVALID_PARAMETER;
4685 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4687 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4689 LOGD("ret : 0x%x", ret);
4695 int camera_attr_set_brightness(camera_h camera, int level)
4697 int ret = CAMERA_ERROR_NONE;
4698 camera_cli_s *pc = (camera_cli_s *)camera;
4699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4700 camera_msg_param param;
4702 if (!pc || !pc->cb_info) {
4703 LOGE("NULL handle");
4704 return CAMERA_ERROR_INVALID_PARAMETER;
4709 CAMERA_MSG_PARAM_SET(param, INT, level);
4711 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4713 LOGD("ret : 0x%x", ret);
4719 int camera_attr_set_contrast(camera_h camera, int level)
4721 int ret = CAMERA_ERROR_NONE;
4722 camera_cli_s *pc = (camera_cli_s *)camera;
4723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4724 camera_msg_param param;
4726 if (!pc || !pc->cb_info) {
4727 LOGE("NULL handle");
4728 return CAMERA_ERROR_INVALID_PARAMETER;
4733 CAMERA_MSG_PARAM_SET(param, INT, level);
4735 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4737 LOGD("ret : 0x%x", ret);
4743 int camera_attr_set_hue(camera_h camera, int level)
4745 int ret = CAMERA_ERROR_NONE;
4746 camera_cli_s *pc = (camera_cli_s *)camera;
4747 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4748 camera_msg_param param;
4750 if (!pc || !pc->cb_info) {
4751 LOGE("NULL handle");
4752 return CAMERA_ERROR_INVALID_PARAMETER;
4757 CAMERA_MSG_PARAM_SET(param, INT, level);
4759 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4761 LOGD("ret : 0x%x", ret);
4767 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4769 int ret = CAMERA_ERROR_NONE;
4770 camera_cli_s *pc = (camera_cli_s *)camera;
4771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4772 camera_msg_param param;
4773 int set_whitebalance = (int)wb;
4775 if (!pc || !pc->cb_info) {
4776 LOGE("NULL handle");
4777 return CAMERA_ERROR_INVALID_PARAMETER;
4782 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4784 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4786 LOGD("ret : 0x%x", ret);
4792 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4794 int ret = CAMERA_ERROR_NONE;
4795 camera_cli_s *pc = (camera_cli_s *)camera;
4796 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4797 camera_msg_param param;
4798 int set_effect = (int)effect;
4800 if (!pc || !pc->cb_info) {
4801 LOGE("NULL handle");
4802 return CAMERA_ERROR_INVALID_PARAMETER;
4807 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4809 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4811 LOGD("ret : 0x%x", ret);
4817 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4819 int ret = CAMERA_ERROR_NONE;
4820 camera_cli_s *pc = (camera_cli_s *)camera;
4821 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4822 camera_msg_param param;
4823 int set_mode = (int)mode;
4825 if (!pc || !pc->cb_info) {
4826 LOGE("NULL handle");
4827 return CAMERA_ERROR_INVALID_PARAMETER;
4832 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4834 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4836 LOGD("ret : 0x%x", ret);
4842 int camera_attr_enable_tag(camera_h camera, bool enable)
4844 int ret = CAMERA_ERROR_NONE;
4845 camera_cli_s *pc = (camera_cli_s *)camera;
4846 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4847 camera_msg_param param;
4848 int set_enable = (int)enable;
4850 if (!pc || !pc->cb_info) {
4851 LOGE("NULL handle");
4852 return CAMERA_ERROR_INVALID_PARAMETER;
4857 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4859 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4861 LOGD("ret : 0x%x", ret);
4867 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4869 int ret = CAMERA_ERROR_NONE;
4870 camera_cli_s *pc = (camera_cli_s *)camera;
4871 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4872 camera_msg_param param;
4874 if (!pc || !pc->cb_info || !description) {
4875 LOGE("NULL pointer %p %p", pc, description);
4876 return CAMERA_ERROR_INVALID_PARAMETER;
4881 CAMERA_MSG_PARAM_SET(param, STRING, description);
4883 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4885 LOGD("ret : 0x%x", ret);
4891 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4893 int ret = CAMERA_ERROR_NONE;
4894 camera_cli_s *pc = (camera_cli_s *)camera;
4895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4896 camera_msg_param param;
4897 int set_orientation = (int)orientation;
4899 if (!pc || !pc->cb_info) {
4900 LOGE("NULL handle");
4901 return CAMERA_ERROR_INVALID_PARAMETER;
4906 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4908 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4910 LOGD("ret : 0x%x", ret);
4916 int camera_attr_set_tag_software(camera_h camera, const char *software)
4918 int ret = CAMERA_ERROR_NONE;
4919 camera_cli_s *pc = (camera_cli_s *)camera;
4920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4921 camera_msg_param param;
4923 if (!pc || !pc->cb_info || !software) {
4924 LOGE("NULL pointer %p %p", pc, software);
4925 return CAMERA_ERROR_INVALID_PARAMETER;
4928 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4930 CAMERA_MSG_PARAM_SET(param, STRING, software);
4932 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4934 LOGD("ret : 0x%x", ret);
4940 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4942 int ret = CAMERA_ERROR_NONE;
4943 camera_cli_s *pc = (camera_cli_s *)camera;
4944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4945 double set_geotag[3] = {latitude, longitude, altitude};
4950 if (!pc || !pc->cb_info) {
4951 LOGE("NULL handle");
4952 return CAMERA_ERROR_INVALID_PARAMETER;
4957 length = sizeof(set_geotag) / sizeof(int) + \
4958 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4960 msg = muse_core_msg_new(api,
4961 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4964 LOGE("msg creation failed: api %d", api);
4965 return CAMERA_ERROR_OUT_OF_MEMORY;
4968 if (pc->cb_info->is_server_connected) {
4969 __camera_update_api_waiting(pc->cb_info, api, 1);
4971 g_mutex_lock(&pc->cb_info->fd_lock);
4972 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4973 g_mutex_unlock(&pc->cb_info->fd_lock);
4977 LOGE("message send failed");
4978 ret = CAMERA_ERROR_INVALID_OPERATION;
4980 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4983 __camera_update_api_waiting(pc->cb_info, api, -1);
4985 muse_core_msg_free(msg);
4987 LOGD("ret : 0x%x", ret);
4993 int camera_attr_remove_geotag(camera_h camera)
4995 int ret = CAMERA_ERROR_NONE;
4996 camera_cli_s *pc = (camera_cli_s *)camera;
4997 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4999 if (!pc || !pc->cb_info) {
5000 LOGE("NULL handle");
5001 return CAMERA_ERROR_INVALID_PARAMETER;
5006 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5008 LOGD("ret : 0x%x", ret);
5014 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5016 int ret = CAMERA_ERROR_NONE;
5017 camera_cli_s *pc = (camera_cli_s *)camera;
5018 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5019 camera_msg_param param;
5020 int set_mode = (int)mode;
5022 if (!pc || !pc->cb_info) {
5023 LOGE("NULL handle");
5024 return CAMERA_ERROR_INVALID_PARAMETER;
5029 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5031 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5033 LOGD("ret : 0x%x", ret);
5039 int camera_attr_get_zoom(camera_h camera, int *zoom)
5041 int ret = CAMERA_ERROR_NONE;
5042 camera_cli_s *pc = (camera_cli_s *)camera;
5043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5045 if (!pc || !pc->cb_info || !zoom) {
5046 LOGE("NULL pointer %p %p", pc, zoom);
5047 return CAMERA_ERROR_INVALID_PARAMETER;
5052 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5054 if (ret == CAMERA_ERROR_NONE)
5055 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5057 LOGD("ret : 0x%x", ret);
5063 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5065 int ret = CAMERA_ERROR_NONE;
5066 camera_cli_s *pc = (camera_cli_s *)camera;
5067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5069 if (!pc || !pc->cb_info || !min || !max) {
5070 LOGE("NULL pointer %p %p %p", pc, min, max);
5071 return CAMERA_ERROR_INVALID_PARAMETER;
5076 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5078 if (ret == CAMERA_ERROR_NONE) {
5079 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5080 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5083 LOGD("ret : 0x%x", ret);
5089 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5091 int ret = CAMERA_ERROR_NONE;
5092 camera_cli_s *pc = (camera_cli_s *)camera;
5093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5095 if (!pc || !pc->cb_info || !mode) {
5096 LOGE("NULL pointer %p %p", pc, mode);
5097 return CAMERA_ERROR_INVALID_PARAMETER;
5102 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5104 if (ret == CAMERA_ERROR_NONE)
5105 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5107 LOGD("ret : 0x%x", ret);
5113 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5115 int ret = CAMERA_ERROR_NONE;
5116 camera_cli_s *pc = (camera_cli_s *)camera;
5117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5119 if (!pc || !pc->cb_info || !mode) {
5120 LOGE("NULL pointer %p %p", pc, mode);
5121 return CAMERA_ERROR_INVALID_PARAMETER;
5126 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5128 if (ret == CAMERA_ERROR_NONE)
5129 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5131 LOGD("ret : 0x%x", ret);
5137 int camera_attr_get_exposure(camera_h camera, int *value)
5139 int ret = CAMERA_ERROR_NONE;
5140 camera_cli_s *pc = (camera_cli_s *)camera;
5141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5143 if (!pc || !pc->cb_info || !value) {
5144 LOGE("NULL pointer %p %p", pc, value);
5145 return CAMERA_ERROR_INVALID_PARAMETER;
5150 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5152 if (ret == CAMERA_ERROR_NONE)
5153 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5155 LOGD("ret : 0x%x", ret);
5161 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5163 int ret = CAMERA_ERROR_NONE;
5164 camera_cli_s *pc = (camera_cli_s *)camera;
5165 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5167 if (!pc || !pc->cb_info || !min || !max) {
5168 LOGE("NULL pointer %p %p %p", pc, min, max);
5169 return CAMERA_ERROR_INVALID_PARAMETER;
5174 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5176 if (ret == CAMERA_ERROR_NONE) {
5177 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5178 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5181 LOGD("ret : 0x%x", ret);
5187 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5189 int ret = CAMERA_ERROR_NONE;
5190 camera_cli_s *pc = (camera_cli_s *)camera;
5191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5193 if (!pc || !pc->cb_info || !iso) {
5194 LOGE("NULL pointer %p %p", pc, iso);
5195 return CAMERA_ERROR_INVALID_PARAMETER;
5200 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5202 if (ret == CAMERA_ERROR_NONE)
5203 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5205 LOGD("ret : 0x%x", ret);
5211 int camera_attr_get_brightness(camera_h camera, int *level)
5213 int ret = CAMERA_ERROR_NONE;
5214 camera_cli_s *pc = (camera_cli_s *)camera;
5215 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5217 if (!pc || !pc->cb_info || !level) {
5218 LOGE("NULL pointer %p %p", pc, level);
5219 return CAMERA_ERROR_INVALID_PARAMETER;
5224 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5226 if (ret == CAMERA_ERROR_NONE)
5227 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5229 LOGD("ret : 0x%x", ret);
5235 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5237 int ret = CAMERA_ERROR_NONE;
5238 camera_cli_s *pc = (camera_cli_s *)camera;
5239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5241 if (!pc || !pc->cb_info || !min || !max) {
5242 LOGE("NULL pointer %p %p %p", pc, min, max);
5243 return CAMERA_ERROR_INVALID_PARAMETER;
5248 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5250 if (ret == CAMERA_ERROR_NONE) {
5251 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5252 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5255 LOGD("ret : 0x%x", ret);
5261 int camera_attr_get_contrast(camera_h camera, int *level)
5263 int ret = CAMERA_ERROR_NONE;
5264 camera_cli_s *pc = (camera_cli_s *)camera;
5265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5267 if (!pc || !pc->cb_info || !level) {
5268 LOGE("NULL pointer %p %p", pc, level);
5269 return CAMERA_ERROR_INVALID_PARAMETER;
5274 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5276 if (ret == CAMERA_ERROR_NONE)
5277 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5279 LOGD("ret : 0x%x", ret);
5285 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5287 int ret = CAMERA_ERROR_NONE;
5288 camera_cli_s *pc = (camera_cli_s *)camera;
5289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5291 if (!pc || !pc->cb_info || !min || !max) {
5292 LOGE("NULL pointer %p %p %p", pc, min, max);
5293 return CAMERA_ERROR_INVALID_PARAMETER;
5298 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5300 if (ret == CAMERA_ERROR_NONE) {
5301 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5302 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5303 LOGD("min %d, max %d", *min, *max);
5306 LOGD("ret : 0x%x", ret);
5312 int camera_attr_get_hue(camera_h camera, int *level)
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_HUE;
5318 if (!pc || !pc->cb_info || !level) {
5319 LOGE("NULL pointer %p %p", pc, level);
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 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5330 LOGD("ret : 0x%x", ret);
5336 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5338 int ret = CAMERA_ERROR_NONE;
5339 camera_cli_s *pc = (camera_cli_s *)camera;
5340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5342 if (!pc || !pc->cb_info || !min || !max) {
5343 LOGE("NULL pointer %p %p %p", pc, min, max);
5344 return CAMERA_ERROR_INVALID_PARAMETER;
5349 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5351 if (ret == CAMERA_ERROR_NONE) {
5352 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5353 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5354 LOGD("min %d, max %d", *min, *max);
5357 LOGD("ret : 0x%x", ret);
5363 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
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_WHITEBALANCE;
5369 if (!pc || !pc->cb_info || !wb) {
5370 LOGE("NULL pointer %p %p", pc, wb);
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 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5381 LOGD("ret : 0x%x", ret);
5387 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5389 int ret = CAMERA_ERROR_NONE;
5390 camera_cli_s *pc = (camera_cli_s *)camera;
5391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5393 if (!pc || !pc->cb_info || !effect) {
5394 LOGE("NULL pointer %p %p", pc, effect);
5395 return CAMERA_ERROR_INVALID_PARAMETER;
5400 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5402 if (ret == CAMERA_ERROR_NONE)
5403 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5405 LOGD("ret : 0x%x", ret);
5411 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5413 int ret = CAMERA_ERROR_NONE;
5414 camera_cli_s *pc = (camera_cli_s *)camera;
5415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5417 if (!pc || !pc->cb_info || !mode) {
5418 LOGE("NULL pointer %p %p", pc, mode);
5419 return CAMERA_ERROR_INVALID_PARAMETER;
5424 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5426 if (ret == CAMERA_ERROR_NONE)
5427 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5429 LOGD("ret : 0x%x", ret);
5435 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5437 int ret = CAMERA_ERROR_NONE;
5438 camera_cli_s *pc = (camera_cli_s *)camera;
5439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5441 if (!pc || !pc->cb_info || !enable) {
5442 LOGE("NULL pointer %p %p", pc, enable);
5443 return CAMERA_ERROR_INVALID_PARAMETER;
5448 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5450 if (ret == CAMERA_ERROR_NONE)
5451 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5453 LOGD("ret : 0x%x", ret);
5459 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5461 int ret = CAMERA_ERROR_NONE;
5462 camera_cli_s *pc = (camera_cli_s *)camera;
5463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5465 if (!pc || !pc->cb_info || !description) {
5466 LOGE("NULL pointer %p %p", pc, description);
5467 return CAMERA_ERROR_INVALID_PARAMETER;
5472 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5474 if (ret == CAMERA_ERROR_NONE)
5475 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5477 LOGD("ret : 0x%x", ret);
5483 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5485 int ret = CAMERA_ERROR_NONE;
5486 camera_cli_s *pc = (camera_cli_s *)camera;
5487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5489 if (!pc || !pc->cb_info || !orientation) {
5490 LOGE("NULL pointer %p %p", pc, orientation);
5491 return CAMERA_ERROR_INVALID_PARAMETER;
5496 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5498 if (ret == CAMERA_ERROR_NONE)
5499 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5501 LOGD("ret : 0x%x", ret);
5507 int camera_attr_get_tag_software(camera_h camera, char **software)
5509 int ret = CAMERA_ERROR_NONE;
5510 camera_cli_s *pc = (camera_cli_s *)camera;
5511 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5513 if (!pc || !pc->cb_info || !software) {
5514 LOGE("NULL pointer %p %p", pc, software);
5515 return CAMERA_ERROR_INVALID_PARAMETER;
5520 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5522 if (ret == CAMERA_ERROR_NONE)
5523 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5525 LOGD("ret : 0x%x", ret);
5531 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5533 int ret = CAMERA_ERROR_NONE;
5534 camera_cli_s *pc = (camera_cli_s *)camera;
5535 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5537 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5538 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5539 return CAMERA_ERROR_INVALID_PARAMETER;
5544 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5546 if (ret == CAMERA_ERROR_NONE) {
5547 *latitude = pc->cb_info->get_geotag[0];
5548 *longitude = pc->cb_info->get_geotag[1];
5549 *altitude = pc->cb_info->get_geotag[2];
5552 LOGD("ret : 0x%x", ret);
5558 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
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_FLASH_MODE;
5564 if (!pc || !pc->cb_info || !mode) {
5565 LOGE("NULL pointer %p %p", pc, mode);
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 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5576 LOGD("ret : 0x%x", ret);
5582 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5584 int ret = CAMERA_ERROR_NONE;
5585 int get_flash_state = 0;
5588 LOGE("NULL pointer");
5589 return CAMERA_ERROR_INVALID_PARAMETER;
5592 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5593 (int)device, "get_flash_state", &get_flash_state);
5595 if (ret == CAMERA_ERROR_NONE) {
5596 *state = (camera_flash_state_e)get_flash_state;
5597 LOGD("flash state %d", *state);
5599 LOGE("failed 0x%x", ret);
5606 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5608 int ret = CAMERA_ERROR_NONE;
5609 camera_cli_s *pc = (camera_cli_s *)camera;
5610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5612 if (!pc || !pc->cb_info || !foreach_cb) {
5613 LOGE("NULL pointer %p %p", pc, foreach_cb);
5614 return CAMERA_ERROR_INVALID_PARAMETER;
5619 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5620 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5622 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5624 LOGD("ret : 0x%x", ret);
5630 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5632 int ret = CAMERA_ERROR_NONE;
5633 camera_cli_s *pc = (camera_cli_s *)camera;
5634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5636 if (!pc || !pc->cb_info || !foreach_cb) {
5637 LOGE("NULL pointer %p %p", pc, foreach_cb);
5638 return CAMERA_ERROR_INVALID_PARAMETER;
5643 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5644 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5646 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5648 LOGD("ret : 0x%x", ret);
5654 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5656 int ret = CAMERA_ERROR_NONE;
5657 camera_cli_s *pc = (camera_cli_s *)camera;
5658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5660 if (!pc || !pc->cb_info || !foreach_cb) {
5661 LOGE("NULL pointer %p %p", pc, foreach_cb);
5662 return CAMERA_ERROR_INVALID_PARAMETER;
5667 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5668 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5670 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5672 LOGD("ret : 0x%x", ret);
5678 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5680 int ret = CAMERA_ERROR_NONE;
5681 camera_cli_s *pc = (camera_cli_s *)camera;
5682 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5684 if (!pc || !pc->cb_info || !foreach_cb) {
5685 LOGE("NULL pointer %p %p", pc, foreach_cb);
5686 return CAMERA_ERROR_INVALID_PARAMETER;
5691 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5692 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5694 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5696 LOGD("ret : 0x%x", ret);
5702 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5704 int ret = CAMERA_ERROR_NONE;
5705 camera_cli_s *pc = (camera_cli_s *)camera;
5706 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5708 if (!pc || !pc->cb_info || !foreach_cb) {
5709 LOGE("NULL pointer %p %p", pc, foreach_cb);
5710 return CAMERA_ERROR_INVALID_PARAMETER;
5715 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5716 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5718 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5720 LOGD("ret : 0x%x", ret);
5726 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5728 int ret = CAMERA_ERROR_NONE;
5729 camera_cli_s *pc = (camera_cli_s *)camera;
5730 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5732 if (!pc || !pc->cb_info || !foreach_cb) {
5733 LOGE("NULL pointer %p %p", pc, foreach_cb);
5734 return CAMERA_ERROR_INVALID_PARAMETER;
5739 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5740 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5742 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5744 LOGD("ret : 0x%x", ret);
5750 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5752 int ret = CAMERA_ERROR_NONE;
5753 camera_cli_s *pc = (camera_cli_s *)camera;
5754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5756 if (!pc || !pc->cb_info || !foreach_cb) {
5757 LOGE("NULL pointer %p %p", pc, foreach_cb);
5758 return CAMERA_ERROR_INVALID_PARAMETER;
5763 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5764 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5766 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5768 LOGD("ret : 0x%x", ret);
5774 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5776 int ret = CAMERA_ERROR_NONE;
5777 camera_cli_s *pc = (camera_cli_s *)camera;
5778 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5780 if (!pc || !pc->cb_info || !foreach_cb) {
5781 LOGE("NULL pointer %p %p", pc, foreach_cb);
5782 return CAMERA_ERROR_INVALID_PARAMETER;
5787 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5788 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5790 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5792 LOGD("Enter, handle :%td", pc->remote_handle);
5798 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)
5800 int ret = CAMERA_ERROR_NONE;
5801 camera_cli_s *pc = (camera_cli_s *)camera;
5802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5803 camera_msg_param param;
5806 if (!pc || !pc->cb_info || !foreach_cb) {
5807 LOGE("NULL pointer %p %p", pc, foreach_cb);
5808 return CAMERA_ERROR_INVALID_PARAMETER;
5813 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5814 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5816 value = (width << 16) | height;
5817 CAMERA_MSG_PARAM_SET(param, INT, value);
5819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5821 LOGD("ret : 0x%x", ret);
5827 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5829 int ret = CAMERA_ERROR_NONE;
5830 camera_cli_s *pc = (camera_cli_s *)camera;
5831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
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_STREAM_FLIP] = foreach_cb;
5841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5843 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5845 LOGD("ret : 0x%x", ret);
5851 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5853 int ret = CAMERA_ERROR_NONE;
5854 camera_cli_s *pc = (camera_cli_s *)camera;
5855 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5857 if (!pc || !pc->cb_info || !foreach_cb) {
5858 LOGE("NULL pointer %p %p", pc, foreach_cb);
5859 return CAMERA_ERROR_INVALID_PARAMETER;
5864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5867 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5869 LOGD("ret : 0x%x", ret);
5875 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5877 int ret = CAMERA_ERROR_NONE;
5878 camera_cli_s *pc = (camera_cli_s *)camera;
5879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5880 camera_msg_param param;
5881 int set_rotation = (int)rotation;
5883 if (!pc || !pc->cb_info) {
5884 LOGE("NULL handle");
5885 return CAMERA_ERROR_INVALID_PARAMETER;
5890 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5892 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5894 LOGD("ret : 0x%x", ret);
5900 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5902 int ret = CAMERA_ERROR_NONE;
5903 camera_cli_s *pc = (camera_cli_s *)camera;
5904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5906 if (!pc || !pc->cb_info || !rotation) {
5907 LOGE("NULL pointer %p %p", pc, rotation);
5908 return CAMERA_ERROR_INVALID_PARAMETER;
5913 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5915 if (ret == CAMERA_ERROR_NONE)
5916 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5918 LOGD("ret : 0x%x", ret);
5924 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5926 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5929 camera_msg_param param;
5930 int set_flip = (int)flip;
5932 if (!pc || !pc->cb_info) {
5933 LOGE("NULL handle");
5934 return CAMERA_ERROR_INVALID_PARAMETER;
5939 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5941 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5943 LOGD("ret : 0x%x", ret);
5949 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5951 int ret = CAMERA_ERROR_NONE;
5952 camera_cli_s *pc = (camera_cli_s *)camera;
5953 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5955 if (!pc || !pc->cb_info || !flip) {
5956 LOGE("NULL pointer %p %p", pc, flip);
5957 return CAMERA_ERROR_INVALID_PARAMETER;
5962 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5964 if (ret == CAMERA_ERROR_NONE)
5965 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5967 LOGD("ret : 0x%x", ret);
5972 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5974 int ret = CAMERA_ERROR_NONE;
5975 camera_cli_s *pc = (camera_cli_s *)camera;
5976 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5977 camera_msg_param param;
5978 int set_mode = (int)mode;
5980 if (!pc || !pc->cb_info) {
5981 LOGE("NULL handle");
5982 return CAMERA_ERROR_INVALID_PARAMETER;
5987 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5989 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5991 LOGD("ret : 0x%x", ret);
5997 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5999 int ret = CAMERA_ERROR_NONE;
6000 camera_cli_s *pc = (camera_cli_s *)camera;
6001 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6003 if (!pc || !pc->cb_info || !mode) {
6004 LOGE("NULL pointer %p %p", pc, mode);
6005 return CAMERA_ERROR_INVALID_PARAMETER;
6010 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6012 if (ret == CAMERA_ERROR_NONE)
6013 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6015 LOGD("ret : 0x%x", ret);
6021 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6023 int ret = CAMERA_ERROR_NONE;
6024 camera_cli_s *pc = (camera_cli_s *)camera;
6025 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6027 if (!pc || !pc->cb_info) {
6028 LOGE("NULL handle");
6029 return CAMERA_ERROR_INVALID_PARAMETER;
6034 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6037 LOGE("error is occurred 0x%x", ret);
6041 LOGD("ret : %d", ret);
6047 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6049 int ret = CAMERA_ERROR_NONE;
6050 camera_cli_s *pc = (camera_cli_s *)camera;
6051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6053 if (!pc || !pc->cb_info) {
6054 LOGE("NULL handle");
6055 return CAMERA_ERROR_INVALID_PARAMETER;
6060 if (!camera_attr_is_supported_hdr_capture(camera)) {
6061 LOGE("HDR not supported");
6062 return CAMERA_ERROR_NOT_SUPPORTED;
6066 LOGE("NULL callback");
6067 return CAMERA_ERROR_INVALID_PARAMETER;
6070 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6072 if (ret == CAMERA_ERROR_NONE) {
6073 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6075 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6076 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6078 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6081 LOGD("ret : 0x%x", ret);
6087 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6089 int ret = CAMERA_ERROR_NONE;
6090 camera_cli_s *pc = (camera_cli_s *)camera;
6091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6093 if (!pc || !pc->cb_info) {
6094 LOGE("NULL handle");
6095 return CAMERA_ERROR_INVALID_PARAMETER;
6100 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6102 if (ret == CAMERA_ERROR_NONE) {
6103 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6105 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6106 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6108 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6111 LOGD("ret : 0x%x", ret);
6117 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6119 int ret = CAMERA_ERROR_NONE;
6120 camera_cli_s *pc = (camera_cli_s *)camera;
6121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6122 camera_msg_param param;
6123 int set_enable = (int)enable;
6125 if (!pc || !pc->cb_info) {
6126 LOGE("NULL handle");
6127 return CAMERA_ERROR_INVALID_PARAMETER;
6132 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6134 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6136 LOGD("ret : 0x%x", ret);
6142 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6144 int ret = CAMERA_ERROR_NONE;
6145 camera_cli_s *pc = (camera_cli_s *)camera;
6146 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6148 if (!pc || !pc->cb_info || !enabled) {
6149 LOGE("NULL pointer %p %p", pc, enabled);
6150 return CAMERA_ERROR_INVALID_PARAMETER;
6155 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6157 if (ret == CAMERA_ERROR_NONE)
6158 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6160 LOGD("ret : 0x%x", ret);
6166 bool camera_attr_is_supported_anti_shake(camera_h camera)
6168 int ret = CAMERA_ERROR_NONE;
6169 camera_cli_s *pc = (camera_cli_s *)camera;
6170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6172 if (!pc || !pc->cb_info) {
6173 LOGE("NULL handle");
6174 return CAMERA_ERROR_INVALID_PARAMETER;
6179 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6182 LOGE("error is occurred 0x%x", ret);
6186 LOGD("ret : %d", ret);
6192 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6194 int ret = CAMERA_ERROR_NONE;
6195 camera_cli_s *pc = (camera_cli_s *)camera;
6196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6197 camera_msg_param param;
6198 int set_enable = (int)enable;
6200 if (!pc || !pc->cb_info) {
6201 LOGE("NULL handle");
6202 return CAMERA_ERROR_INVALID_PARAMETER;
6207 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6209 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6211 LOGD("ret : 0x%x", ret);
6217 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6219 int ret = CAMERA_ERROR_NONE;
6220 camera_cli_s *pc = (camera_cli_s *)camera;
6221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6223 if (!pc || !pc->cb_info || !enabled) {
6224 LOGE("NULL pointer %p %p", pc, enabled);
6225 return CAMERA_ERROR_INVALID_PARAMETER;
6230 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6232 if (ret == CAMERA_ERROR_NONE)
6233 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6235 LOGD("ret : 0x%x", ret);
6241 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6243 int ret = CAMERA_ERROR_NONE;
6244 camera_cli_s *pc = (camera_cli_s *)camera;
6245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6247 if (!pc || !pc->cb_info) {
6248 LOGE("NULL handle");
6249 return CAMERA_ERROR_INVALID_PARAMETER;
6254 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6257 LOGE("error is occurred 0x%x", ret);
6261 LOGD("ret : %d", ret);
6267 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6269 int ret = CAMERA_ERROR_NONE;
6270 camera_cli_s *pc = (camera_cli_s *)camera;
6271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6272 camera_msg_param param;
6273 int set_enable = (int)enable;
6275 if (!pc || !pc->cb_info) {
6276 LOGE("NULL handle");
6277 return CAMERA_ERROR_INVALID_PARAMETER;
6282 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6284 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6286 LOGD("ret : 0x%x", ret);
6292 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6294 int ret = CAMERA_ERROR_NONE;
6295 camera_cli_s *pc = (camera_cli_s *)camera;
6296 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6298 if (!pc || !pc->cb_info || !enabled) {
6299 LOGE("NULL pointer %p %p", pc, enabled);
6300 return CAMERA_ERROR_INVALID_PARAMETER;
6305 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6307 if (ret == CAMERA_ERROR_NONE)
6308 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6310 LOGD("ret : 0x%x", ret);
6316 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6318 int ret = CAMERA_ERROR_NONE;
6319 camera_cli_s *pc = (camera_cli_s *)camera;
6320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6322 if (!pc || !pc->cb_info) {
6323 LOGE("NULL handle");
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6329 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6332 LOGE("error is occurred 0x%x", ret);
6336 LOGD("ret : %d", ret);
6342 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6347 camera_msg_param param;
6348 int set_disable = (int)disable;
6350 if (!pc || !pc->cb_info) {
6351 LOGE("NULL handle");
6352 return CAMERA_ERROR_INVALID_PARAMETER;
6357 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6359 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6361 LOGD("ret : 0x%x", ret);
6367 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6369 int ret = CAMERA_ERROR_NONE;
6370 camera_cli_s *pc = (camera_cli_s *)camera;
6371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6372 camera_msg_param param;
6373 int set_move_type = (int)move_type;
6376 if (!pc || !pc->cb_info) {
6377 LOGE("NULL handle");
6378 return CAMERA_ERROR_INVALID_PARAMETER;
6383 value = (set_move_type << 16) | pan_step;
6384 CAMERA_MSG_PARAM_SET(param, INT, value);
6386 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6388 LOGD("ret : 0x%x", ret);
6394 int camera_attr_get_pan(camera_h camera, 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_GET_PAN;
6400 if (!pc || !pc->cb_info || !pan_step) {
6401 LOGE("NULL pointer %p %p", pc, pan_step);
6402 return CAMERA_ERROR_INVALID_PARAMETER;
6407 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6409 if (ret == CAMERA_ERROR_NONE)
6410 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6412 LOGD("ret : 0x%x", ret);
6418 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6420 int ret = CAMERA_ERROR_NONE;
6421 camera_cli_s *pc = (camera_cli_s *)camera;
6422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6424 if (!pc || !pc->cb_info || !min || !max) {
6425 LOGE("NULL pointer %p %p %p", pc, min, max);
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6433 if (ret == CAMERA_ERROR_NONE) {
6434 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6435 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6438 LOGD("ret : 0x%x", ret);
6444 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6446 int ret = CAMERA_ERROR_NONE;
6447 camera_cli_s *pc = (camera_cli_s *)camera;
6448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6449 camera_msg_param param;
6450 int set_move_type = (int)move_type;
6453 if (!pc || !pc->cb_info) {
6454 LOGE("NULL handle");
6455 return CAMERA_ERROR_INVALID_PARAMETER;
6460 value = (set_move_type << 16) | tilt_step;
6461 CAMERA_MSG_PARAM_SET(param, INT, value);
6463 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6465 LOGD("ret : 0x%x", ret);
6471 int camera_attr_get_tilt(camera_h camera, 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_GET_TILT;
6477 if (!pc || !pc->cb_info || !tilt_step) {
6478 LOGE("NULL pointer %p %p", pc, tilt_step);
6479 return CAMERA_ERROR_INVALID_PARAMETER;
6484 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6486 if (ret == CAMERA_ERROR_NONE)
6487 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6489 LOGD("ret : 0x%x", ret);
6495 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6497 int ret = CAMERA_ERROR_NONE;
6498 camera_cli_s *pc = (camera_cli_s *)camera;
6499 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6501 if (!pc || !pc->cb_info || !min || !max) {
6502 LOGE("NULL pointer %p %p %p", pc, min, max);
6503 return CAMERA_ERROR_INVALID_PARAMETER;
6508 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6510 if (ret == CAMERA_ERROR_NONE) {
6511 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6512 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6515 LOGD("ret : 0x%x", ret);
6521 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6523 int ret = CAMERA_ERROR_NONE;
6524 camera_cli_s *pc = (camera_cli_s *)camera;
6525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6526 camera_msg_param param;
6527 int set_ptz_type = (int)ptz_type;
6529 if (!pc || !pc->cb_info) {
6530 LOGE("NULL handle");
6531 return CAMERA_ERROR_INVALID_PARAMETER;
6536 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6538 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6540 LOGD("ret : 0x%x", ret);
6546 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6548 int ret = CAMERA_ERROR_NONE;
6549 camera_cli_s *pc = (camera_cli_s *)camera;
6550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6552 if (!pc || !pc->cb_info || !foreach_cb) {
6553 LOGE("NULL pointer %p %p", pc, foreach_cb);
6554 return CAMERA_ERROR_INVALID_PARAMETER;
6559 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6560 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6562 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6564 LOGD("ret : 0x%x", ret);
6570 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6572 int ret = CAMERA_ERROR_NONE;
6573 camera_cli_s *pc = (camera_cli_s *)camera;
6574 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6575 int set_display_roi_area[4] = {x, y, width, height};
6580 if (!pc || !pc->cb_info) {
6581 LOGE("NULL handle");
6582 return CAMERA_ERROR_INVALID_PARAMETER;
6587 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6588 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6589 if (ret != MM_ERROR_NONE) {
6590 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6591 return CAMERA_ERROR_INVALID_OPERATION;
6595 length = sizeof(set_display_roi_area) / sizeof(int) + \
6596 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6598 msg = muse_core_msg_new(api,
6599 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6602 LOGE("msg creation failed: api %d", api);
6603 return CAMERA_ERROR_OUT_OF_MEMORY;
6606 if (pc->cb_info->is_server_connected) {
6607 __camera_update_api_waiting(pc->cb_info, api, 1);
6609 g_mutex_lock(&pc->cb_info->fd_lock);
6610 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6611 g_mutex_unlock(&pc->cb_info->fd_lock);
6615 LOGE("message send failed");
6616 ret = CAMERA_ERROR_INVALID_OPERATION;
6618 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6621 __camera_update_api_waiting(pc->cb_info, api, -1);
6623 muse_core_msg_free(msg);
6625 LOGD("ret : 0x%x", ret);
6631 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6633 camera_cli_s *pc = (camera_cli_s *)camera;
6634 int ret = CAMERA_ERROR_NONE;
6635 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6637 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6638 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6639 return CAMERA_ERROR_INVALID_PARAMETER;
6644 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6646 if (ret == CAMERA_ERROR_NONE) {
6647 *x = pc->cb_info->get_display_roi_area[0];
6648 *y = pc->cb_info->get_display_roi_area[1];
6649 *width = pc->cb_info->get_display_roi_area[2];
6650 *height = pc->cb_info->get_display_roi_area[3];
6653 LOGD("ret : 0x%x", ret);
6659 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6661 int ret = CAMERA_ERROR_NONE;
6662 int get_device_state = 0;
6665 LOGE("NULL pointer");
6666 return CAMERA_ERROR_INVALID_PARAMETER;
6669 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6670 (int)device, "get_device_state", &get_device_state);
6672 if (ret == CAMERA_ERROR_NONE) {
6673 *state = (camera_device_state_e)get_device_state;
6674 LOGD("device state %d", *state);
6676 LOGE("failed 0x%x", ret);
6683 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6685 int ret = CAMERA_ERROR_NONE;
6686 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6687 camera_cb_info *info = NULL;
6689 if (!callback || !cb_id) {
6690 LOGE("invalid pointer %p %p", callback, cb_id);
6691 return CAMERA_ERROR_INVALID_PARAMETER;
6694 /* check camera support */
6695 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6696 if (ret != CAMERA_ERROR_NONE) {
6697 LOGE("get device state failed");
6701 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6703 info = g_new0(camera_cb_info, 1);
6705 LOGE("info failed");
6706 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6710 info->id = ++g_cam_dev_state_changed_cb_id;
6711 info->callback = (void *)callback;
6712 info->user_data = user_data;
6716 /* subscribe dbus signal for camera state change */
6717 if (!g_cam_dev_state_changed_cb_conn) {
6718 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6719 if (!g_cam_dev_state_changed_cb_conn) {
6720 LOGE("failed to get gdbus connection");
6721 ret = CAMERA_ERROR_INVALID_OPERATION;
6725 LOGD("subscribe signal %s - %s - %s",
6726 MM_CAMCORDER_DBUS_OBJECT,
6727 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6728 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6730 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6731 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6732 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6733 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6734 LOGE("failed to get gdbus connection");
6735 ret = CAMERA_ERROR_INVALID_OPERATION;
6739 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6742 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6744 LOGD("callback id %d", info->id);
6747 if (ret != CAMERA_ERROR_NONE) {
6753 if (g_cam_dev_state_changed_cb_conn) {
6754 g_object_unref(g_cam_dev_state_changed_cb_conn);
6755 g_cam_dev_state_changed_cb_conn = NULL;
6759 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6765 int camera_remove_device_state_changed_cb(int cb_id)
6767 int ret = CAMERA_ERROR_NONE;
6768 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6769 GList *tmp_list = NULL;
6770 camera_cb_info *info = NULL;
6772 /* check camera support */
6773 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6774 if (ret != CAMERA_ERROR_NONE) {
6775 LOGE("get device state failed");
6779 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6781 if (!g_cam_dev_state_changed_cb_list) {
6782 LOGE("there is no callback info");
6783 ret = CAMERA_ERROR_INVALID_OPERATION;
6787 tmp_list = g_cam_dev_state_changed_cb_list;
6790 info = tmp_list->data;
6791 tmp_list = tmp_list->next;
6798 if (info->id == cb_id) {
6799 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6804 if (!g_cam_dev_state_changed_cb_list) {
6805 /* no remained callback */
6806 if (g_cam_dev_state_changed_cb_conn) {
6807 /* unsubscribe signal */
6808 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6809 g_cam_dev_state_changed_cb_subscribe_id = 0;
6811 /* unref connection */
6812 g_object_unref(g_cam_dev_state_changed_cb_conn);
6813 g_cam_dev_state_changed_cb_conn = NULL;
6817 LOGD("id %d callback removed", cb_id);
6818 ret = CAMERA_ERROR_NONE;
6824 LOGE("id %d callback not found", cb_id);
6825 ret = CAMERA_ERROR_INVALID_PARAMETER;
6828 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);