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));
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);
3126 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3128 int mm_ret = MM_ERROR_NONE;
3129 int ret = CAMERA_ERROR_NONE;
3130 camera_cli_s *pc = (camera_cli_s *)camera;
3131 camera_cb_info_s *cb_info = NULL;
3132 camera_state_e current_state = CAMERA_STATE_NONE;
3133 camera_msg_param param;
3134 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3135 muse_camera_display_info_s *dp_info = NULL;
3137 if (!pc || !pc->cb_info) {
3138 LOGE("NULL handle");
3139 return CAMERA_ERROR_INVALID_PARAMETER;
3142 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3143 LOGE("invalid type %d", type);
3144 return CAMERA_ERROR_INVALID_PARAMETER;
3147 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3148 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3149 return CAMERA_ERROR_INVALID_PARAMETER;
3152 cb_info = (camera_cb_info_s *)pc->cb_info;
3153 dp_info = &cb_info->dp_info;
3155 ret = camera_get_state(camera, ¤t_state);
3156 if (ret != CAMERA_ERROR_NONE) {
3157 LOGE("failed to get current state 0x%x", ret);
3161 if (current_state != CAMERA_STATE_CREATED) {
3162 LOGE("INVALID_STATE : current %d", current_state);
3163 return CAMERA_ERROR_INVALID_STATE;
3166 LOGD("Enter - type : %d, display : %p", type, display);
3168 if (type != MM_DISPLAY_TYPE_NONE) {
3169 /* check display interface handle */
3170 if (!cb_info->dp_interface) {
3171 LOGE("display interface not supported");
3172 return CAMERA_ERROR_NOT_SUPPORTED;
3175 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3176 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3177 LOGE("[NOT_SUPPORTED] type %d", type);
3178 return CAMERA_ERROR_NOT_SUPPORTED;
3179 } else if (mm_ret != MM_ERROR_NONE) {
3180 LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3181 return CAMERA_ERROR_INVALID_OPERATION;
3184 if (type == MM_DISPLAY_TYPE_OVERLAY) {
3185 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3187 LOGD("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3188 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3189 dp_info->window_rect.width, dp_info->window_rect.height);
3190 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3192 camera_flip_e flip = CAMERA_FLIP_NONE;
3193 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3194 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3201 camera_get_display_flip(camera, &flip);
3202 camera_get_display_mode(camera, &mode);
3203 camera_get_display_rotation(camera, &rotation);
3204 camera_is_display_visible(camera, &visible);
3205 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3207 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3208 flip, mode, rotation, visible, x, y, width, height);
3210 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3211 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3212 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3213 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3215 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3216 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3221 if (mm_ret != MM_ERROR_NONE) {
3222 LOGE("mm_ret 0x%x failed", mm_ret);
3223 return CAMERA_ERROR_INVALID_OPERATION;
3226 dp_info->type = type;
3228 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3230 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3232 if (ret == CAMERA_ERROR_NONE) {
3233 if (type == MM_DISPLAY_TYPE_EVAS)
3234 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3241 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3243 LOGD("type %d, display %p", type, display);
3244 return _camera_set_display(camera, (mm_display_type_e)type, display);
3248 int camera_set_preview_resolution(camera_h camera, int width, int height)
3250 int ret = CAMERA_ERROR_NONE;
3251 camera_state_e current_state = CAMERA_STATE_NONE;
3252 camera_cli_s *pc = (camera_cli_s *)camera;
3253 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3254 camera_msg_param param;
3257 if (!pc || !pc->cb_info) {
3258 LOGE("NULL handle");
3259 return CAMERA_ERROR_INVALID_PARAMETER;
3262 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3263 ret = camera_get_state(camera, ¤t_state);
3264 if (ret != CAMERA_ERROR_NONE) {
3265 LOGE("failed to get current state 0x%x", ret);
3269 if (current_state == CAMERA_STATE_PREVIEW) {
3270 ret = _camera_stop_evas_rendering(camera, true);
3271 if (ret != CAMERA_ERROR_NONE)
3276 value = (width << 16) | height;
3277 CAMERA_MSG_PARAM_SET(param, INT, value);
3279 LOGD("%dx%d -> 0x%x", width, height, value);
3281 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3283 LOGD("ret : 0x%x", ret);
3285 if (current_state == CAMERA_STATE_PREVIEW) {
3286 LOGW("restart evas rendering");
3287 _camera_start_evas_rendering(camera);
3294 int camera_set_capture_resolution(camera_h camera, int width, int height)
3296 int ret = CAMERA_ERROR_NONE;
3297 camera_cli_s *pc = (camera_cli_s *)camera;
3298 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3299 camera_msg_param param;
3302 if (!pc || !pc->cb_info) {
3303 LOGE("NULL handle");
3304 return CAMERA_ERROR_INVALID_PARAMETER;
3309 value = (width << 16) | height;
3310 CAMERA_MSG_PARAM_SET(param, INT, value);
3312 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3314 LOGD("ret : 0x%x", ret);
3320 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3322 int ret = CAMERA_ERROR_NONE;
3323 int set_format = (int)format;
3324 camera_cli_s *pc = (camera_cli_s *)camera;
3325 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3326 camera_msg_param param;
3328 if (!pc || !pc->cb_info) {
3329 LOGE("NULL handle");
3330 return CAMERA_ERROR_INVALID_PARAMETER;
3333 LOGD("Enter - format %d", set_format);
3335 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3337 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3339 LOGD("ret : 0x%x", ret);
3345 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3347 int ret = CAMERA_ERROR_NONE;
3348 int set_format = (int)format;
3349 camera_msg_param param;
3350 camera_cli_s *pc = (camera_cli_s *)camera;
3351 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3353 if (!pc || !pc->cb_info) {
3354 LOGE("NULL handle");
3355 return CAMERA_ERROR_INVALID_PARAMETER;
3358 LOGD("Enter - format %d", set_format);
3360 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3362 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3364 if (ret == CAMERA_ERROR_NONE)
3365 pc->cb_info->preview_format = set_format;
3367 LOGD("ret : 0x%x", ret);
3373 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3375 int ret = CAMERA_ERROR_NONE;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3377 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3379 if (!pc || !pc->cb_info || !width || !height) {
3380 LOGE("NULL pointer %p %p %p", pc, width, height);
3381 return CAMERA_ERROR_INVALID_PARAMETER;
3386 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3388 if (ret == CAMERA_ERROR_NONE) {
3389 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3390 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3393 LOGD("ret : 0x%x", ret);
3399 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3401 int ret = CAMERA_ERROR_NONE;
3402 int set_rotation = (int)rotation;
3403 camera_cli_s *pc = (camera_cli_s *)camera;
3404 camera_msg_param param;
3406 if (!pc || !pc->cb_info) {
3407 LOGE("NULL handle");
3408 return CAMERA_ERROR_INVALID_PARAMETER;
3411 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3412 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3413 if (ret != MM_ERROR_NONE) {
3414 LOGE("failed to set rotation for evas surface 0x%x", ret);
3415 return CAMERA_ERROR_INVALID_OPERATION;
3419 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3421 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3427 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3429 int ret = CAMERA_ERROR_NONE;
3430 camera_cli_s *pc = (camera_cli_s *)camera;
3432 if (!pc || !pc->cb_info || !rotation) {
3433 LOGE("NULL pointer %p %p", pc, rotation);
3434 return CAMERA_ERROR_INVALID_PARAMETER;
3437 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3439 if (ret == CAMERA_ERROR_NONE)
3440 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3446 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3448 int ret = CAMERA_ERROR_NONE;
3449 int set_flip = (int)flip;
3450 camera_cli_s *pc = (camera_cli_s *)camera;
3451 camera_msg_param param;
3453 if (!pc || !pc->cb_info) {
3454 LOGE("NULL handle");
3455 return CAMERA_ERROR_INVALID_PARAMETER;
3458 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3459 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3460 if (ret != MM_ERROR_NONE) {
3461 LOGE("failed to set flip for evas surface 0x%x", ret);
3462 return CAMERA_ERROR_INVALID_OPERATION;
3466 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3468 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3474 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3476 int ret = CAMERA_ERROR_NONE;
3477 camera_cli_s *pc = (camera_cli_s *)camera;
3479 if (!pc || !pc->cb_info || !flip) {
3480 LOGE("NULL pointer %p %p", pc, flip);
3481 return CAMERA_ERROR_INVALID_PARAMETER;
3484 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3486 if (ret == CAMERA_ERROR_NONE)
3487 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3493 int camera_set_display_visible(camera_h camera, bool visible)
3495 int ret = CAMERA_ERROR_NONE;
3496 int set_visible = (int)visible;
3497 camera_cli_s *pc = (camera_cli_s *)camera;
3498 camera_msg_param param;
3500 if (!pc || !pc->cb_info) {
3501 LOGE("NULL handle");
3502 return CAMERA_ERROR_INVALID_PARAMETER;
3505 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3506 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3507 if (ret != MM_ERROR_NONE) {
3508 LOGE("failed to set visible for evas surface 0x%x", ret);
3509 return CAMERA_ERROR_INVALID_OPERATION;
3513 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3515 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3521 int camera_is_display_visible(camera_h camera, bool *visible)
3523 int ret = CAMERA_ERROR_NONE;
3524 camera_cli_s *pc = (camera_cli_s *)camera;
3526 if (!pc || !pc->cb_info || !visible) {
3527 LOGE("NULL pointer %p %p", pc, visible);
3528 return CAMERA_ERROR_INVALID_PARAMETER;
3531 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3533 if (ret == CAMERA_ERROR_NONE)
3534 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3540 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3542 int ret = CAMERA_ERROR_NONE;
3543 int set_mode = (int)mode;
3544 camera_cli_s *pc = (camera_cli_s *)camera;
3545 camera_msg_param param;
3547 if (!pc || !pc->cb_info) {
3548 LOGE("NULL handle");
3549 return CAMERA_ERROR_INVALID_PARAMETER;
3552 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3553 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3554 if (ret != MM_ERROR_NONE) {
3555 LOGE("failed to set geometry for evas surface 0x%x", ret);
3556 return CAMERA_ERROR_INVALID_OPERATION;
3560 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3562 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3568 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3570 int ret = CAMERA_ERROR_NONE;
3571 camera_cli_s *pc = (camera_cli_s *)camera;
3573 if (!pc || !pc->cb_info || !mode) {
3574 LOGE("NULL pointer %p %p", pc, mode);
3575 return CAMERA_ERROR_INVALID_PARAMETER;
3578 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3580 if (ret == CAMERA_ERROR_NONE)
3581 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3587 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3589 int ret = CAMERA_ERROR_NONE;
3590 int set_hint = (int)hint;
3591 camera_cli_s *pc = (camera_cli_s *)camera;
3592 camera_msg_param param;
3594 if (!pc || !pc->cb_info) {
3595 LOGE("NULL handle");
3596 return CAMERA_ERROR_INVALID_PARAMETER;
3599 LOGD("Enter - hint %d", set_hint);
3601 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3603 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3609 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3611 int ret = CAMERA_ERROR_NONE;
3612 camera_cli_s *pc = (camera_cli_s *)camera;
3613 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3615 if (!pc || !pc->cb_info || !hint) {
3616 LOGE("NULL pointer %p %p", pc, hint);
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3620 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3622 if (ret == CAMERA_ERROR_NONE) {
3623 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3624 LOGD("display reuse hint %d", *hint);
3631 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3633 int ret = CAMERA_ERROR_NONE;
3634 camera_cli_s *pc = (camera_cli_s *)camera;
3635 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3637 if (!pc || !pc->cb_info || !width || !height) {
3638 LOGE("NULL pointer %p %p %p", pc, width, height);
3639 return CAMERA_ERROR_INVALID_PARAMETER;
3644 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3646 if (ret == CAMERA_ERROR_NONE) {
3647 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3648 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3651 LOGD("ret : 0x%x", ret);
3657 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3659 int ret = CAMERA_ERROR_NONE;
3660 camera_cli_s *pc = (camera_cli_s *)camera;
3661 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3663 if (!pc || !pc->cb_info || !format) {
3664 LOGE("NULL pointer %p %p", pc, format);
3665 return CAMERA_ERROR_INVALID_PARAMETER;
3670 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3672 if (ret == CAMERA_ERROR_NONE)
3673 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3675 LOGD("ret : 0x%x", ret);
3681 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3683 int ret = CAMERA_ERROR_NONE;
3684 camera_cli_s *pc = (camera_cli_s *)camera;
3685 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3687 if (!pc || !pc->cb_info || !format) {
3688 LOGE("NULL pointer %p %p", pc, format);
3689 return CAMERA_ERROR_INVALID_PARAMETER;
3694 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3696 if (ret == CAMERA_ERROR_NONE)
3697 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3699 LOGD("ret : 0x%x", ret);
3705 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3707 int ret = CAMERA_ERROR_NONE;
3708 camera_cli_s *pc = (camera_cli_s *)camera;
3709 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3711 if (!pc || !pc->cb_info || !facing_direction) {
3712 LOGE("NULL pointer %p %p", pc, facing_direction);
3713 return CAMERA_ERROR_INVALID_PARAMETER;
3718 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3720 if (ret == CAMERA_ERROR_NONE)
3721 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3723 LOGD("ret : 0x%x", ret);
3729 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3731 int ret = CAMERA_ERROR_NONE;
3732 camera_cli_s *pc = (camera_cli_s *)camera;
3733 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3735 if (!pc || !pc->cb_info || !callback) {
3736 LOGE("NULL pointer %p %p", pc, callback);
3737 return CAMERA_ERROR_INVALID_PARAMETER;
3742 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3744 if (ret == CAMERA_ERROR_NONE) {
3745 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3747 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3748 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3750 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3752 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3755 LOGD("ret : 0x%x", ret);
3761 int camera_unset_preview_cb(camera_h camera)
3763 int ret = CAMERA_ERROR_NONE;
3764 camera_cli_s *pc = (camera_cli_s *)camera;
3765 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3767 if (!pc || !pc->cb_info) {
3768 LOGE("NULL handle");
3769 return CAMERA_ERROR_INVALID_PARAMETER;
3774 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3776 if (ret == CAMERA_ERROR_NONE) {
3777 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3779 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3780 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3782 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3784 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3787 LOGD("ret : 0x%x", ret);
3793 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3795 int ret = CAMERA_ERROR_NONE;
3796 camera_cli_s *pc = (camera_cli_s *)camera;
3797 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3799 if (!pc || !pc->cb_info) {
3800 LOGE("NULL handle");
3801 return CAMERA_ERROR_INVALID_PARAMETER;
3804 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3805 LOGE("NOT SUPPORTED");
3806 return CAMERA_ERROR_NOT_SUPPORTED;
3809 if (callback == NULL) {
3810 LOGE("NULL callback");
3811 return CAMERA_ERROR_INVALID_PARAMETER;
3816 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3818 if (ret == CAMERA_ERROR_NONE) {
3819 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3821 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3822 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3824 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3827 LOGD("ret : 0x%x", ret);
3833 int camera_unset_media_packet_preview_cb(camera_h camera)
3835 int ret = CAMERA_ERROR_NONE;
3836 camera_cli_s *pc = (camera_cli_s *)camera;
3837 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3839 if (!pc || !pc->cb_info) {
3840 LOGE("NULL handle");
3841 return CAMERA_ERROR_INVALID_PARAMETER;
3846 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3848 if (ret == CAMERA_ERROR_NONE) {
3849 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3851 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3852 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3854 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3857 LOGD("ret : 0x%x", ret);
3863 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3865 int ret = CAMERA_ERROR_NONE;
3866 camera_cli_s *pc = (camera_cli_s *)camera;
3867 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3869 if (!pc || !pc->cb_info || !callback) {
3870 LOGE("NULL pointer %p %p", pc, callback);
3871 return CAMERA_ERROR_INVALID_PARAMETER;
3876 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3878 if (ret == CAMERA_ERROR_NONE) {
3879 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3884 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3887 LOGD("ret : 0x%x", ret);
3893 int camera_unset_state_changed_cb(camera_h camera)
3895 int ret = CAMERA_ERROR_NONE;
3896 camera_cli_s *pc = (camera_cli_s *)camera;
3897 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3899 if (!pc || !pc->cb_info) {
3900 LOGE("NULL handle");
3901 return CAMERA_ERROR_INVALID_PARAMETER;
3906 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3908 if (ret == CAMERA_ERROR_NONE) {
3909 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3911 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3912 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3914 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3917 LOGD("ret : 0x%x", ret);
3923 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3925 int ret = CAMERA_ERROR_NONE;
3926 camera_cli_s *pc = (camera_cli_s *)camera;
3927 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3929 if (!pc || !pc->cb_info || !callback) {
3930 LOGE("NULL pointer %p %p", pc, callback);
3931 return CAMERA_ERROR_INVALID_PARAMETER;
3936 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3938 if (ret == CAMERA_ERROR_NONE) {
3939 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3941 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3942 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3944 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3947 LOGD("ret : 0x%x", ret);
3953 int camera_unset_interrupted_cb(camera_h camera)
3955 int ret = CAMERA_ERROR_NONE;
3956 camera_cli_s *pc = (camera_cli_s *)camera;
3957 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3959 if (!pc || !pc->cb_info) {
3960 LOGE("NULL handle");
3961 return CAMERA_ERROR_INVALID_PARAMETER;
3966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3968 if (ret == CAMERA_ERROR_NONE) {
3969 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3971 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3972 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3974 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3977 LOGD("ret : 0x%x", ret);
3983 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3985 int ret = CAMERA_ERROR_NONE;
3986 camera_cli_s *pc = (camera_cli_s *)camera;
3987 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3989 if (!pc || !pc->cb_info || !callback) {
3990 LOGE("NULL pointer %p %p", pc, callback);
3991 return CAMERA_ERROR_INVALID_PARAMETER;
3996 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3998 if (ret == CAMERA_ERROR_NONE) {
3999 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4001 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4002 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4004 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4007 LOGD("ret : 0x%x", ret);
4013 int camera_unset_interrupt_started_cb(camera_h camera)
4015 int ret = CAMERA_ERROR_NONE;
4016 camera_cli_s *pc = (camera_cli_s *)camera;
4017 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4019 if (!pc || !pc->cb_info) {
4020 LOGE("NULL handle");
4021 return CAMERA_ERROR_INVALID_PARAMETER;
4026 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4028 if (ret == CAMERA_ERROR_NONE) {
4029 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4031 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4032 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4034 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4037 LOGD("ret : 0x%x", ret);
4043 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4045 int ret = CAMERA_ERROR_NONE;
4046 camera_cli_s *pc = (camera_cli_s *)camera;
4047 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4049 if (!pc || !pc->cb_info || !callback) {
4050 LOGE("NULL pointer %p %p", pc, callback);
4051 return CAMERA_ERROR_INVALID_PARAMETER;
4056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4058 if (ret == CAMERA_ERROR_NONE) {
4059 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4061 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4062 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4064 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4067 LOGD("ret : 0x%x", ret);
4073 int camera_unset_focus_changed_cb(camera_h camera)
4075 int ret = CAMERA_ERROR_NONE;
4076 camera_cli_s *pc = (camera_cli_s *)camera;
4077 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4079 if (!pc || !pc->cb_info) {
4080 LOGE("NULL handle");
4081 return CAMERA_ERROR_INVALID_PARAMETER;
4086 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4088 if (ret == CAMERA_ERROR_NONE) {
4089 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4091 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4092 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4094 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4097 LOGD("ret : 0x%x", ret);
4103 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4105 int ret = CAMERA_ERROR_NONE;
4106 camera_cli_s *pc = (camera_cli_s *)camera;
4107 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4109 if (!pc || !pc->cb_info || !callback) {
4110 LOGE("NULL pointer %p %p", pc, callback);
4111 return CAMERA_ERROR_INVALID_PARAMETER;
4116 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4118 if (ret == CAMERA_ERROR_NONE) {
4119 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4121 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4122 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4124 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4127 LOGD("ret : 0x%x", ret);
4133 int camera_unset_error_cb(camera_h camera)
4135 int ret = CAMERA_ERROR_NONE;
4136 camera_cli_s *pc = (camera_cli_s *)camera;
4137 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4139 if (!pc || !pc->cb_info) {
4140 LOGE("NULL handle");
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4146 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4148 if (ret == CAMERA_ERROR_NONE) {
4149 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4151 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4152 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4154 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4157 LOGD("ret : 0x%x", ret);
4163 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4165 int ret = CAMERA_ERROR_NONE;
4166 camera_cli_s *pc = (camera_cli_s *)camera;
4167 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4169 if (!pc || !pc->cb_info || !foreach_cb) {
4170 LOGE("NULL pointer %p %p", pc, foreach_cb);
4171 return CAMERA_ERROR_INVALID_PARAMETER;
4176 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4177 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4179 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4181 LOGD("ret : 0x%x", ret);
4187 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4189 int ret = CAMERA_ERROR_NONE;
4190 camera_cli_s *pc = (camera_cli_s *)camera;
4191 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4193 if (!pc || !pc->cb_info || !foreach_cb) {
4194 LOGE("NULL pointer %p %p", pc, foreach_cb);
4195 return CAMERA_ERROR_INVALID_PARAMETER;
4200 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4201 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4203 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4205 LOGD("ret : 0x%x", ret);
4211 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4213 int ret = CAMERA_ERROR_NONE;
4214 camera_cli_s *pc = (camera_cli_s *)camera;
4215 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4217 if (!pc || !pc->cb_info || !foreach_cb) {
4218 LOGE("NULL pointer %p %p", pc, foreach_cb);
4219 return CAMERA_ERROR_INVALID_PARAMETER;
4224 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4225 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4227 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4229 LOGD("ret : 0x%x", ret);
4235 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4237 int ret = CAMERA_ERROR_NONE;
4238 camera_cli_s *pc = (camera_cli_s *)camera;
4239 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4241 if (!pc || !pc->cb_info || !foreach_cb) {
4242 LOGE("NULL pointer %p %p", pc, foreach_cb);
4243 return CAMERA_ERROR_INVALID_PARAMETER;
4248 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4249 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4251 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4253 LOGD("ret : 0x%x", ret);
4259 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4261 int ret = CAMERA_ERROR_NONE;
4262 camera_cli_s *pc = (camera_cli_s *)camera;
4263 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4265 if (!pc || !pc->cb_info || !width || !height) {
4266 LOGE("NULL pointer %p %p %p", pc, width, height);
4267 return CAMERA_ERROR_INVALID_PARAMETER;
4271 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4273 if (ret == CAMERA_ERROR_NONE) {
4274 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4275 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4278 LOGD("ret : 0x%x", ret);
4284 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4286 int ret = CAMERA_ERROR_NONE;
4287 camera_cli_s *pc = (camera_cli_s *)camera;
4288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4290 if (!pc || !pc->cb_info || !angle) {
4291 LOGE("NULL pointer %p %p", pc, angle);
4292 return CAMERA_ERROR_INVALID_PARAMETER;
4297 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4299 if (ret == CAMERA_ERROR_NONE)
4300 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4302 LOGD("ret : 0x%x", ret);
4308 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4310 int ret = CAMERA_ERROR_NONE;
4311 camera_cli_s *pc = (camera_cli_s *)camera;
4312 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4313 camera_msg_param param;
4314 int set_mode = (int)mode;
4316 if (!pc || !pc->cb_info) {
4317 LOGE("NULL handle");
4318 return CAMERA_ERROR_INVALID_PARAMETER;
4323 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4325 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4327 LOGD("ret : 0x%x", ret);
4333 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4335 int ret = CAMERA_ERROR_NONE;
4336 camera_cli_s *pc = (camera_cli_s *)camera;
4337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4339 if (!pc || !pc->cb_info || !mode) {
4340 LOGE("NULL pointer %p %p", pc, mode);
4341 return CAMERA_ERROR_INVALID_PARAMETER;
4346 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4348 if (ret == CAMERA_ERROR_NONE)
4349 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4351 LOGD("ret : 0x%x", ret);
4357 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4359 int ret = CAMERA_ERROR_NONE;
4360 camera_cli_s *pc = (camera_cli_s *)camera;
4361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4363 if (!pc || !pc->cb_info || !foreach_cb) {
4364 LOGE("NULL pointer %p %p", pc, foreach_cb);
4365 return CAMERA_ERROR_INVALID_PARAMETER;
4370 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4371 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4373 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4375 LOGD("Finish, return :%x", ret);
4381 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4386 camera_msg_param param;
4387 int set_fps = (int)fps;
4389 if (!pc || !pc->cb_info) {
4390 LOGE("NULL handle");
4391 return CAMERA_ERROR_INVALID_PARAMETER;
4396 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4398 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4400 LOGD("ret : 0x%x", ret);
4406 int camera_attr_set_image_quality(camera_h camera, int quality)
4408 int ret = CAMERA_ERROR_NONE;
4409 camera_cli_s *pc = (camera_cli_s *)camera;
4410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4411 camera_msg_param param;
4413 if (!pc || !pc->cb_info) {
4414 LOGE("NULL handle");
4415 return CAMERA_ERROR_INVALID_PARAMETER;
4420 CAMERA_MSG_PARAM_SET(param, INT, quality);
4422 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4424 LOGD("ret : 0x%x", ret);
4430 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4432 int ret = CAMERA_ERROR_NONE;
4433 camera_cli_s *pc = (camera_cli_s *)camera;
4434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4436 if (!pc || !pc->cb_info || !fps) {
4437 LOGE("NULL pointer %p %p", pc, fps);
4438 return CAMERA_ERROR_INVALID_PARAMETER;
4443 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4445 if (ret == CAMERA_ERROR_NONE)
4446 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4448 LOGD("ret : 0x%x", ret);
4454 int camera_attr_get_image_quality(camera_h camera, int *quality)
4456 int ret = CAMERA_ERROR_NONE;
4457 camera_cli_s *pc = (camera_cli_s *)camera;
4458 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4460 if (!pc || !pc->cb_info || !quality) {
4461 LOGE("NULL pointer %p %p", pc, quality);
4462 return CAMERA_ERROR_INVALID_PARAMETER;
4467 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4469 if (ret == CAMERA_ERROR_NONE)
4470 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4472 LOGD("ret : 0x%x", ret);
4478 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4480 int ret = CAMERA_ERROR_NONE;
4481 camera_cli_s *pc = (camera_cli_s *)camera;
4482 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4484 if (!pc || !pc->cb_info || !bitrate) {
4485 LOGE("NULL pointer %p %p", pc, bitrate);
4486 return CAMERA_ERROR_INVALID_PARAMETER;
4491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4493 if (ret == CAMERA_ERROR_NONE)
4494 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4496 LOGD("ret : 0x%x", ret);
4502 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4504 int ret = CAMERA_ERROR_NONE;
4505 camera_cli_s *pc = (camera_cli_s *)camera;
4506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4507 camera_msg_param param;
4508 int set_bitrate = bitrate;
4510 if (!pc || !pc->cb_info) {
4511 LOGE("NULL handle");
4512 return CAMERA_ERROR_INVALID_PARAMETER;
4517 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4519 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4521 LOGD("ret : 0x%x", ret);
4527 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4529 int ret = CAMERA_ERROR_NONE;
4530 camera_cli_s *pc = (camera_cli_s *)camera;
4531 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4533 if (!pc || !pc->cb_info || !interval) {
4534 LOGE("NULL pointer %p %p", pc, interval);
4535 return CAMERA_ERROR_INVALID_PARAMETER;
4540 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4542 if (ret == CAMERA_ERROR_NONE)
4543 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4545 LOGD("ret : 0x%x", ret);
4551 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4553 int ret = CAMERA_ERROR_NONE;
4554 camera_cli_s *pc = (camera_cli_s *)camera;
4555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4556 camera_msg_param param;
4557 int set_gop_interval = interval;
4559 if (!pc || !pc->cb_info) {
4560 LOGE("NULL handle");
4561 return CAMERA_ERROR_INVALID_PARAMETER;
4566 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4568 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4570 LOGD("ret : 0x%x", ret);
4576 int camera_attr_set_zoom(camera_h camera, int zoom)
4578 int ret = CAMERA_ERROR_NONE;
4579 camera_cli_s *pc = (camera_cli_s *)camera;
4580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4581 camera_msg_param param;
4583 if (!pc || !pc->cb_info) {
4584 LOGE("NULL handle");
4585 return CAMERA_ERROR_INVALID_PARAMETER;
4588 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4590 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4592 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4594 LOGD("ret : 0x%x", ret);
4600 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4602 int ret = CAMERA_ERROR_NONE;
4603 camera_cli_s *pc = (camera_cli_s *)camera;
4604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4605 camera_msg_param param;
4606 int set_mode = (int)mode;
4608 if (!pc || !pc->cb_info) {
4609 LOGE("NULL handle");
4610 return CAMERA_ERROR_INVALID_PARAMETER;
4613 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4615 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4617 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4623 int camera_attr_set_af_area(camera_h camera, int x, int y)
4625 int ret = CAMERA_ERROR_NONE;
4626 camera_cli_s *pc = (camera_cli_s *)camera;
4627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4628 camera_msg_param param;
4631 if (!pc || !pc->cb_info) {
4632 LOGE("NULL handle");
4633 return CAMERA_ERROR_INVALID_PARAMETER;
4636 LOGD("Enter - %d,%d", x, y);
4638 value = (x << 16) | y;
4639 CAMERA_MSG_PARAM_SET(param, INT, value);
4641 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4643 LOGD("ret : 0x%x", ret);
4649 int camera_attr_clear_af_area(camera_h camera)
4651 int ret = CAMERA_ERROR_NONE;
4652 camera_cli_s *pc = (camera_cli_s *)camera;
4653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4655 if (!pc || !pc->cb_info) {
4656 LOGE("NULL handle");
4657 return CAMERA_ERROR_INVALID_PARAMETER;
4662 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4664 LOGD("ret : 0x%x", ret);
4670 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4672 int ret = CAMERA_ERROR_NONE;
4673 camera_cli_s *pc = (camera_cli_s *)camera;
4674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4675 camera_msg_param param;
4676 int set_mode = (int)mode;
4678 if (!pc || !pc->cb_info) {
4679 LOGE("NULL handle");
4680 return CAMERA_ERROR_INVALID_PARAMETER;
4685 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4687 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4689 LOGD("ret : 0x%x", ret);
4695 int camera_attr_set_exposure(camera_h camera, int value)
4697 int ret = CAMERA_ERROR_NONE;
4698 camera_cli_s *pc = (camera_cli_s *)camera;
4699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4700 camera_msg_param param;
4702 if (!pc || !pc->cb_info) {
4703 LOGE("NULL handle");
4704 return CAMERA_ERROR_INVALID_PARAMETER;
4709 CAMERA_MSG_PARAM_SET(param, INT, value);
4711 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4713 LOGD("ret : 0x%x", ret);
4719 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4721 int ret = CAMERA_ERROR_NONE;
4722 camera_cli_s *pc = (camera_cli_s *)camera;
4723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4724 camera_msg_param param;
4725 int set_iso = (int)iso;
4727 if (!pc || !pc->cb_info) {
4728 LOGE("NULL handle");
4729 return CAMERA_ERROR_INVALID_PARAMETER;
4734 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4736 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4738 LOGD("ret : 0x%x", ret);
4744 int camera_attr_set_brightness(camera_h camera, int level)
4746 int ret = CAMERA_ERROR_NONE;
4747 camera_cli_s *pc = (camera_cli_s *)camera;
4748 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4749 camera_msg_param param;
4751 if (!pc || !pc->cb_info) {
4752 LOGE("NULL handle");
4753 return CAMERA_ERROR_INVALID_PARAMETER;
4758 CAMERA_MSG_PARAM_SET(param, INT, level);
4760 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4762 LOGD("ret : 0x%x", ret);
4768 int camera_attr_set_contrast(camera_h camera, int level)
4770 int ret = CAMERA_ERROR_NONE;
4771 camera_cli_s *pc = (camera_cli_s *)camera;
4772 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4773 camera_msg_param param;
4775 if (!pc || !pc->cb_info) {
4776 LOGE("NULL handle");
4777 return CAMERA_ERROR_INVALID_PARAMETER;
4782 CAMERA_MSG_PARAM_SET(param, INT, level);
4784 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4786 LOGD("ret : 0x%x", ret);
4792 int camera_attr_set_hue(camera_h camera, int level)
4794 int ret = CAMERA_ERROR_NONE;
4795 camera_cli_s *pc = (camera_cli_s *)camera;
4796 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4797 camera_msg_param param;
4799 if (!pc || !pc->cb_info) {
4800 LOGE("NULL handle");
4801 return CAMERA_ERROR_INVALID_PARAMETER;
4806 CAMERA_MSG_PARAM_SET(param, INT, level);
4808 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4810 LOGD("ret : 0x%x", ret);
4816 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4818 int ret = CAMERA_ERROR_NONE;
4819 camera_cli_s *pc = (camera_cli_s *)camera;
4820 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4821 camera_msg_param param;
4822 int set_whitebalance = (int)wb;
4824 if (!pc || !pc->cb_info) {
4825 LOGE("NULL handle");
4826 return CAMERA_ERROR_INVALID_PARAMETER;
4831 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4833 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4835 LOGD("ret : 0x%x", ret);
4841 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4843 int ret = CAMERA_ERROR_NONE;
4844 camera_cli_s *pc = (camera_cli_s *)camera;
4845 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4846 camera_msg_param param;
4847 int set_effect = (int)effect;
4849 if (!pc || !pc->cb_info) {
4850 LOGE("NULL handle");
4851 return CAMERA_ERROR_INVALID_PARAMETER;
4856 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4858 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4860 LOGD("ret : 0x%x", ret);
4866 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4868 int ret = CAMERA_ERROR_NONE;
4869 camera_cli_s *pc = (camera_cli_s *)camera;
4870 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4871 camera_msg_param param;
4872 int set_mode = (int)mode;
4874 if (!pc || !pc->cb_info) {
4875 LOGE("NULL handle");
4876 return CAMERA_ERROR_INVALID_PARAMETER;
4881 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4883 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4885 LOGD("ret : 0x%x", ret);
4891 int camera_attr_enable_tag(camera_h camera, bool enable)
4893 int ret = CAMERA_ERROR_NONE;
4894 camera_cli_s *pc = (camera_cli_s *)camera;
4895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4896 camera_msg_param param;
4897 int set_enable = (int)enable;
4899 if (!pc || !pc->cb_info) {
4900 LOGE("NULL handle");
4901 return CAMERA_ERROR_INVALID_PARAMETER;
4906 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4908 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4910 LOGD("ret : 0x%x", ret);
4916 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4918 int ret = CAMERA_ERROR_NONE;
4919 camera_cli_s *pc = (camera_cli_s *)camera;
4920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4921 camera_msg_param param;
4923 if (!pc || !pc->cb_info || !description) {
4924 LOGE("NULL pointer %p %p", pc, description);
4925 return CAMERA_ERROR_INVALID_PARAMETER;
4930 CAMERA_MSG_PARAM_SET(param, STRING, description);
4932 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4934 LOGD("ret : 0x%x", ret);
4940 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4942 int ret = CAMERA_ERROR_NONE;
4943 camera_cli_s *pc = (camera_cli_s *)camera;
4944 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4945 camera_msg_param param;
4946 int set_orientation = (int)orientation;
4948 if (!pc || !pc->cb_info) {
4949 LOGE("NULL handle");
4950 return CAMERA_ERROR_INVALID_PARAMETER;
4955 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4957 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4959 LOGD("ret : 0x%x", ret);
4965 int camera_attr_set_tag_software(camera_h camera, const char *software)
4967 int ret = CAMERA_ERROR_NONE;
4968 camera_cli_s *pc = (camera_cli_s *)camera;
4969 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4970 camera_msg_param param;
4972 if (!pc || !pc->cb_info || !software) {
4973 LOGE("NULL pointer %p %p", pc, software);
4974 return CAMERA_ERROR_INVALID_PARAMETER;
4977 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4979 CAMERA_MSG_PARAM_SET(param, STRING, software);
4981 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4983 LOGD("ret : 0x%x", ret);
4989 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4991 int ret = CAMERA_ERROR_NONE;
4992 camera_cli_s *pc = (camera_cli_s *)camera;
4993 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4994 double set_geotag[3] = {latitude, longitude, altitude};
4999 if (!pc || !pc->cb_info) {
5000 LOGE("NULL handle");
5001 return CAMERA_ERROR_INVALID_PARAMETER;
5006 length = sizeof(set_geotag) / sizeof(int) + \
5007 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5009 msg = muse_core_msg_new(api,
5010 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5013 LOGE("msg creation failed: api %d", api);
5014 return CAMERA_ERROR_OUT_OF_MEMORY;
5017 if (pc->cb_info->is_server_connected) {
5018 __camera_update_api_waiting(pc->cb_info, api, 1);
5020 g_mutex_lock(&pc->cb_info->fd_lock);
5021 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5022 g_mutex_unlock(&pc->cb_info->fd_lock);
5026 LOGE("message send failed");
5027 ret = CAMERA_ERROR_INVALID_OPERATION;
5029 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5032 __camera_update_api_waiting(pc->cb_info, api, -1);
5034 muse_core_msg_free(msg);
5036 LOGD("ret : 0x%x", ret);
5042 int camera_attr_remove_geotag(camera_h camera)
5044 int ret = CAMERA_ERROR_NONE;
5045 camera_cli_s *pc = (camera_cli_s *)camera;
5046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5048 if (!pc || !pc->cb_info) {
5049 LOGE("NULL handle");
5050 return CAMERA_ERROR_INVALID_PARAMETER;
5055 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5057 LOGD("ret : 0x%x", ret);
5063 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5065 int ret = CAMERA_ERROR_NONE;
5066 camera_cli_s *pc = (camera_cli_s *)camera;
5067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5068 camera_msg_param param;
5069 int set_mode = (int)mode;
5071 if (!pc || !pc->cb_info) {
5072 LOGE("NULL handle");
5073 return CAMERA_ERROR_INVALID_PARAMETER;
5078 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5080 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5082 LOGD("ret : 0x%x", ret);
5088 int camera_attr_get_zoom(camera_h camera, int *zoom)
5090 int ret = CAMERA_ERROR_NONE;
5091 camera_cli_s *pc = (camera_cli_s *)camera;
5092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5094 if (!pc || !pc->cb_info || !zoom) {
5095 LOGE("NULL pointer %p %p", pc, zoom);
5096 return CAMERA_ERROR_INVALID_PARAMETER;
5101 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5103 if (ret == CAMERA_ERROR_NONE)
5104 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5106 LOGD("ret : 0x%x", ret);
5112 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5114 int ret = CAMERA_ERROR_NONE;
5115 camera_cli_s *pc = (camera_cli_s *)camera;
5116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5118 if (!pc || !pc->cb_info || !min || !max) {
5119 LOGE("NULL pointer %p %p %p", pc, min, max);
5120 return CAMERA_ERROR_INVALID_PARAMETER;
5125 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5127 if (ret == CAMERA_ERROR_NONE) {
5128 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5129 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5132 LOGD("ret : 0x%x", ret);
5138 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5140 int ret = CAMERA_ERROR_NONE;
5141 camera_cli_s *pc = (camera_cli_s *)camera;
5142 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5144 if (!pc || !pc->cb_info || !mode) {
5145 LOGE("NULL pointer %p %p", pc, mode);
5146 return CAMERA_ERROR_INVALID_PARAMETER;
5151 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5153 if (ret == CAMERA_ERROR_NONE)
5154 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5156 LOGD("ret : 0x%x", ret);
5162 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5164 int ret = CAMERA_ERROR_NONE;
5165 camera_cli_s *pc = (camera_cli_s *)camera;
5166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5168 if (!pc || !pc->cb_info || !mode) {
5169 LOGE("NULL pointer %p %p", pc, mode);
5170 return CAMERA_ERROR_INVALID_PARAMETER;
5175 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5177 if (ret == CAMERA_ERROR_NONE)
5178 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5180 LOGD("ret : 0x%x", ret);
5186 int camera_attr_get_exposure(camera_h camera, int *value)
5188 int ret = CAMERA_ERROR_NONE;
5189 camera_cli_s *pc = (camera_cli_s *)camera;
5190 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5192 if (!pc || !pc->cb_info || !value) {
5193 LOGE("NULL pointer %p %p", pc, value);
5194 return CAMERA_ERROR_INVALID_PARAMETER;
5199 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5201 if (ret == CAMERA_ERROR_NONE)
5202 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5204 LOGD("ret : 0x%x", ret);
5210 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5212 int ret = CAMERA_ERROR_NONE;
5213 camera_cli_s *pc = (camera_cli_s *)camera;
5214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5216 if (!pc || !pc->cb_info || !min || !max) {
5217 LOGE("NULL pointer %p %p %p", pc, min, max);
5218 return CAMERA_ERROR_INVALID_PARAMETER;
5223 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5225 if (ret == CAMERA_ERROR_NONE) {
5226 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5227 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5230 LOGD("ret : 0x%x", ret);
5236 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5238 int ret = CAMERA_ERROR_NONE;
5239 camera_cli_s *pc = (camera_cli_s *)camera;
5240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5242 if (!pc || !pc->cb_info || !iso) {
5243 LOGE("NULL pointer %p %p", pc, iso);
5244 return CAMERA_ERROR_INVALID_PARAMETER;
5249 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5251 if (ret == CAMERA_ERROR_NONE)
5252 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5254 LOGD("ret : 0x%x", ret);
5260 int camera_attr_get_brightness(camera_h camera, int *level)
5262 int ret = CAMERA_ERROR_NONE;
5263 camera_cli_s *pc = (camera_cli_s *)camera;
5264 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5266 if (!pc || !pc->cb_info || !level) {
5267 LOGE("NULL pointer %p %p", pc, level);
5268 return CAMERA_ERROR_INVALID_PARAMETER;
5273 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5275 if (ret == CAMERA_ERROR_NONE)
5276 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5278 LOGD("ret : 0x%x", ret);
5284 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5286 int ret = CAMERA_ERROR_NONE;
5287 camera_cli_s *pc = (camera_cli_s *)camera;
5288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5290 if (!pc || !pc->cb_info || !min || !max) {
5291 LOGE("NULL pointer %p %p %p", pc, min, max);
5292 return CAMERA_ERROR_INVALID_PARAMETER;
5297 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5299 if (ret == CAMERA_ERROR_NONE) {
5300 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5301 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5304 LOGD("ret : 0x%x", ret);
5310 int camera_attr_get_contrast(camera_h camera, int *level)
5312 int ret = CAMERA_ERROR_NONE;
5313 camera_cli_s *pc = (camera_cli_s *)camera;
5314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5316 if (!pc || !pc->cb_info || !level) {
5317 LOGE("NULL pointer %p %p", pc, level);
5318 return CAMERA_ERROR_INVALID_PARAMETER;
5323 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5325 if (ret == CAMERA_ERROR_NONE)
5326 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5328 LOGD("ret : 0x%x", ret);
5334 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5336 int ret = CAMERA_ERROR_NONE;
5337 camera_cli_s *pc = (camera_cli_s *)camera;
5338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5340 if (!pc || !pc->cb_info || !min || !max) {
5341 LOGE("NULL pointer %p %p %p", pc, min, max);
5342 return CAMERA_ERROR_INVALID_PARAMETER;
5347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5349 if (ret == CAMERA_ERROR_NONE) {
5350 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5351 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5352 LOGD("min %d, max %d", *min, *max);
5355 LOGD("ret : 0x%x", ret);
5361 int camera_attr_get_hue(camera_h camera, int *level)
5363 int ret = CAMERA_ERROR_NONE;
5364 camera_cli_s *pc = (camera_cli_s *)camera;
5365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5367 if (!pc || !pc->cb_info || !level) {
5368 LOGE("NULL pointer %p %p", pc, level);
5369 return CAMERA_ERROR_INVALID_PARAMETER;
5374 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5376 if (ret == CAMERA_ERROR_NONE)
5377 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5379 LOGD("ret : 0x%x", ret);
5385 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5387 int ret = CAMERA_ERROR_NONE;
5388 camera_cli_s *pc = (camera_cli_s *)camera;
5389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5391 if (!pc || !pc->cb_info || !min || !max) {
5392 LOGE("NULL pointer %p %p %p", pc, min, max);
5393 return CAMERA_ERROR_INVALID_PARAMETER;
5398 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5400 if (ret == CAMERA_ERROR_NONE) {
5401 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5402 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5403 LOGD("min %d, max %d", *min, *max);
5406 LOGD("ret : 0x%x", ret);
5412 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5414 int ret = CAMERA_ERROR_NONE;
5415 camera_cli_s *pc = (camera_cli_s *)camera;
5416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5418 if (!pc || !pc->cb_info || !wb) {
5419 LOGE("NULL pointer %p %p", pc, wb);
5420 return CAMERA_ERROR_INVALID_PARAMETER;
5425 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5427 if (ret == CAMERA_ERROR_NONE)
5428 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5430 LOGD("ret : 0x%x", ret);
5436 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5438 int ret = CAMERA_ERROR_NONE;
5439 camera_cli_s *pc = (camera_cli_s *)camera;
5440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5442 if (!pc || !pc->cb_info || !effect) {
5443 LOGE("NULL pointer %p %p", pc, effect);
5444 return CAMERA_ERROR_INVALID_PARAMETER;
5449 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5451 if (ret == CAMERA_ERROR_NONE)
5452 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5454 LOGD("ret : 0x%x", ret);
5460 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5462 int ret = CAMERA_ERROR_NONE;
5463 camera_cli_s *pc = (camera_cli_s *)camera;
5464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5466 if (!pc || !pc->cb_info || !mode) {
5467 LOGE("NULL pointer %p %p", pc, mode);
5468 return CAMERA_ERROR_INVALID_PARAMETER;
5473 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5475 if (ret == CAMERA_ERROR_NONE)
5476 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5478 LOGD("ret : 0x%x", ret);
5484 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5486 int ret = CAMERA_ERROR_NONE;
5487 camera_cli_s *pc = (camera_cli_s *)camera;
5488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5490 if (!pc || !pc->cb_info || !enable) {
5491 LOGE("NULL pointer %p %p", pc, enable);
5492 return CAMERA_ERROR_INVALID_PARAMETER;
5497 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5499 if (ret == CAMERA_ERROR_NONE)
5500 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5502 LOGD("ret : 0x%x", ret);
5508 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5510 int ret = CAMERA_ERROR_NONE;
5511 camera_cli_s *pc = (camera_cli_s *)camera;
5512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5514 if (!pc || !pc->cb_info || !description) {
5515 LOGE("NULL pointer %p %p", pc, description);
5516 return CAMERA_ERROR_INVALID_PARAMETER;
5521 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5523 if (ret == CAMERA_ERROR_NONE)
5524 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5526 LOGD("ret : 0x%x", ret);
5532 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5534 int ret = CAMERA_ERROR_NONE;
5535 camera_cli_s *pc = (camera_cli_s *)camera;
5536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5538 if (!pc || !pc->cb_info || !orientation) {
5539 LOGE("NULL pointer %p %p", pc, orientation);
5540 return CAMERA_ERROR_INVALID_PARAMETER;
5545 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5547 if (ret == CAMERA_ERROR_NONE)
5548 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5550 LOGD("ret : 0x%x", ret);
5556 int camera_attr_get_tag_software(camera_h camera, char **software)
5558 int ret = CAMERA_ERROR_NONE;
5559 camera_cli_s *pc = (camera_cli_s *)camera;
5560 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5562 if (!pc || !pc->cb_info || !software) {
5563 LOGE("NULL pointer %p %p", pc, software);
5564 return CAMERA_ERROR_INVALID_PARAMETER;
5569 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5571 if (ret == CAMERA_ERROR_NONE)
5572 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5574 LOGD("ret : 0x%x", ret);
5580 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5582 int ret = CAMERA_ERROR_NONE;
5583 camera_cli_s *pc = (camera_cli_s *)camera;
5584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5586 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5587 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5588 return CAMERA_ERROR_INVALID_PARAMETER;
5593 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5595 if (ret == CAMERA_ERROR_NONE) {
5596 *latitude = pc->cb_info->get_geotag[0];
5597 *longitude = pc->cb_info->get_geotag[1];
5598 *altitude = pc->cb_info->get_geotag[2];
5601 LOGD("ret : 0x%x", ret);
5607 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5609 int ret = CAMERA_ERROR_NONE;
5610 camera_cli_s *pc = (camera_cli_s *)camera;
5611 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5613 if (!pc || !pc->cb_info || !mode) {
5614 LOGE("NULL pointer %p %p", pc, mode);
5615 return CAMERA_ERROR_INVALID_PARAMETER;
5620 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5622 if (ret == CAMERA_ERROR_NONE)
5623 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5625 LOGD("ret : 0x%x", ret);
5631 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5633 int ret = CAMERA_ERROR_NONE;
5634 int get_flash_state = 0;
5637 LOGE("NULL pointer");
5638 return CAMERA_ERROR_INVALID_PARAMETER;
5641 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5642 (int)device, "get_flash_state", &get_flash_state);
5644 if (ret == CAMERA_ERROR_NONE) {
5645 *state = (camera_flash_state_e)get_flash_state;
5646 LOGD("flash state %d", *state);
5648 LOGE("failed 0x%x", ret);
5655 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5657 int ret = CAMERA_ERROR_NONE;
5658 camera_cli_s *pc = (camera_cli_s *)camera;
5659 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5661 if (!pc || !pc->cb_info || !foreach_cb) {
5662 LOGE("NULL pointer %p %p", pc, foreach_cb);
5663 return CAMERA_ERROR_INVALID_PARAMETER;
5668 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5669 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5671 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5673 LOGD("ret : 0x%x", ret);
5679 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5681 int ret = CAMERA_ERROR_NONE;
5682 camera_cli_s *pc = (camera_cli_s *)camera;
5683 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5685 if (!pc || !pc->cb_info || !foreach_cb) {
5686 LOGE("NULL pointer %p %p", pc, foreach_cb);
5687 return CAMERA_ERROR_INVALID_PARAMETER;
5692 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5693 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5695 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5697 LOGD("ret : 0x%x", ret);
5703 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5705 int ret = CAMERA_ERROR_NONE;
5706 camera_cli_s *pc = (camera_cli_s *)camera;
5707 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5709 if (!pc || !pc->cb_info || !foreach_cb) {
5710 LOGE("NULL pointer %p %p", pc, foreach_cb);
5711 return CAMERA_ERROR_INVALID_PARAMETER;
5716 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5717 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5719 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5721 LOGD("ret : 0x%x", ret);
5727 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5729 int ret = CAMERA_ERROR_NONE;
5730 camera_cli_s *pc = (camera_cli_s *)camera;
5731 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5733 if (!pc || !pc->cb_info || !foreach_cb) {
5734 LOGE("NULL pointer %p %p", pc, foreach_cb);
5735 return CAMERA_ERROR_INVALID_PARAMETER;
5740 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5741 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5743 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5745 LOGD("ret : 0x%x", ret);
5751 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5753 int ret = CAMERA_ERROR_NONE;
5754 camera_cli_s *pc = (camera_cli_s *)camera;
5755 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5757 if (!pc || !pc->cb_info || !foreach_cb) {
5758 LOGE("NULL pointer %p %p", pc, foreach_cb);
5759 return CAMERA_ERROR_INVALID_PARAMETER;
5764 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5765 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5767 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5769 LOGD("ret : 0x%x", ret);
5775 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5777 int ret = CAMERA_ERROR_NONE;
5778 camera_cli_s *pc = (camera_cli_s *)camera;
5779 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5781 if (!pc || !pc->cb_info || !foreach_cb) {
5782 LOGE("NULL pointer %p %p", pc, foreach_cb);
5783 return CAMERA_ERROR_INVALID_PARAMETER;
5788 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5789 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5791 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5793 LOGD("ret : 0x%x", ret);
5799 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5801 int ret = CAMERA_ERROR_NONE;
5802 camera_cli_s *pc = (camera_cli_s *)camera;
5803 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5805 if (!pc || !pc->cb_info || !foreach_cb) {
5806 LOGE("NULL pointer %p %p", pc, foreach_cb);
5807 return CAMERA_ERROR_INVALID_PARAMETER;
5812 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5813 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5815 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5817 LOGD("ret : 0x%x", ret);
5823 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5825 int ret = CAMERA_ERROR_NONE;
5826 camera_cli_s *pc = (camera_cli_s *)camera;
5827 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5829 if (!pc || !pc->cb_info || !foreach_cb) {
5830 LOGE("NULL pointer %p %p", pc, foreach_cb);
5831 return CAMERA_ERROR_INVALID_PARAMETER;
5836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5839 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5841 LOGD("Enter, handle :%td", pc->remote_handle);
5847 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)
5849 int ret = CAMERA_ERROR_NONE;
5850 camera_cli_s *pc = (camera_cli_s *)camera;
5851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5852 camera_msg_param param;
5855 if (!pc || !pc->cb_info || !foreach_cb) {
5856 LOGE("NULL pointer %p %p", pc, foreach_cb);
5857 return CAMERA_ERROR_INVALID_PARAMETER;
5862 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5863 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5865 value = (width << 16) | height;
5866 CAMERA_MSG_PARAM_SET(param, INT, value);
5868 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5870 LOGD("ret : 0x%x", ret);
5876 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5878 int ret = CAMERA_ERROR_NONE;
5879 camera_cli_s *pc = (camera_cli_s *)camera;
5880 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5882 if (!pc || !pc->cb_info || !foreach_cb) {
5883 LOGE("NULL pointer %p %p", pc, foreach_cb);
5884 return CAMERA_ERROR_INVALID_PARAMETER;
5889 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5890 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5892 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5894 LOGD("ret : 0x%x", ret);
5900 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5902 int ret = CAMERA_ERROR_NONE;
5903 camera_cli_s *pc = (camera_cli_s *)camera;
5904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5906 if (!pc || !pc->cb_info || !foreach_cb) {
5907 LOGE("NULL pointer %p %p", pc, foreach_cb);
5908 return CAMERA_ERROR_INVALID_PARAMETER;
5913 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5914 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5916 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5918 LOGD("ret : 0x%x", ret);
5924 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5926 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5929 camera_msg_param param;
5930 int set_rotation = (int)rotation;
5932 if (!pc || !pc->cb_info) {
5933 LOGE("NULL handle");
5934 return CAMERA_ERROR_INVALID_PARAMETER;
5939 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5941 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5943 LOGD("ret : 0x%x", ret);
5949 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5951 int ret = CAMERA_ERROR_NONE;
5952 camera_cli_s *pc = (camera_cli_s *)camera;
5953 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5955 if (!pc || !pc->cb_info || !rotation) {
5956 LOGE("NULL pointer %p %p", pc, rotation);
5957 return CAMERA_ERROR_INVALID_PARAMETER;
5962 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5964 if (ret == CAMERA_ERROR_NONE)
5965 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5967 LOGD("ret : 0x%x", ret);
5973 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5975 int ret = CAMERA_ERROR_NONE;
5976 camera_cli_s *pc = (camera_cli_s *)camera;
5977 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5978 camera_msg_param param;
5979 int set_flip = (int)flip;
5981 if (!pc || !pc->cb_info) {
5982 LOGE("NULL handle");
5983 return CAMERA_ERROR_INVALID_PARAMETER;
5988 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5990 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5992 LOGD("ret : 0x%x", ret);
5998 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6000 int ret = CAMERA_ERROR_NONE;
6001 camera_cli_s *pc = (camera_cli_s *)camera;
6002 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6004 if (!pc || !pc->cb_info || !flip) {
6005 LOGE("NULL pointer %p %p", pc, flip);
6006 return CAMERA_ERROR_INVALID_PARAMETER;
6011 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6013 if (ret == CAMERA_ERROR_NONE)
6014 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6016 LOGD("ret : 0x%x", ret);
6021 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6023 int ret = CAMERA_ERROR_NONE;
6024 camera_cli_s *pc = (camera_cli_s *)camera;
6025 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6026 camera_msg_param param;
6027 int set_mode = (int)mode;
6029 if (!pc || !pc->cb_info) {
6030 LOGE("NULL handle");
6031 return CAMERA_ERROR_INVALID_PARAMETER;
6036 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6038 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6040 LOGD("ret : 0x%x", ret);
6046 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6048 int ret = CAMERA_ERROR_NONE;
6049 camera_cli_s *pc = (camera_cli_s *)camera;
6050 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6052 if (!pc || !pc->cb_info || !mode) {
6053 LOGE("NULL pointer %p %p", pc, mode);
6054 return CAMERA_ERROR_INVALID_PARAMETER;
6059 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6061 if (ret == CAMERA_ERROR_NONE)
6062 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6064 LOGD("ret : 0x%x", ret);
6070 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6072 int ret = CAMERA_ERROR_NONE;
6073 camera_cli_s *pc = (camera_cli_s *)camera;
6074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6076 if (!pc || !pc->cb_info) {
6077 LOGE("NULL handle");
6078 return CAMERA_ERROR_INVALID_PARAMETER;
6083 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6086 LOGE("error is occurred 0x%x", ret);
6090 LOGD("ret : %d", ret);
6096 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6098 int ret = CAMERA_ERROR_NONE;
6099 camera_cli_s *pc = (camera_cli_s *)camera;
6100 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6102 if (!pc || !pc->cb_info) {
6103 LOGE("NULL handle");
6104 return CAMERA_ERROR_INVALID_PARAMETER;
6109 if (!camera_attr_is_supported_hdr_capture(camera)) {
6110 LOGE("HDR not supported");
6111 return CAMERA_ERROR_NOT_SUPPORTED;
6115 LOGE("NULL callback");
6116 return CAMERA_ERROR_INVALID_PARAMETER;
6119 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6121 if (ret == CAMERA_ERROR_NONE) {
6122 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6124 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6125 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6127 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6130 LOGD("ret : 0x%x", ret);
6136 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6138 int ret = CAMERA_ERROR_NONE;
6139 camera_cli_s *pc = (camera_cli_s *)camera;
6140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6142 if (!pc || !pc->cb_info) {
6143 LOGE("NULL handle");
6144 return CAMERA_ERROR_INVALID_PARAMETER;
6149 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6151 if (ret == CAMERA_ERROR_NONE) {
6152 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6154 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6155 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6157 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6160 LOGD("ret : 0x%x", ret);
6166 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6168 int ret = CAMERA_ERROR_NONE;
6169 camera_cli_s *pc = (camera_cli_s *)camera;
6170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6171 camera_msg_param param;
6172 int set_enable = (int)enable;
6174 if (!pc || !pc->cb_info) {
6175 LOGE("NULL handle");
6176 return CAMERA_ERROR_INVALID_PARAMETER;
6181 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6183 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6185 LOGD("ret : 0x%x", ret);
6191 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6193 int ret = CAMERA_ERROR_NONE;
6194 camera_cli_s *pc = (camera_cli_s *)camera;
6195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6197 if (!pc || !pc->cb_info || !enabled) {
6198 LOGE("NULL pointer %p %p", pc, enabled);
6199 return CAMERA_ERROR_INVALID_PARAMETER;
6204 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6206 if (ret == CAMERA_ERROR_NONE)
6207 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6209 LOGD("ret : 0x%x", ret);
6215 bool camera_attr_is_supported_anti_shake(camera_h camera)
6217 int ret = CAMERA_ERROR_NONE;
6218 camera_cli_s *pc = (camera_cli_s *)camera;
6219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6221 if (!pc || !pc->cb_info) {
6222 LOGE("NULL handle");
6223 return CAMERA_ERROR_INVALID_PARAMETER;
6228 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6231 LOGE("error is occurred 0x%x", ret);
6235 LOGD("ret : %d", ret);
6241 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6243 int ret = CAMERA_ERROR_NONE;
6244 camera_cli_s *pc = (camera_cli_s *)camera;
6245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6246 camera_msg_param param;
6247 int set_enable = (int)enable;
6249 if (!pc || !pc->cb_info) {
6250 LOGE("NULL handle");
6251 return CAMERA_ERROR_INVALID_PARAMETER;
6256 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6258 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6260 LOGD("ret : 0x%x", ret);
6266 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6268 int ret = CAMERA_ERROR_NONE;
6269 camera_cli_s *pc = (camera_cli_s *)camera;
6270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6272 if (!pc || !pc->cb_info || !enabled) {
6273 LOGE("NULL pointer %p %p", pc, enabled);
6274 return CAMERA_ERROR_INVALID_PARAMETER;
6279 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6281 if (ret == CAMERA_ERROR_NONE)
6282 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6284 LOGD("ret : 0x%x", ret);
6290 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6292 int ret = CAMERA_ERROR_NONE;
6293 camera_cli_s *pc = (camera_cli_s *)camera;
6294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6296 if (!pc || !pc->cb_info) {
6297 LOGE("NULL handle");
6298 return CAMERA_ERROR_INVALID_PARAMETER;
6303 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6306 LOGE("error is occurred 0x%x", ret);
6310 LOGD("ret : %d", ret);
6316 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6318 int ret = CAMERA_ERROR_NONE;
6319 camera_cli_s *pc = (camera_cli_s *)camera;
6320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6321 camera_msg_param param;
6322 int set_enable = (int)enable;
6324 if (!pc || !pc->cb_info) {
6325 LOGE("NULL handle");
6326 return CAMERA_ERROR_INVALID_PARAMETER;
6331 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6333 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6335 LOGD("ret : 0x%x", ret);
6341 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6343 int ret = CAMERA_ERROR_NONE;
6344 camera_cli_s *pc = (camera_cli_s *)camera;
6345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6347 if (!pc || !pc->cb_info || !enabled) {
6348 LOGE("NULL pointer %p %p", pc, enabled);
6349 return CAMERA_ERROR_INVALID_PARAMETER;
6354 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6356 if (ret == CAMERA_ERROR_NONE)
6357 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6359 LOGD("ret : 0x%x", ret);
6365 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6367 int ret = CAMERA_ERROR_NONE;
6368 camera_cli_s *pc = (camera_cli_s *)camera;
6369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6371 if (!pc || !pc->cb_info) {
6372 LOGE("NULL handle");
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6378 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6381 LOGE("error is occurred 0x%x", ret);
6385 LOGD("ret : %d", ret);
6391 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6393 int ret = CAMERA_ERROR_NONE;
6394 camera_cli_s *pc = (camera_cli_s *)camera;
6395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6396 camera_msg_param param;
6397 int set_disable = (int)disable;
6399 if (!pc || !pc->cb_info) {
6400 LOGE("NULL handle");
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6406 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6408 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6410 LOGD("ret : 0x%x", ret);
6416 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6418 int ret = CAMERA_ERROR_NONE;
6419 camera_cli_s *pc = (camera_cli_s *)camera;
6420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6421 camera_msg_param param0;
6422 camera_msg_param param1;
6424 if (!pc || !pc->cb_info) {
6425 LOGE("NULL handle");
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6432 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6434 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6435 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6437 LOGD("ret : 0x%x", ret);
6443 int camera_attr_get_pan(camera_h camera, int *pan_step)
6445 int ret = CAMERA_ERROR_NONE;
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6449 if (!pc || !pc->cb_info || !pan_step) {
6450 LOGE("NULL pointer %p %p", pc, pan_step);
6451 return CAMERA_ERROR_INVALID_PARAMETER;
6456 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6458 if (ret == CAMERA_ERROR_NONE)
6459 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6461 LOGD("ret : 0x%x", ret);
6467 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6469 int ret = CAMERA_ERROR_NONE;
6470 camera_cli_s *pc = (camera_cli_s *)camera;
6471 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6473 if (!pc || !pc->cb_info || !min || !max) {
6474 LOGE("NULL pointer %p %p %p", pc, min, max);
6475 return CAMERA_ERROR_INVALID_PARAMETER;
6480 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6482 if (ret == CAMERA_ERROR_NONE) {
6483 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6484 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6487 LOGD("ret : 0x%x", ret);
6493 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6495 int ret = CAMERA_ERROR_NONE;
6496 camera_cli_s *pc = (camera_cli_s *)camera;
6497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6498 camera_msg_param param0;
6499 camera_msg_param param1;
6501 if (!pc || !pc->cb_info) {
6502 LOGE("NULL handle");
6503 return CAMERA_ERROR_INVALID_PARAMETER;
6508 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6509 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6511 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6512 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6514 LOGD("ret : 0x%x", ret);
6520 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6522 int ret = CAMERA_ERROR_NONE;
6523 camera_cli_s *pc = (camera_cli_s *)camera;
6524 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6526 if (!pc || !pc->cb_info || !tilt_step) {
6527 LOGE("NULL pointer %p %p", pc, tilt_step);
6528 return CAMERA_ERROR_INVALID_PARAMETER;
6533 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6535 if (ret == CAMERA_ERROR_NONE)
6536 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6538 LOGD("ret : 0x%x", ret);
6544 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6546 int ret = CAMERA_ERROR_NONE;
6547 camera_cli_s *pc = (camera_cli_s *)camera;
6548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6550 if (!pc || !pc->cb_info || !min || !max) {
6551 LOGE("NULL pointer %p %p %p", pc, min, max);
6552 return CAMERA_ERROR_INVALID_PARAMETER;
6557 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6559 if (ret == CAMERA_ERROR_NONE) {
6560 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6561 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6564 LOGD("ret : 0x%x", ret);
6570 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6572 int ret = CAMERA_ERROR_NONE;
6573 camera_cli_s *pc = (camera_cli_s *)camera;
6574 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6575 camera_msg_param param;
6576 int set_ptz_type = (int)ptz_type;
6578 if (!pc || !pc->cb_info) {
6579 LOGE("NULL handle");
6580 return CAMERA_ERROR_INVALID_PARAMETER;
6585 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6587 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6589 LOGD("ret : 0x%x", ret);
6595 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6597 int ret = CAMERA_ERROR_NONE;
6598 camera_cli_s *pc = (camera_cli_s *)camera;
6599 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6601 if (!pc || !pc->cb_info || !foreach_cb) {
6602 LOGE("NULL pointer %p %p", pc, foreach_cb);
6603 return CAMERA_ERROR_INVALID_PARAMETER;
6608 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6609 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6611 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6613 LOGD("ret : 0x%x", ret);
6619 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6621 int ret = CAMERA_ERROR_NONE;
6622 camera_cli_s *pc = (camera_cli_s *)camera;
6623 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6624 int set_display_roi_area[4] = {x, y, width, height};
6629 if (!pc || !pc->cb_info) {
6630 LOGE("NULL handle");
6631 return CAMERA_ERROR_INVALID_PARAMETER;
6636 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6637 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6638 if (ret != MM_ERROR_NONE) {
6639 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6640 return CAMERA_ERROR_INVALID_OPERATION;
6644 length = sizeof(set_display_roi_area) / sizeof(int) + \
6645 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6647 msg = muse_core_msg_new(api,
6648 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6651 LOGE("msg creation failed: api %d", api);
6652 return CAMERA_ERROR_OUT_OF_MEMORY;
6655 if (pc->cb_info->is_server_connected) {
6656 __camera_update_api_waiting(pc->cb_info, api, 1);
6658 g_mutex_lock(&pc->cb_info->fd_lock);
6659 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6660 g_mutex_unlock(&pc->cb_info->fd_lock);
6664 LOGE("message send failed");
6665 ret = CAMERA_ERROR_INVALID_OPERATION;
6667 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6670 __camera_update_api_waiting(pc->cb_info, api, -1);
6672 muse_core_msg_free(msg);
6674 LOGD("ret : 0x%x", ret);
6680 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6682 camera_cli_s *pc = (camera_cli_s *)camera;
6683 int ret = CAMERA_ERROR_NONE;
6684 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6686 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6687 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6688 return CAMERA_ERROR_INVALID_PARAMETER;
6693 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6695 if (ret == CAMERA_ERROR_NONE) {
6696 *x = pc->cb_info->get_display_roi_area[0];
6697 *y = pc->cb_info->get_display_roi_area[1];
6698 *width = pc->cb_info->get_display_roi_area[2];
6699 *height = pc->cb_info->get_display_roi_area[3];
6702 LOGD("ret : 0x%x", ret);
6708 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6710 int ret = CAMERA_ERROR_NONE;
6711 int get_device_state = 0;
6714 LOGE("NULL pointer");
6715 return CAMERA_ERROR_INVALID_PARAMETER;
6718 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6719 (int)device, "get_device_state", &get_device_state);
6721 if (ret == CAMERA_ERROR_NONE) {
6722 *state = (camera_device_state_e)get_device_state;
6723 LOGD("device state %d", *state);
6725 LOGE("failed 0x%x", ret);
6732 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6734 int ret = CAMERA_ERROR_NONE;
6735 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6736 camera_cb_info *info = NULL;
6738 if (!callback || !cb_id) {
6739 LOGE("invalid pointer %p %p", callback, cb_id);
6740 return CAMERA_ERROR_INVALID_PARAMETER;
6743 /* check camera support */
6744 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6745 if (ret != CAMERA_ERROR_NONE) {
6746 LOGE("get device state failed");
6750 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6752 info = g_new0(camera_cb_info, 1);
6754 LOGE("info failed");
6755 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6759 info->id = ++g_cam_dev_state_changed_cb_id;
6760 info->callback = (void *)callback;
6761 info->user_data = user_data;
6765 /* subscribe dbus signal for camera state change */
6766 if (!g_cam_dev_state_changed_cb_conn) {
6767 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6768 if (!g_cam_dev_state_changed_cb_conn) {
6769 LOGE("failed to get gdbus connection");
6770 ret = CAMERA_ERROR_INVALID_OPERATION;
6774 LOGD("subscribe signal %s - %s - %s",
6775 MM_CAMCORDER_DBUS_OBJECT,
6776 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6777 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6779 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6780 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6781 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6782 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6783 LOGE("failed to get gdbus connection");
6784 ret = CAMERA_ERROR_INVALID_OPERATION;
6788 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6791 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6793 LOGD("callback id %d", info->id);
6796 if (ret != CAMERA_ERROR_NONE) {
6802 if (g_cam_dev_state_changed_cb_conn) {
6803 g_object_unref(g_cam_dev_state_changed_cb_conn);
6804 g_cam_dev_state_changed_cb_conn = NULL;
6808 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6814 int camera_remove_device_state_changed_cb(int cb_id)
6816 int ret = CAMERA_ERROR_NONE;
6817 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6818 GList *tmp_list = NULL;
6819 camera_cb_info *info = NULL;
6821 /* check camera support */
6822 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6823 if (ret != CAMERA_ERROR_NONE) {
6824 LOGE("get device state failed");
6828 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6830 if (!g_cam_dev_state_changed_cb_list) {
6831 LOGE("there is no callback info");
6832 ret = CAMERA_ERROR_INVALID_OPERATION;
6836 tmp_list = g_cam_dev_state_changed_cb_list;
6839 info = tmp_list->data;
6840 tmp_list = tmp_list->next;
6847 if (info->id == cb_id) {
6848 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6853 if (!g_cam_dev_state_changed_cb_list) {
6854 /* no remained callback */
6855 if (g_cam_dev_state_changed_cb_conn) {
6856 /* unsubscribe signal */
6857 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6858 g_cam_dev_state_changed_cb_subscribe_id = 0;
6860 /* unref connection */
6861 g_object_unref(g_cam_dev_state_changed_cb_conn);
6862 g_cam_dev_state_changed_cb_conn = NULL;
6866 LOGD("id %d callback removed", cb_id);
6867 ret = CAMERA_ERROR_NONE;
6873 LOGE("id %d callback not found", cb_id);
6874 ret = CAMERA_ERROR_INVALID_PARAMETER;
6877 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);