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 <mm_camcorder.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_client.h>
34 #define LOG_TAG "TIZEN_N_CAMERA"
35 #define MODULE_NAME "camera"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
44 static GMutex g_cam_idle_event_lock;
47 static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO;
49 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
50 static void __camera_release_imported_bo(tbm_bo *bo);
52 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
53 camera_media_packet_data *mp_data, media_packet_h *packet);
54 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
55 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
56 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
58 static gboolean __camera_allocate_preview_buffer(camera_h camera);
59 static void __camera_release_preview_buffer(camera_h camera);
60 static void __camera_release_tfd(int tfd[MUSE_NUM_FD]);
62 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
63 int type, const char *thread_name, camera_cb_info_s *cb_info);
64 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info);
68 static gboolean __camera_allocate_preview_buffer(camera_h camera)
71 int ret = CAMERA_ERROR_NONE;
72 int format = CAMERA_PIXEL_FORMAT_INVALID;
76 camera_cli_s *pc = (camera_cli_s *)camera;
77 camera_cb_info_s *cb_info = NULL;
79 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
81 cb_info = pc->cb_info;
83 CAM_LOG_INFO("Enter");
85 /* get preview info and calculate size */
86 ret = camera_get_preview_format(camera, &format);
87 if (ret != CAMERA_ERROR_NONE) {
88 CAM_LOG_ERROR("get preview format failed 0x%x", ret);
92 ret = camera_get_preview_resolution(camera, &width, &height);
93 if (ret != CAMERA_ERROR_NONE) {
94 CAM_LOG_ERROR("get preview resolution failed 0x%x", ret);
98 CAM_LOG_INFO("preview %dx%d, format %d", width, height, format);
101 case CAMERA_PIXEL_FORMAT_INVZ:
102 buffer_size = width * height;
104 case CAMERA_PIXEL_FORMAT_NV12:
105 case CAMERA_PIXEL_FORMAT_I420:
106 buffer_size = (width * height * 3) >> 1;
108 case CAMERA_PIXEL_FORMAT_YUYV:
109 case CAMERA_PIXEL_FORMAT_UYVY:
110 buffer_size = width * height * 2;
113 CAM_LOG_ERROR("unhandled format %d", format);
114 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
117 CAM_LOG_INFO("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
119 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
120 cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
121 if (!cb_info->bos[i]) {
122 CAM_LOG_ERROR("bo alloc failed [%d,i:%d]", buffer_size, i);
123 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
126 cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
127 if (cb_info->fds[i] < 0) {
128 CAM_LOG_ERROR("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
129 goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
132 CAM_LOG_INFO("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
135 CAM_LOG_INFO("Done");
139 _ALLOCATE_PREVIEW_BUFFER_FAILED:
140 __camera_release_preview_buffer(camera);
145 static void __camera_release_preview_buffer(camera_h camera)
148 camera_cli_s *pc = (camera_cli_s *)camera;
149 camera_cb_info_s *cb_info = NULL;
151 CAMERA_CHECK_HANDLE_RETURN(pc);
153 CAM_LOG_INFO("Enter");
155 cb_info = pc->cb_info;
157 /* close exported fd and bos */
158 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
159 CAM_LOG_INFO("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
161 if (cb_info->bos[i]) {
162 tbm_bo_unref(cb_info->bos[i]);
163 cb_info->bos[i] = NULL;
168 if (CAMERA_IS_FD_VALID(cb_info->fds[i])) {
169 close(cb_info->fds[i]);
170 cb_info->fds[i] = CAMERA_FD_INIT;
174 CAM_LOG_INFO("Done");
178 static void __camera_release_tfd(int tfd[MUSE_NUM_FD])
183 CAM_LOG_WARNING("NULL tfd");
187 for (i = 0 ; i < MUSE_NUM_FD ; i++) {
188 if (!CAMERA_IS_FD_VALID(tfd[i]))
192 tfd[i] = CAMERA_FD_INIT;
197 void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
200 api < 0 || api >= MUSE_CAMERA_API_MAX) {
201 CAM_LOG_ERROR("invalid param %p %d", cb_info, api);
205 g_mutex_lock(&(cb_info->api_mutex[api]));
206 cb_info->api_waiting[api] += value;
207 g_mutex_unlock(&(cb_info->api_mutex[api]));
209 CAM_LOG_DEBUG("api[%d], value[%d], waiting[%d]",
210 api, value, cb_info->api_waiting[api]);
214 static void __camera_device_state_changed_cb(GDBusConnection *connection,
215 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
216 const gchar *signal_name, GVariant *param, gpointer user_data)
219 camera_device_e device = CAMERA_DEVICE_CAMERA0;
220 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
221 GList *tmp_list = NULL;
222 camera_cb_info *info = NULL;
224 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
226 if (!g_cam_dev_state_changed_cb_list || !param) {
227 CAM_LOG_WARNING("no callback or NULL param %p", param);
231 /* get device and state */
232 g_variant_get(param, "(i)", &value);
234 device = value >> 16;
235 state = 0x0000ffff & value;
237 CAM_LOG_INFO("device %d, state %d", device, state);
239 tmp_list = g_cam_dev_state_changed_cb_list;
242 info = (camera_cb_info *)tmp_list->data;
245 if (info->callback) {
246 CAM_LOG_INFO("start id[%d] callback", info->id);
247 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
248 CAM_LOG_INFO("returned id[%d] callback", info->id);
250 CAM_LOG_WARNING("NULL callback for id %d", info->id);
254 tmp_list = tmp_list->next;
258 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
262 static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
265 CAM_LOG_ERROR("NULL info_sub");
269 info_sub->frame_count = 0;
270 info_sub->elapsed_sec_accum = 0.0;
271 info_sub->elapsed_sec_peak = 0.0;
275 static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
278 CAM_LOG_ERROR("NULL info");
282 __camera_preview_cb_monitoring_info_sub_reset(info->total);
283 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
287 static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
290 CAM_LOG_ERROR("NULL info");
294 g_timer_start(info->timer_calling);
296 if (info->interval->frame_count == 0)
297 g_timer_start(info->timer_interval);
301 static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
304 CAM_LOG_ERROR("NULL info_sub");
308 info_sub->frame_count++;
309 info_sub->elapsed_sec_accum += elapsed_sec;
311 if (info_sub->elapsed_sec_peak < elapsed_sec)
312 info_sub->elapsed_sec_peak = elapsed_sec;
316 static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
318 gdouble elapsed_sec = 0.0;
319 gdouble elapsed_sec_interval = 0.0;
322 CAM_LOG_ERROR("NULL info");
326 elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
327 elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
329 __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
330 __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
332 if (elapsed_sec_interval >= 1.0) {
333 CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
334 info->stream_id, info->total->frame_count, info->interval->frame_count,
335 (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
336 (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
337 (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
339 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
344 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
348 int ret_fd = CAMERA_FD_INIT;
349 int preview_fd = CAMERA_FD_INIT;
350 int num_buffer_fd = 0;
351 unsigned char *buf_pos = NULL;
354 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
355 tbm_bo_handle bo_handle = {.ptr = NULL};
356 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
357 tbm_bo data_bo = NULL;
358 tbm_bo_handle data_bo_handle = {.ptr = NULL};
360 camera_msg_param param;
361 camera_preview_data_s frame;
362 MMCamcorderVideoStreamDataType *stream = NULL;
363 camera_media_packet_data *mp_data = NULL;
364 media_packet_h pkt = NULL;
365 camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
367 /* tfd[0]: MMCamcorderVideoStreamDataType
368 tfd[1]: data_bo or zero copy bo[0]
369 tfd[2]: zero copy bo[1]
370 tfd[3]: zero copy bo[2] */
372 if (!cb_info || !recv_msg || !tfd) {
373 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
377 muse_camera_msg_get(preview_fd, recv_msg);
378 muse_camera_msg_get(num_buffer_fd, recv_msg);
380 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
382 memset(&frame, 0x0, sizeof(camera_preview_data_s));
385 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
390 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
392 if (cb_info->invoke_preview_cb == FALSE) {
393 CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
394 goto _PREVIEW_CB_HANDLER_DONE;
397 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
398 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
399 goto _PREVIEW_CB_HANDLER_DONE;
402 /* import tbm bo and get virtual address */
403 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
404 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
405 goto _PREVIEW_CB_HANDLER_DONE;
408 buf_pos = (unsigned char *)bo_handle.ptr;
410 /* get stream info */
411 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
413 CAM_LOG_VERBOSE("meta [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu]",
414 stream->frame_meta.ts_soe, stream->frame_meta.ts_eoe,
415 stream->frame_meta.ts_sof, stream->frame_meta.ts_eof,
416 stream->frame_meta.ts_hal, stream->frame_meta.ts_qmf,
417 stream->frame_meta.ts_gst, stream->frame_meta.td_exp,
418 stream->frame_meta.ts_aux, stream->frame_meta.td_aux,
419 stream->frame_meta.seqnum, stream->frame_meta.flags);
421 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
422 /* import tbm data_bo and get virtual address */
423 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
424 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
425 goto _PREVIEW_CB_HANDLER_DONE;
428 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
429 stream->data.encoded.data = data_bo_handle.ptr;
431 for (i = 0 ; i < num_buffer_fd ; i++) {
432 /* import buffer bo and get virtual address */
433 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
434 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
435 goto _PREVIEW_CB_HANDLER_DONE;
439 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
440 stream->data.encoded.data = buffer_bo_handle[0].ptr;
443 /* preview callback */
444 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
445 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
446 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
448 /* set stream data for camera_get_preview_frame_rotation() */
449 cb_info->stream_data = stream;
451 if (stream->extra_stream_id < 0) {
452 monitoring_info = cb_info->monitoring_info_preview;
453 __camera_preview_cb_monitoring_info_start(monitoring_info);
455 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
456 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
457 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
459 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
460 __camera_preview_cb_monitoring_info_start(monitoring_info);
462 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
463 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
464 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
467 __camera_preview_cb_monitoring_info_end(monitoring_info);
469 cb_info->stream_data = NULL;
472 if (stream->extra_stream_id >= 0)
473 goto _PREVIEW_CB_HANDLER_DONE;
475 /* make media packet with below cases.
476 * 1. media_packet_preview_cb is set
477 * 2. EVAS display rendering
478 * 3. media bridge is set
480 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
481 cb_info->is_evas_render ||
483 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
484 if (ret != CAMERA_ERROR_NONE) {
485 CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
486 goto _PREVIEW_CB_HANDLER_DONE;
489 ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
490 if (ret != CAMERA_ERROR_NONE) {
491 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
492 __camera_release_media_packet_data(mp_data, cb_info);
494 goto _PREVIEW_CB_HANDLER_DONE;
498 /* 1. media packet preview callback */
499 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
500 media_packet_ref(pkt);
502 monitoring_info = cb_info->monitoring_info_preview_mp;
503 __camera_preview_cb_monitoring_info_start(monitoring_info);
505 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
506 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
508 __camera_preview_cb_monitoring_info_end(monitoring_info);
511 /* 2. call evas renderer */
512 if (cb_info->is_evas_render) {
513 if (cb_info->run_evas_render) {
514 media_packet_ref(pkt);
515 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
516 if (ret != MM_ERROR_NONE) {
517 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
518 media_packet_unref(pkt);
521 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
526 /* 3. media bridge */
527 g_mutex_lock(&cb_info->bridge_lock);
529 if (cb_info->bridge) {
530 media_packet_ref(pkt);
531 ret = media_bridge_push_packet(cb_info->bridge, pkt);
532 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
533 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
534 media_packet_unref(pkt);
539 g_mutex_unlock(&cb_info->bridge_lock);
541 _PREVIEW_CB_HANDLER_DONE:
542 /* send PREVIEW_CB_RETURN message if zero copy buffer is used(num_buffer_fd is bigger than 0)
543 and preview callback(normal or media packet) is set. */
544 if (num_buffer_fd > 0 &&
545 (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
546 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]))
547 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
550 media_packet_unref(pkt);
555 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
557 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
559 /* release imported bo and fd */
560 __camera_release_imported_bo(&data_bo);
561 __camera_release_imported_bo(&bo);
563 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
564 __camera_release_imported_bo(&buffer_bo[i]);
566 __camera_release_tfd(tfd);
570 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
573 int capture_fd_main = 0;
574 int capture_fd_post = 0;
575 int capture_fd_thumb = 0;
576 unsigned char *buf_pos = NULL;
578 camera_image_data_s *rImage = NULL;
579 camera_image_data_s *rPostview = NULL;
580 camera_image_data_s *rThumbnail = NULL;
582 tbm_bo bo_main = NULL;
583 tbm_bo bo_post = NULL;
584 tbm_bo bo_thumb = NULL;
585 tbm_bo_handle bo_main_handle = {.ptr = NULL};
586 tbm_bo_handle bo_post_handle = {.ptr = NULL};
587 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
589 if (!cb_info || !recv_msg || !tfd) {
590 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
594 muse_camera_msg_get(capture_fd_main, recv_msg);
595 muse_camera_msg_get(capture_fd_post, recv_msg);
596 muse_camera_msg_get(capture_fd_thumb, recv_msg);
598 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
599 capture_fd_main, capture_fd_post, capture_fd_thumb,
600 tfd[0], tfd[1], tfd[2]);
602 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
603 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
604 goto _CAPTURE_CB_HANDLER_DONE;
607 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
608 CAM_LOG_WARNING("NULL callback");
609 goto _CAPTURE_CB_HANDLER_DONE;
612 /* import tbm bo and get virtual address */
613 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
614 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
615 goto _CAPTURE_CB_HANDLER_DONE;
618 buf_pos = (unsigned char *)bo_main_handle.ptr;
619 rImage = (camera_image_data_s *)buf_pos;
620 rImage->data = buf_pos + sizeof(camera_image_data_s);
621 if (rImage->exif && rImage->exif_size > 0) {
622 rImage->exif = rImage->data + rImage->size;
625 rImage->exif_size = 0;
628 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
629 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
632 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
633 /* import tbm bo and get virtual address */
635 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
636 buf_pos = (unsigned char *)bo_post_handle.ptr;
637 rPostview = (camera_image_data_s *)buf_pos;
638 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
639 rPostview->data = buf_pos + sizeof(camera_image_data_s);
641 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
645 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
646 /* import tbm bo and get virtual address */
648 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
649 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
650 rThumbnail = (camera_image_data_s *)buf_pos;
651 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
652 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
654 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
659 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
660 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
662 _CAPTURE_CB_HANDLER_DONE:
664 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
665 __camera_release_imported_bo(&bo_main);
666 _camera_msg_return_buffer(capture_fd_main, cb_info);
669 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
670 __camera_release_imported_bo(&bo_post);
671 _camera_msg_return_buffer(capture_fd_post, cb_info);
674 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
675 __camera_release_imported_bo(&bo_thumb);
676 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
679 __camera_release_tfd(tfd);
681 CAM_LOG_INFO("return buffer done");
686 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
689 int face_fd = CAMERA_FD_INIT;
690 camera_detected_face_s *faces = NULL;
693 tbm_bo_handle bo_handle = {.ptr = NULL};
695 if (!cb_info || !recv_msg || !tfd) {
696 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
700 muse_camera_msg_get(count, recv_msg);
701 muse_camera_msg_get(face_fd, recv_msg);
703 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
704 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
706 if (CAMERA_IS_FD_VALID(tfd[0])) {
707 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
709 faces = bo_handle.ptr;
713 tfd[0] = CAMERA_FD_INIT;
716 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
717 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
720 __camera_release_imported_bo(&bo);
722 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
723 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
727 _camera_msg_return_buffer(face_fd, cb_info);
732 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
734 tbm_bo tmp_bo = NULL;
735 tbm_bo_handle tmp_bo_handle = {NULL, };
737 if (!bufmgr || !bo || !bo_handle || fd < 0) {
738 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
739 bufmgr, bo, bo_handle, fd);
743 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
744 if (tmp_bo == NULL) {
745 CAM_LOG_ERROR("import failed - fd %d", fd);
749 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
750 if (tmp_bo_handle.ptr == NULL) {
751 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
752 tbm_bo_unref(tmp_bo);
757 /* set bo and bo_handle */
759 *bo_handle = tmp_bo_handle;
761 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
766 static void __camera_release_imported_bo(tbm_bo *bo)
769 CAM_LOG_DEBUG("NULL bo");
778 static bool __is_supported(camera_h camera, muse_camera_api_e api)
780 int ret = CAMERA_ERROR_NONE;
781 camera_cli_s *pc = (camera_cli_s *)camera;
783 if (!pc || !pc->cb_info) {
784 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
785 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
789 CAM_LOG_INFO("Enter - api[%d]", api);
791 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
793 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
799 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
801 int ret = CAMERA_ERROR_NONE;
802 camera_cli_s *pc = (camera_cli_s *)camera;
803 camera_msg_param param;
805 if (!pc || !pc->cb_info) {
806 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
807 return CAMERA_ERROR_INVALID_PARAMETER;
810 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
812 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
816 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
822 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
824 int ret = CAMERA_ERROR_NONE;
825 camera_cli_s *pc = (camera_cli_s *)camera;
826 camera_msg_param param;
828 if (!pc || !pc->cb_info) {
829 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
830 return CAMERA_ERROR_INVALID_PARAMETER;
833 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
835 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
837 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
839 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
845 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
850 CAM_LOG_ERROR("api[%d] message failed", api);
852 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
857 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
858 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
860 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
862 if (cb_info->is_server_connected) {
863 _camera_update_api_waiting(cb_info, api, 1);
865 g_mutex_lock(&cb_info->fd_lock);
866 send_ret = muse_core_msg_send(cb_info->fd, msg);
867 g_mutex_unlock(&cb_info->fd_lock);
871 CAM_LOG_ERROR("message send failed");
873 *ret = CAMERA_ERROR_INVALID_OPERATION;
876 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
879 _camera_update_api_waiting(cb_info, api, -1);
881 muse_core_msg_free(msg);
883 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
884 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
886 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
890 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
892 int ret = CAMERA_ERROR_NONE;
895 if (!cb_info->is_server_connected) {
896 CAM_LOG_ERROR("server is disconnected");
897 return CAMERA_ERROR_SERVICE_DISCONNECTED;
900 g_mutex_lock(&(cb_info->api_mutex[api]));
902 CAM_LOG_INFO("api [%d], timeout [%d sec]", api, time_out);
904 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
906 while (!cb_info->api_activating[api]) {
907 if (time_out == CAMERA_CB_NO_TIMEOUT) {
908 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
909 CAM_LOG_WARNING("api %d returned 0x%x", api, cb_info->api_ret[api]);
910 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
911 CAM_LOG_ERROR("api %d TIMED OUT!", api);
912 ret = CAMERA_ERROR_INVALID_OPERATION;
916 if (!cb_info->is_server_connected) {
917 ret = CAMERA_ERROR_SERVICE_DISCONNECTED;
921 if (!cb_info->api_activating[api])
922 CAM_LOG_WARNING("invalid signal received, wait again...");
925 ret = cb_info->api_ret[api];
926 cb_info->api_activating[api] = FALSE;
929 g_mutex_unlock(&(cb_info->api_mutex[api]));
931 if (ret != CAMERA_ERROR_NONE)
932 CAM_LOG_ERROR("api %d : error 0x%x", api, ret);
938 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
939 int *ret, int timeout)
944 CAM_LOG_ERROR("NULL info - api %d", api);
947 *ret = CAMERA_ERROR_INVALID_PARAMETER;
952 msg = muse_core_msg_new(api, NULL);
954 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
958 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
959 int *ret, camera_msg_param *param, int timeout)
964 if (!cb_info || !param) {
965 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
968 *ret = CAMERA_ERROR_INVALID_PARAMETER;
973 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
975 switch (param->type) {
977 msg = muse_core_msg_new(api,
978 param->type, param->name, param->value.value_INT,
981 case MUSE_TYPE_STRING:
982 msg = muse_core_msg_new(api,
983 param->type, param->name, param->value.value_STRING,
986 case MUSE_TYPE_ARRAY:
987 array_length = param->value_size / sizeof(int) + \
988 (param->value_size % sizeof(int) ? 1 : 0);
990 msg = muse_core_msg_new(api,
991 param->type, param->name, array_length, param->value.value_ARRAY,
995 CAM_LOG_ERROR("unknown type %d", param->type);
999 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1003 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1004 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1008 if (!cb_info || !param0 || !param1) {
1009 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1010 cb_info, param0, param1, api);
1013 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1018 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1020 param0->name, param0->value.value_INT,
1021 param1->name, param1->value.value_INT);
1023 msg = muse_core_msg_new(api,
1024 param0->type, param0->name, param0->value.value_INT,
1025 param1->type, param1->name, param1->value.value_INT,
1028 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1032 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1034 camera_msg_param param;
1037 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1041 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1043 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1047 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1049 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1050 in_format >= MM_PIXEL_FORMAT_NUM ||
1051 out_format == NULL) {
1052 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1053 return CAMERA_ERROR_INVALID_PARAMETER;
1056 switch (in_format) {
1057 case MM_PIXEL_FORMAT_NV12:
1058 case MM_PIXEL_FORMAT_NV12T:
1059 *out_format = TBM_FORMAT_NV12;
1062 case MM_PIXEL_FORMAT_NV16:
1063 *out_format = TBM_FORMAT_NV16;
1065 case MM_PIXEL_FORMAT_NV21:
1066 *out_format = TBM_FORMAT_NV21;
1068 case MM_PIXEL_FORMAT_YUYV:
1069 *out_format = TBM_FORMAT_YUYV;
1071 case MM_PIXEL_FORMAT_UYVY:
1072 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1073 *out_format = TBM_FORMAT_UYVY;
1075 case MM_PIXEL_FORMAT_422P:
1076 *out_format = TBM_FORMAT_YUV422;
1078 case MM_PIXEL_FORMAT_I420:
1079 *out_format = TBM_FORMAT_YUV420;
1081 case MM_PIXEL_FORMAT_YV12:
1082 *out_format = TBM_FORMAT_YVU420;
1084 case MM_PIXEL_FORMAT_RGB565:
1085 *out_format = TBM_FORMAT_RGB565;
1087 case MM_PIXEL_FORMAT_RGB888:
1088 *out_format = TBM_FORMAT_RGB888;
1090 case MM_PIXEL_FORMAT_RGBA:
1091 *out_format = TBM_FORMAT_RGBA8888;
1093 case MM_PIXEL_FORMAT_ARGB:
1094 *out_format = TBM_FORMAT_ARGB8888;
1097 CAM_LOG_ERROR("invalid in_format %d", in_format);
1098 return CAMERA_ERROR_INVALID_PARAMETER;
1102 return CAMERA_ERROR_NONE;
1106 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1108 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1109 in_format >= MM_PIXEL_FORMAT_NUM ||
1111 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1112 return CAMERA_ERROR_INVALID_PARAMETER;
1115 switch (in_format) {
1116 case MM_PIXEL_FORMAT_NV12:
1117 case MM_PIXEL_FORMAT_NV12T:
1118 *mimetype = MEDIA_FORMAT_NV12;
1121 case MM_PIXEL_FORMAT_NV16:
1122 *mimetype = MEDIA_FORMAT_NV16;
1124 case MM_PIXEL_FORMAT_NV21:
1125 *mimetype = MEDIA_FORMAT_NV21;
1127 case MM_PIXEL_FORMAT_YUYV:
1128 *mimetype = MEDIA_FORMAT_YUYV;
1130 case MM_PIXEL_FORMAT_UYVY:
1131 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1132 *mimetype = MEDIA_FORMAT_UYVY;
1134 case MM_PIXEL_FORMAT_422P:
1135 *mimetype = MEDIA_FORMAT_422P;
1137 case MM_PIXEL_FORMAT_I420:
1138 *mimetype = MEDIA_FORMAT_I420;
1140 case MM_PIXEL_FORMAT_YV12:
1141 *mimetype = MEDIA_FORMAT_YV12;
1143 case MM_PIXEL_FORMAT_RGB565:
1144 *mimetype = MEDIA_FORMAT_RGB565;
1146 case MM_PIXEL_FORMAT_RGB888:
1147 *mimetype = MEDIA_FORMAT_RGB888;
1149 case MM_PIXEL_FORMAT_RGBA:
1150 *mimetype = MEDIA_FORMAT_RGBA;
1152 case MM_PIXEL_FORMAT_ARGB:
1153 *mimetype = MEDIA_FORMAT_ARGB;
1155 case MM_PIXEL_FORMAT_ENCODED_H264:
1156 /* TODO: How can we determine the profile for H.264 format? */
1157 *mimetype = MEDIA_FORMAT_H264_SP;
1159 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1160 *mimetype = MEDIA_FORMAT_MJPEG;
1162 case MM_PIXEL_FORMAT_ENCODED_VP8:
1163 *mimetype = MEDIA_FORMAT_VP8;
1165 case MM_PIXEL_FORMAT_ENCODED_VP9:
1166 *mimetype = MEDIA_FORMAT_VP9;
1169 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1170 return CAMERA_ERROR_NOT_SUPPORTED;
1174 return CAMERA_ERROR_NONE;
1178 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1179 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1182 int ret = CAMERA_ERROR_NONE;
1183 camera_media_packet_data *new_mp_data = NULL;
1185 if (!tfd || !mp_data) {
1186 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1187 return CAMERA_ERROR_INVALID_PARAMETER;
1190 new_mp_data = g_new0(camera_media_packet_data, 1);
1192 new_mp_data->ret_fd = ret_fd;
1193 new_mp_data->fd = tfd[0];
1194 new_mp_data->num_buffer_fd = num_buffer_fd;
1195 new_mp_data->bo = bo;
1197 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1201 new_mp_data->data_bo = data_bo;
1202 new_mp_data->data_fd = tfd[1];
1204 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1205 new_mp_data->data_bo, new_mp_data->data_fd);
1208 for (i = 0 ; i < num_buffer_fd ; i++) {
1209 new_mp_data->buffer_bo[i] = buffer_bo[i];
1210 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1212 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1213 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1216 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1217 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1219 new_mp_data->data_fd = CAMERA_FD_INIT;
1222 *mp_data = new_mp_data;
1224 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1229 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1233 if (!mp_data || !cb_info) {
1234 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1238 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1240 /* release imported bo and close fd */
1241 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1242 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1243 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1245 tbm_bo_unref(mp_data->buffer_bo[i]);
1247 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1248 close(mp_data->buffer_fd[i]);
1250 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1253 if (mp_data->data_bo) {
1254 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1255 mp_data->data_fd, mp_data->data_bo);
1257 tbm_bo_unref(mp_data->data_bo);
1259 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1260 close(mp_data->data_fd);
1262 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1265 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1267 tbm_bo_unref(mp_data->bo);
1269 if (CAMERA_IS_FD_VALID(mp_data->fd))
1272 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1275 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1281 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1284 int ret = CAMERA_ERROR_NONE;
1285 uint32_t tbm_format = 0;
1286 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1287 tbm_surface_info_s tsurf_info;
1289 if (!stream || !mp_data) {
1290 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1294 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1295 CAM_LOG_ERROR("No valid data");
1299 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1300 if (ret != CAMERA_ERROR_NONE)
1303 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1305 if (mp_data->num_buffer_fd > 0) {
1306 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1307 bos[i] = mp_data->buffer_bo[i];
1309 bos[0] = mp_data->data_bo;
1312 tsurf_info.width = stream->width;
1313 tsurf_info.height = stream->height;
1314 tsurf_info.format = tbm_format;
1315 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1316 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1318 switch (tbm_format) {
1319 case TBM_FORMAT_NV12: /* fall through */
1320 case TBM_FORMAT_NV21: /* fall through */
1321 case TBM_FORMAT_YUV420: /* fall through */
1322 case TBM_FORMAT_YVU420: /* fall through */
1323 case TBM_FORMAT_UYVY: /* fall through */
1324 case TBM_FORMAT_YUYV:
1325 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1326 tsurf_info.planes[i].stride = stream->stride[i];
1327 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1328 if (i != 0 && mp_data->num_buffer_fd <= 1)
1329 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1330 tsurf_info.size += tsurf_info.planes[i].size;
1332 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1333 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1337 case TBM_FORMAT_RGB565: /* fall through */
1338 case TBM_FORMAT_RGB888: /* fall through */
1339 case TBM_FORMAT_RGBA8888: /* fall through */
1340 case TBM_FORMAT_ARGB8888:
1341 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1342 tsurf_info.planes[0].offset = 0;
1343 tsurf_info.size = stream->data.rgb.length_data;
1346 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1351 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1352 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1356 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1358 int ret = CAMERA_ERROR_NONE;
1359 int pkt_fmt_width = 0;
1360 int pkt_fmt_height = 0;
1361 bool make_pkt_fmt = false;
1362 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1363 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1365 if (!cb_info || !stream) {
1366 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1367 return CAMERA_ERROR_INVALID_PARAMETER;
1370 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1371 if (ret != CAMERA_ERROR_NONE)
1374 /* check media packet format */
1375 if (cb_info->pkt_fmt) {
1376 media_format_get_video_info(cb_info->pkt_fmt,
1377 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1379 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1380 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1382 if (pkt_fmt_mimetype != mimetype ||
1383 pkt_fmt_width != stream->width ||
1384 pkt_fmt_height != stream->height) {
1385 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1386 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1388 media_format_unref(cb_info->pkt_fmt);
1389 cb_info->pkt_fmt = NULL;
1390 make_pkt_fmt = true;
1393 make_pkt_fmt = true;
1396 /* create packet format */
1398 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1399 mimetype, stream->width, stream->height);
1401 ret = media_format_create(&cb_info->pkt_fmt);
1402 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1403 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1404 return CAMERA_ERROR_INVALID_OPERATION;
1407 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1408 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1409 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1410 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1411 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1412 return CAMERA_ERROR_INVALID_OPERATION;
1416 return CAMERA_ERROR_NONE;
1420 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1421 camera_media_packet_data *mp_data, media_packet_h *packet)
1423 media_packet_h pkt = NULL;
1424 tbm_surface_h tsurf = NULL;
1425 int ret = CAMERA_ERROR_NONE;
1427 if (!cb_info || !stream || !mp_data || !packet) {
1428 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1429 cb_info, stream, mp_data, packet);
1430 return CAMERA_ERROR_INVALID_PARAMETER;
1433 ret = __camera_update_media_packet_format(cb_info, stream);
1434 if (ret != CAMERA_ERROR_NONE)
1437 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1438 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1439 stream->data.encoded.data, stream->data.encoded.length_data,
1440 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1444 if (!stream->data.encoded.is_delta_frame)
1445 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1447 if (stream->data.encoded.is_header_included) {
1448 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1449 CAM_LOG_INFO("Codec config in buffer");
1453 tsurf = __camera_get_tbm_surface(stream, mp_data);
1455 CAM_LOG_ERROR("get tbm surface failed");
1456 ret = CAMERA_ERROR_INVALID_OPERATION;
1457 goto _PACKET_CREATE_FAILED;
1460 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1461 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1462 (void *)cb_info, &pkt);
1465 if (ret != MEDIA_PACKET_ERROR_NONE) {
1466 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1467 goto _PACKET_CREATE_FAILED;
1470 ret = media_packet_set_extra(pkt, (void *)mp_data);
1471 if (ret != MEDIA_PACKET_ERROR_NONE) {
1472 CAM_LOG_ERROR("media_packet_set_extra failed");
1473 goto _PACKET_CREATE_FAILED;
1476 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1477 CAM_LOG_WARNING("media_packet_set_pts failed");
1479 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1480 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1482 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1486 return CAMERA_ERROR_NONE;
1488 _PACKET_CREATE_FAILED:
1490 tbm_surface_destroy(tsurf);
1492 media_packet_unref(pkt);
1494 return CAMERA_ERROR_INVALID_OPERATION;
1497 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1500 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1501 camera_media_packet_data *mp_data = NULL;
1502 tbm_surface_h tsurf = NULL;
1504 if (!pkt || !cb_info) {
1505 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1509 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1510 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1511 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1515 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1517 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1518 pkt, mp_data, tsurf);
1521 tbm_surface_destroy(tsurf);
1523 g_mutex_lock(&cb_info->mp_data_mutex);
1524 __camera_release_media_packet_data(mp_data, cb_info);
1525 g_mutex_unlock(&cb_info->mp_data_mutex);
1528 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1533 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1534 CAM_LOG_ERROR("invalid parameter - camera msg %p, event %d", recv_msg, event);
1538 CAM_LOG_DEBUG("get camera msg[%s], event[%d]", recv_msg, event);
1540 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1542 if (cb_info->user_cb[event] == NULL) {
1543 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1544 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1545 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1546 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1547 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1548 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1552 /* return buffer message should be sent for some events.
1553 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1554 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1555 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1556 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1561 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1567 muse_camera_msg_get(previous, recv_msg);
1568 muse_camera_msg_get(current, recv_msg);
1569 muse_camera_msg_get(by_policy, recv_msg);
1571 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1572 previous, current, by_policy);
1574 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1575 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1578 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1582 muse_camera_msg_get(state, recv_msg);
1584 CAM_LOG_INFO("FOCUS state - %d", state);
1586 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1589 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1590 CAM_LOG_INFO("CAPTURE_COMPLETED");
1591 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1593 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1594 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1595 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1598 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1602 muse_camera_msg_get(percent, recv_msg);
1604 CAM_LOG_INFO("HDR progress - %d %%", percent);
1606 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1609 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1615 muse_camera_msg_get(policy, recv_msg);
1616 muse_camera_msg_get(previous, recv_msg);
1617 muse_camera_msg_get(current, recv_msg);
1619 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1621 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1622 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1625 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1630 muse_camera_msg_get(policy, recv_msg);
1631 muse_camera_msg_get(state, recv_msg);
1633 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1635 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1636 (camera_state_e)state, cb_info->user_data[event]);
1639 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1640 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1642 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1645 int current_state = 0;
1647 muse_camera_msg_get(error, recv_msg);
1648 muse_camera_msg_get(current_state, recv_msg);
1650 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1652 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1653 (camera_state_e)current_state, cb_info->user_data[event]);
1657 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1659 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1660 muse_camera_msg_get(param1, recv_msg);
1661 muse_camera_msg_get(param2, recv_msg);
1663 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1665 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1666 cb_info->user_cb[event] = NULL;
1667 cb_info->user_data[event] = NULL;
1668 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1671 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1673 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1675 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1677 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1679 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1681 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1683 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1685 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1687 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1689 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1691 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1693 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1695 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1698 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1700 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1701 muse_camera_msg_get(param1, recv_msg);
1703 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1705 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1706 cb_info->user_cb[event] = NULL;
1707 cb_info->user_data[event] = NULL;
1708 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1712 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1713 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1716 CAM_LOG_WARNING("unhandled event %d", event);
1720 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1723 static gboolean __camera_idle_event_callback(gpointer data)
1725 camera_cb_info_s *cb_info = NULL;
1726 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1728 if (cam_idle_event == NULL) {
1729 CAM_LOG_ERROR("cam_idle_event is NULL");
1734 g_mutex_lock(&g_cam_idle_event_lock);
1736 cb_info = cam_idle_event->cb_info;
1737 if (cb_info == NULL) {
1738 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1739 g_mutex_unlock(&g_cam_idle_event_lock);
1740 goto IDLE_EVENT_CALLBACK_DONE;
1743 /* remove event from list */
1744 if (cb_info->idle_event_list)
1745 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1747 g_mutex_unlock(&g_cam_idle_event_lock);
1750 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1752 IDLE_EVENT_CALLBACK_DONE:
1754 g_free(cam_idle_event);
1755 cam_idle_event = NULL;
1760 static gpointer __camera_msg_handler_func(gpointer data)
1764 camera_message_s *cam_msg = NULL;
1765 camera_idle_event_s *cam_idle_event = NULL;
1766 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1767 camera_cb_info_s *cb_info = NULL;
1768 GThread *thread = NULL;
1770 if (!handler_info || !handler_info->cb_info) {
1771 CAM_LOG_ERROR("NULL handler %p", handler_info);
1775 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1776 type = handler_info->type;
1777 thread = handler_info->thread;
1779 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1781 g_mutex_lock(&handler_info->mutex);
1783 while (g_atomic_int_get(&handler_info->running)) {
1784 if (g_queue_is_empty(handler_info->queue)) {
1785 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1786 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1787 CAM_LOG_VERBOSE("t[%d] signal received", type);
1789 if (g_atomic_int_get(&handler_info->running) == 0) {
1790 CAM_LOG_INFO("t:%d stop event thread", type);
1795 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1797 g_mutex_unlock(&handler_info->mutex);
1799 if (cam_msg == NULL) {
1800 CAM_LOG_ERROR("t:%d NULL message", type);
1801 g_mutex_lock(&handler_info->mutex);
1807 if (api < MUSE_CAMERA_API_MAX) {
1810 g_mutex_lock(&cb_info->api_mutex[api]);
1812 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1813 if (cb_info->api_waiting[api] > 0) {
1814 cb_info->api_ret[api] = ret;
1815 cb_info->api_activating[api] = TRUE;
1817 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1819 g_cond_broadcast(&cb_info->api_cond[api]);
1821 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1824 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1827 g_mutex_unlock(&cb_info->api_mutex[api]);
1828 } else if (api == MUSE_CAMERA_CB_EVENT) {
1829 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1830 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1831 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1834 switch (cam_msg->event_class) {
1835 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1836 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1838 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1839 cam_idle_event = g_new0(camera_idle_event_s, 1);
1840 if (cam_idle_event == NULL) {
1841 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1845 cam_idle_event->event = cam_msg->event;
1846 cam_idle_event->cb_info = cb_info;
1848 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1849 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1851 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1852 type, cam_msg->event, cam_idle_event);
1854 g_mutex_lock(&g_cam_idle_event_lock);
1855 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1856 g_mutex_unlock(&g_cam_idle_event_lock);
1858 g_idle_add_full(G_PRIORITY_DEFAULT,
1859 (GSourceFunc)__camera_idle_event_callback,
1860 (gpointer)cam_idle_event,
1864 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1868 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1873 g_mutex_lock(&handler_info->mutex);
1876 /* remove remained event */
1877 while (!g_queue_is_empty(handler_info->queue)) {
1878 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1880 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1881 __camera_release_tfd(cam_msg->tfd);
1884 CAM_LOG_WARNING("t:%d NULL message", type);
1888 g_mutex_unlock(&handler_info->mutex);
1890 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1896 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1898 camera_idle_event_s *cam_idle_event = NULL;
1901 if (cb_info == NULL) {
1902 CAM_LOG_ERROR("cb_info is NULL");
1906 g_mutex_lock(&g_cam_idle_event_lock);
1908 if (cb_info->idle_event_list == NULL) {
1909 CAM_LOG_INFO("No remained idle event");
1910 g_mutex_unlock(&g_cam_idle_event_lock);
1914 list = cb_info->idle_event_list;
1917 cam_idle_event = list->data;
1918 list = g_list_next(list);
1920 if (!cam_idle_event) {
1921 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1925 if (g_idle_remove_by_data(cam_idle_event)) {
1926 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1928 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1930 g_free(cam_idle_event);
1935 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1936 cam_idle_event, cam_idle_event->event);
1938 cam_idle_event->cb_info = NULL;
1940 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1943 g_list_free(cb_info->idle_event_list);
1944 cb_info->idle_event_list = NULL;
1946 g_mutex_unlock(&g_cam_idle_event_lock);
1950 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1952 camera_message_s *cam_msg = NULL;
1954 if (!cb_info || !msg) {
1955 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1959 cam_msg = g_new0(camera_message_s, 1);
1961 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1966 cam_msg->event = event;
1967 cam_msg->event_class = event_class;
1970 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1972 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1974 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1975 api, event, event_class);
1977 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1978 if (!cb_info->preview_cb_info.thread) {
1979 LOGI("The thread for preview cb is not created yet, create it now");
1980 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1981 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1982 CAM_LOG_ERROR("failed to create thread for preview cb");
1988 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1989 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1990 g_cond_signal(&cb_info->preview_cb_info.cond);
1991 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1992 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1993 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1994 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1995 g_cond_signal(&cb_info->capture_cb_info.cond);
1996 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1998 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1999 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
2000 g_cond_signal(&cb_info->msg_handler_info.cond);
2001 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
2008 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2010 int ret = CAMERA_ERROR_NONE;
2014 int event_class = -1;
2018 if (!cb_info || !msg) {
2019 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2023 CAM_LOG_DEBUG("msg[%s]", msg);
2025 if (!muse_camera_msg_get(api, msg)) {
2026 CAM_LOG_ERROR("failed to get camera api");
2030 if (api == MUSE_CAMERA_CB_EVENT) {
2031 if (!muse_camera_msg_get(event, msg) ||
2032 !muse_camera_msg_get(event_class, msg)) {
2033 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2037 if (!muse_camera_msg_get(api_class, msg)) {
2038 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2043 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2044 if (api >= MUSE_CAMERA_API_MAX) {
2045 CAM_LOG_ERROR("invalid api %d", api);
2049 if (!muse_camera_msg_get(ret, msg)) {
2050 CAM_LOG_ERROR("failed to get camera ret");
2054 g_mutex_lock(&cb_info->api_mutex[api]);
2057 case MUSE_CAMERA_API_CREATE:
2058 if (ret != CAMERA_ERROR_NONE) {
2059 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2060 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2063 case MUSE_CAMERA_API_DESTROY:
2064 if (ret == CAMERA_ERROR_NONE) {
2065 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2066 CAM_LOG_INFO("camera destroy done. close client cb handler");
2070 muse_camera_msg_get(get_type, msg);
2071 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2072 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2073 muse_camera_msg_get(get_index, msg);
2076 case MUSE_CAMERA_GET_TYPE_INT:
2077 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2079 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2080 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2081 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2083 case MUSE_CAMERA_GET_TYPE_ARRAY:
2085 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2086 muse_core_msg_deserialize("get_value",
2087 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2088 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2089 cb_info->get_display_roi_area[0],
2090 cb_info->get_display_roi_area[1],
2091 cb_info->get_display_roi_area[2],
2092 cb_info->get_display_roi_area[3]);
2094 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2095 muse_core_msg_deserialize("get_value",
2096 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2097 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2098 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2100 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2101 muse_core_msg_deserialize("get_value",
2102 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2103 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2104 cb_info->get_extra_preview_stream_format[0],
2105 cb_info->get_extra_preview_stream_format[1],
2106 cb_info->get_extra_preview_stream_format[2],
2107 cb_info->get_extra_preview_stream_format[3]);
2110 CAM_LOG_WARNING("unknown api[%d]", api);
2114 case MUSE_CAMERA_GET_TYPE_STRING:
2115 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2118 CAM_LOG_WARNING("unknown type %d", get_type);
2125 if (cb_info->api_waiting[api] > 0) {
2126 cb_info->api_ret[api] = ret;
2127 cb_info->api_activating[api] = TRUE;
2129 g_cond_broadcast(&cb_info->api_cond[api]);
2131 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2134 g_mutex_unlock(&cb_info->api_mutex[api]);
2135 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2136 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2138 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2143 static gpointer __camera_msg_recv_func(gpointer data)
2146 int recv_length = 0;
2147 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2148 char *recv_msg = NULL;
2149 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2152 CAM_LOG_ERROR("cb_info NULL");
2156 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2158 recv_msg = cb_info->recv_msg;
2160 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2161 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2162 tfd[i] = CAMERA_FD_INIT;
2164 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2165 if (recv_length <= 0) {
2166 cb_info->is_server_connected = FALSE;
2167 CAM_LOG_ERROR("receive msg failed - server disconnected");
2171 if (CAMERA_IS_FD_VALID(tfd[0]))
2172 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2174 recv_msg[recv_length] = '\0';
2176 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2178 __camera_process_msg(cb_info, recv_msg, tfd);
2181 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2184 if (!cb_info->is_server_connected) {
2185 char *error_msg = NULL;
2187 if (cb_info->bufmgr == NULL) {
2188 CAM_LOG_ERROR("No need to send error(handle is not created)");
2192 if (cb_info->fd < 0) {
2193 CAM_LOG_ERROR("fd is closed in client side");
2197 /* send error msg for server disconnection */
2198 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2199 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2200 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2204 CAM_LOG_ERROR("error_msg failed");
2208 __camera_add_msg_to_queue(cb_info,
2209 MUSE_CAMERA_CB_EVENT,
2210 MUSE_CAMERA_EVENT_TYPE_ERROR,
2211 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2215 muse_core_msg_free(error_msg);
2218 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2219 if (cb_info->api_waiting[i])
2220 g_cond_broadcast(&cb_info->api_cond[i]);
2223 CAM_LOG_ERROR("add error msg for service disconnection done");
2231 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2232 int type, const char *thread_name, camera_cb_info_s *cb_info)
2234 if (!handler_info || !thread_name || !cb_info) {
2235 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2236 type, handler_info, thread_name, cb_info);
2240 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2242 if (handler_info->thread) {
2243 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2247 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2249 handler_info->type = type;
2250 handler_info->queue = g_queue_new();
2251 if (handler_info->queue == NULL) {
2252 CAM_LOG_ERROR("t:%d queue failed", type);
2256 handler_info->cb_info = (void *)cb_info;
2257 g_atomic_int_set(&handler_info->running, 1);
2259 handler_info->thread = g_thread_try_new(thread_name,
2260 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2261 if (handler_info->thread == NULL) {
2262 CAM_LOG_ERROR("t:%d thread failed", type);
2264 g_queue_free(handler_info->queue);
2265 handler_info->queue = NULL;
2270 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2276 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2278 GThread *thread = NULL;
2280 if (!handler_info) {
2281 CAM_LOG_ERROR("NULL handler");
2285 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
2287 if (!handler_info->thread) {
2288 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2292 thread = handler_info->thread;
2293 handler_info->thread = NULL;
2295 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2297 g_atomic_int_set(&handler_info->running, 0);
2298 g_cond_signal(&handler_info->cond);
2300 g_clear_pointer(&locker, g_mutex_locker_free);
2302 g_thread_join(thread);
2304 g_queue_free(handler_info->queue);
2305 handler_info->queue = NULL;
2307 CAM_LOG_INFO("t:%d done", handler_info->type);
2311 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2316 CAM_LOG_ERROR("NULL cb_info");
2320 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2321 g_mutex_init(&cb_info->api_mutex[i]);
2322 g_cond_init(&cb_info->api_cond[i]);
2325 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2326 g_mutex_init(&cb_info->user_cb_mutex[i]);
2328 g_mutex_init(&cb_info->fd_lock);
2329 g_mutex_init(&cb_info->mp_data_mutex);
2330 g_mutex_init(&cb_info->bridge_lock);
2332 g_mutex_init(&cb_info->msg_handler_info.mutex);
2333 g_mutex_init(&cb_info->preview_cb_info.mutex);
2334 g_mutex_init(&cb_info->capture_cb_info.mutex);
2335 g_cond_init(&cb_info->msg_handler_info.cond);
2336 g_cond_init(&cb_info->preview_cb_info.cond);
2337 g_cond_init(&cb_info->capture_cb_info.cond);
2339 CAM_LOG_INFO("done");
2343 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2348 CAM_LOG_ERROR("NULL cb_info");
2352 g_mutex_clear(&cb_info->msg_handler_info.mutex);
2353 g_mutex_clear(&cb_info->preview_cb_info.mutex);
2354 g_mutex_clear(&cb_info->capture_cb_info.mutex);
2355 g_cond_clear(&cb_info->msg_handler_info.cond);
2356 g_cond_clear(&cb_info->preview_cb_info.cond);
2357 g_cond_clear(&cb_info->capture_cb_info.cond);
2359 g_mutex_clear(&cb_info->fd_lock);
2360 g_mutex_clear(&cb_info->mp_data_mutex);
2361 g_mutex_clear(&cb_info->bridge_lock);
2363 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2364 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2366 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2367 g_mutex_clear(&cb_info->api_mutex[i]);
2368 g_cond_clear(&cb_info->api_cond[i]);
2371 CAM_LOG_INFO("done");
2375 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2377 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2379 new_info->stream_id = stream_id;
2380 new_info->total = g_new0(monitoring_info_sub_s, 1);
2381 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2382 new_info->timer_calling = g_timer_new();
2383 new_info->timer_interval = g_timer_new();
2385 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2391 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2396 g_timer_destroy(info->timer_calling);
2397 g_timer_destroy(info->timer_interval);
2398 g_free(info->total);
2399 g_free(info->interval);
2401 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2407 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2410 camera_cb_info_s *cb_info = NULL;
2412 g_return_val_if_fail(sockfd > 0, NULL);
2414 cb_info = g_new0(camera_cb_info_s, 1);
2416 CAM_LOG_ERROR("cb_info failed");
2420 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2422 __camera_mutex_cond_init(cb_info);
2424 /* message handler thread */
2425 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2426 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2427 CAM_LOG_ERROR("msg_handler_info failed");
2431 /* message handler thread for capture callback */
2432 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2433 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2434 CAM_LOG_ERROR("capture_cb_info failed");
2438 cb_info->fd = sockfd;
2440 /* message receive thread */
2441 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2442 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2443 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2444 if (cb_info->msg_recv_thread == NULL) {
2445 CAM_LOG_ERROR("message receive thread creation failed");
2450 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2451 cb_info->fds[i] = CAMERA_FD_INIT;
2453 cb_info->is_server_connected = TRUE;
2455 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2456 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2457 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2458 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2464 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2465 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2467 __camera_mutex_cond_clear(cb_info);
2478 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2483 CAM_LOG_ERROR("NULL cb_info");
2487 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2489 g_thread_join(cb_info->msg_recv_thread);
2490 cb_info->msg_recv_thread = NULL;
2492 CAM_LOG_INFO("msg_recv thread removed");
2494 /* destroy msg handler threads */
2495 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2496 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2497 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2499 __camera_mutex_cond_clear(cb_info);
2501 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2502 muse_client_close(cb_info->fd);
2503 cb_info->fd = CAMERA_FD_INIT;
2506 if (cb_info->bufmgr) {
2507 tbm_bufmgr_deinit(cb_info->bufmgr);
2508 cb_info->bufmgr = NULL;
2510 if (cb_info->pkt_fmt) {
2511 media_format_unref(cb_info->pkt_fmt);
2512 cb_info->pkt_fmt = NULL;
2515 if (cb_info->dp_interface) {
2516 mm_display_interface_deinit(cb_info->dp_interface);
2517 cb_info->dp_interface = NULL;
2520 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2521 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2522 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2523 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2529 int _camera_start_evas_rendering(camera_h camera)
2531 camera_cli_s *pc = (camera_cli_s *)camera;
2533 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2535 CAM_LOG_INFO("start");
2537 if (!pc->cb_info->is_evas_render) {
2538 CAM_LOG_ERROR("EVAS surface is not set");
2539 return CAMERA_ERROR_NONE;
2542 /* set evas render flag as RUN */
2543 pc->cb_info->run_evas_render = true;
2545 return CAMERA_ERROR_NONE;
2549 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2551 int ret = CAMERA_ERROR_NONE;
2552 camera_cli_s *pc = (camera_cli_s *)camera;
2554 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2556 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2558 if (!pc->cb_info->is_evas_render) {
2559 CAM_LOG_ERROR("EVAS surface is not set");
2560 return CAMERA_ERROR_NONE;
2563 /* set evas render flag as STOP and release buffers */
2564 pc->cb_info->run_evas_render = false;
2566 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2567 if (ret == MM_ERROR_NONE) {
2568 ret = CAMERA_ERROR_NONE;
2570 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2571 ret = CAMERA_ERROR_INVALID_OPERATION;
2578 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2580 int ret = CAMERA_ERROR_NONE;
2581 int sock_fd = CAMERA_FD_INIT;
2582 int module_index = -1;
2584 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2586 /* create muse connection */
2587 if (!key || !value) {
2588 CAM_LOG_ERROR("NULL pointer");
2589 return CAMERA_ERROR_INVALID_PARAMETER;
2592 sock_fd = muse_client_new();
2594 CAM_LOG_ERROR("muse_client_new failed");
2595 return CAMERA_ERROR_INVALID_OPERATION;
2598 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2599 CAM_LOG_ERROR("muse client get module index failed");
2600 ret = CAMERA_ERROR_INVALID_OPERATION;
2604 msg = muse_core_msg_new(api,
2605 MUSE_TYPE_INT, "module", module_index,
2606 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2609 CAM_LOG_ERROR("msg failed");
2610 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2614 ret = muse_core_msg_send(sock_fd, msg);
2616 muse_core_msg_free(msg);
2620 CAM_LOG_ERROR("send msg failed");
2621 ret = CAMERA_ERROR_INVALID_OPERATION;
2625 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2627 CAM_LOG_ERROR("recv msg failed %d", errno);
2628 ret = CAMERA_ERROR_INVALID_OPERATION;
2632 if (!muse_camera_msg_get(ret, recv_msg)) {
2633 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2634 ret = CAMERA_ERROR_INVALID_OPERATION;
2638 if (ret == CAMERA_ERROR_NONE)
2639 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2641 CAM_LOG_INFO("api %d - value %d", api, *value);
2644 if (CAMERA_IS_FD_VALID(sock_fd)) {
2645 muse_client_close(sock_fd);
2646 sock_fd = CAMERA_FD_INIT;
2653 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2655 int sock_fd = CAMERA_FD_INIT;
2656 char *send_msg = NULL;
2658 int ret = CAMERA_ERROR_NONE;
2659 camera_cli_s *pc = NULL;
2660 tbm_bufmgr bufmgr = NULL;
2662 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2663 int module_index = -1;
2664 int device_type = (int)device;
2666 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2668 sock_fd = muse_client_new();
2670 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2671 ret = CAMERA_ERROR_INVALID_OPERATION;
2675 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2676 CAM_LOG_ERROR("muse client get module index failed");
2677 ret = CAMERA_ERROR_INVALID_OPERATION;
2681 send_msg = muse_core_msg_new(api,
2682 MUSE_TYPE_INT, "module", module_index,
2683 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2684 MUSE_TYPE_INT, "is_network", (int)is_network,
2688 CAM_LOG_ERROR("NULL msg");
2689 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2693 send_ret = muse_core_msg_send(sock_fd, send_msg);
2695 muse_core_msg_free(send_msg);
2699 CAM_LOG_ERROR("send msg failed %d", errno);
2700 ret = CAMERA_ERROR_INVALID_OPERATION;
2704 pc = g_new0(camera_cli_s, 1);
2706 CAM_LOG_ERROR("camera_cli_s alloc failed");
2707 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2711 bufmgr = tbm_bufmgr_init(-1);
2712 if (bufmgr == NULL) {
2713 CAM_LOG_ERROR("get tbm bufmgr failed");
2714 ret = CAMERA_ERROR_INVALID_OPERATION;
2718 pc->cb_info = __camera_client_callback_new(sock_fd);
2719 if (pc->cb_info == NULL) {
2720 CAM_LOG_ERROR("cb_info alloc failed");
2721 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2725 sock_fd = CAMERA_FD_INIT;
2727 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2729 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2731 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2733 if (ret == CAMERA_ERROR_NONE) {
2734 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2735 int user_buffer_supported = 0;
2736 int log_level = CAMERA_LOG_LEVEL_INFO;
2737 intptr_t handle = 0;
2739 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2741 CAM_LOG_ERROR("Receiving Handle Failed!!");
2742 ret = CAMERA_ERROR_INVALID_OPERATION;
2746 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2747 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2748 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2750 pc->remote_handle = handle;
2751 pc->cb_info->bufmgr = bufmgr;
2752 pc->cb_info->preview_format = preview_format;
2753 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2754 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2755 pc->cb_info->is_network = is_network;
2756 g_camera_log_level = log_level;
2758 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2759 preview_format, user_buffer_supported, g_camera_log_level);
2762 CAM_LOG_ERROR("NULL out handle");
2763 ret= CAMERA_ERROR_INVALID_PARAMETER;
2767 *camera = (camera_h)pc;
2769 /* get display interface handle */
2770 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2771 CAM_LOG_WARNING("display interface init failed");
2780 tbm_bufmgr_deinit(bufmgr);
2784 if (CAMERA_IS_FD_VALID(sock_fd)) {
2785 muse_client_close(sock_fd);
2786 sock_fd = CAMERA_FD_INIT;
2791 int temp_fd = pc->cb_info->fd;
2793 /* pc->cb_info->fd should be closed,
2794 because g_thread_join for msg_recv_thread is not returned
2795 in __camera_client_callback_destroy. */
2796 if (CAMERA_IS_FD_VALID(temp_fd)) {
2797 pc->cb_info->fd = CAMERA_FD_INIT;
2798 muse_client_close(temp_fd);
2801 __camera_client_callback_destroy(pc->cb_info);
2808 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2815 int camera_create(camera_device_e device, camera_h *camera)
2817 return _camera_create_private(device, false, camera);
2821 int camera_change_device(camera_h camera, camera_device_e device)
2824 int ret = CAMERA_ERROR_NONE;
2825 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2826 camera_cli_s *pc = (camera_cli_s *)camera;
2827 camera_msg_param param;
2829 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2831 CAMERA_MSG_PARAM_SET(param, INT, device);
2833 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2835 if (ret == CAMERA_ERROR_NONE) {
2836 /* reset callback and user data */
2837 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2838 pc->cb_info->user_cb[i] = NULL;
2839 pc->cb_info->user_data[i] = NULL;
2847 int camera_destroy(camera_h camera)
2849 int ret = CAMERA_ERROR_NONE;
2850 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2851 camera_cli_s *pc = (camera_cli_s *)camera;
2853 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2855 CAM_LOG_INFO("Enter");
2857 if (pc->cb_info->is_server_connected)
2858 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2860 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2862 if (ret == CAMERA_ERROR_NONE) {
2863 __camera_deactivate_idle_event_all(pc->cb_info);
2864 __camera_client_callback_destroy(pc->cb_info);
2871 CAM_LOG_INFO("ret : 0x%x", ret);
2876 int camera_start_preview(camera_h camera)
2879 int ret = CAMERA_ERROR_NONE;
2881 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2882 camera_cli_s *pc = (camera_cli_s *)camera;
2883 camera_state_e current_state = CAMERA_STATE_NONE;
2885 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2887 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2888 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2890 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2891 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2892 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2893 pc->cb_info->dp_info.type);
2894 return CAMERA_ERROR_INVALID_OPERATION;
2897 ret = camera_get_state(camera, ¤t_state);
2898 if (ret != CAMERA_ERROR_NONE) {
2899 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2903 if (current_state == CAMERA_STATE_CREATED) {
2904 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2905 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2906 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2907 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2909 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2910 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2911 CAM_LOG_ERROR("preview_cb_info failed");
2912 return CAMERA_ERROR_INVALID_OPERATION;
2915 if (pc->cb_info->user_buffer_supported) {
2916 if (!__camera_allocate_preview_buffer(camera)) {
2917 ret = CAMERA_ERROR_INVALID_OPERATION;
2921 fds = pc->cb_info->fds;
2925 pc->cb_info->invoke_preview_cb = TRUE;
2927 _camera_msg_send(api, fds, pc->cb_info, &ret,
2928 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2929 CAMERA_CB_NO_TIMEOUT);
2931 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2933 if (ret != CAMERA_ERROR_NONE)
2936 if (pc->cb_info->is_evas_render) {
2937 ret = _camera_start_evas_rendering(camera);
2938 if (ret != CAMERA_ERROR_NONE) {
2939 CAM_LOG_ERROR("stop preview because of error");
2940 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2945 CAM_LOG_INFO("done");
2947 return CAMERA_ERROR_NONE;
2950 if (current_state == CAMERA_STATE_CREATED) {
2951 if (pc->cb_info->user_buffer_supported)
2952 __camera_release_preview_buffer(camera);
2954 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2957 CAM_LOG_ERROR("failed : 0x%x", ret);
2963 int camera_stop_preview(camera_h camera)
2965 int ret = CAMERA_ERROR_NONE;
2966 camera_cli_s *pc = (camera_cli_s *)camera;
2967 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2968 camera_state_e current_state = CAMERA_STATE_NONE;
2970 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2972 CAM_LOG_INFO("Enter");
2975 if (pc->cb_info->is_evas_render) {
2976 ret = camera_get_state(camera, ¤t_state);
2977 if (ret != CAMERA_ERROR_NONE) {
2978 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2982 if (current_state == CAMERA_STATE_PREVIEW) {
2983 ret = _camera_stop_evas_rendering(camera, false);
2984 if (ret != CAMERA_ERROR_NONE)
2990 pc->cb_info->invoke_preview_cb = FALSE;
2992 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2994 if (ret == CAMERA_ERROR_NONE) {
2995 if (pc->cb_info->user_buffer_supported)
2996 __camera_release_preview_buffer(camera);
2998 /* release remained message for preview callback */
2999 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
3000 } else if (current_state == CAMERA_STATE_PREVIEW) {
3001 CAM_LOG_WARNING("restart evas rendering");
3002 _camera_start_evas_rendering(camera);
3005 CAM_LOG_INFO("ret : 0x%x", ret);
3011 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3013 int ret = CAMERA_ERROR_NONE;
3014 camera_cli_s *pc = (camera_cli_s *)camera;
3015 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3017 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3019 CAM_LOG_INFO("Enter");
3021 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3022 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3027 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3029 CAM_LOG_INFO("ret : 0x%x", ret);
3035 bool camera_is_supported_continuous_capture(camera_h camera)
3037 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3041 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)
3043 int ret = CAMERA_ERROR_NONE;
3044 camera_cli_s *pc = (camera_cli_s *)camera;
3045 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3046 camera_msg_param param;
3049 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3051 CAM_LOG_INFO("Enter");
3053 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3054 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3059 value = (count << 16) | interval;
3060 CAMERA_MSG_PARAM_SET(param, INT, value);
3062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3064 CAM_LOG_INFO("ret : 0x%x", ret);
3070 int camera_stop_continuous_capture(camera_h camera)
3072 int ret = CAMERA_ERROR_NONE;
3073 camera_cli_s *pc = (camera_cli_s *)camera;
3074 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3076 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3078 CAM_LOG_INFO("Enter");
3080 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3082 CAM_LOG_INFO("ret : 0x%x", ret);
3088 bool camera_is_supported_face_detection(camera_h camera)
3090 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3094 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3096 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3100 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3102 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3106 bool camera_is_supported_extra_preview(camera_h camera)
3108 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3112 int camera_get_device_count(camera_h camera, int *device_count)
3114 int ret = CAMERA_ERROR_NONE;
3115 camera_cli_s *pc = (camera_cli_s *)camera;
3116 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3118 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3120 CAM_LOG_INFO("Enter");
3122 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3124 if (ret == CAMERA_ERROR_NONE)
3125 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3127 CAM_LOG_INFO("ret : 0x%x", ret);
3132 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3134 int ret = CAMERA_ERROR_NONE;
3135 camera_cli_s *pc = (camera_cli_s *)camera;
3136 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3138 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3140 CAM_LOG_INFO("Enter");
3142 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3144 if (ret == CAMERA_ERROR_NONE) {
3145 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3147 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3148 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3150 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3153 CAM_LOG_INFO("ret : 0x%x", ret);
3158 int camera_stop_face_detection(camera_h camera)
3160 int ret = CAMERA_ERROR_NONE;
3161 camera_cli_s *pc = (camera_cli_s *)camera;
3162 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3164 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3166 CAM_LOG_INFO("Enter");
3168 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3170 if (ret == CAMERA_ERROR_NONE) {
3171 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3173 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3174 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3176 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3179 CAM_LOG_INFO("ret : 0x%x", ret);
3184 int camera_get_state(camera_h camera, camera_state_e *state)
3186 int ret = CAMERA_ERROR_NONE;
3187 camera_cli_s *pc = (camera_cli_s *)camera;
3188 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3190 if (!pc || !pc->cb_info || !state) {
3191 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3192 return CAMERA_ERROR_INVALID_PARAMETER;
3195 CAM_LOG_INFO("Enter");
3197 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3199 if (ret == CAMERA_ERROR_NONE)
3200 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3202 CAM_LOG_INFO("ret : 0x%x", ret);
3207 int camera_start_focusing(camera_h camera, bool continuous)
3209 int ret = CAMERA_ERROR_NONE;
3210 camera_cli_s *pc = (camera_cli_s *)camera;
3211 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3212 camera_msg_param param;
3213 int is_continuous = (int)continuous;
3215 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3217 CAM_LOG_INFO("Enter");
3219 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3221 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3223 CAM_LOG_INFO("ret : 0x%x", ret);
3228 int camera_cancel_focusing(camera_h camera)
3230 int ret = CAMERA_ERROR_NONE;
3231 camera_cli_s *pc = (camera_cli_s *)camera;
3232 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3234 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3236 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3238 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3240 CAM_LOG_INFO("ret : 0x%x", ret);
3246 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3248 int mm_ret = MM_ERROR_NONE;
3249 int ret = CAMERA_ERROR_NONE;
3250 camera_cli_s *pc = (camera_cli_s *)camera;
3251 camera_cb_info_s *cb_info = NULL;
3252 camera_state_e current_state = CAMERA_STATE_NONE;
3253 camera_msg_param param;
3254 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3255 muse_camera_display_info_s *dp_info = NULL;
3257 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3259 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3260 CAM_LOG_ERROR("invalid type %d", type);
3261 return CAMERA_ERROR_INVALID_PARAMETER;
3264 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3265 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3266 return CAMERA_ERROR_INVALID_PARAMETER;
3269 cb_info = (camera_cb_info_s *)pc->cb_info;
3270 dp_info = &cb_info->dp_info;
3272 ret = camera_get_state(camera, ¤t_state);
3273 if (ret != CAMERA_ERROR_NONE) {
3274 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3278 if (current_state != CAMERA_STATE_CREATED) {
3279 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3280 return CAMERA_ERROR_INVALID_STATE;
3283 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3285 if (type != MM_DISPLAY_TYPE_NONE) {
3286 /* check display interface handle */
3287 if (!cb_info->dp_interface) {
3288 CAM_LOG_ERROR("display interface not supported");
3289 return CAMERA_ERROR_NOT_SUPPORTED;
3292 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3293 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3294 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3295 return CAMERA_ERROR_NOT_SUPPORTED;
3296 } else if (mm_ret != MM_ERROR_NONE) {
3297 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3298 return CAMERA_ERROR_INVALID_OPERATION;
3301 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3302 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3304 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3305 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3306 dp_info->window_rect.width, dp_info->window_rect.height);
3307 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3309 camera_flip_e flip = CAMERA_FLIP_NONE;
3310 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3311 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3318 camera_get_display_flip(camera, &flip);
3319 camera_get_display_mode(camera, &mode);
3320 camera_get_display_rotation(camera, &rotation);
3321 camera_is_display_visible(camera, &visible);
3323 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3324 flip, mode, rotation, visible);
3326 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3327 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3328 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3329 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3331 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3332 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3333 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3334 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3340 if (mm_ret != MM_ERROR_NONE) {
3341 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3342 return CAMERA_ERROR_INVALID_OPERATION;
3345 dp_info->type = type;
3347 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3349 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3351 if (ret == CAMERA_ERROR_NONE)
3352 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3358 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3360 CAM_LOG_INFO("type %d, display %p", type, display);
3361 return _camera_set_display(camera, (mm_display_type_e)type, display);
3365 int camera_set_preview_resolution(camera_h camera, int width, int height)
3367 int ret = CAMERA_ERROR_NONE;
3368 camera_state_e current_state = CAMERA_STATE_NONE;
3369 camera_cli_s *pc = (camera_cli_s *)camera;
3370 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3371 camera_msg_param param;
3374 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3376 if (pc->cb_info->is_evas_render) {
3377 ret = camera_get_state(camera, ¤t_state);
3378 if (ret != CAMERA_ERROR_NONE) {
3379 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3383 if (current_state == CAMERA_STATE_PREVIEW) {
3384 ret = _camera_stop_evas_rendering(camera, true);
3385 if (ret != CAMERA_ERROR_NONE)
3390 value = (width << 16) | height;
3391 CAMERA_MSG_PARAM_SET(param, INT, value);
3393 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3395 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3397 CAM_LOG_INFO("ret : 0x%x", ret);
3399 if (current_state == CAMERA_STATE_PREVIEW) {
3400 CAM_LOG_WARNING("restart evas rendering");
3401 _camera_start_evas_rendering(camera);
3408 int camera_set_capture_resolution(camera_h camera, int width, int height)
3410 int ret = CAMERA_ERROR_NONE;
3411 camera_cli_s *pc = (camera_cli_s *)camera;
3412 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3413 camera_msg_param param;
3416 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3418 CAM_LOG_INFO("Enter");
3420 value = (width << 16) | height;
3421 CAMERA_MSG_PARAM_SET(param, INT, value);
3423 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3425 CAM_LOG_INFO("ret : 0x%x", ret);
3431 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3433 int ret = CAMERA_ERROR_NONE;
3434 int set_format = (int)format;
3435 camera_cli_s *pc = (camera_cli_s *)camera;
3436 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3437 camera_msg_param param;
3439 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3441 CAM_LOG_INFO("Enter - format %d", set_format);
3443 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3445 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3447 CAM_LOG_INFO("ret : 0x%x", ret);
3453 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3455 int ret = CAMERA_ERROR_NONE;
3456 int set_format = (int)format;
3457 camera_msg_param param;
3458 camera_cli_s *pc = (camera_cli_s *)camera;
3459 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3461 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3463 CAM_LOG_INFO("Enter - format %d", set_format);
3465 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3467 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3469 if (ret == CAMERA_ERROR_NONE)
3470 pc->cb_info->preview_format = set_format;
3472 CAM_LOG_INFO("ret : 0x%x", ret);
3478 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3480 int ret = CAMERA_ERROR_NONE;
3481 camera_cli_s *pc = (camera_cli_s *)camera;
3482 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3484 if (!pc || !pc->cb_info || !width || !height) {
3485 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3486 return CAMERA_ERROR_INVALID_PARAMETER;
3489 CAM_LOG_INFO("Enter");
3491 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3493 if (ret == CAMERA_ERROR_NONE) {
3494 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3495 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3498 CAM_LOG_INFO("ret : 0x%x", ret);
3504 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3506 int ret = CAMERA_ERROR_NONE;
3507 int set_rotation = (int)rotation;
3508 camera_cli_s *pc = (camera_cli_s *)camera;
3509 camera_msg_param param;
3511 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3513 if (pc->cb_info->is_evas_render) {
3514 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3515 if (ret != MM_ERROR_NONE) {
3516 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3517 return CAMERA_ERROR_INVALID_OPERATION;
3521 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3523 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3529 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3531 int ret = CAMERA_ERROR_NONE;
3532 camera_cli_s *pc = (camera_cli_s *)camera;
3534 if (!pc || !pc->cb_info || !rotation) {
3535 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3536 return CAMERA_ERROR_INVALID_PARAMETER;
3539 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3541 if (ret == CAMERA_ERROR_NONE)
3542 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3548 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3550 int ret = CAMERA_ERROR_NONE;
3551 int set_flip = (int)flip;
3552 camera_cli_s *pc = (camera_cli_s *)camera;
3553 camera_msg_param param;
3555 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3557 if (pc->cb_info->is_evas_render) {
3558 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3559 if (ret != MM_ERROR_NONE) {
3560 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3561 return CAMERA_ERROR_INVALID_OPERATION;
3565 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3567 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3573 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3575 int ret = CAMERA_ERROR_NONE;
3576 camera_cli_s *pc = (camera_cli_s *)camera;
3578 if (!pc || !pc->cb_info || !flip) {
3579 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3580 return CAMERA_ERROR_INVALID_PARAMETER;
3583 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3585 if (ret == CAMERA_ERROR_NONE)
3586 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3592 int camera_set_display_visible(camera_h camera, bool visible)
3594 int ret = CAMERA_ERROR_NONE;
3595 int set_visible = (int)visible;
3596 camera_cli_s *pc = (camera_cli_s *)camera;
3597 camera_msg_param param;
3599 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3601 if (pc->cb_info->is_evas_render) {
3602 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3603 if (ret != MM_ERROR_NONE) {
3604 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3605 return CAMERA_ERROR_INVALID_OPERATION;
3609 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3611 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3617 int camera_is_display_visible(camera_h camera, bool *visible)
3619 int ret = CAMERA_ERROR_NONE;
3620 camera_cli_s *pc = (camera_cli_s *)camera;
3622 if (!pc || !pc->cb_info || !visible) {
3623 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3624 return CAMERA_ERROR_INVALID_PARAMETER;
3627 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3629 if (ret == CAMERA_ERROR_NONE)
3630 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3636 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3638 int ret = CAMERA_ERROR_NONE;
3639 int set_mode = (int)mode;
3640 camera_cli_s *pc = (camera_cli_s *)camera;
3641 camera_msg_param param;
3643 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3645 if (pc->cb_info->is_evas_render) {
3646 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3647 if (ret != MM_ERROR_NONE) {
3648 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3649 return CAMERA_ERROR_INVALID_OPERATION;
3653 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3655 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3661 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3663 int ret = CAMERA_ERROR_NONE;
3664 camera_cli_s *pc = (camera_cli_s *)camera;
3666 if (!pc || !pc->cb_info || !mode) {
3667 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3668 return CAMERA_ERROR_INVALID_PARAMETER;
3671 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3673 if (ret == CAMERA_ERROR_NONE)
3674 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3680 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3682 int ret = CAMERA_ERROR_NONE;
3683 int set_hint = (int)hint;
3684 camera_cli_s *pc = (camera_cli_s *)camera;
3685 camera_msg_param param;
3687 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3689 CAM_LOG_INFO("Enter - hint %d", set_hint);
3691 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3693 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3699 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3701 int ret = CAMERA_ERROR_NONE;
3702 camera_cli_s *pc = (camera_cli_s *)camera;
3703 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3705 if (!pc || !pc->cb_info || !hint) {
3706 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3707 return CAMERA_ERROR_INVALID_PARAMETER;
3710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3712 if (ret == CAMERA_ERROR_NONE) {
3713 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3714 CAM_LOG_INFO("display reuse hint %d", *hint);
3721 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3723 int ret = CAMERA_ERROR_NONE;
3724 camera_cli_s *pc = (camera_cli_s *)camera;
3725 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3727 if (!pc || !pc->cb_info || !width || !height) {
3728 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3729 return CAMERA_ERROR_INVALID_PARAMETER;
3732 CAM_LOG_INFO("Enter");
3734 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3736 if (ret == CAMERA_ERROR_NONE) {
3737 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3738 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3741 CAM_LOG_INFO("ret : 0x%x", ret);
3747 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3749 int ret = CAMERA_ERROR_NONE;
3750 camera_cli_s *pc = (camera_cli_s *)camera;
3751 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3753 if (!pc || !pc->cb_info || !format) {
3754 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3755 return CAMERA_ERROR_INVALID_PARAMETER;
3758 CAM_LOG_INFO("Enter");
3760 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3762 if (ret == CAMERA_ERROR_NONE)
3763 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3765 CAM_LOG_INFO("ret : 0x%x", ret);
3771 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3773 int ret = CAMERA_ERROR_NONE;
3774 camera_cli_s *pc = (camera_cli_s *)camera;
3775 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3777 if (!pc || !pc->cb_info || !format) {
3778 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3779 return CAMERA_ERROR_INVALID_PARAMETER;
3782 CAM_LOG_INFO("Enter");
3784 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3786 if (ret == CAMERA_ERROR_NONE)
3787 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3789 CAM_LOG_INFO("ret : 0x%x", ret);
3795 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3797 int ret = CAMERA_ERROR_NONE;
3798 camera_cli_s *pc = (camera_cli_s *)camera;
3799 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3801 if (!pc || !pc->cb_info || !facing_direction) {
3802 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3803 return CAMERA_ERROR_INVALID_PARAMETER;
3806 CAM_LOG_INFO("Enter");
3808 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3810 if (ret == CAMERA_ERROR_NONE)
3811 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3813 CAM_LOG_INFO("ret : 0x%x", ret);
3819 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3821 int ret = CAMERA_ERROR_NONE;
3822 camera_cli_s *pc = (camera_cli_s *)camera;
3823 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3825 if (!pc || !pc->cb_info || !callback) {
3826 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3827 return CAMERA_ERROR_INVALID_PARAMETER;
3830 CAM_LOG_INFO("Enter");
3832 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3834 if (ret == CAMERA_ERROR_NONE) {
3835 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3837 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3838 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3840 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3843 CAM_LOG_INFO("ret : 0x%x", ret);
3849 int camera_unset_preview_cb(camera_h camera)
3851 int ret = CAMERA_ERROR_NONE;
3852 camera_cli_s *pc = (camera_cli_s *)camera;
3853 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3855 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3857 CAM_LOG_INFO("Enter");
3859 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3861 if (ret == CAMERA_ERROR_NONE) {
3862 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3867 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3870 CAM_LOG_INFO("ret : 0x%x", ret);
3876 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3878 int ret = CAMERA_ERROR_NONE;
3879 camera_cli_s *pc = (camera_cli_s *)camera;
3880 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3882 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3884 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3885 CAM_LOG_ERROR("NOT SUPPORTED");
3886 return CAMERA_ERROR_NOT_SUPPORTED;
3889 if (callback == NULL) {
3890 CAM_LOG_ERROR("NULL callback");
3891 return CAMERA_ERROR_INVALID_PARAMETER;
3894 CAM_LOG_INFO("Enter");
3896 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3898 if (ret == CAMERA_ERROR_NONE) {
3899 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3901 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3902 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3904 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3907 CAM_LOG_INFO("ret : 0x%x", ret);
3913 int camera_unset_media_packet_preview_cb(camera_h camera)
3915 int ret = CAMERA_ERROR_NONE;
3916 camera_cli_s *pc = (camera_cli_s *)camera;
3917 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3919 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3921 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3922 CAM_LOG_ERROR("NOT SUPPORTED");
3923 return CAMERA_ERROR_NOT_SUPPORTED;
3926 CAM_LOG_INFO("Enter");
3928 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3930 if (ret == CAMERA_ERROR_NONE) {
3931 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3933 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3934 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3936 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3939 CAM_LOG_INFO("ret : 0x%x", ret);
3945 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3947 int ret = CAMERA_ERROR_NONE;
3948 camera_cli_s *pc = (camera_cli_s *)camera;
3949 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3951 if (!pc || !pc->cb_info || !callback) {
3952 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3953 return CAMERA_ERROR_INVALID_PARAMETER;
3956 CAM_LOG_INFO("Enter");
3958 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3960 if (ret == CAMERA_ERROR_NONE) {
3961 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3963 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3964 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3966 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3969 CAM_LOG_INFO("ret : 0x%x", ret);
3975 int camera_unset_state_changed_cb(camera_h camera)
3977 int ret = CAMERA_ERROR_NONE;
3978 camera_cli_s *pc = (camera_cli_s *)camera;
3979 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3981 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3983 CAM_LOG_INFO("Enter");
3985 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3987 if (ret == CAMERA_ERROR_NONE) {
3988 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3990 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3991 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3993 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3996 CAM_LOG_INFO("ret : 0x%x", ret);
4002 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4004 int ret = CAMERA_ERROR_NONE;
4005 camera_cli_s *pc = (camera_cli_s *)camera;
4006 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4008 if (!pc || !pc->cb_info || !callback) {
4009 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4010 return CAMERA_ERROR_INVALID_PARAMETER;
4013 CAM_LOG_INFO("Enter");
4015 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4017 if (ret == CAMERA_ERROR_NONE) {
4018 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4020 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4021 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4023 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4026 CAM_LOG_INFO("ret : 0x%x", ret);
4032 int camera_unset_interrupted_cb(camera_h camera)
4034 int ret = CAMERA_ERROR_NONE;
4035 camera_cli_s *pc = (camera_cli_s *)camera;
4036 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4038 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4040 CAM_LOG_INFO("Enter");
4042 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4044 if (ret == CAMERA_ERROR_NONE) {
4045 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4047 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4048 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4050 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4053 CAM_LOG_INFO("ret : 0x%x", ret);
4059 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4061 int ret = CAMERA_ERROR_NONE;
4062 camera_cli_s *pc = (camera_cli_s *)camera;
4063 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4065 if (!pc || !pc->cb_info || !callback) {
4066 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4070 CAM_LOG_INFO("Enter");
4072 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4074 if (ret == CAMERA_ERROR_NONE) {
4075 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4077 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4078 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4080 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4083 CAM_LOG_INFO("ret : 0x%x", ret);
4089 int camera_unset_interrupt_started_cb(camera_h camera)
4091 int ret = CAMERA_ERROR_NONE;
4092 camera_cli_s *pc = (camera_cli_s *)camera;
4093 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4095 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4097 CAM_LOG_INFO("Enter");
4099 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4101 if (ret == CAMERA_ERROR_NONE) {
4102 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4104 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4105 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4107 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4110 CAM_LOG_INFO("ret : 0x%x", ret);
4116 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4118 int ret = CAMERA_ERROR_NONE;
4119 camera_cli_s *pc = (camera_cli_s *)camera;
4120 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4122 if (!pc || !pc->cb_info || !callback) {
4123 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4124 return CAMERA_ERROR_INVALID_PARAMETER;
4127 CAM_LOG_INFO("Enter");
4129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4131 if (ret == CAMERA_ERROR_NONE) {
4132 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4134 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4135 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4137 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4140 CAM_LOG_INFO("ret : 0x%x", ret);
4146 int camera_unset_focus_changed_cb(camera_h camera)
4148 int ret = CAMERA_ERROR_NONE;
4149 camera_cli_s *pc = (camera_cli_s *)camera;
4150 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4152 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4154 CAM_LOG_INFO("Enter");
4156 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4158 if (ret == CAMERA_ERROR_NONE) {
4159 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4161 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4162 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4164 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4167 CAM_LOG_INFO("ret : 0x%x", ret);
4173 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4175 int ret = CAMERA_ERROR_NONE;
4176 camera_cli_s *pc = (camera_cli_s *)camera;
4177 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4179 if (!pc || !pc->cb_info || !callback) {
4180 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4181 return CAMERA_ERROR_INVALID_PARAMETER;
4184 CAM_LOG_INFO("Enter");
4186 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4188 if (ret == CAMERA_ERROR_NONE) {
4189 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4191 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4192 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4194 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4197 CAM_LOG_INFO("ret : 0x%x", ret);
4203 int camera_unset_error_cb(camera_h camera)
4205 int ret = CAMERA_ERROR_NONE;
4206 camera_cli_s *pc = (camera_cli_s *)camera;
4207 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4209 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4211 CAM_LOG_INFO("Enter");
4213 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4215 if (ret == CAMERA_ERROR_NONE) {
4216 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4218 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4219 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4221 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4224 CAM_LOG_INFO("ret : 0x%x", ret);
4230 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4232 int ret = CAMERA_ERROR_NONE;
4233 camera_cli_s *pc = (camera_cli_s *)camera;
4234 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4236 if (!pc || !pc->cb_info || !foreach_cb) {
4237 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4238 return CAMERA_ERROR_INVALID_PARAMETER;
4241 CAM_LOG_INFO("Enter");
4243 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4244 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4246 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4248 CAM_LOG_INFO("ret : 0x%x", ret);
4254 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4256 int ret = CAMERA_ERROR_NONE;
4257 camera_cli_s *pc = (camera_cli_s *)camera;
4258 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4260 if (!pc || !pc->cb_info || !foreach_cb) {
4261 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4262 return CAMERA_ERROR_INVALID_PARAMETER;
4265 CAM_LOG_INFO("Enter");
4267 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4268 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4270 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4272 CAM_LOG_INFO("ret : 0x%x", ret);
4278 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4280 int ret = CAMERA_ERROR_NONE;
4281 camera_cli_s *pc = (camera_cli_s *)camera;
4282 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4284 if (!pc || !pc->cb_info || !foreach_cb) {
4285 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4286 return CAMERA_ERROR_INVALID_PARAMETER;
4289 CAM_LOG_INFO("Enter");
4291 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4292 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4294 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4296 CAM_LOG_INFO("ret : 0x%x", ret);
4302 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4308 if (!pc || !pc->cb_info || !foreach_cb) {
4309 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4310 return CAMERA_ERROR_INVALID_PARAMETER;
4313 CAM_LOG_INFO("Enter");
4315 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4316 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4318 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4320 CAM_LOG_INFO("ret : 0x%x", ret);
4326 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4328 int ret = CAMERA_ERROR_NONE;
4329 camera_cli_s *pc = (camera_cli_s *)camera;
4330 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4332 if (!pc || !pc->cb_info || !width || !height) {
4333 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4334 return CAMERA_ERROR_INVALID_PARAMETER;
4337 CAM_LOG_INFO("Enter");
4338 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4340 if (ret == CAMERA_ERROR_NONE) {
4341 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4342 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4345 CAM_LOG_INFO("ret : 0x%x", ret);
4351 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4353 int ret = CAMERA_ERROR_NONE;
4354 camera_cli_s *pc = (camera_cli_s *)camera;
4355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4357 if (!pc || !pc->cb_info || !angle) {
4358 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4359 return CAMERA_ERROR_INVALID_PARAMETER;
4362 CAM_LOG_INFO("Enter");
4364 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4366 if (ret == CAMERA_ERROR_NONE)
4367 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4369 CAM_LOG_INFO("ret : 0x%x", ret);
4375 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4377 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4381 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4387 if (!pc || !pc->cb_info || !mode) {
4388 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4389 return CAMERA_ERROR_INVALID_PARAMETER;
4392 CAM_LOG_INFO("Enter");
4394 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4396 if (ret == CAMERA_ERROR_NONE)
4397 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4399 CAM_LOG_INFO("ret : 0x%x", ret);
4405 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4407 int ret = CAMERA_ERROR_NONE;
4408 camera_cli_s *pc = (camera_cli_s *)camera;
4409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4411 if (!pc || !pc->cb_info || !foreach_cb) {
4412 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4413 return CAMERA_ERROR_INVALID_PARAMETER;
4416 CAM_LOG_INFO("Enter");
4418 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4419 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4421 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4423 CAM_LOG_INFO("Finish, return :%x", ret);
4429 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4431 int ret = CAMERA_ERROR_NONE;
4432 camera_cli_s *pc = (camera_cli_s *)camera;
4433 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4434 camera_msg_param param;
4435 int set_fps = (int)fps;
4437 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4439 CAM_LOG_INFO("Enter");
4441 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4443 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4445 CAM_LOG_INFO("ret : 0x%x", ret);
4451 int camera_attr_set_image_quality(camera_h camera, int quality)
4453 int ret = CAMERA_ERROR_NONE;
4454 camera_cli_s *pc = (camera_cli_s *)camera;
4455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4456 camera_msg_param param;
4458 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4460 CAM_LOG_INFO("Enter");
4462 CAMERA_MSG_PARAM_SET(param, INT, quality);
4464 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4466 CAM_LOG_INFO("ret : 0x%x", ret);
4472 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4474 int ret = CAMERA_ERROR_NONE;
4475 camera_cli_s *pc = (camera_cli_s *)camera;
4476 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4478 if (!pc || !pc->cb_info || !fps) {
4479 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4480 return CAMERA_ERROR_INVALID_PARAMETER;
4483 CAM_LOG_INFO("Enter");
4485 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4487 if (ret == CAMERA_ERROR_NONE)
4488 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4490 CAM_LOG_INFO("ret : 0x%x", ret);
4496 int camera_attr_get_image_quality(camera_h camera, int *quality)
4498 int ret = CAMERA_ERROR_NONE;
4499 camera_cli_s *pc = (camera_cli_s *)camera;
4500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4502 if (!pc || !pc->cb_info || !quality) {
4503 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4504 return CAMERA_ERROR_INVALID_PARAMETER;
4507 CAM_LOG_INFO("Enter");
4509 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4511 if (ret == CAMERA_ERROR_NONE)
4512 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4514 CAM_LOG_INFO("ret : 0x%x", ret);
4520 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4522 int ret = CAMERA_ERROR_NONE;
4523 camera_cli_s *pc = (camera_cli_s *)camera;
4524 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4526 if (!pc || !pc->cb_info || !bitrate) {
4527 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4528 return CAMERA_ERROR_INVALID_PARAMETER;
4531 CAM_LOG_INFO("Enter");
4533 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4535 if (ret == CAMERA_ERROR_NONE)
4536 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4538 CAM_LOG_INFO("ret : 0x%x", ret);
4544 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4546 int ret = CAMERA_ERROR_NONE;
4547 camera_cli_s *pc = (camera_cli_s *)camera;
4548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4549 camera_msg_param param;
4550 int set_bitrate = bitrate;
4552 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4554 CAM_LOG_INFO("Enter");
4556 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4558 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4560 CAM_LOG_INFO("ret : 0x%x", ret);
4566 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4568 int ret = CAMERA_ERROR_NONE;
4569 camera_cli_s *pc = (camera_cli_s *)camera;
4570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4572 if (!pc || !pc->cb_info || !interval) {
4573 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4574 return CAMERA_ERROR_INVALID_PARAMETER;
4577 CAM_LOG_INFO("Enter");
4579 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4581 if (ret == CAMERA_ERROR_NONE)
4582 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4584 CAM_LOG_INFO("ret : 0x%x", ret);
4590 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4592 int ret = CAMERA_ERROR_NONE;
4593 camera_cli_s *pc = (camera_cli_s *)camera;
4594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4595 camera_msg_param param;
4596 int set_gop_interval = interval;
4598 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4600 CAM_LOG_INFO("Enter");
4602 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4604 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4606 CAM_LOG_INFO("ret : 0x%x", ret);
4612 int camera_attr_set_zoom(camera_h camera, int zoom)
4614 int ret = CAMERA_ERROR_NONE;
4615 camera_cli_s *pc = (camera_cli_s *)camera;
4616 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4617 camera_msg_param param;
4619 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4621 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4623 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4625 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4627 CAM_LOG_INFO("ret : 0x%x", ret);
4633 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4635 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4639 int camera_attr_set_af_area(camera_h camera, int x, int y)
4641 int ret = CAMERA_ERROR_NONE;
4642 camera_cli_s *pc = (camera_cli_s *)camera;
4643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4644 camera_msg_param param;
4647 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4649 CAM_LOG_INFO("Enter - %d,%d", x, y);
4651 value = (x << 16) | y;
4652 CAMERA_MSG_PARAM_SET(param, INT, value);
4654 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4656 CAM_LOG_INFO("ret : 0x%x", ret);
4662 int camera_attr_clear_af_area(camera_h camera)
4664 int ret = CAMERA_ERROR_NONE;
4665 camera_cli_s *pc = (camera_cli_s *)camera;
4666 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4668 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4670 CAM_LOG_INFO("Enter");
4672 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4674 CAM_LOG_INFO("ret : 0x%x", ret);
4680 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4682 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4686 int camera_attr_set_exposure(camera_h camera, int value)
4688 int ret = CAMERA_ERROR_NONE;
4689 camera_cli_s *pc = (camera_cli_s *)camera;
4690 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4691 camera_msg_param param;
4693 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4695 CAM_LOG_INFO("Enter");
4697 CAMERA_MSG_PARAM_SET(param, INT, value);
4699 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4701 CAM_LOG_INFO("ret : 0x%x", ret);
4707 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4709 int ret = CAMERA_ERROR_NONE;
4710 camera_cli_s *pc = (camera_cli_s *)camera;
4711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4712 camera_msg_param param;
4713 int set_iso = (int)iso;
4715 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4717 CAM_LOG_INFO("Enter");
4719 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4723 CAM_LOG_INFO("ret : 0x%x", ret);
4729 int camera_attr_set_gain(camera_h camera, int level)
4731 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_GAIN, level);
4735 int camera_attr_set_brightness(camera_h camera, int level)
4737 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS, level);
4741 int camera_attr_set_contrast(camera_h camera, int level)
4743 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_CONTRAST, level);
4747 int camera_attr_set_hue(camera_h camera, int level)
4749 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_HUE, level);
4753 int camera_attr_set_saturation(camera_h camera, int level)
4755 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_SATURATION, level);
4759 int camera_attr_set_sharpness(camera_h camera, int level)
4761 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_SHARPNESS, level);
4765 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4767 int ret = CAMERA_ERROR_NONE;
4768 camera_cli_s *pc = (camera_cli_s *)camera;
4769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4770 camera_msg_param param;
4771 int set_whitebalance = (int)wb;
4773 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4775 CAM_LOG_INFO("Enter");
4777 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4779 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4781 CAM_LOG_INFO("ret : 0x%x", ret);
4787 int camera_attr_set_whitebalance_temperature(camera_h camera, int temperature)
4789 int ret = CAMERA_ERROR_NONE;
4790 camera_cli_s *pc = (camera_cli_s *)camera;
4791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE_TEMPERATURE;
4792 camera_msg_param param;
4794 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4796 CAM_LOG_INFO("Enter");
4798 CAMERA_MSG_PARAM_SET(param, INT, temperature);
4800 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4802 CAM_LOG_INFO("ret : 0x%x", ret);
4808 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4810 int ret = CAMERA_ERROR_NONE;
4811 camera_cli_s *pc = (camera_cli_s *)camera;
4812 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4813 camera_msg_param param;
4814 int set_effect = (int)effect;
4816 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4818 CAM_LOG_INFO("Enter");
4820 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4822 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4824 CAM_LOG_INFO("ret : 0x%x", ret);
4830 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4832 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4836 int camera_attr_enable_tag(camera_h camera, bool enable)
4838 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4842 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4844 int ret = CAMERA_ERROR_NONE;
4845 camera_cli_s *pc = (camera_cli_s *)camera;
4846 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4847 camera_msg_param param;
4849 if (!pc || !pc->cb_info || !description) {
4850 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4851 return CAMERA_ERROR_INVALID_PARAMETER;
4854 CAM_LOG_INFO("Enter");
4856 CAMERA_MSG_PARAM_SET(param, STRING, description);
4858 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4860 CAM_LOG_INFO("ret : 0x%x", ret);
4866 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
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_TAG_ORIENTATION;
4871 camera_msg_param param;
4872 int set_orientation = (int)orientation;
4874 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4876 CAM_LOG_INFO("Enter");
4878 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4880 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4882 CAM_LOG_INFO("ret : 0x%x", ret);
4888 int camera_attr_set_tag_software(camera_h camera, const char *software)
4890 int ret = CAMERA_ERROR_NONE;
4891 camera_cli_s *pc = (camera_cli_s *)camera;
4892 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4893 camera_msg_param param;
4895 if (!pc || !pc->cb_info || !software) {
4896 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4897 return CAMERA_ERROR_INVALID_PARAMETER;
4900 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4902 CAMERA_MSG_PARAM_SET(param, STRING, software);
4904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4906 CAM_LOG_INFO("ret : 0x%x", ret);
4912 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4917 double set_geotag[3] = {latitude, longitude, altitude};
4921 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4923 CAM_LOG_INFO("Enter");
4925 length = sizeof(set_geotag) / sizeof(int) + \
4926 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4928 msg = muse_core_msg_new(api,
4929 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4932 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4938 int camera_attr_remove_geotag(camera_h camera)
4940 int ret = CAMERA_ERROR_NONE;
4941 camera_cli_s *pc = (camera_cli_s *)camera;
4942 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4944 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4946 CAM_LOG_INFO("Enter");
4948 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4950 CAM_LOG_INFO("ret : 0x%x", ret);
4956 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4958 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4962 int camera_attr_get_zoom(camera_h camera, int *zoom)
4964 int ret = CAMERA_ERROR_NONE;
4965 camera_cli_s *pc = (camera_cli_s *)camera;
4966 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4968 if (!pc || !pc->cb_info || !zoom) {
4969 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4970 return CAMERA_ERROR_INVALID_PARAMETER;
4973 CAM_LOG_INFO("Enter");
4975 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4977 if (ret == CAMERA_ERROR_NONE)
4978 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4980 CAM_LOG_INFO("ret : 0x%x", ret);
4986 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4988 return _camera_attr_get_range(camera,
4989 MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE,
4990 MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE,
4995 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4997 int ret = CAMERA_ERROR_NONE;
4998 camera_cli_s *pc = (camera_cli_s *)camera;
4999 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5001 if (!pc || !pc->cb_info || !mode) {
5002 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5003 return CAMERA_ERROR_INVALID_PARAMETER;
5006 CAM_LOG_INFO("Enter");
5008 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5010 if (ret == CAMERA_ERROR_NONE)
5011 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5013 CAM_LOG_INFO("ret : 0x%x", ret);
5019 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5021 int ret = CAMERA_ERROR_NONE;
5022 camera_cli_s *pc = (camera_cli_s *)camera;
5023 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5025 if (!pc || !pc->cb_info || !mode) {
5026 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5027 return CAMERA_ERROR_INVALID_PARAMETER;
5030 CAM_LOG_INFO("Enter");
5032 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5034 if (ret == CAMERA_ERROR_NONE)
5035 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5037 CAM_LOG_INFO("ret : 0x%x", ret);
5043 int camera_attr_get_exposure(camera_h camera, int *value)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5049 if (!pc || !pc->cb_info || !value) {
5050 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5054 CAM_LOG_INFO("Enter");
5056 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5058 if (ret == CAMERA_ERROR_NONE)
5059 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5061 CAM_LOG_INFO("ret : 0x%x", ret);
5067 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5069 return _camera_attr_get_range(camera,
5070 MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE,
5071 MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE,
5076 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5078 int ret = CAMERA_ERROR_NONE;
5079 camera_cli_s *pc = (camera_cli_s *)camera;
5080 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5082 if (!pc || !pc->cb_info || !iso) {
5083 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5084 return CAMERA_ERROR_INVALID_PARAMETER;
5087 CAM_LOG_INFO("Enter");
5089 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5091 if (ret == CAMERA_ERROR_NONE)
5092 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5094 CAM_LOG_INFO("ret : 0x%x", ret);
5100 int camera_attr_get_gain(camera_h camera, int *level)
5102 return _camera_attr_get_level(camera,
5103 MUSE_CAMERA_API_ATTR_GET_GAIN,
5104 MUSE_CAMERA_GET_INT_GAIN,
5109 int camera_attr_get_gain_range(camera_h camera, int *min, int *max)
5111 return _camera_attr_get_range(camera,
5112 MUSE_CAMERA_API_ATTR_GET_GAIN_RANGE,
5113 MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE,
5118 int camera_attr_get_gain_step(camera_h camera, int *step)
5120 int ret = CAMERA_ERROR_NONE;
5121 camera_cli_s *pc = (camera_cli_s *)camera;
5122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_STEP;
5124 if (!pc || !pc->cb_info || !step) {
5125 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5126 return CAMERA_ERROR_INVALID_PARAMETER;
5129 CAM_LOG_INFO("Enter");
5131 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5133 if (ret == CAMERA_ERROR_NONE)
5134 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN_STEP];
5136 CAM_LOG_INFO("ret : 0x%x", ret);
5142 int camera_attr_get_brightness(camera_h camera, int *level)
5144 return _camera_attr_get_level(camera,
5145 MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS,
5146 MUSE_CAMERA_GET_INT_BRIGHTNESS,
5151 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5153 return _camera_attr_get_range(camera,
5154 MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE,
5155 MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE,
5160 int camera_attr_get_contrast(camera_h camera, int *level)
5162 return _camera_attr_get_level(camera,
5163 MUSE_CAMERA_API_ATTR_GET_CONTRAST,
5164 MUSE_CAMERA_GET_INT_CONTRAST,
5169 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5171 return _camera_attr_get_range(camera,
5172 MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE,
5173 MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE,
5178 int camera_attr_get_hue(camera_h camera, int *level)
5180 return _camera_attr_get_level(camera,
5181 MUSE_CAMERA_API_ATTR_GET_HUE,
5182 MUSE_CAMERA_GET_INT_HUE,
5187 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5189 return _camera_attr_get_range(camera,
5190 MUSE_CAMERA_API_ATTR_GET_HUE_RANGE,
5191 MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE,
5196 int camera_attr_get_saturation(camera_h camera, int *level)
5198 return _camera_attr_get_level(camera,
5199 MUSE_CAMERA_API_ATTR_GET_SATURATION,
5200 MUSE_CAMERA_GET_INT_SATURATION,
5205 int camera_attr_get_saturation_range(camera_h camera, int *min, int *max)
5207 return _camera_attr_get_range(camera,
5208 MUSE_CAMERA_API_ATTR_GET_SATURATION_RANGE,
5209 MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE,
5214 int camera_attr_get_sharpness(camera_h camera, int *level)
5216 return _camera_attr_get_level(camera,
5217 MUSE_CAMERA_API_ATTR_GET_SHARPNESS,
5218 MUSE_CAMERA_GET_INT_SHARPNESS,
5223 int camera_attr_get_sharpness_range(camera_h camera, int *min, int *max)
5225 return _camera_attr_get_range(camera,
5226 MUSE_CAMERA_API_ATTR_GET_SHARPNESS_RANGE,
5227 MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE,
5232 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5234 int ret = CAMERA_ERROR_NONE;
5235 camera_cli_s *pc = (camera_cli_s *)camera;
5236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5238 if (!pc || !pc->cb_info || !wb) {
5239 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5240 return CAMERA_ERROR_INVALID_PARAMETER;
5243 CAM_LOG_INFO("Enter");
5245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5247 if (ret == CAMERA_ERROR_NONE)
5248 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5250 CAM_LOG_INFO("ret : 0x%x", ret);
5256 int camera_attr_get_whitebalance_temperature(camera_h camera, int *temperature)
5258 int ret = CAMERA_ERROR_NONE;
5259 camera_cli_s *pc = (camera_cli_s *)camera;
5260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE;
5262 if (!pc || !pc->cb_info || !temperature) {
5263 CAM_LOG_ERROR("NULL pointer %p %p", pc, temperature);
5264 return CAMERA_ERROR_INVALID_PARAMETER;
5267 CAM_LOG_INFO("Enter");
5269 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5271 if (ret == CAMERA_ERROR_NONE)
5272 *temperature = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE];
5274 CAM_LOG_INFO("ret : 0x%x", ret);
5280 int camera_attr_get_whitebalance_temperature_range(camera_h camera, int *min, int *max)
5282 return _camera_attr_get_range(camera,
5283 MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_RANGE,
5284 MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE,
5289 int camera_attr_get_whitebalance_temperature_step(camera_h camera, int *step)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_STEP;
5295 if (!pc || !pc->cb_info || !step) {
5296 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5300 CAM_LOG_INFO("Enter");
5302 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE)
5305 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE_STEP];
5307 CAM_LOG_INFO("ret : 0x%x", ret);
5313 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5315 int ret = CAMERA_ERROR_NONE;
5316 camera_cli_s *pc = (camera_cli_s *)camera;
5317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5319 if (!pc || !pc->cb_info || !effect) {
5320 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5321 return CAMERA_ERROR_INVALID_PARAMETER;
5324 CAM_LOG_INFO("Enter");
5326 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5328 if (ret == CAMERA_ERROR_NONE)
5329 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5331 CAM_LOG_INFO("ret : 0x%x", ret);
5337 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5339 int ret = CAMERA_ERROR_NONE;
5340 camera_cli_s *pc = (camera_cli_s *)camera;
5341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5343 if (!pc || !pc->cb_info || !mode) {
5344 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5345 return CAMERA_ERROR_INVALID_PARAMETER;
5348 CAM_LOG_INFO("Enter");
5350 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5352 if (ret == CAMERA_ERROR_NONE)
5353 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5355 CAM_LOG_INFO("ret : 0x%x", ret);
5361 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
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_IS_ENABLED_TAG;
5367 if (!pc || !pc->cb_info || !enable) {
5368 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5369 return CAMERA_ERROR_INVALID_PARAMETER;
5372 CAM_LOG_INFO("Enter");
5374 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5376 if (ret == CAMERA_ERROR_NONE)
5377 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5379 CAM_LOG_INFO("ret : 0x%x", ret);
5385 int camera_attr_get_tag_image_description(camera_h camera, char **description)
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_TAG_IMAGE_DESCRIPTION;
5391 if (!pc || !pc->cb_info || !description) {
5392 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5393 return CAMERA_ERROR_INVALID_PARAMETER;
5396 CAM_LOG_INFO("Enter");
5398 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5400 if (ret == CAMERA_ERROR_NONE)
5401 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5403 CAM_LOG_INFO("ret : 0x%x", ret);
5409 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5411 int ret = CAMERA_ERROR_NONE;
5412 camera_cli_s *pc = (camera_cli_s *)camera;
5413 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5415 if (!pc || !pc->cb_info || !orientation) {
5416 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5417 return CAMERA_ERROR_INVALID_PARAMETER;
5420 CAM_LOG_INFO("Enter");
5422 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5424 if (ret == CAMERA_ERROR_NONE)
5425 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5427 CAM_LOG_INFO("ret : 0x%x", ret);
5433 int camera_attr_get_tag_software(camera_h camera, char **software)
5435 int ret = CAMERA_ERROR_NONE;
5436 camera_cli_s *pc = (camera_cli_s *)camera;
5437 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5439 if (!pc || !pc->cb_info || !software) {
5440 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5441 return CAMERA_ERROR_INVALID_PARAMETER;
5444 CAM_LOG_INFO("Enter");
5446 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5448 if (ret == CAMERA_ERROR_NONE)
5449 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5451 CAM_LOG_INFO("ret : 0x%x", ret);
5457 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5459 int ret = CAMERA_ERROR_NONE;
5460 camera_cli_s *pc = (camera_cli_s *)camera;
5461 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5463 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5464 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5465 return CAMERA_ERROR_INVALID_PARAMETER;
5468 CAM_LOG_INFO("Enter");
5470 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5472 if (ret == CAMERA_ERROR_NONE) {
5473 *latitude = pc->cb_info->get_geotag[0];
5474 *longitude = pc->cb_info->get_geotag[1];
5475 *altitude = pc->cb_info->get_geotag[2];
5478 CAM_LOG_INFO("ret : 0x%x", ret);
5484 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
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_GET_FLASH_MODE;
5490 if (!pc || !pc->cb_info || !mode) {
5491 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5492 return CAMERA_ERROR_INVALID_PARAMETER;
5495 CAM_LOG_INFO("Enter");
5497 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5499 if (ret == CAMERA_ERROR_NONE)
5500 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5502 CAM_LOG_INFO("ret : 0x%x", ret);
5508 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5510 int ret = CAMERA_ERROR_NONE;
5511 int get_flash_state = 0;
5514 CAM_LOG_ERROR("NULL pointer");
5515 return CAMERA_ERROR_INVALID_PARAMETER;
5518 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5519 (int)device, "get_flash_state", &get_flash_state);
5521 if (ret == CAMERA_ERROR_NONE) {
5522 *state = (camera_flash_state_e)get_flash_state;
5523 CAM_LOG_INFO("flash state %d", *state);
5525 CAM_LOG_ERROR("failed 0x%x", ret);
5532 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_AF_MODE;
5538 if (!pc || !pc->cb_info || !foreach_cb) {
5539 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5540 return CAMERA_ERROR_INVALID_PARAMETER;
5543 CAM_LOG_INFO("Enter");
5545 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5546 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5548 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5550 CAM_LOG_INFO("ret : 0x%x", ret);
5556 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_EXPOSURE_MODE;
5562 if (!pc || !pc->cb_info || !foreach_cb) {
5563 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5564 return CAMERA_ERROR_INVALID_PARAMETER;
5567 CAM_LOG_INFO("Enter");
5569 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5570 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5572 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5574 CAM_LOG_INFO("ret : 0x%x", ret);
5580 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_ISO;
5586 if (!pc || !pc->cb_info || !foreach_cb) {
5587 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5588 return CAMERA_ERROR_INVALID_PARAMETER;
5591 CAM_LOG_INFO("Enter");
5593 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5594 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5596 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5598 CAM_LOG_INFO("ret : 0x%x", ret);
5604 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5606 int ret = CAMERA_ERROR_NONE;
5607 camera_cli_s *pc = (camera_cli_s *)camera;
5608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5610 if (!pc || !pc->cb_info || !foreach_cb) {
5611 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5612 return CAMERA_ERROR_INVALID_PARAMETER;
5615 CAM_LOG_INFO("Enter");
5617 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5618 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5620 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5622 CAM_LOG_INFO("ret : 0x%x", ret);
5628 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5630 int ret = CAMERA_ERROR_NONE;
5631 camera_cli_s *pc = (camera_cli_s *)camera;
5632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5634 if (!pc || !pc->cb_info || !foreach_cb) {
5635 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5636 return CAMERA_ERROR_INVALID_PARAMETER;
5639 CAM_LOG_INFO("Enter");
5641 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5642 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5644 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5646 CAM_LOG_INFO("ret : 0x%x", ret);
5652 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5654 int ret = CAMERA_ERROR_NONE;
5655 camera_cli_s *pc = (camera_cli_s *)camera;
5656 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5658 if (!pc || !pc->cb_info || !foreach_cb) {
5659 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5660 return CAMERA_ERROR_INVALID_PARAMETER;
5663 CAM_LOG_INFO("Enter");
5665 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5666 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5668 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5670 CAM_LOG_INFO("ret : 0x%x", ret);
5676 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5678 int ret = CAMERA_ERROR_NONE;
5679 camera_cli_s *pc = (camera_cli_s *)camera;
5680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5682 if (!pc || !pc->cb_info || !foreach_cb) {
5683 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5684 return CAMERA_ERROR_INVALID_PARAMETER;
5687 CAM_LOG_INFO("Enter");
5689 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5690 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5692 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5694 CAM_LOG_INFO("ret : 0x%x", ret);
5700 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5702 int ret = CAMERA_ERROR_NONE;
5703 camera_cli_s *pc = (camera_cli_s *)camera;
5704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5706 if (!pc || !pc->cb_info || !foreach_cb) {
5707 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5708 return CAMERA_ERROR_INVALID_PARAMETER;
5711 CAM_LOG_INFO("Enter");
5713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5716 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5718 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5724 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)
5726 int ret = CAMERA_ERROR_NONE;
5727 camera_cli_s *pc = (camera_cli_s *)camera;
5728 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5729 camera_msg_param param;
5732 if (!pc || !pc->cb_info || !foreach_cb) {
5733 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5734 return CAMERA_ERROR_INVALID_PARAMETER;
5737 CAM_LOG_INFO("Enter");
5739 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5740 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5742 value = (width << 16) | height;
5743 CAMERA_MSG_PARAM_SET(param, INT, value);
5745 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5747 CAM_LOG_INFO("ret : 0x%x", ret);
5753 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5755 int ret = CAMERA_ERROR_NONE;
5756 camera_cli_s *pc = (camera_cli_s *)camera;
5757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5759 if (!pc || !pc->cb_info || !foreach_cb) {
5760 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5761 return CAMERA_ERROR_INVALID_PARAMETER;
5764 CAM_LOG_INFO("Enter");
5766 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5769 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5771 CAM_LOG_INFO("ret : 0x%x", ret);
5777 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5779 int ret = CAMERA_ERROR_NONE;
5780 camera_cli_s *pc = (camera_cli_s *)camera;
5781 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5783 if (!pc || !pc->cb_info || !foreach_cb) {
5784 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5785 return CAMERA_ERROR_INVALID_PARAMETER;
5788 CAM_LOG_INFO("Enter");
5790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5793 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5795 CAM_LOG_INFO("ret : 0x%x", ret);
5801 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5803 int ret = CAMERA_ERROR_NONE;
5804 camera_cli_s *pc = (camera_cli_s *)camera;
5805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5806 camera_msg_param param;
5807 int set_rotation = (int)rotation;
5809 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5811 CAM_LOG_INFO("Enter");
5813 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5815 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5817 CAM_LOG_INFO("ret : 0x%x", ret);
5823 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
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_GET_STREAM_ROTATION;
5829 if (!pc || !pc->cb_info || !rotation) {
5830 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5831 return CAMERA_ERROR_INVALID_PARAMETER;
5834 CAM_LOG_INFO("Enter");
5836 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5838 if (ret == CAMERA_ERROR_NONE)
5839 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5841 CAM_LOG_INFO("ret : 0x%x", ret);
5847 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
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_SET_STREAM_FLIP;
5852 camera_msg_param param;
5853 int set_flip = (int)flip;
5855 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5857 CAM_LOG_INFO("Enter");
5859 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5863 CAM_LOG_INFO("ret : 0x%x", ret);
5869 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5871 int ret = CAMERA_ERROR_NONE;
5872 camera_cli_s *pc = (camera_cli_s *)camera;
5873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5875 if (!pc || !pc->cb_info || !flip) {
5876 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5877 return CAMERA_ERROR_INVALID_PARAMETER;
5880 CAM_LOG_INFO("Enter");
5882 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5884 if (ret == CAMERA_ERROR_NONE)
5885 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5887 CAM_LOG_INFO("ret : 0x%x", ret);
5892 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5894 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5898 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5900 int ret = CAMERA_ERROR_NONE;
5901 camera_cli_s *pc = (camera_cli_s *)camera;
5902 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5904 if (!pc || !pc->cb_info || !mode) {
5905 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5906 return CAMERA_ERROR_INVALID_PARAMETER;
5909 CAM_LOG_INFO("Enter");
5911 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5913 if (ret == CAMERA_ERROR_NONE)
5914 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5916 CAM_LOG_INFO("ret : 0x%x", ret);
5922 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5924 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5928 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5930 int ret = CAMERA_ERROR_NONE;
5931 camera_cli_s *pc = (camera_cli_s *)camera;
5932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5934 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5936 CAM_LOG_INFO("Enter");
5938 if (!camera_attr_is_supported_hdr_capture(camera)) {
5939 CAM_LOG_ERROR("HDR not supported");
5940 return CAMERA_ERROR_NOT_SUPPORTED;
5944 CAM_LOG_ERROR("NULL callback");
5945 return CAMERA_ERROR_INVALID_PARAMETER;
5948 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5950 if (ret == CAMERA_ERROR_NONE) {
5951 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5953 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5954 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5956 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5959 CAM_LOG_INFO("ret : 0x%x", ret);
5965 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5967 int ret = CAMERA_ERROR_NONE;
5968 camera_cli_s *pc = (camera_cli_s *)camera;
5969 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5971 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5973 CAM_LOG_INFO("Enter");
5975 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5977 if (ret == CAMERA_ERROR_NONE) {
5978 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5980 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5981 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5983 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5986 CAM_LOG_INFO("ret : 0x%x", ret);
5992 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5994 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
5998 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
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_IS_ENABLED_ANTI_SHAKE;
6004 if (!pc || !pc->cb_info || !enabled) {
6005 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6006 return CAMERA_ERROR_INVALID_PARAMETER;
6009 CAM_LOG_INFO("Enter");
6011 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6013 if (ret == CAMERA_ERROR_NONE)
6014 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6016 CAM_LOG_INFO("ret : 0x%x", ret);
6022 bool camera_attr_is_supported_anti_shake(camera_h camera)
6024 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6028 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6030 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6034 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6036 int ret = CAMERA_ERROR_NONE;
6037 camera_cli_s *pc = (camera_cli_s *)camera;
6038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6040 if (!pc || !pc->cb_info || !enabled) {
6041 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6042 return CAMERA_ERROR_INVALID_PARAMETER;
6045 CAM_LOG_INFO("Enter");
6047 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6049 if (ret == CAMERA_ERROR_NONE)
6050 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6052 CAM_LOG_INFO("ret : 0x%x", ret);
6058 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6060 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6064 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6066 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6070 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
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_ENABLED_AUTO_CONTRAST;
6076 if (!pc || !pc->cb_info || !enabled) {
6077 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6078 return CAMERA_ERROR_INVALID_PARAMETER;
6081 CAM_LOG_INFO("Enter");
6083 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6085 if (ret == CAMERA_ERROR_NONE)
6086 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6088 CAM_LOG_INFO("ret : 0x%x", ret);
6094 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6096 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6100 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6102 int ret = CAMERA_ERROR_NONE;
6103 camera_cli_s *pc = (camera_cli_s *)camera;
6104 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6105 camera_msg_param param;
6106 int set_disable = (int)disable;
6108 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6110 CAM_LOG_INFO("Enter");
6112 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6114 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6116 CAM_LOG_INFO("ret : 0x%x", ret);
6122 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6124 int ret = CAMERA_ERROR_NONE;
6125 camera_cli_s *pc = (camera_cli_s *)camera;
6126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6127 camera_msg_param param0;
6128 camera_msg_param param1;
6130 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6132 CAM_LOG_INFO("Enter");
6134 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6135 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6137 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6138 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6140 CAM_LOG_INFO("ret : 0x%x", ret);
6146 int camera_attr_get_pan(camera_h camera, int *pan_step)
6148 int ret = CAMERA_ERROR_NONE;
6149 camera_cli_s *pc = (camera_cli_s *)camera;
6150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6152 if (!pc || !pc->cb_info || !pan_step) {
6153 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6154 return CAMERA_ERROR_INVALID_PARAMETER;
6157 CAM_LOG_INFO("Enter");
6159 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6161 if (ret == CAMERA_ERROR_NONE)
6162 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6164 CAM_LOG_INFO("ret : 0x%x", ret);
6170 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6172 return _camera_attr_get_range(camera,
6173 MUSE_CAMERA_API_ATTR_GET_PAN_RANGE,
6174 MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE,
6179 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6181 int ret = CAMERA_ERROR_NONE;
6182 camera_cli_s *pc = (camera_cli_s *)camera;
6183 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6184 camera_msg_param param0;
6185 camera_msg_param param1;
6187 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6189 CAM_LOG_INFO("Enter");
6191 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6192 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6194 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6195 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6197 CAM_LOG_INFO("ret : 0x%x", ret);
6203 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6205 int ret = CAMERA_ERROR_NONE;
6206 camera_cli_s *pc = (camera_cli_s *)camera;
6207 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6209 if (!pc || !pc->cb_info || !tilt_step) {
6210 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6211 return CAMERA_ERROR_INVALID_PARAMETER;
6214 CAM_LOG_INFO("Enter");
6216 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6218 if (ret == CAMERA_ERROR_NONE)
6219 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6221 CAM_LOG_INFO("ret : 0x%x", ret);
6227 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6229 return _camera_attr_get_range(camera,
6230 MUSE_CAMERA_API_ATTR_GET_TILT_RANGE,
6231 MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE,
6236 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6238 int ret = CAMERA_ERROR_NONE;
6239 camera_cli_s *pc = (camera_cli_s *)camera;
6240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6241 camera_msg_param param;
6242 int set_ptz_type = (int)ptz_type;
6244 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6246 CAM_LOG_INFO("Enter");
6248 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6252 CAM_LOG_INFO("ret : 0x%x", ret);
6258 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6260 int ret = CAMERA_ERROR_NONE;
6261 camera_cli_s *pc = (camera_cli_s *)camera;
6262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6264 if (!pc || !pc->cb_info || !foreach_cb) {
6265 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6266 return CAMERA_ERROR_INVALID_PARAMETER;
6269 CAM_LOG_INFO("Enter");
6271 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6272 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6274 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6276 CAM_LOG_INFO("ret : 0x%x", ret);
6282 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6284 int ret = CAMERA_ERROR_NONE;
6285 camera_cli_s *pc = (camera_cli_s *)camera;
6286 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6287 int set_display_roi_area[4] = {x, y, width, height};
6291 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6293 CAM_LOG_INFO("Enter");
6295 if (pc->cb_info->is_evas_render) {
6296 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6297 if (ret != MM_ERROR_NONE) {
6298 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6299 return CAMERA_ERROR_INVALID_OPERATION;
6303 length = sizeof(set_display_roi_area) / sizeof(int) + \
6304 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6306 msg = muse_core_msg_new(api,
6307 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6310 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6316 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6318 camera_cli_s *pc = (camera_cli_s *)camera;
6319 int ret = CAMERA_ERROR_NONE;
6320 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6322 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6323 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6327 CAM_LOG_INFO("Enter");
6329 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6331 if (ret == CAMERA_ERROR_NONE) {
6332 *x = pc->cb_info->get_display_roi_area[0];
6333 *y = pc->cb_info->get_display_roi_area[1];
6334 *width = pc->cb_info->get_display_roi_area[2];
6335 *height = pc->cb_info->get_display_roi_area[3];
6338 CAM_LOG_INFO("ret : 0x%x", ret);
6344 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6346 int ret = CAMERA_ERROR_NONE;
6347 int get_device_state = 0;
6350 CAM_LOG_ERROR("NULL pointer");
6351 return CAMERA_ERROR_INVALID_PARAMETER;
6354 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6355 (int)device, "get_device_state", &get_device_state);
6357 if (ret == CAMERA_ERROR_NONE) {
6358 *state = (camera_device_state_e)get_device_state;
6359 CAM_LOG_INFO("device state %d", *state);
6361 CAM_LOG_ERROR("failed 0x%x", ret);
6368 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6370 int ret = CAMERA_ERROR_NONE;
6371 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6372 camera_cb_info *info = NULL;
6374 if (!callback || !cb_id) {
6375 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6376 return CAMERA_ERROR_INVALID_PARAMETER;
6379 /* check camera support */
6380 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6381 if (ret != CAMERA_ERROR_NONE) {
6382 CAM_LOG_ERROR("get device state failed");
6386 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6388 info = g_new0(camera_cb_info, 1);
6390 CAM_LOG_ERROR("info failed");
6391 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6395 info->id = ++g_cam_dev_state_changed_cb_id;
6396 info->callback = (void *)callback;
6397 info->user_data = user_data;
6401 /* subscribe dbus signal for camera state change */
6402 if (!g_cam_dev_state_changed_cb_conn) {
6403 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6404 if (!g_cam_dev_state_changed_cb_conn) {
6405 CAM_LOG_ERROR("failed to get gdbus connection");
6406 ret = CAMERA_ERROR_INVALID_OPERATION;
6410 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6411 MM_CAMCORDER_DBUS_OBJECT,
6412 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6413 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6415 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6416 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6417 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6418 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6419 CAM_LOG_ERROR("failed to get gdbus connection");
6420 ret = CAMERA_ERROR_INVALID_OPERATION;
6424 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6427 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6429 CAM_LOG_INFO("callback id %d", info->id);
6432 if (ret != CAMERA_ERROR_NONE) {
6438 if (g_cam_dev_state_changed_cb_conn) {
6439 g_object_unref(g_cam_dev_state_changed_cb_conn);
6440 g_cam_dev_state_changed_cb_conn = NULL;
6444 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6450 int camera_remove_device_state_changed_cb(int cb_id)
6452 int ret = CAMERA_ERROR_NONE;
6453 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6454 GList *tmp_list = NULL;
6455 camera_cb_info *info = NULL;
6457 /* check camera support */
6458 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6459 if (ret != CAMERA_ERROR_NONE) {
6460 CAM_LOG_ERROR("get device state failed");
6464 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6466 if (!g_cam_dev_state_changed_cb_list) {
6467 CAM_LOG_ERROR("there is no callback info");
6468 ret = CAMERA_ERROR_INVALID_OPERATION;
6472 tmp_list = g_cam_dev_state_changed_cb_list;
6475 info = tmp_list->data;
6476 tmp_list = tmp_list->next;
6479 CAM_LOG_WARNING("NULL info");
6483 if (info->id == cb_id) {
6484 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6489 if (!g_cam_dev_state_changed_cb_list) {
6490 /* no remained callback */
6491 if (g_cam_dev_state_changed_cb_conn) {
6492 /* unsubscribe signal */
6493 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6494 g_cam_dev_state_changed_cb_subscribe_id = 0;
6496 /* unref connection */
6497 g_object_unref(g_cam_dev_state_changed_cb_conn);
6498 g_cam_dev_state_changed_cb_conn = NULL;
6502 CAM_LOG_INFO("id %d callback removed", cb_id);
6503 ret = CAMERA_ERROR_NONE;
6509 CAM_LOG_ERROR("id %d callback not found", cb_id);
6510 ret = CAMERA_ERROR_INVALID_PARAMETER;
6513 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6520 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6522 int ret = CAMERA_ERROR_NONE;
6523 camera_cli_s *pc = (camera_cli_s *)camera;
6524 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6526 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6528 g_mutex_lock(&pc->cb_info->bridge_lock);
6530 if (pc->cb_info->bridge) {
6531 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6532 ret = CAMERA_ERROR_INVALID_OPERATION;
6533 goto _SET_MEDIA_BRIDGE_DONE;
6536 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6537 if (ret != CAMERA_ERROR_NONE) {
6538 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6539 goto _SET_MEDIA_BRIDGE_DONE;
6542 pc->cb_info->bridge = bridge;
6544 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6546 _SET_MEDIA_BRIDGE_DONE:
6547 g_mutex_unlock(&pc->cb_info->bridge_lock);
6553 int camera_media_bridge_unset_bridge(camera_h camera)
6555 int ret = CAMERA_ERROR_NONE;
6556 camera_cli_s *pc = (camera_cli_s *)camera;
6557 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6559 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6561 g_mutex_lock(&pc->cb_info->bridge_lock);
6563 if (!pc->cb_info->bridge) {
6564 CAM_LOG_ERROR("no media bridge");
6565 ret = CAMERA_ERROR_INVALID_OPERATION;
6566 goto _UNSET_MEDIA_BRIDGE_DONE;
6569 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6570 if (ret != CAMERA_ERROR_NONE) {
6571 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6572 goto _UNSET_MEDIA_BRIDGE_DONE;
6575 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6577 pc->cb_info->bridge = NULL;
6579 _UNSET_MEDIA_BRIDGE_DONE:
6580 g_mutex_unlock(&pc->cb_info->bridge_lock);
6587 int camera_create_network(camera_device_e device, camera_h *camera)
6589 return _camera_create_private(device, true, camera);
6593 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6595 int ret = CAMERA_ERROR_NONE;
6596 camera_cli_s *pc = (camera_cli_s *)camera;
6597 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6599 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6601 if (!camera_is_supported_extra_preview(camera)) {
6602 CAM_LOG_ERROR("extra preview is not supported");
6603 return CAMERA_ERROR_NOT_SUPPORTED;
6607 CAM_LOG_ERROR("NULL callback");
6608 return CAMERA_ERROR_INVALID_PARAMETER;
6611 CAM_LOG_INFO("Enter");
6613 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6615 if (ret == CAMERA_ERROR_NONE) {
6616 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6618 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6619 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6621 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6624 CAM_LOG_INFO("ret : 0x%x", ret);
6630 int camera_unset_extra_preview_cb(camera_h camera)
6632 int ret = CAMERA_ERROR_NONE;
6633 camera_cli_s *pc = (camera_cli_s *)camera;
6634 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6636 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6638 if (!camera_is_supported_extra_preview(camera)) {
6639 CAM_LOG_ERROR("extra preview is not supported");
6640 return CAMERA_ERROR_NOT_SUPPORTED;
6643 CAM_LOG_INFO("Enter");
6645 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6647 if (ret == CAMERA_ERROR_NONE) {
6648 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6650 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6651 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6653 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6656 CAM_LOG_INFO("ret : 0x%x", ret);
6662 int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
6664 int ret = CAMERA_ERROR_NONE;
6665 int stream_format[4] = {pixel_format, width, height, fps};
6667 camera_cli_s *pc = (camera_cli_s *)camera;
6668 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6670 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6672 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6673 stream_id, pixel_format, width, height, fps);
6675 msg = muse_core_msg_new(api,
6676 MUSE_TYPE_INT, "stream_id", stream_id,
6677 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6680 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6686 int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e *pixel_format, int *width, int *height, int *fps)
6688 int ret = CAMERA_ERROR_NONE;
6689 camera_cli_s *pc = (camera_cli_s *)camera;
6690 camera_msg_param param;
6691 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6693 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6694 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6695 return CAMERA_ERROR_INVALID_PARAMETER;
6698 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6700 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6702 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6704 if (ret == CAMERA_ERROR_NONE) {
6705 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6706 *width = pc->cb_info->get_extra_preview_stream_format[1];
6707 *height = pc->cb_info->get_extra_preview_stream_format[2];
6708 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6711 CAM_LOG_INFO("ret : 0x%x", ret);
6717 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6719 int ret = CAMERA_ERROR_NONE;
6720 camera_cli_s *pc = (camera_cli_s *)camera;
6721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6722 camera_msg_param param0;
6723 camera_msg_param param1;
6725 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6727 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6729 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6730 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6732 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6733 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6735 CAM_LOG_INFO("ret : 0x%x", ret);
6741 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6743 int ret = CAMERA_ERROR_NONE;
6744 camera_cli_s *pc = (camera_cli_s *)camera;
6745 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6746 camera_msg_param param;
6748 if (!pc || !pc->cb_info || !bitrate) {
6749 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6750 return CAMERA_ERROR_INVALID_PARAMETER;
6753 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6755 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6759 if (ret == CAMERA_ERROR_NONE) {
6760 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6761 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6763 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6770 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6772 int ret = CAMERA_ERROR_NONE;
6773 camera_cli_s *pc = (camera_cli_s *)camera;
6774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6775 camera_msg_param param0;
6776 camera_msg_param param1;
6778 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6780 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6782 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6783 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6785 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6786 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6788 CAM_LOG_INFO("ret : 0x%x", ret);
6794 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6796 int ret = CAMERA_ERROR_NONE;
6797 camera_cli_s *pc = (camera_cli_s *)camera;
6798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6799 camera_msg_param param;
6801 if (!pc || !pc->cb_info || !interval) {
6802 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6803 return CAMERA_ERROR_INVALID_PARAMETER;
6806 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6808 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6810 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6812 if (ret == CAMERA_ERROR_NONE) {
6813 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6814 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6816 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6823 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6825 camera_cli_s *pc = (camera_cli_s *)camera;
6827 if (!pc || !pc->cb_info || !rotation) {
6828 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6829 return CAMERA_ERROR_INVALID_PARAMETER;
6832 if (!pc->cb_info->stream_data) {
6833 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6834 return CAMERA_ERROR_INVALID_OPERATION;
6837 *rotation = pc->cb_info->stream_data->rotation;
6839 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6841 return CAMERA_ERROR_NONE;
6845 int _camera_get_log_level(void)
6847 return g_camera_log_level;
6851 int _camera_attr_set_level(camera_h camera, muse_camera_api_e api, int level)
6853 int ret = CAMERA_ERROR_NONE;
6854 camera_cli_s *pc = (camera_cli_s *)camera;
6855 camera_msg_param param;
6857 if (!pc || !pc->cb_info) {
6858 CAM_LOG_ERROR("api[%d] NULL handle", api);
6859 return CAMERA_ERROR_INVALID_PARAMETER;
6862 CAM_LOG_INFO("api[%d] Enter - level[%d]", api, level);
6864 CAMERA_MSG_PARAM_SET(param, INT, level);
6866 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6868 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);
6874 int _camera_attr_get_level(camera_h camera, muse_camera_api_e api, muse_camera_get_int_e get_index, int *level)
6876 int ret = CAMERA_ERROR_NONE;
6877 camera_cli_s *pc = (camera_cli_s *)camera;
6879 if (!pc || !pc->cb_info || !level) {
6880 CAM_LOG_ERROR("api[%d] NULL param[%p,%p]", api, pc, level);
6881 return CAMERA_ERROR_INVALID_PARAMETER;
6884 if (get_index >= MUSE_CAMERA_GET_INT_NUM) {
6885 CAM_LOG_ERROR("api[%d] INVALID index[%d]", api, get_index);
6886 return CAMERA_ERROR_INVALID_OPERATION;
6889 CAM_LOG_INFO("api[%d] Enter", api);
6891 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6893 if (ret == CAMERA_ERROR_NONE) {
6894 *level = pc->cb_info->get_int[get_index];
6895 CAM_LOG_INFO("api[%d] level[%d]", api, *level);
6898 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);
6904 int _camera_attr_get_range(camera_h camera, muse_camera_api_e api, muse_camera_get_int_pair_e get_index, int *min, int *max)
6906 int ret = CAMERA_ERROR_NONE;
6907 camera_cli_s *pc = (camera_cli_s *)camera;
6909 if (!pc || !pc->cb_info || !min || !max) {
6910 CAM_LOG_ERROR("api[%d] NULL param[%p,%p,%p]", api, pc, min, max);
6911 return CAMERA_ERROR_INVALID_PARAMETER;
6914 if (get_index >= MUSE_CAMERA_GET_INT_PAIR_NUM) {
6915 CAM_LOG_ERROR("api[%d] INVALID index[%d]", api, get_index);
6916 return CAMERA_ERROR_INVALID_OPERATION;
6919 CAM_LOG_INFO("api[%d] Enter", api);
6921 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6923 if (ret == CAMERA_ERROR_NONE) {
6924 *min = pc->cb_info->get_int_pair[get_index][0];
6925 *max = pc->cb_info->get_int_pair[get_index][1];
6926 CAM_LOG_INFO("api[%d] min[%d], max[%d]", api, *min, *max);
6929 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);