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 if (!cb_info->is_server_connected) {
641 LOGE("server is disconnected");
642 return CAMERA_ERROR_SERVICE_DISCONNECTED;
645 g_mutex_lock(&(cb_info->api_mutex[api]));
647 LOGD("api [%d], timeout [%d sec]", api, time_out);
649 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
651 while (!cb_info->api_activating[api]) {
652 if (time_out == CAMERA_CB_NO_TIMEOUT) {
653 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
654 LOGW("api %d returned 0x%x", api, cb_info->api_ret[api]);
655 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
656 LOGE("api %d TIMED OUT!", api);
657 ret = CAMERA_ERROR_INVALID_OPERATION;
661 if (!cb_info->api_activating[api])
662 LOGW("invalid signal received, wait again...");
665 ret = cb_info->api_ret[api];
666 cb_info->api_activating[api] = FALSE;
669 g_mutex_unlock(&(cb_info->api_mutex[api]));
671 if (ret != CAMERA_ERROR_NONE)
672 LOGE("api %d : error 0x%x", api, ret);
678 static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
679 int *ret, int timeout)
685 LOGE("NULL info - api %d", api);
688 *ret = CAMERA_ERROR_INVALID_PARAMETER;
693 msg = muse_core_msg_new(api, NULL);
695 LOGE("msg failed: api %d", api);
698 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
703 /*LOGD("send msg %s", msg);*/
705 if (cb_info->is_server_connected) {
706 __camera_update_api_waiting(cb_info, api, 1);
708 g_mutex_lock(&cb_info->fd_lock);
709 send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
710 g_mutex_unlock(&cb_info->fd_lock);
714 LOGE("msg send failed");
716 *ret = CAMERA_ERROR_INVALID_OPERATION;
719 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
722 __camera_update_api_waiting(cb_info, api, -1);
724 muse_core_msg_free(msg);
730 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
731 int *ret, camera_msg_param *param, int timeout)
737 if (!cb_info || !param) {
738 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
741 *ret = CAMERA_ERROR_INVALID_PARAMETER;
746 /*LOGD("type %d, name %s", param->type, param->name);*/
748 switch (param->type) {
750 msg = muse_core_msg_new(api,
751 param->type, param->name, param->value.value_INT,
754 case MUSE_TYPE_STRING:
755 msg = muse_core_msg_new(api,
756 param->type, param->name, param->value.value_STRING,
759 case MUSE_TYPE_ARRAY:
760 array_length = param->value_size / sizeof(int) + \
761 (param->value_size % sizeof(int) ? 1 : 0);
763 msg = muse_core_msg_new(api,
764 param->type, param->name, array_length, param->value.value_ARRAY,
768 LOGE("unknown type %d", param->type);
773 LOGE("msg failed: api %d", api);
776 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
781 /*LOGD("send msg %s", msg);*/
783 if (cb_info->is_server_connected) {
784 __camera_update_api_waiting(cb_info, api, 1);
786 g_mutex_lock(&cb_info->fd_lock);
787 send_ret = muse_core_msg_send(cb_info->fd, msg);
788 g_mutex_unlock(&cb_info->fd_lock);
792 LOGE("msg send failed");
795 *ret = CAMERA_ERROR_INVALID_OPERATION;
798 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
801 __camera_update_api_waiting(cb_info, api, -1);
803 muse_core_msg_free(msg);
809 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
810 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
812 int func_ret = CAMERA_ERROR_NONE;
816 if (!cb_info || !param0 || !param1) {
817 LOGE("invalid ptr %p %p %p : api %d",
818 cb_info, param0, param1, api);
819 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
820 goto _SEND_PARAM2_INT_DONE;
823 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
825 param0->name, param0->value.value_INT,
826 param1->name, param1->value.value_INT);*/
828 msg = muse_core_msg_new(api,
829 param0->type, param0->name, param0->value.value_INT,
830 param1->type, param1->name, param1->value.value_INT,
833 LOGE("msg failed: api %d", api);
834 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
835 goto _SEND_PARAM2_INT_DONE;
838 /*LOGD("send msg [%s]", msg);*/
840 if (cb_info->is_server_connected) {
841 __camera_update_api_waiting(cb_info, api, 1);
843 g_mutex_lock(&cb_info->fd_lock);
844 send_ret = muse_core_msg_send(cb_info->fd, msg);
845 g_mutex_unlock(&cb_info->fd_lock);
849 LOGE("msg send failed");
851 func_ret = CAMERA_ERROR_INVALID_OPERATION;
853 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
856 __camera_update_api_waiting(cb_info, api, -1);
858 muse_core_msg_free(msg);
860 _SEND_PARAM2_INT_DONE:
868 static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
870 camera_msg_param param;
873 LOGW("invalid fd %d", ret_fd);
877 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
879 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
885 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
887 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
888 in_format >= MM_PIXEL_FORMAT_NUM ||
889 out_format == NULL) {
890 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
891 return CAMERA_ERROR_INVALID_PARAMETER;
895 case MM_PIXEL_FORMAT_NV12:
896 case MM_PIXEL_FORMAT_NV12T:
897 *out_format = TBM_FORMAT_NV12;
900 case MM_PIXEL_FORMAT_NV16:
901 *out_format = TBM_FORMAT_NV16;
903 case MM_PIXEL_FORMAT_NV21:
904 *out_format = TBM_FORMAT_NV21;
906 case MM_PIXEL_FORMAT_YUYV:
907 *out_format = TBM_FORMAT_YUYV;
909 case MM_PIXEL_FORMAT_UYVY:
910 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
911 *out_format = TBM_FORMAT_UYVY;
913 case MM_PIXEL_FORMAT_422P:
914 *out_format = TBM_FORMAT_YUV422;
916 case MM_PIXEL_FORMAT_I420:
917 *out_format = TBM_FORMAT_YUV420;
919 case MM_PIXEL_FORMAT_YV12:
920 *out_format = TBM_FORMAT_YVU420;
922 case MM_PIXEL_FORMAT_RGB565:
923 *out_format = TBM_FORMAT_RGB565;
925 case MM_PIXEL_FORMAT_RGB888:
926 *out_format = TBM_FORMAT_RGB888;
928 case MM_PIXEL_FORMAT_RGBA:
929 *out_format = TBM_FORMAT_RGBA8888;
931 case MM_PIXEL_FORMAT_ARGB:
932 *out_format = TBM_FORMAT_ARGB8888;
935 LOGE("invalid in_format %d", in_format);
936 return CAMERA_ERROR_INVALID_PARAMETER;
940 return CAMERA_ERROR_NONE;
944 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
946 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
947 in_format >= MM_PIXEL_FORMAT_NUM ||
949 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
950 return CAMERA_ERROR_INVALID_PARAMETER;
954 case MM_PIXEL_FORMAT_NV12:
955 case MM_PIXEL_FORMAT_NV12T:
956 *mimetype = MEDIA_FORMAT_NV12;
959 case MM_PIXEL_FORMAT_NV16:
960 *mimetype = MEDIA_FORMAT_NV16;
962 case MM_PIXEL_FORMAT_NV21:
963 *mimetype = MEDIA_FORMAT_NV21;
965 case MM_PIXEL_FORMAT_YUYV:
966 *mimetype = MEDIA_FORMAT_YUYV;
968 case MM_PIXEL_FORMAT_UYVY:
969 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
970 *mimetype = MEDIA_FORMAT_UYVY;
972 case MM_PIXEL_FORMAT_422P:
973 *mimetype = MEDIA_FORMAT_422P;
975 case MM_PIXEL_FORMAT_I420:
976 *mimetype = MEDIA_FORMAT_I420;
978 case MM_PIXEL_FORMAT_YV12:
979 *mimetype = MEDIA_FORMAT_YV12;
981 case MM_PIXEL_FORMAT_RGB565:
982 *mimetype = MEDIA_FORMAT_RGB565;
984 case MM_PIXEL_FORMAT_RGB888:
985 *mimetype = MEDIA_FORMAT_RGB888;
987 case MM_PIXEL_FORMAT_RGBA:
988 *mimetype = MEDIA_FORMAT_RGBA;
990 case MM_PIXEL_FORMAT_ARGB:
991 *mimetype = MEDIA_FORMAT_ARGB;
994 LOGE("invalid in_format %d", in_format);
995 return CAMERA_ERROR_INVALID_PARAMETER;
999 return CAMERA_ERROR_NONE;
1002 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
1003 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1006 unsigned char *buf_pos = NULL;
1008 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1009 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1013 /* set frame info */
1014 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1015 frame->format = MM_PIXEL_FORMAT_UYVY;
1017 frame->format = stream->format;
1019 frame->width = stream->width;
1020 frame->height = stream->height;
1021 frame->timestamp = stream->timestamp;
1022 frame->num_of_planes = stream->num_planes;
1024 if (num_buffer_fd == 0) {
1027 if (!data_bo_handle || !data_bo_handle->ptr) {
1028 LOGE("NULL pointer");
1032 buf_pos = data_bo_handle->ptr;
1034 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1035 frame->data.encoded_plane.data = buf_pos;
1036 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1037 frame->data.encoded_plane.is_delta_frame = (bool)stream->data.encoded.is_delta_frame;
1038 total_size = stream->data.encoded.length_data;
1039 } else if (stream->format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
1040 frame->data.encoded_plane.data = buf_pos;
1041 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1042 total_size = stream->data.encoded.length_data;
1043 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
1044 frame->data.depth_plane.data = buf_pos;
1045 frame->data.depth_plane.size = stream->data.depth.length_data;
1046 total_size = stream->data.depth.length_data;
1047 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
1048 stream->format == MM_PIXEL_FORMAT_ARGB) {
1049 frame->data.rgb_plane.data = buf_pos;
1050 frame->data.rgb_plane.size = stream->data.rgb.length_data;
1051 total_size = stream->data.rgb.length_data;
1053 switch (stream->num_planes) {
1055 frame->data.single_plane.yuv = buf_pos;
1056 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1057 total_size = stream->data.yuv420.length_yuv;
1060 frame->data.double_plane.y = buf_pos;
1061 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1062 buf_pos += stream->data.yuv420sp.length_y;
1063 frame->data.double_plane.uv = buf_pos;
1064 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1065 total_size = stream->data.yuv420sp.length_y + \
1066 stream->data.yuv420sp.length_uv;
1069 frame->data.triple_plane.y = buf_pos;
1070 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1071 buf_pos += stream->data.yuv420p.length_y;
1072 frame->data.triple_plane.u = buf_pos;
1073 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1074 buf_pos += stream->data.yuv420p.length_u;
1075 frame->data.triple_plane.v = buf_pos;
1076 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1077 total_size = stream->data.yuv420p.length_y + \
1078 stream->data.yuv420p.length_u + \
1079 stream->data.yuv420p.length_v;
1088 switch (stream->num_planes) {
1091 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1092 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1093 total_size = stream->data.yuv420.length_yuv;
1097 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1098 if (stream->num_planes == (unsigned int)num_buffer_fd)
1099 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1101 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1102 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1103 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1104 total_size = stream->data.yuv420sp.length_y + \
1105 stream->data.yuv420sp.length_uv;
1109 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1110 if (stream->num_planes == (unsigned int)num_buffer_fd) {
1111 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1112 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1114 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1115 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1117 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1118 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1119 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1120 total_size = stream->data.yuv420p.length_y + \
1121 stream->data.yuv420p.length_u + \
1122 stream->data.yuv420p.length_v;
1131 LOGD("format %d, %dx%d, size %d plane num %d",
1132 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1138 static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1139 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1142 int ret = CAMERA_ERROR_NONE;
1143 camera_media_packet_data *tmp_mp_data = NULL;
1147 return CAMERA_ERROR_INVALID_PARAMETER;
1150 if (*mp_data == NULL) {
1151 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1153 tmp_mp_data->ret_fd = ret_fd;
1154 tmp_mp_data->fd = tfd[0];
1155 tmp_mp_data->num_buffer_fd = num_buffer_fd;
1156 tmp_mp_data->bo = bo;
1160 tmp_mp_data->data_bo = data_bo;
1161 tmp_mp_data->data_fd = tfd[1];
1164 for (i = 0 ; i < num_buffer_fd ; i++) {
1165 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1166 tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1170 tmp_mp_data->ref_cnt++;
1172 *mp_data = tmp_mp_data;
1173 /*LOGD("mp_data %p", tmp_mp_data);*/
1175 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1176 LOGE("failed to alloc media packet data");
1179 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1185 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1189 if (!mp_data || !cb_info) {
1190 LOGE("NULL pointer %p %p", mp_data, cb_info);
1194 if (mp_data->ref_cnt > 1) {
1196 LOGD("ref count %d", mp_data->ref_cnt);
1198 /* release imported bo and close imported fd */
1199 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1200 tbm_bo_unref(mp_data->buffer_bo[i]);
1201 mp_data->buffer_bo[i] = NULL;
1203 close(mp_data->buffer_fd[i]);
1204 mp_data->buffer_fd[i] = -1;
1207 /* unref tbm bo and close imported fd */
1210 _camera_release_imported_bo(&mp_data->bo);
1212 if (mp_data->data_bo && mp_data->data_fd >= 0) {
1213 close(mp_data->data_fd);
1214 mp_data->data_fd = -1;
1216 _camera_release_imported_bo(&mp_data->data_bo);
1219 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1227 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1228 camera_media_packet_data *mp_data, media_packet_h *packet)
1230 media_packet_h pkt = NULL;
1231 bool make_pkt_fmt = false;
1232 tbm_surface_h tsurf = NULL;
1233 tbm_surface_info_s tsurf_info;
1234 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1235 uint32_t bo_format = 0;
1238 int num_buffer_fd = 0;
1239 tbm_bo *buffer_bo = NULL;
1241 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1242 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1243 cb_info, stream, mp_data, packet);
1244 return CAMERA_ERROR_INVALID_PARAMETER;
1247 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1248 buffer_bo = mp_data->buffer_bo;
1249 num_buffer_fd = mp_data->num_buffer_fd;
1251 /* create tbm surface */
1252 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1253 tsurf_info.planes[i].stride = stream->stride[i];
1255 /* get tbm surface format */
1256 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1257 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1259 if (ret == CAMERA_ERROR_NONE) {
1260 tsurf_info.width = stream->width;
1261 tsurf_info.height = stream->height;
1262 tsurf_info.format = bo_format;
1263 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1264 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1266 if (num_buffer_fd > 0) {
1267 switch (bo_format) {
1268 case TBM_FORMAT_NV12:
1269 case TBM_FORMAT_NV21:
1270 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1271 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1272 tsurf_info.planes[0].offset = 0;
1273 if (num_buffer_fd == 1)
1274 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1275 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1278 case TBM_FORMAT_YUV420:
1279 case TBM_FORMAT_YVU420:
1280 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1281 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1282 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1283 tsurf_info.planes[0].offset = 0;
1284 if (num_buffer_fd == 1) {
1285 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1286 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1288 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1290 case TBM_FORMAT_UYVY:
1291 case TBM_FORMAT_YUYV:
1292 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1293 tsurf_info.planes[0].offset = 0;
1294 tsurf_info.size = tsurf_info.planes[0].size;
1301 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
1302 } else if (mp_data->data_bo) {
1304 switch (bo_format) {
1305 case TBM_FORMAT_NV12:
1306 case TBM_FORMAT_NV21:
1307 tsurf_info.planes[0].size = stream->width * stream->height;
1308 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1309 tsurf_info.planes[0].offset = 0;
1310 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1311 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1313 case TBM_FORMAT_YUV420:
1314 case TBM_FORMAT_YVU420:
1315 tsurf_info.planes[0].size = stream->width * stream->height;
1316 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1317 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1318 tsurf_info.planes[0].offset = 0;
1319 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1320 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1321 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1323 case TBM_FORMAT_UYVY:
1324 case TBM_FORMAT_YUYV:
1325 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1326 tsurf_info.planes[0].offset = 0;
1327 tsurf_info.size = tsurf_info.planes[0].size;
1333 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1336 /*LOGD("tbm surface %p", tsurf);*/
1340 /* check media packet format */
1341 if (cb_info->pkt_fmt) {
1342 int pkt_fmt_width = 0;
1343 int pkt_fmt_height = 0;
1344 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1346 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1347 if (pkt_fmt_mimetype != mimetype ||
1348 pkt_fmt_width != stream->width ||
1349 pkt_fmt_height != stream->height) {
1350 LOGW("change fmt: current 0x%x, %dx%d",
1351 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1352 media_format_unref(cb_info->pkt_fmt);
1353 cb_info->pkt_fmt = NULL;
1354 make_pkt_fmt = true;
1357 make_pkt_fmt = true;
1360 /* create packet format */
1362 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1363 ret = media_format_create(&cb_info->pkt_fmt);
1364 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1365 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1366 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1367 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1368 LOGW("media_format_set : 0x%x", ret);
1370 LOGW("media_format_create failed 0x%x", ret);
1374 /* create media packet */
1375 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1376 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1377 (void *)cb_info, &pkt);
1378 if (ret != MEDIA_PACKET_ERROR_NONE) {
1379 LOGE("media_packet_create failed 0x%x", ret);
1380 tbm_surface_destroy(tsurf);
1384 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
1385 stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
1389 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1390 /* set media packet data */
1391 ret = media_packet_set_extra(pkt, (void *)mp_data);
1392 if (ret != MEDIA_PACKET_ERROR_NONE) {
1393 LOGE("media_packet_set_extra failed");
1395 _camera_media_packet_data_release(mp_data, cb_info);
1397 media_packet_destroy(pkt);
1399 /* set timestamp : msec -> nsec */
1400 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1401 LOGW("media_packet_set_pts failed");
1410 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1413 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1414 camera_media_packet_data *mp_data = NULL;
1415 tbm_surface_h tsurf = NULL;
1417 if (!pkt || !cb_info) {
1418 LOGE("NULL pointer %p %p", pkt, cb_info);
1419 return MEDIA_PACKET_FINALIZE;
1422 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1423 if (ret != MEDIA_PACKET_ERROR_NONE) {
1424 LOGE("media_packet_get_extra failed 0x%x", ret);
1425 return MEDIA_PACKET_FINALIZE;
1428 /*LOGD("mp_data %p", mp_data);*/
1430 g_mutex_lock(&cb_info->mp_data_mutex);
1432 _camera_media_packet_data_release(mp_data, cb_info);
1435 g_mutex_unlock(&cb_info->mp_data_mutex);
1437 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1438 if (ret != MEDIA_PACKET_ERROR_NONE)
1439 LOGE("get tbm_surface failed 0x%x", ret);
1442 tbm_surface_destroy(tsurf);
1446 return MEDIA_PACKET_FINALIZE;
1449 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1454 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1455 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1459 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1461 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1463 if (cb_info->user_cb[event] == NULL) {
1464 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1465 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1466 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1467 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1468 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1469 LOGW("NULL callback for event %d, return here", event);
1473 /* return buffer message should be sent for some events.
1474 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1475 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1476 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1477 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1482 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1488 muse_camera_msg_get(previous, recv_msg);
1489 muse_camera_msg_get(current, recv_msg);
1490 muse_camera_msg_get(by_policy, recv_msg);
1492 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1493 previous, current, by_policy);
1495 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1496 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1499 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1503 muse_camera_msg_get(state, recv_msg);
1505 LOGD("FOCUS state - %d", state);
1507 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1510 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1511 LOGD("CAPTURE_COMPLETED");
1512 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1514 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1515 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1516 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1519 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1523 muse_camera_msg_get(percent, recv_msg);
1525 LOGD("HDR progress - %d %%", percent);
1527 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1530 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1536 muse_camera_msg_get(policy, recv_msg);
1537 muse_camera_msg_get(previous, recv_msg);
1538 muse_camera_msg_get(current, recv_msg);
1540 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1542 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1543 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1546 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1551 muse_camera_msg_get(policy, recv_msg);
1552 muse_camera_msg_get(state, recv_msg);
1554 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1556 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1557 (camera_state_e)state, cb_info->user_data[event]);
1560 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1561 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1563 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1566 int current_state = 0;
1568 muse_camera_msg_get(error, recv_msg);
1569 muse_camera_msg_get(current_state, recv_msg);
1571 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1573 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1574 (camera_state_e)current_state, cb_info->user_data[event]);
1578 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1580 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1581 muse_camera_msg_get(param1, recv_msg);
1582 muse_camera_msg_get(param2, recv_msg);
1584 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1586 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1587 cb_info->user_cb[event] = NULL;
1588 cb_info->user_data[event] = NULL;
1589 LOGW("stop foreach callback for event %d", event);
1592 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1594 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1596 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1598 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1600 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1602 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1604 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1606 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1608 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1610 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1612 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1614 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1616 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1619 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1621 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1622 muse_camera_msg_get(param1, recv_msg);
1624 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1626 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1627 cb_info->user_cb[event] = NULL;
1628 cb_info->user_data[event] = NULL;
1629 LOGW("stop foreach callback for event %d", event);
1633 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1634 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1637 LOGW("unhandled event %d", event);
1641 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1646 static gboolean _camera_idle_event_callback(gpointer data)
1648 camera_cb_info_s *cb_info = NULL;
1649 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1651 if (cam_idle_event == NULL) {
1652 LOGE("cam_idle_event is NULL");
1657 g_mutex_lock(&g_cam_idle_event_lock);
1659 cb_info = cam_idle_event->cb_info;
1660 if (cb_info == NULL) {
1661 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1662 g_mutex_unlock(&g_cam_idle_event_lock);
1663 goto IDLE_EVENT_CALLBACK_DONE;
1666 /* remove event from list */
1667 if (cb_info->idle_event_list)
1668 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1670 g_mutex_unlock(&g_cam_idle_event_lock);
1673 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1675 IDLE_EVENT_CALLBACK_DONE:
1677 g_free(cam_idle_event);
1678 cam_idle_event = NULL;
1683 static gpointer _camera_msg_handler_func(gpointer data)
1687 camera_message_s *cam_msg = NULL;
1688 camera_idle_event_s *cam_idle_event = NULL;
1689 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1690 camera_cb_info_s *cb_info = NULL;
1692 if (!handler_info || !handler_info->cb_info) {
1693 LOGE("NULL handler %p", handler_info);
1697 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1698 type = handler_info->type;
1700 LOGD("t:%d start", type);
1702 g_mutex_lock(&handler_info->mutex);
1704 while (g_atomic_int_get(&handler_info->running)) {
1705 if (g_queue_is_empty(handler_info->queue)) {
1706 /*LOGD("t:%d signal wait...", type);*/
1707 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1708 /*LOGD("t:%d signal received", type);*/
1710 if (g_atomic_int_get(&handler_info->running) == 0) {
1711 LOGD("t:%d stop event thread", type);
1716 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1718 g_mutex_unlock(&handler_info->mutex);
1720 if (cam_msg == NULL) {
1721 LOGE("t:%d NULL message", type);
1722 g_mutex_lock(&handler_info->mutex);
1728 if (api < MUSE_CAMERA_API_MAX) {
1731 g_mutex_lock(&cb_info->api_mutex[api]);
1733 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1734 if (cb_info->api_waiting[api] > 0) {
1735 cb_info->api_ret[api] = ret;
1736 cb_info->api_activating[api] = TRUE;
1738 /*LOGD("t:%d camera api %d - return 0x%x", type, api, ret);*/
1740 g_cond_signal(&cb_info->api_cond[api]);
1742 LOGW("no waiting for this api [%d]", api);
1745 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1748 g_mutex_unlock(&cb_info->api_mutex[api]);
1749 } else if (api == MUSE_CAMERA_CB_EVENT) {
1750 switch (cam_msg->event_class) {
1751 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1752 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1754 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1755 cam_idle_event = g_new0(camera_idle_event_s, 1);
1756 if (cam_idle_event == NULL) {
1757 LOGE("t:%d cam_idle_event alloc failed", type);
1761 cam_idle_event->event = cam_msg->event;
1762 cam_idle_event->cb_info = cb_info;
1764 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1765 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1767 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1769 g_mutex_lock(&g_cam_idle_event_lock);
1770 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1771 g_mutex_unlock(&g_cam_idle_event_lock);
1773 g_idle_add_full(G_PRIORITY_DEFAULT,
1774 (GSourceFunc)_camera_idle_event_callback,
1775 (gpointer)cam_idle_event,
1779 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1783 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1789 g_mutex_lock(&handler_info->mutex);
1792 /* remove remained event */
1793 while (!g_queue_is_empty(handler_info->queue)) {
1794 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1796 LOGD("t:%d remove camera message %p", type, cam_msg);
1800 LOGW("t:%d NULL camera message", type);
1804 g_mutex_unlock(&handler_info->mutex);
1806 LOGD("t:%d return", type);
1812 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1814 camera_idle_event_s *cam_idle_event = NULL;
1817 if (cb_info == NULL) {
1818 LOGE("cb_info is NULL");
1822 g_mutex_lock(&g_cam_idle_event_lock);
1824 if (cb_info->idle_event_list == NULL) {
1825 LOGD("No remained idle event");
1826 g_mutex_unlock(&g_cam_idle_event_lock);
1830 list = cb_info->idle_event_list;
1833 cam_idle_event = list->data;
1834 list = g_list_next(list);
1836 if (!cam_idle_event) {
1837 LOGW("Fail to remove idle event. The event is NULL");
1841 if (g_idle_remove_by_data(cam_idle_event)) {
1842 LOGW("remove idle event %p done", cam_idle_event);
1844 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1846 g_free(cam_idle_event);
1847 cam_idle_event = NULL;
1852 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1853 cam_idle_event, cam_idle_event->event);
1855 cam_idle_event->cb_info = NULL;
1857 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1860 g_list_free(cb_info->idle_event_list);
1861 cb_info->idle_event_list = NULL;
1863 g_mutex_unlock(&g_cam_idle_event_lock);
1869 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1871 camera_message_s *cam_msg = NULL;
1873 if (!cb_info || !msg) {
1874 LOGE("NULL pointer %p %p", cb_info, msg);
1878 cam_msg = g_new0(camera_message_s, 1);
1880 LOGE("failed to alloc cam_msg for [%s]", msg);
1885 cam_msg->event = event;
1886 cam_msg->event_class = event_class;
1888 if (tfd && tfd[0] >= 0)
1889 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1891 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1893 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1895 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1896 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1897 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1898 g_cond_signal(&cb_info->preview_cb_info.cond);
1899 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1900 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1901 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1902 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1903 g_cond_signal(&cb_info->capture_cb_info.cond);
1904 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1906 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1907 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1908 g_cond_signal(&cb_info->msg_handler_info.cond);
1909 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1918 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
1920 int ret = CAMERA_ERROR_NONE;
1924 int event_class = -1;
1928 if (!cb_info || !msg) {
1929 LOGE("invalid ptr %p %p", cb_info, msg);
1933 /*LOGD("msg [%s]", msg);*/
1935 if (!muse_camera_msg_get(api, msg)) {
1936 LOGE("failed to get camera api");
1940 if (api == MUSE_CAMERA_CB_EVENT) {
1941 if (!muse_camera_msg_get(event, msg) ||
1942 !muse_camera_msg_get(event_class, msg)) {
1943 LOGE("failed to get camera event or event_class [%s]", msg);
1947 if (!muse_camera_msg_get(api_class, msg)) {
1948 LOGE("failed to get camera api_class [%s]", msg);
1953 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1954 if (api >= MUSE_CAMERA_API_MAX) {
1955 LOGE("invalid api %d", api);
1959 if (!muse_camera_msg_get(ret, msg)) {
1960 LOGE("failed to get camera ret");
1964 g_mutex_lock(&cb_info->api_mutex[api]);
1967 case MUSE_CAMERA_API_CREATE:
1968 if (ret != CAMERA_ERROR_NONE) {
1969 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1970 LOGE("camera create error 0x%x. close client cb handler", ret);
1973 case MUSE_CAMERA_API_DESTROY:
1974 if (ret == CAMERA_ERROR_NONE) {
1975 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1976 LOGD("camera destroy done. close client cb handler");
1980 muse_camera_msg_get(get_type, msg);
1981 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1982 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1983 muse_camera_msg_get(get_index, msg);
1986 case MUSE_CAMERA_GET_TYPE_INT:
1987 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1989 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1990 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1991 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1993 case MUSE_CAMERA_GET_TYPE_ARRAY:
1994 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1995 muse_core_msg_deserialize("get_value",
1996 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1997 LOGD("get display roi %d,%d,%dx%d",
1998 cb_info->get_display_roi_area[0],
1999 cb_info->get_display_roi_area[1],
2000 cb_info->get_display_roi_area[2],
2001 cb_info->get_display_roi_area[3]);
2003 muse_core_msg_deserialize("get_value",
2004 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2005 LOGD("get geotag %lf, %lf, %lf",
2006 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2009 case MUSE_CAMERA_GET_TYPE_STRING:
2010 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2013 LOGW("unknown type %d", get_type);
2020 if (cb_info->api_waiting[api] > 0) {
2021 cb_info->api_ret[api] = ret;
2022 cb_info->api_activating[api] = TRUE;
2024 g_cond_signal(&cb_info->api_cond[api]);
2026 LOGW("no waiting for this api [%d]", api);
2029 g_mutex_unlock(&cb_info->api_mutex[api]);
2030 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2031 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2033 LOGW("unknown camera api %d, class %d", api, api_class);
2040 static gpointer _camera_msg_recv_func(gpointer data)
2043 int recv_length = 0;
2044 int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
2045 char *recv_msg = NULL;
2046 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2049 LOGE("cb_info NULL");
2053 LOGD("start - fd : %d", cb_info->fd);
2055 recv_msg = cb_info->recv_msg;
2057 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2058 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2061 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2062 if (recv_length <= 0) {
2063 cb_info->is_server_connected = FALSE;
2064 LOGE("receive msg failed - server disconnected");
2070 LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
2073 recv_msg[recv_length] = '\0';
2075 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2077 __camera_process_msg(cb_info, recv_msg, tfd);
2080 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2082 if (!cb_info->is_server_connected) {
2083 char *error_msg = NULL;
2085 if (cb_info->bufmgr == NULL) {
2086 LOGE("No need to send error(handle is not created)");
2090 if (cb_info->fd < 0) {
2091 LOGE("fd is closed in client side");
2095 /* send error msg for server disconnection */
2096 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2097 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2098 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2102 LOGE("error_msg failed");
2106 __camera_add_msg_to_queue(cb_info,
2107 MUSE_CAMERA_CB_EVENT,
2108 MUSE_CAMERA_EVENT_TYPE_ERROR,
2109 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2113 muse_core_msg_free(error_msg);
2116 LOGE("add error msg for service disconnection done");
2123 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2124 int type, const char *thread_name, camera_cb_info_s *cb_info)
2126 if (!handler_info || !thread_name || !cb_info) {
2127 LOGE("t:%d NULL %p %p %p",
2128 type, handler_info, thread_name, cb_info);
2134 handler_info->type = type;
2135 handler_info->queue = g_queue_new();
2136 if (handler_info->queue == NULL) {
2137 LOGE("t:%d queue failed", type);
2141 g_mutex_init(&handler_info->mutex);
2142 g_cond_init(&handler_info->cond);
2144 handler_info->cb_info = (void *)cb_info;
2145 g_atomic_int_set(&handler_info->running, 1);
2147 handler_info->thread = g_thread_try_new(thread_name,
2148 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2149 if (handler_info->thread == NULL) {
2150 LOGE("t:%d thread failed", type);
2152 g_mutex_clear(&handler_info->mutex);
2153 g_cond_clear(&handler_info->cond);
2154 g_queue_free(handler_info->queue);
2155 handler_info->queue = NULL;
2160 LOGD("t:%d done", type);
2166 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2170 if (!handler_info) {
2171 LOGE("NULL handler");
2175 if (!handler_info->thread) {
2176 LOGW("thread is not created");
2180 type = handler_info->type;
2182 LOGD("t:%d thread %p", type, handler_info->thread);
2184 g_mutex_lock(&handler_info->mutex);
2185 g_atomic_int_set(&handler_info->running, 0);
2186 g_cond_signal(&handler_info->cond);
2187 g_mutex_unlock(&handler_info->mutex);
2189 g_thread_join(handler_info->thread);
2190 handler_info->thread = NULL;
2192 g_mutex_clear(&handler_info->mutex);
2193 g_cond_clear(&handler_info->cond);
2194 g_queue_free(handler_info->queue);
2195 handler_info->queue = NULL;
2197 LOGD("t:%d done", type);
2203 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2205 camera_cb_info_s *cb_info = NULL;
2208 g_return_val_if_fail(sockfd > 0, NULL);
2210 cb_info = g_new0(camera_cb_info_s, 1);
2211 if (cb_info == NULL) {
2212 LOGE("cb_info failed");
2216 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2218 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2219 g_mutex_init(&cb_info->api_mutex[i]);
2220 g_cond_init(&cb_info->api_cond[i]);
2223 g_mutex_init(&cb_info->fd_lock);
2224 g_mutex_init(&cb_info->mp_data_mutex);
2226 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2227 g_mutex_init(&cb_info->user_cb_mutex[i]);
2229 /* message handler thread */
2230 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2231 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2232 LOGE("msg_handler_info failed");
2236 /* message handler thread for preview callback */
2237 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2238 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2239 LOGE("preview_cb_info failed");
2243 /* message handler thread for capture callback */
2244 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2245 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2246 LOGE("capture_cb_info failed");
2250 cb_info->fd = sockfd;
2251 cb_info->preview_cb_flag = 0;
2253 /* message receive thread */
2254 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2255 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2256 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2257 if (cb_info->msg_recv_thread == NULL) {
2258 LOGE("message receive thread creation failed");
2263 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2264 cb_info->fds[i] = -1;
2266 cb_info->is_server_connected = TRUE;
2272 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2273 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2274 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2276 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2277 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2279 g_mutex_clear(&cb_info->fd_lock);
2280 g_mutex_clear(&cb_info->mp_data_mutex);
2282 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2283 g_mutex_clear(&cb_info->api_mutex[i]);
2284 g_cond_clear(&cb_info->api_cond[i]);
2295 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2299 g_return_if_fail(cb_info != NULL);
2301 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2303 g_thread_join(cb_info->msg_recv_thread);
2304 cb_info->msg_recv_thread = NULL;
2306 LOGD("msg_recv thread removed");
2308 /* destroy msg handler threads */
2309 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2310 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2311 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2313 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2314 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2316 g_mutex_clear(&cb_info->fd_lock);
2317 g_mutex_clear(&cb_info->mp_data_mutex);
2319 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2320 g_mutex_clear(&cb_info->api_mutex[i]);
2321 g_cond_clear(&cb_info->api_cond[i]);
2324 if (cb_info->fd > -1) {
2325 muse_client_close(cb_info->fd);
2329 if (cb_info->bufmgr) {
2330 tbm_bufmgr_deinit(cb_info->bufmgr);
2331 cb_info->bufmgr = NULL;
2333 if (cb_info->pkt_fmt) {
2334 media_format_unref(cb_info->pkt_fmt);
2335 cb_info->pkt_fmt = NULL;
2338 if (cb_info->dp_interface) {
2339 mm_display_interface_deinit(cb_info->dp_interface);
2340 cb_info->dp_interface = NULL;
2343 cb_info->preview_cb_flag = 0;
2351 int _camera_start_evas_rendering(camera_h camera)
2353 camera_cli_s *pc = (camera_cli_s *)camera;
2355 if (!pc || !pc->cb_info) {
2356 LOGE("NULL handle");
2357 return CAMERA_ERROR_INVALID_PARAMETER;
2362 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2363 LOGE("EVAS surface is not set");
2364 return CAMERA_ERROR_NONE;
2367 /* set evas render flag as RUN */
2368 pc->cb_info->run_evas_render = true;
2370 return CAMERA_ERROR_NONE;
2374 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2376 int ret = CAMERA_ERROR_NONE;
2377 camera_cli_s *pc = (camera_cli_s *)camera;
2379 if (!pc || !pc->cb_info) {
2380 LOGE("NULL handle");
2381 return CAMERA_ERROR_INVALID_PARAMETER;
2384 LOGD("stop - keep screen %d", keep_screen);
2386 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2387 LOGE("EVAS surface is not set");
2388 return CAMERA_ERROR_NONE;
2391 /* set evas render flag as STOP and release buffers */
2392 pc->cb_info->run_evas_render = false;
2394 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2395 if (ret == MM_ERROR_NONE) {
2396 ret = CAMERA_ERROR_NONE;
2398 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2399 ret = CAMERA_ERROR_INVALID_OPERATION;
2406 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2408 int ret = CAMERA_ERROR_NONE;
2410 int module_index = -1;
2412 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2414 /* create muse connection */
2415 if (!key || !value) {
2416 LOGE("NULL pointer");
2417 return CAMERA_ERROR_INVALID_PARAMETER;
2420 sock_fd = muse_client_new();
2422 LOGE("muse_client_new failed");
2423 return CAMERA_ERROR_INVALID_OPERATION;
2426 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2427 LOGE("muse client get module index failed");
2428 ret = CAMERA_ERROR_INVALID_OPERATION;
2432 msg = muse_core_msg_new(api,
2433 MUSE_TYPE_INT, "module", module_index,
2434 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2438 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2442 ret = muse_core_msg_send(sock_fd, msg);
2444 muse_core_msg_free(msg);
2448 LOGE("send msg failed");
2449 ret = CAMERA_ERROR_INVALID_OPERATION;
2453 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2455 LOGE("recv msg failed %d", errno);
2456 ret = CAMERA_ERROR_INVALID_OPERATION;
2460 if (!muse_camera_msg_get(ret, recv_msg)) {
2461 LOGE("failed to get return value from msg [%s]", recv_msg);
2462 ret = CAMERA_ERROR_INVALID_OPERATION;
2466 if (ret == CAMERA_ERROR_NONE)
2467 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2469 LOGD("api %d - value %d", api, *value);
2473 muse_client_close(sock_fd);
2481 int camera_create(camera_device_e device, camera_h *camera)
2484 char *send_msg = NULL;
2486 int ret = CAMERA_ERROR_NONE;
2487 camera_cli_s *pc = NULL;
2488 tbm_bufmgr bufmgr = NULL;
2490 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2491 int module_index = -1;
2492 int device_type = (int)device;
2495 LOGE("NULL pointer");
2496 return CAMERA_ERROR_INVALID_PARAMETER;
2499 sock_fd = muse_client_new();
2501 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2502 ret = CAMERA_ERROR_INVALID_OPERATION;
2506 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2507 LOGE("muse client get module index failed");
2508 ret = CAMERA_ERROR_INVALID_OPERATION;
2512 send_msg = muse_core_msg_new(api,
2513 MUSE_TYPE_INT, "module", module_index,
2514 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2519 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2523 send_ret = muse_core_msg_send(sock_fd, send_msg);
2525 muse_core_msg_free(send_msg);
2529 LOGE("send msg failed %d", errno);
2530 ret = CAMERA_ERROR_INVALID_OPERATION;
2534 pc = g_new0(camera_cli_s, 1);
2536 LOGE("camera_cli_s alloc failed");
2537 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2541 bufmgr = tbm_bufmgr_init(-1);
2542 if (bufmgr == NULL) {
2543 LOGE("get tbm bufmgr failed");
2544 ret = CAMERA_ERROR_INVALID_OPERATION;
2548 pc->cb_info = _camera_client_callback_new(sock_fd);
2549 if (pc->cb_info == NULL) {
2550 LOGE("cb_info alloc failed");
2551 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2557 LOGD("cb info : %d", pc->cb_info->fd);
2559 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2561 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2563 if (ret == CAMERA_ERROR_NONE) {
2564 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2565 int user_buffer_supported = 0;
2566 intptr_t handle = 0;
2568 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2570 LOGE("Receiving Handle Failed!!");
2571 ret = CAMERA_ERROR_INVALID_OPERATION;
2575 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2576 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2578 pc->remote_handle = handle;
2579 pc->cb_info->bufmgr = bufmgr;
2580 pc->cb_info->preview_format = preview_format;
2581 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2582 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2584 LOGD("default preview format %d, user buffer %d",
2585 preview_format, user_buffer_supported);
2587 *camera = (camera_h)pc;
2589 /* get display interface handle */
2590 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2591 LOGW("display interface init failed");
2600 tbm_bufmgr_deinit(bufmgr);
2605 muse_client_close(sock_fd);
2611 int temp_fd = pc->cb_info->fd;
2613 /* pc->cb_info->fd should be closed,
2614 because g_thread_join for msg_recv_thread is not returned
2615 in _camera_client_callback_destroy. */
2617 pc->cb_info->fd = -1;
2618 muse_client_close(temp_fd);
2621 _camera_client_callback_destroy(pc->cb_info);
2628 LOGE("camera create error : 0x%x", ret);
2635 int camera_change_device(camera_h camera, camera_device_e device)
2638 int ret = CAMERA_ERROR_NONE;
2639 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2640 camera_cli_s *pc = (camera_cli_s *)camera;
2641 camera_msg_param param;
2643 if (!pc || !pc->cb_info) {
2644 LOGE("NULL handle");
2645 return CAMERA_ERROR_INVALID_PARAMETER;
2648 CAMERA_MSG_PARAM_SET(param, INT, device);
2650 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2652 if (ret == CAMERA_ERROR_NONE) {
2653 /* reset callback and user data */
2654 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2655 pc->cb_info->user_cb[i] = NULL;
2656 pc->cb_info->user_data[i] = NULL;
2658 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2665 int camera_destroy(camera_h camera)
2667 int ret = CAMERA_ERROR_NONE;
2668 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2669 camera_cli_s *pc = (camera_cli_s *)camera;
2671 if (!pc || !pc->cb_info) {
2672 LOGE("NULL handle");
2673 return CAMERA_ERROR_INVALID_PARAMETER;
2678 if (pc->cb_info->is_server_connected)
2679 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2681 LOGW("server disconnected. release resource without send message.");
2683 if (ret == CAMERA_ERROR_NONE) {
2684 _camera_deactivate_idle_event_all(pc->cb_info);
2685 _camera_client_callback_destroy(pc->cb_info);
2692 LOGD("ret : 0x%x", ret);
2697 int camera_start_preview(camera_h camera)
2699 int ret = CAMERA_ERROR_NONE;
2700 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2701 camera_cli_s *pc = (camera_cli_s *)camera;
2702 camera_state_e current_state = CAMERA_STATE_NONE;
2704 if (!pc || !pc->cb_info) {
2705 LOGE("NULL handle");
2706 return CAMERA_ERROR_INVALID_PARAMETER;
2709 LOGD("Enter : preview format %d, display type %d",
2710 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2712 ret = camera_get_state(camera, ¤t_state);
2713 if (ret != CAMERA_ERROR_NONE) {
2714 LOGE("failed to get current state 0x%x", ret);
2718 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2719 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2720 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2721 pc->cb_info->dp_info.type);
2722 return CAMERA_ERROR_INVALID_OPERATION;
2725 if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
2726 if (!_camera_allocate_preview_buffer(camera))
2727 return CAMERA_ERROR_INVALID_OPERATION;
2729 _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2731 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2734 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2735 ret = _camera_start_evas_rendering(camera);
2736 if (ret != CAMERA_ERROR_NONE) {
2737 LOGE("stop preview because of error");
2738 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2742 LOGD("ret : 0x%x", ret);
2748 int camera_stop_preview(camera_h camera)
2750 int ret = CAMERA_ERROR_NONE;
2751 camera_cli_s *pc = (camera_cli_s *)camera;
2752 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2753 camera_state_e current_state = CAMERA_STATE_NONE;
2755 if (!pc || !pc->cb_info) {
2756 LOGE("NULL handle");
2757 return CAMERA_ERROR_INVALID_PARAMETER;
2763 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2764 ret = camera_get_state(camera, ¤t_state);
2765 if (ret != CAMERA_ERROR_NONE) {
2766 LOGE("failed to get current state 0x%x", ret);
2770 if (current_state == CAMERA_STATE_PREVIEW) {
2771 ret = _camera_stop_evas_rendering(camera, false);
2772 if (ret != CAMERA_ERROR_NONE)
2777 /* send stop preview message */
2778 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2780 if (ret == CAMERA_ERROR_NONE) {
2781 if (pc->cb_info->user_buffer_supported)
2782 _camera_release_preview_buffer(camera);
2783 } else if (current_state == CAMERA_STATE_PREVIEW) {
2784 LOGW("restart evas rendering");
2785 _camera_start_evas_rendering(camera);
2788 LOGD("ret : 0x%x", ret);
2794 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2796 int ret = CAMERA_ERROR_NONE;
2797 camera_cli_s *pc = (camera_cli_s *)camera;
2798 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2800 if (!pc || !pc->cb_info) {
2801 LOGE("NULL handle");
2802 return CAMERA_ERROR_INVALID_PARAMETER;
2807 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2808 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2810 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2811 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2813 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2815 LOGD("ret : 0x%x", ret);
2821 bool camera_is_supported_continuous_capture(camera_h camera)
2823 int ret = CAMERA_ERROR_NONE;
2824 camera_cli_s *pc = (camera_cli_s *)camera;
2825 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2827 if (!pc || !pc->cb_info) {
2828 LOGE("NULL handle");
2829 return CAMERA_ERROR_INVALID_PARAMETER;
2834 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2837 LOGE("error is occurred 0x%x", ret);
2841 LOGD("ret : %d", ret);
2847 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)
2849 int ret = CAMERA_ERROR_NONE;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2851 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2852 camera_msg_param param;
2855 if (!pc || !pc->cb_info) {
2856 LOGE("NULL handle");
2857 return CAMERA_ERROR_INVALID_PARAMETER;
2862 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2863 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2865 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2866 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2868 value = (count << 16) | interval;
2869 CAMERA_MSG_PARAM_SET(param, INT, value);
2871 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2873 LOGD("ret : 0x%x", ret);
2879 int camera_stop_continuous_capture(camera_h camera)
2881 int ret = CAMERA_ERROR_NONE;
2882 camera_cli_s *pc = (camera_cli_s *)camera;
2883 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2885 if (!pc || !pc->cb_info) {
2886 LOGE("NULL handle");
2887 return CAMERA_ERROR_INVALID_PARAMETER;
2892 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2894 LOGD("ret : 0x%x", ret);
2900 bool camera_is_supported_face_detection(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_FACE_DETECTION;
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_zero_shutter_lag(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_ZERO_SHUTTER_LAG;
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);
2952 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2954 int ret = CAMERA_ERROR_NONE;
2955 camera_cli_s *pc = (camera_cli_s *)camera;
2956 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2958 if (!pc || !pc->cb_info) {
2959 LOGE("NULL handle");
2960 return CAMERA_ERROR_INVALID_PARAMETER;
2965 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2968 LOGE("error is occurred 0x%x", ret);
2972 LOGD("ret : %d", ret);
2977 int camera_get_device_count(camera_h camera, int *device_count)
2979 int ret = CAMERA_ERROR_NONE;
2980 camera_cli_s *pc = (camera_cli_s *)camera;
2981 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2983 if (!pc || !pc->cb_info) {
2984 LOGE("NULL handle");
2985 return CAMERA_ERROR_INVALID_PARAMETER;
2990 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2992 if (ret == CAMERA_ERROR_NONE)
2993 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2995 LOGD("ret : 0x%x", ret);
3000 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3002 int ret = CAMERA_ERROR_NONE;
3003 camera_cli_s *pc = (camera_cli_s *)camera;
3004 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3006 if (!pc || !pc->cb_info) {
3007 LOGE("NULL handle");
3008 return CAMERA_ERROR_INVALID_PARAMETER;
3013 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3015 if (ret == CAMERA_ERROR_NONE) {
3016 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3018 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3019 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3021 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3024 LOGD("ret : 0x%x", ret);
3029 int camera_stop_face_detection(camera_h camera)
3031 int ret = CAMERA_ERROR_NONE;
3032 camera_cli_s *pc = (camera_cli_s *)camera;
3033 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3035 if (!pc || !pc->cb_info) {
3036 LOGE("NULL handle");
3037 return CAMERA_ERROR_INVALID_PARAMETER;
3042 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3044 if (ret == CAMERA_ERROR_NONE) {
3045 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3047 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3048 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3050 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3053 LOGD("ret : 0x%x", ret);
3058 int camera_get_state(camera_h camera, camera_state_e *state)
3060 int ret = CAMERA_ERROR_NONE;
3061 camera_cli_s *pc = (camera_cli_s *)camera;
3062 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3064 if (!pc || !pc->cb_info || !state) {
3065 LOGE("NULL pointer %p %p", pc, state);
3066 return CAMERA_ERROR_INVALID_PARAMETER;
3071 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3073 if (ret == CAMERA_ERROR_NONE)
3074 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3076 LOGD("ret : 0x%x", ret);
3081 int camera_start_focusing(camera_h camera, bool continuous)
3083 int ret = CAMERA_ERROR_NONE;
3084 camera_cli_s *pc = (camera_cli_s *)camera;
3085 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3086 camera_msg_param param;
3087 int is_continuous = (int)continuous;
3089 if (!pc || !pc->cb_info) {
3090 LOGE("NULL handle");
3091 return CAMERA_ERROR_INVALID_PARAMETER;
3096 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3098 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3100 LOGD("ret : 0x%x", ret);
3105 int camera_cancel_focusing(camera_h camera)
3107 int ret = CAMERA_ERROR_NONE;
3108 camera_cli_s *pc = (camera_cli_s *)camera;
3109 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3111 if (!pc || !pc->cb_info) {
3112 LOGE("NULL handle");
3113 return CAMERA_ERROR_INVALID_PARAMETER;
3116 LOGD("Enter, remote_handle : %td", pc->remote_handle);
3118 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3120 LOGD("ret : 0x%x", ret);
3125 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3127 int mm_ret = MM_ERROR_NONE;
3128 int ret = CAMERA_ERROR_NONE;
3129 camera_cli_s *pc = (camera_cli_s *)camera;
3130 camera_cb_info_s *cb_info = NULL;
3131 camera_state_e current_state = CAMERA_STATE_NONE;
3132 camera_msg_param param;
3133 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3134 muse_camera_display_info_s *dp_info = NULL;
3136 if (!pc || !pc->cb_info) {
3137 LOGE("NULL handle");
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3142 LOGE("invalid type %d", type);
3143 return CAMERA_ERROR_INVALID_PARAMETER;
3146 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3147 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3148 return CAMERA_ERROR_INVALID_PARAMETER;
3151 cb_info = (camera_cb_info_s *)pc->cb_info;
3152 dp_info = &cb_info->dp_info;
3154 ret = camera_get_state(camera, ¤t_state);
3155 if (ret != CAMERA_ERROR_NONE) {
3156 LOGE("failed to get current state 0x%x", ret);
3160 if (current_state != CAMERA_STATE_CREATED) {
3161 LOGE("INVALID_STATE : current %d", current_state);
3162 return CAMERA_ERROR_INVALID_STATE;
3165 LOGD("Enter - type : %d, display : %p", type, display);
3167 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3168 /* check display interface handle */
3169 if (!cb_info->dp_interface) {
3170 LOGE("display interface not supported");
3171 return CAMERA_ERROR_NOT_SUPPORTED;
3174 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3175 if (mm_ret == MM_ERROR_NOT_SUPPORT_API) {
3176 LOGE("[NOT_SUPPORTED] type %d", type);
3177 return CAMERA_ERROR_NOT_SUPPORTED;
3178 } else if (mm_ret != MM_ERROR_NONE) {
3179 LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3180 return CAMERA_ERROR_INVALID_OPERATION;
3183 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3184 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3186 LOGD("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3187 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3188 dp_info->window_rect.width, dp_info->window_rect.height);
3189 } else if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3191 camera_flip_e flip = CAMERA_FLIP_NONE;
3192 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3193 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3200 camera_get_display_flip(camera, &flip);
3201 camera_get_display_mode(camera, &mode);
3202 camera_get_display_rotation(camera, &rotation);
3203 camera_is_display_visible(camera, &visible);
3204 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3206 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3207 flip, mode, rotation, visible, x, y, width, height);
3209 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3210 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3211 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3212 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3214 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3215 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3220 if (mm_ret != MM_ERROR_NONE) {
3221 LOGE("mm_ret 0x%x failed", mm_ret);
3222 return CAMERA_ERROR_INVALID_OPERATION;
3225 dp_info->type = type;
3227 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3229 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3231 if (ret == CAMERA_ERROR_NONE) {
3232 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3233 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3240 int camera_set_preview_resolution(camera_h camera, int width, int height)
3242 int ret = CAMERA_ERROR_NONE;
3243 camera_state_e current_state = CAMERA_STATE_NONE;
3244 camera_cli_s *pc = (camera_cli_s *)camera;
3245 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3246 camera_msg_param param;
3249 if (!pc || !pc->cb_info) {
3250 LOGE("NULL handle");
3251 return CAMERA_ERROR_INVALID_PARAMETER;
3254 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3255 ret = camera_get_state(camera, ¤t_state);
3256 if (ret != CAMERA_ERROR_NONE) {
3257 LOGE("failed to get current state 0x%x", ret);
3261 if (current_state == CAMERA_STATE_PREVIEW) {
3262 ret = _camera_stop_evas_rendering(camera, true);
3263 if (ret != CAMERA_ERROR_NONE)
3268 value = (width << 16) | height;
3269 CAMERA_MSG_PARAM_SET(param, INT, value);
3271 LOGD("%dx%d -> 0x%x", width, height, value);
3273 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3275 LOGD("ret : 0x%x", ret);
3277 if (current_state == CAMERA_STATE_PREVIEW) {
3278 LOGW("restart evas rendering");
3279 _camera_start_evas_rendering(camera);
3286 int camera_set_capture_resolution(camera_h camera, int width, int height)
3288 int ret = CAMERA_ERROR_NONE;
3289 camera_cli_s *pc = (camera_cli_s *)camera;
3290 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3291 camera_msg_param param;
3294 if (!pc || !pc->cb_info) {
3295 LOGE("NULL handle");
3296 return CAMERA_ERROR_INVALID_PARAMETER;
3301 value = (width << 16) | height;
3302 CAMERA_MSG_PARAM_SET(param, INT, value);
3304 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3306 LOGD("ret : 0x%x", ret);
3312 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3314 int ret = CAMERA_ERROR_NONE;
3315 int set_format = (int)format;
3316 camera_cli_s *pc = (camera_cli_s *)camera;
3317 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3318 camera_msg_param param;
3320 if (!pc || !pc->cb_info) {
3321 LOGE("NULL handle");
3322 return CAMERA_ERROR_INVALID_PARAMETER;
3325 LOGD("Enter - format %d", set_format);
3327 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3331 LOGD("ret : 0x%x", ret);
3337 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3339 int ret = CAMERA_ERROR_NONE;
3340 int set_format = (int)format;
3341 camera_msg_param param;
3342 camera_cli_s *pc = (camera_cli_s *)camera;
3343 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3345 if (!pc || !pc->cb_info) {
3346 LOGE("NULL handle");
3347 return CAMERA_ERROR_INVALID_PARAMETER;
3350 LOGD("Enter - format %d", set_format);
3352 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3354 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3356 if (ret == CAMERA_ERROR_NONE)
3357 pc->cb_info->preview_format = set_format;
3359 LOGD("ret : 0x%x", ret);
3365 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3367 int ret = CAMERA_ERROR_NONE;
3368 camera_cli_s *pc = (camera_cli_s *)camera;
3369 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3371 if (!pc || !pc->cb_info || !width || !height) {
3372 LOGE("NULL pointer %p %p %p", pc, width, height);
3373 return CAMERA_ERROR_INVALID_PARAMETER;
3378 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3380 if (ret == CAMERA_ERROR_NONE) {
3381 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3382 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3385 LOGD("ret : 0x%x", ret);
3391 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3393 int ret = CAMERA_ERROR_NONE;
3394 int set_rotation = (int)rotation;
3395 camera_cli_s *pc = (camera_cli_s *)camera;
3396 camera_msg_param param;
3398 if (!pc || !pc->cb_info) {
3399 LOGE("NULL handle");
3400 return CAMERA_ERROR_INVALID_PARAMETER;
3403 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3404 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3405 if (ret != MM_ERROR_NONE) {
3406 LOGE("failed to set rotation for evas surface 0x%x", ret);
3407 return CAMERA_ERROR_INVALID_OPERATION;
3411 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3413 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3419 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3421 int ret = CAMERA_ERROR_NONE;
3422 camera_cli_s *pc = (camera_cli_s *)camera;
3424 if (!pc || !pc->cb_info || !rotation) {
3425 LOGE("NULL pointer %p %p", pc, rotation);
3426 return CAMERA_ERROR_INVALID_PARAMETER;
3429 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3431 if (ret == CAMERA_ERROR_NONE)
3432 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3438 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3440 int ret = CAMERA_ERROR_NONE;
3441 int set_flip = (int)flip;
3442 camera_cli_s *pc = (camera_cli_s *)camera;
3443 camera_msg_param param;
3445 if (!pc || !pc->cb_info) {
3446 LOGE("NULL handle");
3447 return CAMERA_ERROR_INVALID_PARAMETER;
3450 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3451 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3452 if (ret != MM_ERROR_NONE) {
3453 LOGE("failed to set flip for evas surface 0x%x", ret);
3454 return CAMERA_ERROR_INVALID_OPERATION;
3458 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3460 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3466 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3468 int ret = CAMERA_ERROR_NONE;
3469 camera_cli_s *pc = (camera_cli_s *)camera;
3471 if (!pc || !pc->cb_info || !flip) {
3472 LOGE("NULL pointer %p %p", pc, flip);
3473 return CAMERA_ERROR_INVALID_PARAMETER;
3476 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3478 if (ret == CAMERA_ERROR_NONE)
3479 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3485 int camera_set_display_visible(camera_h camera, bool visible)
3487 int ret = CAMERA_ERROR_NONE;
3488 int set_visible = (int)visible;
3489 camera_cli_s *pc = (camera_cli_s *)camera;
3490 camera_msg_param param;
3492 if (!pc || !pc->cb_info) {
3493 LOGE("NULL handle");
3494 return CAMERA_ERROR_INVALID_PARAMETER;
3497 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3498 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3499 if (ret != MM_ERROR_NONE) {
3500 LOGE("failed to set visible for evas surface 0x%x", ret);
3501 return CAMERA_ERROR_INVALID_OPERATION;
3505 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3507 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3513 int camera_is_display_visible(camera_h camera, bool *visible)
3515 int ret = CAMERA_ERROR_NONE;
3516 camera_cli_s *pc = (camera_cli_s *)camera;
3518 if (!pc || !pc->cb_info || !visible) {
3519 LOGE("NULL pointer %p %p", pc, visible);
3520 return CAMERA_ERROR_INVALID_PARAMETER;
3523 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3525 if (ret == CAMERA_ERROR_NONE)
3526 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3532 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3534 int ret = CAMERA_ERROR_NONE;
3535 int set_mode = (int)mode;
3536 camera_cli_s *pc = (camera_cli_s *)camera;
3537 camera_msg_param param;
3539 if (!pc || !pc->cb_info) {
3540 LOGE("NULL handle");
3541 return CAMERA_ERROR_INVALID_PARAMETER;
3544 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3545 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3546 if (ret != MM_ERROR_NONE) {
3547 LOGE("failed to set geometry for evas surface 0x%x", ret);
3548 return CAMERA_ERROR_INVALID_OPERATION;
3552 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3554 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3560 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3562 int ret = CAMERA_ERROR_NONE;
3563 camera_cli_s *pc = (camera_cli_s *)camera;
3565 if (!pc || !pc->cb_info || !mode) {
3566 LOGE("NULL pointer %p %p", pc, mode);
3567 return CAMERA_ERROR_INVALID_PARAMETER;
3570 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3572 if (ret == CAMERA_ERROR_NONE)
3573 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3579 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3581 int ret = CAMERA_ERROR_NONE;
3582 int set_hint = (int)hint;
3583 camera_cli_s *pc = (camera_cli_s *)camera;
3584 camera_msg_param param;
3586 if (!pc || !pc->cb_info) {
3587 LOGE("NULL handle");
3588 return CAMERA_ERROR_INVALID_PARAMETER;
3591 LOGD("Enter - hint %d", set_hint);
3593 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3595 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3601 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3603 int ret = CAMERA_ERROR_NONE;
3604 camera_cli_s *pc = (camera_cli_s *)camera;
3605 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3607 if (!pc || !pc->cb_info || !hint) {
3608 LOGE("NULL pointer %p %p", pc, hint);
3609 return CAMERA_ERROR_INVALID_PARAMETER;
3612 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3614 if (ret == CAMERA_ERROR_NONE) {
3615 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3616 LOGD("display reuse hint %d", *hint);
3623 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3625 int ret = CAMERA_ERROR_NONE;
3626 camera_cli_s *pc = (camera_cli_s *)camera;
3627 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3629 if (!pc || !pc->cb_info || !width || !height) {
3630 LOGE("NULL pointer %p %p %p", pc, width, height);
3631 return CAMERA_ERROR_INVALID_PARAMETER;
3636 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3638 if (ret == CAMERA_ERROR_NONE) {
3639 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3640 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3643 LOGD("ret : 0x%x", ret);
3649 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3651 int ret = CAMERA_ERROR_NONE;
3652 camera_cli_s *pc = (camera_cli_s *)camera;
3653 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3655 if (!pc || !pc->cb_info || !format) {
3656 LOGE("NULL pointer %p %p", pc, format);
3657 return CAMERA_ERROR_INVALID_PARAMETER;
3662 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3664 if (ret == CAMERA_ERROR_NONE)
3665 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3667 LOGD("ret : 0x%x", ret);
3673 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3675 int ret = CAMERA_ERROR_NONE;
3676 camera_cli_s *pc = (camera_cli_s *)camera;
3677 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3679 if (!pc || !pc->cb_info || !format) {
3680 LOGE("NULL pointer %p %p", pc, format);
3681 return CAMERA_ERROR_INVALID_PARAMETER;
3686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3688 if (ret == CAMERA_ERROR_NONE)
3689 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3691 LOGD("ret : 0x%x", ret);
3697 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3699 int ret = CAMERA_ERROR_NONE;
3700 camera_cli_s *pc = (camera_cli_s *)camera;
3701 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3703 if (!pc || !pc->cb_info || !facing_direction) {
3704 LOGE("NULL pointer %p %p", pc, facing_direction);
3705 return CAMERA_ERROR_INVALID_PARAMETER;
3710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3712 if (ret == CAMERA_ERROR_NONE)
3713 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3715 LOGD("ret : 0x%x", ret);
3721 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3723 int ret = CAMERA_ERROR_NONE;
3724 camera_cli_s *pc = (camera_cli_s *)camera;
3725 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3727 if (!pc || !pc->cb_info || !callback) {
3728 LOGE("NULL pointer %p %p", pc, callback);
3729 return CAMERA_ERROR_INVALID_PARAMETER;
3734 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3736 if (ret == CAMERA_ERROR_NONE) {
3737 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3739 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3740 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3742 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3744 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3747 LOGD("ret : 0x%x", ret);
3753 int camera_unset_preview_cb(camera_h camera)
3755 int ret = CAMERA_ERROR_NONE;
3756 camera_cli_s *pc = (camera_cli_s *)camera;
3757 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3759 if (!pc || !pc->cb_info) {
3760 LOGE("NULL handle");
3761 return CAMERA_ERROR_INVALID_PARAMETER;
3766 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3768 if (ret == CAMERA_ERROR_NONE) {
3769 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3771 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3772 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3774 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3776 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3779 LOGD("ret : 0x%x", ret);
3785 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3787 int ret = CAMERA_ERROR_NONE;
3788 camera_cli_s *pc = (camera_cli_s *)camera;
3789 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3791 if (!pc || !pc->cb_info) {
3792 LOGE("NULL handle");
3793 return CAMERA_ERROR_INVALID_PARAMETER;
3796 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3797 LOGE("NOT SUPPORTED");
3798 return CAMERA_ERROR_NOT_SUPPORTED;
3801 if (callback == NULL) {
3802 LOGE("NULL callback");
3803 return CAMERA_ERROR_INVALID_PARAMETER;
3808 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3810 if (ret == CAMERA_ERROR_NONE) {
3811 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3813 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3814 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3816 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3819 LOGD("ret : 0x%x", ret);
3825 int camera_unset_media_packet_preview_cb(camera_h camera)
3827 int ret = CAMERA_ERROR_NONE;
3828 camera_cli_s *pc = (camera_cli_s *)camera;
3829 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3831 if (!pc || !pc->cb_info) {
3832 LOGE("NULL handle");
3833 return CAMERA_ERROR_INVALID_PARAMETER;
3838 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3840 if (ret == CAMERA_ERROR_NONE) {
3841 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3846 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3849 LOGD("ret : 0x%x", ret);
3855 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3857 int ret = CAMERA_ERROR_NONE;
3858 camera_cli_s *pc = (camera_cli_s *)camera;
3859 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3861 if (!pc || !pc->cb_info || !callback) {
3862 LOGE("NULL pointer %p %p", pc, callback);
3863 return CAMERA_ERROR_INVALID_PARAMETER;
3868 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3876 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3879 LOGD("ret : 0x%x", ret);
3885 int camera_unset_state_changed_cb(camera_h camera)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3891 if (!pc || !pc->cb_info) {
3892 LOGE("NULL handle");
3893 return CAMERA_ERROR_INVALID_PARAMETER;
3898 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3900 if (ret == CAMERA_ERROR_NONE) {
3901 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3903 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3904 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3906 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3909 LOGD("ret : 0x%x", ret);
3915 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3917 int ret = CAMERA_ERROR_NONE;
3918 camera_cli_s *pc = (camera_cli_s *)camera;
3919 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3921 if (!pc || !pc->cb_info || !callback) {
3922 LOGE("NULL pointer %p %p", pc, callback);
3923 return CAMERA_ERROR_INVALID_PARAMETER;
3928 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3930 if (ret == CAMERA_ERROR_NONE) {
3931 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3933 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3934 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3936 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3939 LOGD("ret : 0x%x", ret);
3945 int camera_unset_interrupted_cb(camera_h camera)
3947 int ret = CAMERA_ERROR_NONE;
3948 camera_cli_s *pc = (camera_cli_s *)camera;
3949 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3951 if (!pc || !pc->cb_info) {
3952 LOGE("NULL handle");
3953 return CAMERA_ERROR_INVALID_PARAMETER;
3958 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3960 if (ret == CAMERA_ERROR_NONE) {
3961 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3963 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3964 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3966 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3969 LOGD("ret : 0x%x", ret);
3975 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3977 int ret = CAMERA_ERROR_NONE;
3978 camera_cli_s *pc = (camera_cli_s *)camera;
3979 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3981 if (!pc || !pc->cb_info || !callback) {
3982 LOGE("NULL pointer %p %p", pc, callback);
3983 return CAMERA_ERROR_INVALID_PARAMETER;
3988 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3990 if (ret == CAMERA_ERROR_NONE) {
3991 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3993 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3994 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3996 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3999 LOGD("ret : 0x%x", ret);
4005 int camera_unset_interrupt_started_cb(camera_h camera)
4007 int ret = CAMERA_ERROR_NONE;
4008 camera_cli_s *pc = (camera_cli_s *)camera;
4009 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4011 if (!pc || !pc->cb_info) {
4012 LOGE("NULL handle");
4013 return CAMERA_ERROR_INVALID_PARAMETER;
4018 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4020 if (ret == CAMERA_ERROR_NONE) {
4021 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4023 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4024 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4026 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4029 LOGD("ret : 0x%x", ret);
4035 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4037 int ret = CAMERA_ERROR_NONE;
4038 camera_cli_s *pc = (camera_cli_s *)camera;
4039 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4041 if (!pc || !pc->cb_info || !callback) {
4042 LOGE("NULL pointer %p %p", pc, callback);
4043 return CAMERA_ERROR_INVALID_PARAMETER;
4048 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4050 if (ret == CAMERA_ERROR_NONE) {
4051 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4053 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4054 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4056 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4059 LOGD("ret : 0x%x", ret);
4065 int camera_unset_focus_changed_cb(camera_h camera)
4067 int ret = CAMERA_ERROR_NONE;
4068 camera_cli_s *pc = (camera_cli_s *)camera;
4069 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4071 if (!pc || !pc->cb_info) {
4072 LOGE("NULL handle");
4073 return CAMERA_ERROR_INVALID_PARAMETER;
4078 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4080 if (ret == CAMERA_ERROR_NONE) {
4081 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4083 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4084 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4086 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4089 LOGD("ret : 0x%x", ret);
4095 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4097 int ret = CAMERA_ERROR_NONE;
4098 camera_cli_s *pc = (camera_cli_s *)camera;
4099 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4101 if (!pc || !pc->cb_info || !callback) {
4102 LOGE("NULL pointer %p %p", pc, callback);
4103 return CAMERA_ERROR_INVALID_PARAMETER;
4108 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4110 if (ret == CAMERA_ERROR_NONE) {
4111 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4113 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4114 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4116 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4119 LOGD("ret : 0x%x", ret);
4125 int camera_unset_error_cb(camera_h camera)
4127 int ret = CAMERA_ERROR_NONE;
4128 camera_cli_s *pc = (camera_cli_s *)camera;
4129 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4131 if (!pc || !pc->cb_info) {
4132 LOGE("NULL handle");
4133 return CAMERA_ERROR_INVALID_PARAMETER;
4138 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4140 if (ret == CAMERA_ERROR_NONE) {
4141 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4143 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4144 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4146 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4149 LOGD("ret : 0x%x", ret);
4155 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4161 if (!pc || !pc->cb_info || !foreach_cb) {
4162 LOGE("NULL pointer %p %p", pc, foreach_cb);
4163 return CAMERA_ERROR_INVALID_PARAMETER;
4168 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4169 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4171 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4173 LOGD("ret : 0x%x", ret);
4179 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4181 int ret = CAMERA_ERROR_NONE;
4182 camera_cli_s *pc = (camera_cli_s *)camera;
4183 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4185 if (!pc || !pc->cb_info || !foreach_cb) {
4186 LOGE("NULL pointer %p %p", pc, foreach_cb);
4187 return CAMERA_ERROR_INVALID_PARAMETER;
4192 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4193 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4195 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 LOGD("ret : 0x%x", ret);
4203 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4205 int ret = CAMERA_ERROR_NONE;
4206 camera_cli_s *pc = (camera_cli_s *)camera;
4207 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4209 if (!pc || !pc->cb_info || !foreach_cb) {
4210 LOGE("NULL pointer %p %p", pc, foreach_cb);
4211 return CAMERA_ERROR_INVALID_PARAMETER;
4216 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4217 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4219 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4221 LOGD("ret : 0x%x", ret);
4227 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4229 int ret = CAMERA_ERROR_NONE;
4230 camera_cli_s *pc = (camera_cli_s *)camera;
4231 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4233 if (!pc || !pc->cb_info || !foreach_cb) {
4234 LOGE("NULL pointer %p %p", pc, foreach_cb);
4235 return CAMERA_ERROR_INVALID_PARAMETER;
4240 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4241 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4243 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4245 LOGD("ret : 0x%x", ret);
4251 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4253 int ret = CAMERA_ERROR_NONE;
4254 camera_cli_s *pc = (camera_cli_s *)camera;
4255 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4257 if (!pc || !pc->cb_info || !width || !height) {
4258 LOGE("NULL pointer %p %p %p", pc, width, height);
4259 return CAMERA_ERROR_INVALID_PARAMETER;
4263 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4265 if (ret == CAMERA_ERROR_NONE) {
4266 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4267 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4270 LOGD("ret : 0x%x", ret);
4276 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4278 int ret = CAMERA_ERROR_NONE;
4279 camera_cli_s *pc = (camera_cli_s *)camera;
4280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4282 if (!pc || !pc->cb_info || !angle) {
4283 LOGE("NULL pointer %p %p", pc, angle);
4284 return CAMERA_ERROR_INVALID_PARAMETER;
4289 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4291 if (ret == CAMERA_ERROR_NONE)
4292 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4294 LOGD("ret : 0x%x", ret);
4300 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4302 int ret = CAMERA_ERROR_NONE;
4303 camera_cli_s *pc = (camera_cli_s *)camera;
4304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4305 camera_msg_param param;
4306 int set_mode = (int)mode;
4308 if (!pc || !pc->cb_info) {
4309 LOGE("NULL handle");
4310 return CAMERA_ERROR_INVALID_PARAMETER;
4315 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4317 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4319 LOGD("ret : 0x%x", ret);
4325 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4331 if (!pc || !pc->cb_info || !mode) {
4332 LOGE("NULL pointer %p %p", pc, mode);
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4338 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4340 if (ret == CAMERA_ERROR_NONE)
4341 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4343 LOGD("ret : 0x%x", ret);
4349 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4355 if (!pc || !pc->cb_info || !foreach_cb) {
4356 LOGE("NULL pointer %p %p", pc, foreach_cb);
4357 return CAMERA_ERROR_INVALID_PARAMETER;
4362 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4363 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4365 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4367 LOGD("Finish, return :%x", ret);
4373 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4375 int ret = CAMERA_ERROR_NONE;
4376 camera_cli_s *pc = (camera_cli_s *)camera;
4377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4378 camera_msg_param param;
4379 int set_fps = (int)fps;
4381 if (!pc || !pc->cb_info) {
4382 LOGE("NULL handle");
4383 return CAMERA_ERROR_INVALID_PARAMETER;
4388 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4390 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4392 LOGD("ret : 0x%x", ret);
4398 int camera_attr_set_image_quality(camera_h camera, int quality)
4400 int ret = CAMERA_ERROR_NONE;
4401 camera_cli_s *pc = (camera_cli_s *)camera;
4402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4403 camera_msg_param param;
4405 if (!pc || !pc->cb_info) {
4406 LOGE("NULL handle");
4407 return CAMERA_ERROR_INVALID_PARAMETER;
4412 CAMERA_MSG_PARAM_SET(param, INT, quality);
4414 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4416 LOGD("ret : 0x%x", ret);
4422 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4424 int ret = CAMERA_ERROR_NONE;
4425 camera_cli_s *pc = (camera_cli_s *)camera;
4426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4428 if (!pc || !pc->cb_info || !fps) {
4429 LOGE("NULL pointer %p %p", pc, fps);
4430 return CAMERA_ERROR_INVALID_PARAMETER;
4435 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4437 if (ret == CAMERA_ERROR_NONE)
4438 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4440 LOGD("ret : 0x%x", ret);
4446 int camera_attr_get_image_quality(camera_h camera, int *quality)
4448 int ret = CAMERA_ERROR_NONE;
4449 camera_cli_s *pc = (camera_cli_s *)camera;
4450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4452 if (!pc || !pc->cb_info || !quality) {
4453 LOGE("NULL pointer %p %p", pc, quality);
4454 return CAMERA_ERROR_INVALID_PARAMETER;
4459 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4461 if (ret == CAMERA_ERROR_NONE)
4462 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4464 LOGD("ret : 0x%x", ret);
4470 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4472 int ret = CAMERA_ERROR_NONE;
4473 camera_cli_s *pc = (camera_cli_s *)camera;
4474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4476 if (!pc || !pc->cb_info || !bitrate) {
4477 LOGE("NULL pointer %p %p", pc, bitrate);
4478 return CAMERA_ERROR_INVALID_PARAMETER;
4483 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4485 if (ret == CAMERA_ERROR_NONE)
4486 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4488 LOGD("ret : 0x%x", ret);
4494 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4496 int ret = CAMERA_ERROR_NONE;
4497 camera_cli_s *pc = (camera_cli_s *)camera;
4498 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4499 camera_msg_param param;
4500 int set_bitrate = bitrate;
4502 if (!pc || !pc->cb_info) {
4503 LOGE("NULL handle");
4504 return CAMERA_ERROR_INVALID_PARAMETER;
4509 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4511 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4513 LOGD("ret : 0x%x", ret);
4519 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4525 if (!pc || !pc->cb_info || !interval) {
4526 LOGE("NULL pointer %p %p", pc, interval);
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4532 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4534 if (ret == CAMERA_ERROR_NONE)
4535 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4537 LOGD("ret : 0x%x", ret);
4543 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4545 int ret = CAMERA_ERROR_NONE;
4546 camera_cli_s *pc = (camera_cli_s *)camera;
4547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4548 camera_msg_param param;
4549 int set_gop_interval = interval;
4551 if (!pc || !pc->cb_info) {
4552 LOGE("NULL handle");
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4558 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4560 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4562 LOGD("ret : 0x%x", ret);
4568 int camera_attr_set_zoom(camera_h camera, int zoom)
4570 int ret = CAMERA_ERROR_NONE;
4571 camera_cli_s *pc = (camera_cli_s *)camera;
4572 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4573 camera_msg_param param;
4575 if (!pc || !pc->cb_info) {
4576 LOGE("NULL handle");
4577 return CAMERA_ERROR_INVALID_PARAMETER;
4580 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4582 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4584 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4586 LOGD("ret : 0x%x", ret);
4592 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4594 int ret = CAMERA_ERROR_NONE;
4595 camera_cli_s *pc = (camera_cli_s *)camera;
4596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4597 camera_msg_param param;
4598 int set_mode = (int)mode;
4600 if (!pc || !pc->cb_info) {
4601 LOGE("NULL handle");
4602 return CAMERA_ERROR_INVALID_PARAMETER;
4605 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4607 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4609 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4615 int camera_attr_set_af_area(camera_h camera, int x, int y)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4620 camera_msg_param param;
4623 if (!pc || !pc->cb_info) {
4624 LOGE("NULL handle");
4625 return CAMERA_ERROR_INVALID_PARAMETER;
4628 LOGD("Enter - %d,%d", x, y);
4630 value = (x << 16) | y;
4631 CAMERA_MSG_PARAM_SET(param, INT, value);
4633 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4635 LOGD("ret : 0x%x", ret);
4641 int camera_attr_clear_af_area(camera_h camera)
4643 int ret = CAMERA_ERROR_NONE;
4644 camera_cli_s *pc = (camera_cli_s *)camera;
4645 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4647 if (!pc || !pc->cb_info) {
4648 LOGE("NULL handle");
4649 return CAMERA_ERROR_INVALID_PARAMETER;
4654 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4656 LOGD("ret : 0x%x", ret);
4662 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4664 int ret = CAMERA_ERROR_NONE;
4665 camera_cli_s *pc = (camera_cli_s *)camera;
4666 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4667 camera_msg_param param;
4668 int set_mode = (int)mode;
4670 if (!pc || !pc->cb_info) {
4671 LOGE("NULL handle");
4672 return CAMERA_ERROR_INVALID_PARAMETER;
4677 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4679 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4681 LOGD("ret : 0x%x", ret);
4687 int camera_attr_set_exposure(camera_h camera, int value)
4689 int ret = CAMERA_ERROR_NONE;
4690 camera_cli_s *pc = (camera_cli_s *)camera;
4691 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4692 camera_msg_param param;
4694 if (!pc || !pc->cb_info) {
4695 LOGE("NULL handle");
4696 return CAMERA_ERROR_INVALID_PARAMETER;
4701 CAMERA_MSG_PARAM_SET(param, INT, value);
4703 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4705 LOGD("ret : 0x%x", ret);
4711 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4713 int ret = CAMERA_ERROR_NONE;
4714 camera_cli_s *pc = (camera_cli_s *)camera;
4715 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4716 camera_msg_param param;
4717 int set_iso = (int)iso;
4719 if (!pc || !pc->cb_info) {
4720 LOGE("NULL handle");
4721 return CAMERA_ERROR_INVALID_PARAMETER;
4726 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4728 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4730 LOGD("ret : 0x%x", ret);
4736 int camera_attr_set_brightness(camera_h camera, int level)
4738 int ret = CAMERA_ERROR_NONE;
4739 camera_cli_s *pc = (camera_cli_s *)camera;
4740 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4741 camera_msg_param param;
4743 if (!pc || !pc->cb_info) {
4744 LOGE("NULL handle");
4745 return CAMERA_ERROR_INVALID_PARAMETER;
4750 CAMERA_MSG_PARAM_SET(param, INT, level);
4752 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4754 LOGD("ret : 0x%x", ret);
4760 int camera_attr_set_contrast(camera_h camera, int level)
4762 int ret = CAMERA_ERROR_NONE;
4763 camera_cli_s *pc = (camera_cli_s *)camera;
4764 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4765 camera_msg_param param;
4767 if (!pc || !pc->cb_info) {
4768 LOGE("NULL handle");
4769 return CAMERA_ERROR_INVALID_PARAMETER;
4774 CAMERA_MSG_PARAM_SET(param, INT, level);
4776 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4778 LOGD("ret : 0x%x", ret);
4784 int camera_attr_set_hue(camera_h camera, int level)
4786 int ret = CAMERA_ERROR_NONE;
4787 camera_cli_s *pc = (camera_cli_s *)camera;
4788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4789 camera_msg_param param;
4791 if (!pc || !pc->cb_info) {
4792 LOGE("NULL handle");
4793 return CAMERA_ERROR_INVALID_PARAMETER;
4798 CAMERA_MSG_PARAM_SET(param, INT, level);
4800 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4802 LOGD("ret : 0x%x", ret);
4808 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4810 int ret = CAMERA_ERROR_NONE;
4811 camera_cli_s *pc = (camera_cli_s *)camera;
4812 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4813 camera_msg_param param;
4814 int set_whitebalance = (int)wb;
4816 if (!pc || !pc->cb_info) {
4817 LOGE("NULL handle");
4818 return CAMERA_ERROR_INVALID_PARAMETER;
4823 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4825 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4827 LOGD("ret : 0x%x", ret);
4833 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4835 int ret = CAMERA_ERROR_NONE;
4836 camera_cli_s *pc = (camera_cli_s *)camera;
4837 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4838 camera_msg_param param;
4839 int set_effect = (int)effect;
4841 if (!pc || !pc->cb_info) {
4842 LOGE("NULL handle");
4843 return CAMERA_ERROR_INVALID_PARAMETER;
4848 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4850 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4852 LOGD("ret : 0x%x", ret);
4858 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4860 int ret = CAMERA_ERROR_NONE;
4861 camera_cli_s *pc = (camera_cli_s *)camera;
4862 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4863 camera_msg_param param;
4864 int set_mode = (int)mode;
4866 if (!pc || !pc->cb_info) {
4867 LOGE("NULL handle");
4868 return CAMERA_ERROR_INVALID_PARAMETER;
4873 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4875 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4877 LOGD("ret : 0x%x", ret);
4883 int camera_attr_enable_tag(camera_h camera, bool enable)
4885 int ret = CAMERA_ERROR_NONE;
4886 camera_cli_s *pc = (camera_cli_s *)camera;
4887 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4888 camera_msg_param param;
4889 int set_enable = (int)enable;
4891 if (!pc || !pc->cb_info) {
4892 LOGE("NULL handle");
4893 return CAMERA_ERROR_INVALID_PARAMETER;
4898 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4900 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4902 LOGD("ret : 0x%x", ret);
4908 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4910 int ret = CAMERA_ERROR_NONE;
4911 camera_cli_s *pc = (camera_cli_s *)camera;
4912 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4913 camera_msg_param param;
4915 if (!pc || !pc->cb_info || !description) {
4916 LOGE("NULL pointer %p %p", pc, description);
4917 return CAMERA_ERROR_INVALID_PARAMETER;
4922 CAMERA_MSG_PARAM_SET(param, STRING, description);
4924 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4926 LOGD("ret : 0x%x", ret);
4932 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4934 int ret = CAMERA_ERROR_NONE;
4935 camera_cli_s *pc = (camera_cli_s *)camera;
4936 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4937 camera_msg_param param;
4938 int set_orientation = (int)orientation;
4940 if (!pc || !pc->cb_info) {
4941 LOGE("NULL handle");
4942 return CAMERA_ERROR_INVALID_PARAMETER;
4947 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4949 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4951 LOGD("ret : 0x%x", ret);
4957 int camera_attr_set_tag_software(camera_h camera, const char *software)
4959 int ret = CAMERA_ERROR_NONE;
4960 camera_cli_s *pc = (camera_cli_s *)camera;
4961 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4962 camera_msg_param param;
4964 if (!pc || !pc->cb_info || !software) {
4965 LOGE("NULL pointer %p %p", pc, software);
4966 return CAMERA_ERROR_INVALID_PARAMETER;
4969 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4971 CAMERA_MSG_PARAM_SET(param, STRING, software);
4973 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4975 LOGD("ret : 0x%x", ret);
4981 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4983 int ret = CAMERA_ERROR_NONE;
4984 camera_cli_s *pc = (camera_cli_s *)camera;
4985 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4986 double set_geotag[3] = {latitude, longitude, altitude};
4991 if (!pc || !pc->cb_info) {
4992 LOGE("NULL handle");
4993 return CAMERA_ERROR_INVALID_PARAMETER;
4998 length = sizeof(set_geotag) / sizeof(int) + \
4999 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5001 msg = muse_core_msg_new(api,
5002 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5005 LOGE("msg creation failed: api %d", api);
5006 return CAMERA_ERROR_OUT_OF_MEMORY;
5009 if (pc->cb_info->is_server_connected) {
5010 __camera_update_api_waiting(pc->cb_info, api, 1);
5012 g_mutex_lock(&pc->cb_info->fd_lock);
5013 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5014 g_mutex_unlock(&pc->cb_info->fd_lock);
5018 LOGE("message send failed");
5019 ret = CAMERA_ERROR_INVALID_OPERATION;
5021 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5024 __camera_update_api_waiting(pc->cb_info, api, -1);
5026 muse_core_msg_free(msg);
5028 LOGD("ret : 0x%x", ret);
5034 int camera_attr_remove_geotag(camera_h camera)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5040 if (!pc || !pc->cb_info) {
5041 LOGE("NULL handle");
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 LOGD("ret : 0x%x", ret);
5055 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5057 int ret = CAMERA_ERROR_NONE;
5058 camera_cli_s *pc = (camera_cli_s *)camera;
5059 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5060 camera_msg_param param;
5061 int set_mode = (int)mode;
5063 if (!pc || !pc->cb_info) {
5064 LOGE("NULL handle");
5065 return CAMERA_ERROR_INVALID_PARAMETER;
5070 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5072 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5074 LOGD("ret : 0x%x", ret);
5080 int camera_attr_get_zoom(camera_h camera, int *zoom)
5082 int ret = CAMERA_ERROR_NONE;
5083 camera_cli_s *pc = (camera_cli_s *)camera;
5084 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5086 if (!pc || !pc->cb_info || !zoom) {
5087 LOGE("NULL pointer %p %p", pc, zoom);
5088 return CAMERA_ERROR_INVALID_PARAMETER;
5093 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5095 if (ret == CAMERA_ERROR_NONE)
5096 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5098 LOGD("ret : 0x%x", ret);
5104 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5106 int ret = CAMERA_ERROR_NONE;
5107 camera_cli_s *pc = (camera_cli_s *)camera;
5108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5110 if (!pc || !pc->cb_info || !min || !max) {
5111 LOGE("NULL pointer %p %p %p", pc, min, max);
5112 return CAMERA_ERROR_INVALID_PARAMETER;
5117 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5119 if (ret == CAMERA_ERROR_NONE) {
5120 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5121 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5124 LOGD("ret : 0x%x", ret);
5130 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5132 int ret = CAMERA_ERROR_NONE;
5133 camera_cli_s *pc = (camera_cli_s *)camera;
5134 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5136 if (!pc || !pc->cb_info || !mode) {
5137 LOGE("NULL pointer %p %p", pc, mode);
5138 return CAMERA_ERROR_INVALID_PARAMETER;
5143 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5145 if (ret == CAMERA_ERROR_NONE)
5146 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5148 LOGD("ret : 0x%x", ret);
5154 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5156 int ret = CAMERA_ERROR_NONE;
5157 camera_cli_s *pc = (camera_cli_s *)camera;
5158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5160 if (!pc || !pc->cb_info || !mode) {
5161 LOGE("NULL pointer %p %p", pc, mode);
5162 return CAMERA_ERROR_INVALID_PARAMETER;
5167 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5169 if (ret == CAMERA_ERROR_NONE)
5170 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5172 LOGD("ret : 0x%x", ret);
5178 int camera_attr_get_exposure(camera_h camera, int *value)
5180 int ret = CAMERA_ERROR_NONE;
5181 camera_cli_s *pc = (camera_cli_s *)camera;
5182 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5184 if (!pc || !pc->cb_info || !value) {
5185 LOGE("NULL pointer %p %p", pc, value);
5186 return CAMERA_ERROR_INVALID_PARAMETER;
5191 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5193 if (ret == CAMERA_ERROR_NONE)
5194 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5196 LOGD("ret : 0x%x", ret);
5202 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5204 int ret = CAMERA_ERROR_NONE;
5205 camera_cli_s *pc = (camera_cli_s *)camera;
5206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5208 if (!pc || !pc->cb_info || !min || !max) {
5209 LOGE("NULL pointer %p %p %p", pc, min, max);
5210 return CAMERA_ERROR_INVALID_PARAMETER;
5215 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5217 if (ret == CAMERA_ERROR_NONE) {
5218 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5219 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5222 LOGD("ret : 0x%x", ret);
5228 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5230 int ret = CAMERA_ERROR_NONE;
5231 camera_cli_s *pc = (camera_cli_s *)camera;
5232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5234 if (!pc || !pc->cb_info || !iso) {
5235 LOGE("NULL pointer %p %p", pc, iso);
5236 return CAMERA_ERROR_INVALID_PARAMETER;
5241 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5243 if (ret == CAMERA_ERROR_NONE)
5244 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5246 LOGD("ret : 0x%x", ret);
5252 int camera_attr_get_brightness(camera_h camera, int *level)
5254 int ret = CAMERA_ERROR_NONE;
5255 camera_cli_s *pc = (camera_cli_s *)camera;
5256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5258 if (!pc || !pc->cb_info || !level) {
5259 LOGE("NULL pointer %p %p", pc, level);
5260 return CAMERA_ERROR_INVALID_PARAMETER;
5265 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5267 if (ret == CAMERA_ERROR_NONE)
5268 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5270 LOGD("ret : 0x%x", ret);
5276 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5278 int ret = CAMERA_ERROR_NONE;
5279 camera_cli_s *pc = (camera_cli_s *)camera;
5280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5282 if (!pc || !pc->cb_info || !min || !max) {
5283 LOGE("NULL pointer %p %p %p", pc, min, max);
5284 return CAMERA_ERROR_INVALID_PARAMETER;
5289 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5291 if (ret == CAMERA_ERROR_NONE) {
5292 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5293 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5296 LOGD("ret : 0x%x", ret);
5302 int camera_attr_get_contrast(camera_h camera, int *level)
5304 int ret = CAMERA_ERROR_NONE;
5305 camera_cli_s *pc = (camera_cli_s *)camera;
5306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5308 if (!pc || !pc->cb_info || !level) {
5309 LOGE("NULL pointer %p %p", pc, level);
5310 return CAMERA_ERROR_INVALID_PARAMETER;
5315 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5317 if (ret == CAMERA_ERROR_NONE)
5318 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5320 LOGD("ret : 0x%x", ret);
5326 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5328 int ret = CAMERA_ERROR_NONE;
5329 camera_cli_s *pc = (camera_cli_s *)camera;
5330 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5332 if (!pc || !pc->cb_info || !min || !max) {
5333 LOGE("NULL pointer %p %p %p", pc, min, max);
5334 return CAMERA_ERROR_INVALID_PARAMETER;
5339 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5341 if (ret == CAMERA_ERROR_NONE) {
5342 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5343 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5344 LOGD("min %d, max %d", *min, *max);
5347 LOGD("ret : 0x%x", ret);
5353 int camera_attr_get_hue(camera_h camera, int *level)
5355 int ret = CAMERA_ERROR_NONE;
5356 camera_cli_s *pc = (camera_cli_s *)camera;
5357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5359 if (!pc || !pc->cb_info || !level) {
5360 LOGE("NULL pointer %p %p", pc, level);
5361 return CAMERA_ERROR_INVALID_PARAMETER;
5366 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5368 if (ret == CAMERA_ERROR_NONE)
5369 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5371 LOGD("ret : 0x%x", ret);
5377 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5379 int ret = CAMERA_ERROR_NONE;
5380 camera_cli_s *pc = (camera_cli_s *)camera;
5381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5383 if (!pc || !pc->cb_info || !min || !max) {
5384 LOGE("NULL pointer %p %p %p", pc, min, max);
5385 return CAMERA_ERROR_INVALID_PARAMETER;
5390 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5392 if (ret == CAMERA_ERROR_NONE) {
5393 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5394 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5395 LOGD("min %d, max %d", *min, *max);
5398 LOGD("ret : 0x%x", ret);
5404 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5406 int ret = CAMERA_ERROR_NONE;
5407 camera_cli_s *pc = (camera_cli_s *)camera;
5408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5410 if (!pc || !pc->cb_info || !wb) {
5411 LOGE("NULL pointer %p %p", pc, wb);
5412 return CAMERA_ERROR_INVALID_PARAMETER;
5417 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5419 if (ret == CAMERA_ERROR_NONE)
5420 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5422 LOGD("ret : 0x%x", ret);
5428 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5430 int ret = CAMERA_ERROR_NONE;
5431 camera_cli_s *pc = (camera_cli_s *)camera;
5432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5434 if (!pc || !pc->cb_info || !effect) {
5435 LOGE("NULL pointer %p %p", pc, effect);
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5441 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5443 if (ret == CAMERA_ERROR_NONE)
5444 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5446 LOGD("ret : 0x%x", ret);
5452 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5454 int ret = CAMERA_ERROR_NONE;
5455 camera_cli_s *pc = (camera_cli_s *)camera;
5456 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5458 if (!pc || !pc->cb_info || !mode) {
5459 LOGE("NULL pointer %p %p", pc, mode);
5460 return CAMERA_ERROR_INVALID_PARAMETER;
5465 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5467 if (ret == CAMERA_ERROR_NONE)
5468 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5470 LOGD("ret : 0x%x", ret);
5476 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5478 int ret = CAMERA_ERROR_NONE;
5479 camera_cli_s *pc = (camera_cli_s *)camera;
5480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5482 if (!pc || !pc->cb_info || !enable) {
5483 LOGE("NULL pointer %p %p", pc, enable);
5484 return CAMERA_ERROR_INVALID_PARAMETER;
5489 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5491 if (ret == CAMERA_ERROR_NONE)
5492 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5494 LOGD("ret : 0x%x", ret);
5500 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5506 if (!pc || !pc->cb_info || !description) {
5507 LOGE("NULL pointer %p %p", pc, description);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5513 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5515 if (ret == CAMERA_ERROR_NONE)
5516 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5518 LOGD("ret : 0x%x", ret);
5524 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5530 if (!pc || !pc->cb_info || !orientation) {
5531 LOGE("NULL pointer %p %p", pc, orientation);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5537 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5539 if (ret == CAMERA_ERROR_NONE)
5540 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5542 LOGD("ret : 0x%x", ret);
5548 int camera_attr_get_tag_software(camera_h camera, char **software)
5550 int ret = CAMERA_ERROR_NONE;
5551 camera_cli_s *pc = (camera_cli_s *)camera;
5552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5554 if (!pc || !pc->cb_info || !software) {
5555 LOGE("NULL pointer %p %p", pc, software);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5561 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5563 if (ret == CAMERA_ERROR_NONE)
5564 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5566 LOGD("ret : 0x%x", ret);
5572 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5574 int ret = CAMERA_ERROR_NONE;
5575 camera_cli_s *pc = (camera_cli_s *)camera;
5576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5578 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5579 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5580 return CAMERA_ERROR_INVALID_PARAMETER;
5585 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5587 if (ret == CAMERA_ERROR_NONE) {
5588 *latitude = pc->cb_info->get_geotag[0];
5589 *longitude = pc->cb_info->get_geotag[1];
5590 *altitude = pc->cb_info->get_geotag[2];
5593 LOGD("ret : 0x%x", ret);
5599 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5601 int ret = CAMERA_ERROR_NONE;
5602 camera_cli_s *pc = (camera_cli_s *)camera;
5603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5605 if (!pc || !pc->cb_info || !mode) {
5606 LOGE("NULL pointer %p %p", pc, mode);
5607 return CAMERA_ERROR_INVALID_PARAMETER;
5612 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5614 if (ret == CAMERA_ERROR_NONE)
5615 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5617 LOGD("ret : 0x%x", ret);
5623 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5625 int ret = CAMERA_ERROR_NONE;
5626 int get_flash_state = 0;
5629 LOGE("NULL pointer");
5630 return CAMERA_ERROR_INVALID_PARAMETER;
5633 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5634 (int)device, "get_flash_state", &get_flash_state);
5636 if (ret == CAMERA_ERROR_NONE) {
5637 *state = (camera_flash_state_e)get_flash_state;
5638 LOGD("flash state %d", *state);
5640 LOGE("failed 0x%x", ret);
5647 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5649 int ret = CAMERA_ERROR_NONE;
5650 camera_cli_s *pc = (camera_cli_s *)camera;
5651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5653 if (!pc || !pc->cb_info || !foreach_cb) {
5654 LOGE("NULL pointer %p %p", pc, foreach_cb);
5655 return CAMERA_ERROR_INVALID_PARAMETER;
5660 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5661 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5663 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5665 LOGD("ret : 0x%x", ret);
5671 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5673 int ret = CAMERA_ERROR_NONE;
5674 camera_cli_s *pc = (camera_cli_s *)camera;
5675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5677 if (!pc || !pc->cb_info || !foreach_cb) {
5678 LOGE("NULL pointer %p %p", pc, foreach_cb);
5679 return CAMERA_ERROR_INVALID_PARAMETER;
5684 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5685 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5687 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5689 LOGD("ret : 0x%x", ret);
5695 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5697 int ret = CAMERA_ERROR_NONE;
5698 camera_cli_s *pc = (camera_cli_s *)camera;
5699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5701 if (!pc || !pc->cb_info || !foreach_cb) {
5702 LOGE("NULL pointer %p %p", pc, foreach_cb);
5703 return CAMERA_ERROR_INVALID_PARAMETER;
5708 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5709 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5711 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5713 LOGD("ret : 0x%x", ret);
5719 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5721 int ret = CAMERA_ERROR_NONE;
5722 camera_cli_s *pc = (camera_cli_s *)camera;
5723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5725 if (!pc || !pc->cb_info || !foreach_cb) {
5726 LOGE("NULL pointer %p %p", pc, foreach_cb);
5727 return CAMERA_ERROR_INVALID_PARAMETER;
5732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5735 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5737 LOGD("ret : 0x%x", ret);
5743 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5745 int ret = CAMERA_ERROR_NONE;
5746 camera_cli_s *pc = (camera_cli_s *)camera;
5747 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5749 if (!pc || !pc->cb_info || !foreach_cb) {
5750 LOGE("NULL pointer %p %p", pc, foreach_cb);
5751 return CAMERA_ERROR_INVALID_PARAMETER;
5756 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5757 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5759 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5761 LOGD("ret : 0x%x", ret);
5767 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5769 int ret = CAMERA_ERROR_NONE;
5770 camera_cli_s *pc = (camera_cli_s *)camera;
5771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5773 if (!pc || !pc->cb_info || !foreach_cb) {
5774 LOGE("NULL pointer %p %p", pc, foreach_cb);
5775 return CAMERA_ERROR_INVALID_PARAMETER;
5780 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5781 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5783 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5785 LOGD("ret : 0x%x", ret);
5791 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5793 int ret = CAMERA_ERROR_NONE;
5794 camera_cli_s *pc = (camera_cli_s *)camera;
5795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5797 if (!pc || !pc->cb_info || !foreach_cb) {
5798 LOGE("NULL pointer %p %p", pc, foreach_cb);
5799 return CAMERA_ERROR_INVALID_PARAMETER;
5804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5807 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5809 LOGD("ret : 0x%x", ret);
5815 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5817 int ret = CAMERA_ERROR_NONE;
5818 camera_cli_s *pc = (camera_cli_s *)camera;
5819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5821 if (!pc || !pc->cb_info || !foreach_cb) {
5822 LOGE("NULL pointer %p %p", pc, foreach_cb);
5823 return CAMERA_ERROR_INVALID_PARAMETER;
5828 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5829 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5831 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5833 LOGD("Enter, handle :%td", pc->remote_handle);
5839 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)
5841 int ret = CAMERA_ERROR_NONE;
5842 camera_cli_s *pc = (camera_cli_s *)camera;
5843 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5844 camera_msg_param param;
5847 if (!pc || !pc->cb_info || !foreach_cb) {
5848 LOGE("NULL pointer %p %p", pc, foreach_cb);
5849 return CAMERA_ERROR_INVALID_PARAMETER;
5854 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5855 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5857 value = (width << 16) | height;
5858 CAMERA_MSG_PARAM_SET(param, INT, value);
5860 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5862 LOGD("ret : 0x%x", ret);
5868 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5870 int ret = CAMERA_ERROR_NONE;
5871 camera_cli_s *pc = (camera_cli_s *)camera;
5872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5874 if (!pc || !pc->cb_info || !foreach_cb) {
5875 LOGE("NULL pointer %p %p", pc, foreach_cb);
5876 return CAMERA_ERROR_INVALID_PARAMETER;
5881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5884 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5886 LOGD("ret : 0x%x", ret);
5892 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5894 int ret = CAMERA_ERROR_NONE;
5895 camera_cli_s *pc = (camera_cli_s *)camera;
5896 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5898 if (!pc || !pc->cb_info || !foreach_cb) {
5899 LOGE("NULL pointer %p %p", pc, foreach_cb);
5900 return CAMERA_ERROR_INVALID_PARAMETER;
5905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5908 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 LOGD("ret : 0x%x", ret);
5916 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5921 camera_msg_param param;
5922 int set_rotation = (int)rotation;
5924 if (!pc || !pc->cb_info) {
5925 LOGE("NULL handle");
5926 return CAMERA_ERROR_INVALID_PARAMETER;
5931 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5933 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5935 LOGD("ret : 0x%x", ret);
5941 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5943 int ret = CAMERA_ERROR_NONE;
5944 camera_cli_s *pc = (camera_cli_s *)camera;
5945 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5947 if (!pc || !pc->cb_info || !rotation) {
5948 LOGE("NULL pointer %p %p", pc, rotation);
5949 return CAMERA_ERROR_INVALID_PARAMETER;
5954 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5956 if (ret == CAMERA_ERROR_NONE)
5957 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5959 LOGD("ret : 0x%x", ret);
5965 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5967 int ret = CAMERA_ERROR_NONE;
5968 camera_cli_s *pc = (camera_cli_s *)camera;
5969 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5970 camera_msg_param param;
5971 int set_flip = (int)flip;
5973 if (!pc || !pc->cb_info) {
5974 LOGE("NULL handle");
5975 return CAMERA_ERROR_INVALID_PARAMETER;
5980 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5982 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5984 LOGD("ret : 0x%x", ret);
5990 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5992 int ret = CAMERA_ERROR_NONE;
5993 camera_cli_s *pc = (camera_cli_s *)camera;
5994 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5996 if (!pc || !pc->cb_info || !flip) {
5997 LOGE("NULL pointer %p %p", pc, flip);
5998 return CAMERA_ERROR_INVALID_PARAMETER;
6003 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6005 if (ret == CAMERA_ERROR_NONE)
6006 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6008 LOGD("ret : 0x%x", ret);
6013 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6015 int ret = CAMERA_ERROR_NONE;
6016 camera_cli_s *pc = (camera_cli_s *)camera;
6017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6018 camera_msg_param param;
6019 int set_mode = (int)mode;
6021 if (!pc || !pc->cb_info) {
6022 LOGE("NULL handle");
6023 return CAMERA_ERROR_INVALID_PARAMETER;
6028 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6030 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6032 LOGD("ret : 0x%x", ret);
6038 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6040 int ret = CAMERA_ERROR_NONE;
6041 camera_cli_s *pc = (camera_cli_s *)camera;
6042 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6044 if (!pc || !pc->cb_info || !mode) {
6045 LOGE("NULL pointer %p %p", pc, mode);
6046 return CAMERA_ERROR_INVALID_PARAMETER;
6051 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6053 if (ret == CAMERA_ERROR_NONE)
6054 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6056 LOGD("ret : 0x%x", ret);
6062 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6064 int ret = CAMERA_ERROR_NONE;
6065 camera_cli_s *pc = (camera_cli_s *)camera;
6066 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6068 if (!pc || !pc->cb_info) {
6069 LOGE("NULL handle");
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6075 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6078 LOGE("error is occurred 0x%x", ret);
6082 LOGD("ret : %d", ret);
6088 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6094 if (!pc || !pc->cb_info) {
6095 LOGE("NULL handle");
6096 return CAMERA_ERROR_INVALID_PARAMETER;
6101 if (!camera_attr_is_supported_hdr_capture(camera)) {
6102 LOGE("HDR not supported");
6103 return CAMERA_ERROR_NOT_SUPPORTED;
6107 LOGE("NULL callback");
6108 return CAMERA_ERROR_INVALID_PARAMETER;
6111 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6113 if (ret == CAMERA_ERROR_NONE) {
6114 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6116 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6117 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6119 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6122 LOGD("ret : 0x%x", ret);
6128 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6130 int ret = CAMERA_ERROR_NONE;
6131 camera_cli_s *pc = (camera_cli_s *)camera;
6132 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6134 if (!pc || !pc->cb_info) {
6135 LOGE("NULL handle");
6136 return CAMERA_ERROR_INVALID_PARAMETER;
6141 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6143 if (ret == CAMERA_ERROR_NONE) {
6144 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6146 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6147 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6149 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6152 LOGD("ret : 0x%x", ret);
6158 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6160 int ret = CAMERA_ERROR_NONE;
6161 camera_cli_s *pc = (camera_cli_s *)camera;
6162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6163 camera_msg_param param;
6164 int set_enable = (int)enable;
6166 if (!pc || !pc->cb_info) {
6167 LOGE("NULL handle");
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6173 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6175 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6177 LOGD("ret : 0x%x", ret);
6183 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6185 int ret = CAMERA_ERROR_NONE;
6186 camera_cli_s *pc = (camera_cli_s *)camera;
6187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6189 if (!pc || !pc->cb_info || !enabled) {
6190 LOGE("NULL pointer %p %p", pc, enabled);
6191 return CAMERA_ERROR_INVALID_PARAMETER;
6196 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6198 if (ret == CAMERA_ERROR_NONE)
6199 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6201 LOGD("ret : 0x%x", ret);
6207 bool camera_attr_is_supported_anti_shake(camera_h camera)
6209 int ret = CAMERA_ERROR_NONE;
6210 camera_cli_s *pc = (camera_cli_s *)camera;
6211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6213 if (!pc || !pc->cb_info) {
6214 LOGE("NULL handle");
6215 return CAMERA_ERROR_INVALID_PARAMETER;
6220 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6223 LOGE("error is occurred 0x%x", ret);
6227 LOGD("ret : %d", ret);
6233 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6235 int ret = CAMERA_ERROR_NONE;
6236 camera_cli_s *pc = (camera_cli_s *)camera;
6237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6238 camera_msg_param param;
6239 int set_enable = (int)enable;
6241 if (!pc || !pc->cb_info) {
6242 LOGE("NULL handle");
6243 return CAMERA_ERROR_INVALID_PARAMETER;
6248 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6252 LOGD("ret : 0x%x", ret);
6258 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6260 int ret = CAMERA_ERROR_NONE;
6261 camera_cli_s *pc = (camera_cli_s *)camera;
6262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6264 if (!pc || !pc->cb_info || !enabled) {
6265 LOGE("NULL pointer %p %p", pc, enabled);
6266 return CAMERA_ERROR_INVALID_PARAMETER;
6271 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6273 if (ret == CAMERA_ERROR_NONE)
6274 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6276 LOGD("ret : 0x%x", ret);
6282 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6284 int ret = CAMERA_ERROR_NONE;
6285 camera_cli_s *pc = (camera_cli_s *)camera;
6286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6288 if (!pc || !pc->cb_info) {
6289 LOGE("NULL handle");
6290 return CAMERA_ERROR_INVALID_PARAMETER;
6295 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6298 LOGE("error is occurred 0x%x", ret);
6302 LOGD("ret : %d", ret);
6308 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6310 int ret = CAMERA_ERROR_NONE;
6311 camera_cli_s *pc = (camera_cli_s *)camera;
6312 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6313 camera_msg_param param;
6314 int set_enable = (int)enable;
6316 if (!pc || !pc->cb_info) {
6317 LOGE("NULL handle");
6318 return CAMERA_ERROR_INVALID_PARAMETER;
6323 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6325 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6327 LOGD("ret : 0x%x", ret);
6333 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6335 int ret = CAMERA_ERROR_NONE;
6336 camera_cli_s *pc = (camera_cli_s *)camera;
6337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6339 if (!pc || !pc->cb_info || !enabled) {
6340 LOGE("NULL pointer %p %p", pc, enabled);
6341 return CAMERA_ERROR_INVALID_PARAMETER;
6346 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6348 if (ret == CAMERA_ERROR_NONE)
6349 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6351 LOGD("ret : 0x%x", ret);
6357 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6359 int ret = CAMERA_ERROR_NONE;
6360 camera_cli_s *pc = (camera_cli_s *)camera;
6361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6363 if (!pc || !pc->cb_info) {
6364 LOGE("NULL handle");
6365 return CAMERA_ERROR_INVALID_PARAMETER;
6370 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6373 LOGE("error is occurred 0x%x", ret);
6377 LOGD("ret : %d", ret);
6383 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6385 int ret = CAMERA_ERROR_NONE;
6386 camera_cli_s *pc = (camera_cli_s *)camera;
6387 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6388 camera_msg_param param;
6389 int set_disable = (int)disable;
6391 if (!pc || !pc->cb_info) {
6392 LOGE("NULL handle");
6393 return CAMERA_ERROR_INVALID_PARAMETER;
6398 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6400 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6402 LOGD("ret : 0x%x", ret);
6408 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6410 int ret = CAMERA_ERROR_NONE;
6411 camera_cli_s *pc = (camera_cli_s *)camera;
6412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6413 camera_msg_param param0;
6414 camera_msg_param param1;
6416 if (!pc || !pc->cb_info) {
6417 LOGE("NULL handle");
6418 return CAMERA_ERROR_INVALID_PARAMETER;
6423 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6424 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6426 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6427 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6429 LOGD("ret : 0x%x", ret);
6435 int camera_attr_get_pan(camera_h camera, int *pan_step)
6437 int ret = CAMERA_ERROR_NONE;
6438 camera_cli_s *pc = (camera_cli_s *)camera;
6439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6441 if (!pc || !pc->cb_info || !pan_step) {
6442 LOGE("NULL pointer %p %p", pc, pan_step);
6443 return CAMERA_ERROR_INVALID_PARAMETER;
6448 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6450 if (ret == CAMERA_ERROR_NONE)
6451 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6453 LOGD("ret : 0x%x", ret);
6459 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6461 int ret = CAMERA_ERROR_NONE;
6462 camera_cli_s *pc = (camera_cli_s *)camera;
6463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6465 if (!pc || !pc->cb_info || !min || !max) {
6466 LOGE("NULL pointer %p %p %p", pc, min, max);
6467 return CAMERA_ERROR_INVALID_PARAMETER;
6472 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6474 if (ret == CAMERA_ERROR_NONE) {
6475 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6476 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6479 LOGD("ret : 0x%x", ret);
6485 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6487 int ret = CAMERA_ERROR_NONE;
6488 camera_cli_s *pc = (camera_cli_s *)camera;
6489 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6490 camera_msg_param param0;
6491 camera_msg_param param1;
6493 if (!pc || !pc->cb_info) {
6494 LOGE("NULL handle");
6495 return CAMERA_ERROR_INVALID_PARAMETER;
6500 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6501 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6503 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6504 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6506 LOGD("ret : 0x%x", ret);
6512 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6514 int ret = CAMERA_ERROR_NONE;
6515 camera_cli_s *pc = (camera_cli_s *)camera;
6516 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6518 if (!pc || !pc->cb_info || !tilt_step) {
6519 LOGE("NULL pointer %p %p", pc, tilt_step);
6520 return CAMERA_ERROR_INVALID_PARAMETER;
6525 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6527 if (ret == CAMERA_ERROR_NONE)
6528 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6530 LOGD("ret : 0x%x", ret);
6536 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6538 int ret = CAMERA_ERROR_NONE;
6539 camera_cli_s *pc = (camera_cli_s *)camera;
6540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6542 if (!pc || !pc->cb_info || !min || !max) {
6543 LOGE("NULL pointer %p %p %p", pc, min, max);
6544 return CAMERA_ERROR_INVALID_PARAMETER;
6549 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6551 if (ret == CAMERA_ERROR_NONE) {
6552 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6553 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6556 LOGD("ret : 0x%x", ret);
6562 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6564 int ret = CAMERA_ERROR_NONE;
6565 camera_cli_s *pc = (camera_cli_s *)camera;
6566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6567 camera_msg_param param;
6568 int set_ptz_type = (int)ptz_type;
6570 if (!pc || !pc->cb_info) {
6571 LOGE("NULL handle");
6572 return CAMERA_ERROR_INVALID_PARAMETER;
6577 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6579 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6581 LOGD("ret : 0x%x", ret);
6587 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6589 int ret = CAMERA_ERROR_NONE;
6590 camera_cli_s *pc = (camera_cli_s *)camera;
6591 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6593 if (!pc || !pc->cb_info || !foreach_cb) {
6594 LOGE("NULL pointer %p %p", pc, foreach_cb);
6595 return CAMERA_ERROR_INVALID_PARAMETER;
6600 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6601 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6603 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6605 LOGD("ret : 0x%x", ret);
6611 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6613 int ret = CAMERA_ERROR_NONE;
6614 camera_cli_s *pc = (camera_cli_s *)camera;
6615 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6616 int set_display_roi_area[4] = {x, y, width, height};
6621 if (!pc || !pc->cb_info) {
6622 LOGE("NULL handle");
6623 return CAMERA_ERROR_INVALID_PARAMETER;
6628 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6629 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6630 if (ret != MM_ERROR_NONE) {
6631 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6632 return CAMERA_ERROR_INVALID_OPERATION;
6636 length = sizeof(set_display_roi_area) / sizeof(int) + \
6637 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6639 msg = muse_core_msg_new(api,
6640 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6643 LOGE("msg creation failed: api %d", api);
6644 return CAMERA_ERROR_OUT_OF_MEMORY;
6647 if (pc->cb_info->is_server_connected) {
6648 __camera_update_api_waiting(pc->cb_info, api, 1);
6650 g_mutex_lock(&pc->cb_info->fd_lock);
6651 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6652 g_mutex_unlock(&pc->cb_info->fd_lock);
6656 LOGE("message send failed");
6657 ret = CAMERA_ERROR_INVALID_OPERATION;
6659 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6662 __camera_update_api_waiting(pc->cb_info, api, -1);
6664 muse_core_msg_free(msg);
6666 LOGD("ret : 0x%x", ret);
6672 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6674 camera_cli_s *pc = (camera_cli_s *)camera;
6675 int ret = CAMERA_ERROR_NONE;
6676 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6678 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6679 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6680 return CAMERA_ERROR_INVALID_PARAMETER;
6685 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6687 if (ret == CAMERA_ERROR_NONE) {
6688 *x = pc->cb_info->get_display_roi_area[0];
6689 *y = pc->cb_info->get_display_roi_area[1];
6690 *width = pc->cb_info->get_display_roi_area[2];
6691 *height = pc->cb_info->get_display_roi_area[3];
6694 LOGD("ret : 0x%x", ret);
6700 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6702 int ret = CAMERA_ERROR_NONE;
6703 int get_device_state = 0;
6706 LOGE("NULL pointer");
6707 return CAMERA_ERROR_INVALID_PARAMETER;
6710 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6711 (int)device, "get_device_state", &get_device_state);
6713 if (ret == CAMERA_ERROR_NONE) {
6714 *state = (camera_device_state_e)get_device_state;
6715 LOGD("device state %d", *state);
6717 LOGE("failed 0x%x", ret);
6724 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6726 int ret = CAMERA_ERROR_NONE;
6727 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6728 camera_cb_info *info = NULL;
6730 if (!callback || !cb_id) {
6731 LOGE("invalid pointer %p %p", callback, cb_id);
6732 return CAMERA_ERROR_INVALID_PARAMETER;
6735 /* check camera support */
6736 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6737 if (ret != CAMERA_ERROR_NONE) {
6738 LOGE("get device state failed");
6742 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6744 info = g_new0(camera_cb_info, 1);
6746 LOGE("info failed");
6747 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6751 info->id = ++g_cam_dev_state_changed_cb_id;
6752 info->callback = (void *)callback;
6753 info->user_data = user_data;
6757 /* subscribe dbus signal for camera state change */
6758 if (!g_cam_dev_state_changed_cb_conn) {
6759 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6760 if (!g_cam_dev_state_changed_cb_conn) {
6761 LOGE("failed to get gdbus connection");
6762 ret = CAMERA_ERROR_INVALID_OPERATION;
6766 LOGD("subscribe signal %s - %s - %s",
6767 MM_CAMCORDER_DBUS_OBJECT,
6768 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6769 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6771 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6772 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6773 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6774 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6775 LOGE("failed to get gdbus connection");
6776 ret = CAMERA_ERROR_INVALID_OPERATION;
6780 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6783 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6785 LOGD("callback id %d", info->id);
6788 if (ret != CAMERA_ERROR_NONE) {
6794 if (g_cam_dev_state_changed_cb_conn) {
6795 g_object_unref(g_cam_dev_state_changed_cb_conn);
6796 g_cam_dev_state_changed_cb_conn = NULL;
6800 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6806 int camera_remove_device_state_changed_cb(int cb_id)
6808 int ret = CAMERA_ERROR_NONE;
6809 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6810 GList *tmp_list = NULL;
6811 camera_cb_info *info = NULL;
6813 /* check camera support */
6814 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6815 if (ret != CAMERA_ERROR_NONE) {
6816 LOGE("get device state failed");
6820 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6822 if (!g_cam_dev_state_changed_cb_list) {
6823 LOGE("there is no callback info");
6824 ret = CAMERA_ERROR_INVALID_OPERATION;
6828 tmp_list = g_cam_dev_state_changed_cb_list;
6831 info = tmp_list->data;
6832 tmp_list = tmp_list->next;
6839 if (info->id == cb_id) {
6840 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6845 if (!g_cam_dev_state_changed_cb_list) {
6846 /* no remained callback */
6847 if (g_cam_dev_state_changed_cb_conn) {
6848 /* unsubscribe signal */
6849 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6850 g_cam_dev_state_changed_cb_subscribe_id = 0;
6852 /* unref connection */
6853 g_object_unref(g_cam_dev_state_changed_cb_conn);
6854 g_cam_dev_state_changed_cb_conn = NULL;
6858 LOGD("id %d callback removed", cb_id);
6859 ret = CAMERA_ERROR_NONE;
6865 LOGE("id %d callback not found", cb_id);
6866 ret = CAMERA_ERROR_INVALID_PARAMETER;
6869 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);