2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera_msg.h>
25 #include <camera_private.h>
26 #include <muse_client.h>
29 #include <tbm_surface_internal.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_lock[api]));
206 cb_info->api_waiting[api] += value;
207 g_mutex_unlock(&(cb_info->api_lock[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;
223 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
225 if (!g_cam_dev_state_changed_cb_list || !param) {
226 CAM_LOG_WARNING("no callback or NULL param %p", param);
230 /* get device and state */
231 g_variant_get(param, "(i)", &value);
233 device = value >> 16;
234 state = 0x0000ffff & value;
236 CAM_LOG_INFO("device %d, state %d", device, state);
238 tmp_list = g_cam_dev_state_changed_cb_list;
241 info = (camera_cb_info *)tmp_list->data;
244 if (info->callback) {
245 CAM_LOG_INFO("start id[%d] callback", info->id);
246 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
247 CAM_LOG_INFO("returned id[%d] callback", info->id);
249 CAM_LOG_WARNING("NULL callback for id %d", info->id);
253 tmp_list = tmp_list->next;
258 static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
261 CAM_LOG_ERROR("NULL info_sub");
265 info_sub->frame_count = 0;
266 info_sub->elapsed_sec_accum = 0.0;
267 info_sub->elapsed_sec_peak = 0.0;
271 static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
274 CAM_LOG_ERROR("NULL info");
278 __camera_preview_cb_monitoring_info_sub_reset(info->total);
279 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
283 static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
286 CAM_LOG_ERROR("NULL info");
290 g_timer_start(info->timer_calling);
292 if (info->interval->frame_count == 0)
293 g_timer_start(info->timer_interval);
297 static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
300 CAM_LOG_ERROR("NULL info_sub");
304 info_sub->frame_count++;
305 info_sub->elapsed_sec_accum += elapsed_sec;
307 if (info_sub->elapsed_sec_peak < elapsed_sec)
308 info_sub->elapsed_sec_peak = elapsed_sec;
312 static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
314 gdouble elapsed_sec = 0.0;
315 gdouble elapsed_sec_interval = 0.0;
318 CAM_LOG_ERROR("NULL info");
322 elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
323 elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
325 __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
326 __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
328 if (elapsed_sec_interval >= 1.0) {
329 CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
330 info->stream_id, info->total->frame_count, info->interval->frame_count,
331 (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
332 (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
333 (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
335 __camera_preview_cb_monitoring_info_sub_reset(info->interval);
340 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
344 int ret_fd = CAMERA_FD_INIT;
345 int preview_fd = CAMERA_FD_INIT;
346 int num_buffer_fd = 0;
347 unsigned char *buf_pos = NULL;
350 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
351 tbm_bo_handle bo_handle = {.ptr = NULL};
352 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
353 tbm_bo data_bo = NULL;
354 tbm_bo_handle data_bo_handle = {.ptr = NULL};
356 camera_msg_param param;
357 camera_preview_data_s frame;
358 MMCamcorderVideoStreamDataType *stream = NULL;
359 camera_media_packet_data *mp_data = NULL;
360 media_packet_h pkt = NULL;
361 camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
363 /* tfd[0]: MMCamcorderVideoStreamDataType
364 tfd[1]: data_bo or zero copy bo[0]
365 tfd[2]: zero copy bo[1]
366 tfd[3]: zero copy bo[2] */
368 if (!cb_info || !recv_msg || !tfd) {
369 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
373 muse_camera_msg_get(preview_fd, recv_msg);
374 muse_camera_msg_get(num_buffer_fd, recv_msg);
376 CAM_LOG_DEBUG("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);
378 memset(&frame, 0x0, sizeof(camera_preview_data_s));
381 CAM_LOG_ERROR("invalid fd %d", tfd[0]);
386 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
388 if (cb_info->invoke_preview_cb == FALSE) {
389 CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
390 goto _PREVIEW_CB_HANDLER_DONE;
393 if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
394 CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
395 goto _PREVIEW_CB_HANDLER_DONE;
398 /* import tbm bo and get virtual address */
399 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
400 CAM_LOG_ERROR("failed to import fd %d", tfd[0]);
401 goto _PREVIEW_CB_HANDLER_DONE;
404 buf_pos = (unsigned char *)bo_handle.ptr;
406 /* get stream info */
407 stream = (MMCamcorderVideoStreamDataType *)buf_pos;
409 CAM_LOG_VERBOSE("meta [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu] [%llu]",
410 stream->frame_meta.ts_soe, stream->frame_meta.ts_eoe,
411 stream->frame_meta.ts_sof, stream->frame_meta.ts_eof,
412 stream->frame_meta.ts_hal, stream->frame_meta.ts_qmf,
413 stream->frame_meta.ts_gst, stream->frame_meta.td_exp,
414 stream->frame_meta.ts_aux, stream->frame_meta.td_aux,
415 stream->frame_meta.seqnum, stream->frame_meta.flags);
417 if (num_buffer_fd == 0 && CAMERA_IS_FD_VALID(tfd[1])) {
418 /* import tbm data_bo and get virtual address */
419 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
420 CAM_LOG_ERROR("failed to import data fd %d", tfd[1]);
421 goto _PREVIEW_CB_HANDLER_DONE;
424 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
425 stream->data.encoded.data = data_bo_handle.ptr;
427 for (i = 0 ; i < num_buffer_fd ; i++) {
428 /* import buffer bo and get virtual address */
429 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
430 CAM_LOG_ERROR("failed to import buffer fd %d", tfd[i + 1]);
431 goto _PREVIEW_CB_HANDLER_DONE;
435 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED)
436 stream->data.encoded.data = buffer_bo_handle[0].ptr;
439 /* preview callback */
440 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] ||
441 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]) {
442 camera_create_preview_frame(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
444 /* set stream data for camera_get_preview_frame_rotation() */
445 cb_info->stream_data = stream;
447 if (stream->extra_stream_id < 0) {
448 monitoring_info = cb_info->monitoring_info_preview;
449 __camera_preview_cb_monitoring_info_start(monitoring_info);
451 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
452 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
453 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
455 monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
456 __camera_preview_cb_monitoring_info_start(monitoring_info);
458 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
459 ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
460 stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
463 __camera_preview_cb_monitoring_info_end(monitoring_info);
465 cb_info->stream_data = NULL;
468 if (stream->extra_stream_id >= 0)
469 goto _PREVIEW_CB_HANDLER_DONE;
471 /* make media packet with below cases.
472 * 1. media_packet_preview_cb is set
473 * 2. EVAS display rendering
474 * 3. media bridge is set
477 g_mutex_lock(&cb_info->bridge_lock);
479 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
480 cb_info->is_evas_render ||
482 ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
483 if (ret != CAMERA_ERROR_NONE) {
484 g_mutex_unlock(&cb_info->bridge_lock);
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 g_mutex_unlock(&cb_info->bridge_lock);
492 CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
493 __camera_release_media_packet_data(mp_data, cb_info);
495 goto _PREVIEW_CB_HANDLER_DONE;
499 /* 3. media bridge */
500 if (cb_info->bridge) {
501 media_packet_ref(pkt);
502 ret = media_bridge_push_packet(cb_info->bridge, pkt);
503 if (ret != MEDIA_BRIDGE_ERROR_NONE) {
504 CAM_LOG_ERROR("push packet to bridge failed[0x%x]", ret);
505 media_packet_unref(pkt);
511 g_mutex_unlock(&cb_info->bridge_lock);
513 /* 1. media packet preview callback */
514 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
515 media_packet_ref(pkt);
517 monitoring_info = cb_info->monitoring_info_preview_mp;
518 __camera_preview_cb_monitoring_info_start(monitoring_info);
520 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
521 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
523 __camera_preview_cb_monitoring_info_end(monitoring_info);
526 /* 2. call evas renderer */
527 if (cb_info->is_evas_render) {
528 if (cb_info->run_evas_render) {
529 media_packet_ref(pkt);
530 ret = mm_display_interface_evas_render(cb_info->dp_interface, pkt);
531 if (ret != MM_ERROR_NONE) {
532 CAM_LOG_ERROR("mm_display_interface_evas_render failed[0x%x]", ret);
533 media_packet_unref(pkt);
536 CAM_LOG_WARNING("evas renderer is stopped, skip this buffer...");
540 _PREVIEW_CB_HANDLER_DONE:
541 /* send PREVIEW_CB_RETURN message if zero copy buffer is used */
542 if (num_buffer_fd > 0)
543 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
546 media_packet_unref(pkt);
551 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
553 CAM_LOG_DEBUG("return buffer Done[tfd:%d, ret fd:%d]", tfd[0], ret_fd);
555 /* release imported bo and fd */
556 __camera_release_imported_bo(&data_bo);
557 __camera_release_imported_bo(&bo);
559 for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
560 __camera_release_imported_bo(&buffer_bo[i]);
562 __camera_release_tfd(tfd);
566 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
569 int capture_fd_main = 0;
570 int capture_fd_post = 0;
571 int capture_fd_thumb = 0;
572 unsigned char *buf_pos = NULL;
574 camera_image_data_s *rImage = NULL;
575 camera_image_data_s *rPostview = NULL;
576 camera_image_data_s *rThumbnail = NULL;
578 tbm_bo bo_main = NULL;
579 tbm_bo bo_post = NULL;
580 tbm_bo bo_thumb = NULL;
581 tbm_bo_handle bo_main_handle = {.ptr = NULL};
582 tbm_bo_handle bo_post_handle = {.ptr = NULL};
583 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
585 if (!cb_info || !recv_msg || !tfd) {
586 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
590 muse_camera_msg_get(capture_fd_main, recv_msg);
591 muse_camera_msg_get(capture_fd_post, recv_msg);
592 muse_camera_msg_get(capture_fd_thumb, recv_msg);
594 CAM_LOG_INFO("capture fd %d %d %d, received fd %d %d %d",
595 capture_fd_main, capture_fd_post, capture_fd_thumb,
596 tfd[0], tfd[1], tfd[2]);
598 if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
599 CAM_LOG_ERROR("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
600 goto _CAPTURE_CB_HANDLER_DONE;
603 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
604 CAM_LOG_WARNING("NULL callback");
605 goto _CAPTURE_CB_HANDLER_DONE;
608 /* import tbm bo and get virtual address */
609 if (!__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
610 CAM_LOG_ERROR("failed to import fd [%d] for main", tfd[tfd_index]);
611 goto _CAPTURE_CB_HANDLER_DONE;
614 buf_pos = (unsigned char *)bo_main_handle.ptr;
615 rImage = (camera_image_data_s *)buf_pos;
616 rImage->data = buf_pos + sizeof(camera_image_data_s);
617 if (rImage->exif && rImage->exif_size > 0) {
618 rImage->exif = rImage->data + rImage->size;
621 rImage->exif_size = 0;
624 CAM_LOG_INFO("image info %dx%d, size %d, EXIF info %p, size %d",
625 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
628 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
629 /* import tbm bo and get virtual address */
631 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
632 buf_pos = (unsigned char *)bo_post_handle.ptr;
633 rPostview = (camera_image_data_s *)buf_pos;
634 CAM_LOG_INFO("rPostview->size : %d", rPostview->size);
635 rPostview->data = buf_pos + sizeof(camera_image_data_s);
637 CAM_LOG_ERROR("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
641 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
642 /* import tbm bo and get virtual address */
644 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
645 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
646 rThumbnail = (camera_image_data_s *)buf_pos;
647 CAM_LOG_INFO("rThumbnail->size : %d", rThumbnail->size);
648 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
650 CAM_LOG_ERROR("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
655 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
656 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
658 _CAPTURE_CB_HANDLER_DONE:
660 if (CAMERA_IS_FD_VALID(capture_fd_main)) {
661 __camera_release_imported_bo(&bo_main);
662 _camera_msg_return_buffer(capture_fd_main, cb_info);
665 if (CAMERA_IS_FD_VALID(capture_fd_post)) {
666 __camera_release_imported_bo(&bo_post);
667 _camera_msg_return_buffer(capture_fd_post, cb_info);
670 if (CAMERA_IS_FD_VALID(capture_fd_thumb)) {
671 __camera_release_imported_bo(&bo_thumb);
672 _camera_msg_return_buffer(capture_fd_thumb, cb_info);
675 __camera_release_tfd(tfd);
677 CAM_LOG_INFO("return buffer done");
682 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
685 int face_fd = CAMERA_FD_INIT;
686 camera_detected_face_s *faces = NULL;
689 tbm_bo_handle bo_handle = {.ptr = NULL};
691 if (!cb_info || !recv_msg || !tfd) {
692 CAM_LOG_ERROR("invalid param %p %p %p", cb_info, recv_msg, tfd);
696 muse_camera_msg_get(count, recv_msg);
697 muse_camera_msg_get(face_fd, recv_msg);
699 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
700 CAM_LOG_INFO("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
702 if (CAMERA_IS_FD_VALID(tfd[0])) {
703 if (__camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
705 faces = bo_handle.ptr;
709 tfd[0] = CAMERA_FD_INIT;
712 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
713 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
716 __camera_release_imported_bo(&bo);
718 CAM_LOG_WARNING("skip face detection message [count %d, fd %d, cb %p]",
719 count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
723 _camera_msg_return_buffer(face_fd, cb_info);
728 static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
730 tbm_bo tmp_bo = NULL;
731 tbm_bo_handle tmp_bo_handle = {NULL, };
733 if (!bufmgr || !bo || !bo_handle || fd < 0) {
734 CAM_LOG_ERROR("invalid parameter - %p %p %p, fd %d",
735 bufmgr, bo, bo_handle, fd);
739 tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
740 if (tmp_bo == NULL) {
741 CAM_LOG_ERROR("import failed - fd %d", fd);
745 tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
746 if (tmp_bo_handle.ptr == NULL) {
747 CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
748 tbm_bo_unref(tmp_bo);
753 /* set bo and bo_handle */
755 *bo_handle = tmp_bo_handle;
757 CAM_LOG_VERBOSE("fd[%d] -> bo[%p]", fd, tmp_bo);
762 static void __camera_release_imported_bo(tbm_bo *bo)
765 CAM_LOG_DEBUG("NULL bo");
774 static bool __is_supported(camera_h camera, muse_camera_api_e api)
776 int ret = CAMERA_ERROR_NONE;
777 camera_cli_s *pc = (camera_cli_s *)camera;
779 if (!pc || !pc->cb_info) {
780 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
781 set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
785 CAM_LOG_INFO("Enter - api[%d]", api);
787 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
789 CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
795 static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
797 int ret = CAMERA_ERROR_NONE;
798 camera_cli_s *pc = (camera_cli_s *)camera;
799 camera_msg_param param;
801 if (!pc || !pc->cb_info) {
802 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
803 return CAMERA_ERROR_INVALID_PARAMETER;
806 CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
808 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
810 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
812 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
818 static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
820 int ret = CAMERA_ERROR_NONE;
821 camera_cli_s *pc = (camera_cli_s *)camera;
822 camera_msg_param param;
824 if (!pc || !pc->cb_info) {
825 CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
826 return CAMERA_ERROR_INVALID_PARAMETER;
829 CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
831 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
833 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
835 CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
841 void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
846 CAM_LOG_ERROR("api[%d] message failed", api);
848 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
853 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
854 CAM_LOG_INFO("api[%d], message[%s]", api, msg);
856 CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
858 if (cb_info->is_server_connected) {
859 _camera_update_api_waiting(cb_info, api, 1);
861 g_mutex_lock(&cb_info->fd_lock);
862 send_ret = muse_core_msg_send(cb_info->fd, msg);
863 g_mutex_unlock(&cb_info->fd_lock);
867 CAM_LOG_ERROR("message send failed");
869 *ret = CAMERA_ERROR_INVALID_OPERATION;
872 *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
875 _camera_update_api_waiting(cb_info, api, -1);
877 muse_core_msg_free(msg);
879 if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
880 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
882 CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
886 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
888 int ret = CAMERA_ERROR_NONE;
890 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&cb_info->api_lock[api]);
892 if (!cb_info->is_server_connected) {
893 CAM_LOG_ERROR("server is disconnected");
894 return CAMERA_ERROR_SERVICE_DISCONNECTED;
897 CAM_LOG_INFO("api[%d] timeout[%ds] START:activating[%d]",
898 api, time_out, cb_info->api_activating[api]);
900 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
902 while (cb_info->api_activating[api] <= 0) {
903 if (time_out == CAMERA_CB_NO_TIMEOUT) {
904 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_lock[api]));
905 CAM_LOG_WARNING("api[%d] returned[0x%x]", api, cb_info->api_ret[api]);
906 } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_lock[api]), end_time)) {
907 CAM_LOG_ERROR("api[%d] TIMED OUT!", api);
908 return CAMERA_ERROR_INVALID_OPERATION;
911 if (!cb_info->is_server_connected) {
912 CAM_LOG_ERROR("server is disconnected");
913 return CAMERA_ERROR_SERVICE_DISCONNECTED;
916 if (cb_info->api_activating[api] <= 0)
917 CAM_LOG_WARNING("api[%d] invalid signal received, wait again...", api);
920 ret = cb_info->api_ret[api];
922 if (cb_info->api_activating[api] > 0) {
923 cb_info->api_activating[api]--;
924 CAM_LOG_INFO("api[%d] END:activating[%d]", api, cb_info->api_activating[api]);
926 CAM_LOG_WARNING("api[%d] invalid activating[%d]",
927 api, cb_info->api_activating[api]);
930 if (ret != CAMERA_ERROR_NONE)
931 CAM_LOG_ERROR("api[%d] : error 0x%x", api, ret);
937 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
938 int *ret, int timeout)
943 CAM_LOG_ERROR("NULL info - api %d", api);
946 *ret = CAMERA_ERROR_INVALID_PARAMETER;
951 msg = muse_core_msg_new(api, NULL);
953 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
957 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
958 int *ret, camera_msg_param *param, int timeout)
963 if (!cb_info || !param) {
964 CAM_LOG_ERROR("invalid pointer : api %d - %p %p", api, cb_info, param);
967 *ret = CAMERA_ERROR_INVALID_PARAMETER;
972 CAM_LOG_DEBUG("type[%d], name[%s]", param->type, param->name);
974 switch (param->type) {
976 msg = muse_core_msg_new(api,
977 param->type, param->name, param->value.value_INT,
980 case MUSE_TYPE_STRING:
981 msg = muse_core_msg_new(api,
982 param->type, param->name, param->value.value_STRING,
985 case MUSE_TYPE_ARRAY:
986 array_length = param->value_size / sizeof(int) + \
987 (param->value_size % sizeof(int) ? 1 : 0);
989 msg = muse_core_msg_new(api,
990 param->type, param->name, array_length, param->value.value_ARRAY,
994 CAM_LOG_ERROR("unknown type %d", param->type);
998 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1002 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
1003 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
1007 if (!cb_info || !param0 || !param1) {
1008 CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
1009 cb_info, param0, param1, api);
1012 *ret = CAMERA_ERROR_INVALID_PARAMETER;
1017 CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
1019 param0->name, param0->value.value_INT,
1020 param1->name, param1->value.value_INT);
1022 msg = muse_core_msg_new(api,
1023 param0->type, param0->name, param0->value.value_INT,
1024 param1->type, param1->name, param1->value.value_INT,
1027 _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
1031 void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
1033 camera_msg_param param;
1036 CAM_LOG_WARNING("invalid fd %d", ret_fd);
1040 CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
1042 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1046 int _camera_get_tbm_format(int in_format, uint32_t *out_format)
1048 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1049 in_format >= MM_PIXEL_FORMAT_NUM ||
1050 out_format == NULL) {
1051 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
1052 return CAMERA_ERROR_INVALID_PARAMETER;
1055 switch (in_format) {
1056 case MM_PIXEL_FORMAT_NV12:
1057 case MM_PIXEL_FORMAT_NV12T:
1058 *out_format = TBM_FORMAT_NV12;
1061 case MM_PIXEL_FORMAT_NV16:
1062 *out_format = TBM_FORMAT_NV16;
1064 case MM_PIXEL_FORMAT_NV21:
1065 *out_format = TBM_FORMAT_NV21;
1067 case MM_PIXEL_FORMAT_YUYV:
1068 *out_format = TBM_FORMAT_YUYV;
1070 case MM_PIXEL_FORMAT_UYVY:
1071 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1072 *out_format = TBM_FORMAT_UYVY;
1074 case MM_PIXEL_FORMAT_422P:
1075 *out_format = TBM_FORMAT_YUV422;
1077 case MM_PIXEL_FORMAT_I420:
1078 *out_format = TBM_FORMAT_YUV420;
1080 case MM_PIXEL_FORMAT_YV12:
1081 *out_format = TBM_FORMAT_YVU420;
1083 case MM_PIXEL_FORMAT_RGB565:
1084 *out_format = TBM_FORMAT_RGB565;
1086 case MM_PIXEL_FORMAT_RGB888:
1087 *out_format = TBM_FORMAT_RGB888;
1089 case MM_PIXEL_FORMAT_RGBA:
1090 *out_format = TBM_FORMAT_RGBA8888;
1092 case MM_PIXEL_FORMAT_ARGB:
1093 *out_format = TBM_FORMAT_ARGB8888;
1096 CAM_LOG_ERROR("invalid in_format %d", in_format);
1097 return CAMERA_ERROR_INVALID_PARAMETER;
1101 return CAMERA_ERROR_NONE;
1105 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
1107 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
1108 in_format >= MM_PIXEL_FORMAT_NUM ||
1110 CAM_LOG_ERROR("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
1111 return CAMERA_ERROR_INVALID_PARAMETER;
1114 switch (in_format) {
1115 case MM_PIXEL_FORMAT_NV12:
1116 case MM_PIXEL_FORMAT_NV12T:
1117 *mimetype = MEDIA_FORMAT_NV12;
1120 case MM_PIXEL_FORMAT_NV16:
1121 *mimetype = MEDIA_FORMAT_NV16;
1123 case MM_PIXEL_FORMAT_NV21:
1124 *mimetype = MEDIA_FORMAT_NV21;
1126 case MM_PIXEL_FORMAT_YUYV:
1127 *mimetype = MEDIA_FORMAT_YUYV;
1129 case MM_PIXEL_FORMAT_UYVY:
1130 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
1131 *mimetype = MEDIA_FORMAT_UYVY;
1133 case MM_PIXEL_FORMAT_422P:
1134 *mimetype = MEDIA_FORMAT_422P;
1136 case MM_PIXEL_FORMAT_I420:
1137 *mimetype = MEDIA_FORMAT_I420;
1139 case MM_PIXEL_FORMAT_YV12:
1140 *mimetype = MEDIA_FORMAT_YV12;
1142 case MM_PIXEL_FORMAT_RGB565:
1143 *mimetype = MEDIA_FORMAT_RGB565;
1145 case MM_PIXEL_FORMAT_RGB888:
1146 *mimetype = MEDIA_FORMAT_RGB888;
1148 case MM_PIXEL_FORMAT_RGBA:
1149 *mimetype = MEDIA_FORMAT_RGBA;
1151 case MM_PIXEL_FORMAT_ARGB:
1152 *mimetype = MEDIA_FORMAT_ARGB;
1154 case MM_PIXEL_FORMAT_ENCODED_H264:
1155 /* TODO: How can we determine the profile for H.264 format? */
1156 *mimetype = MEDIA_FORMAT_H264_SP;
1158 case MM_PIXEL_FORMAT_ENCODED_MJPEG:
1159 *mimetype = MEDIA_FORMAT_MJPEG;
1161 case MM_PIXEL_FORMAT_ENCODED_VP8:
1162 *mimetype = MEDIA_FORMAT_VP8;
1164 case MM_PIXEL_FORMAT_ENCODED_VP9:
1165 *mimetype = MEDIA_FORMAT_VP9;
1168 CAM_LOG_ERROR("unsupported format[%d]", in_format);
1169 return CAMERA_ERROR_NOT_SUPPORTED;
1173 return CAMERA_ERROR_NONE;
1177 static int __camera_create_media_packet_data(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
1178 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1181 int ret = CAMERA_ERROR_NONE;
1182 camera_media_packet_data *new_mp_data = NULL;
1184 if (!tfd || !mp_data) {
1185 CAM_LOG_ERROR("NULL param[%p,%p]", tfd, mp_data);
1186 return CAMERA_ERROR_INVALID_PARAMETER;
1189 new_mp_data = g_new0(camera_media_packet_data, 1);
1191 new_mp_data->ret_fd = ret_fd;
1192 new_mp_data->fd = tfd[0];
1193 new_mp_data->num_buffer_fd = num_buffer_fd;
1194 new_mp_data->bo = bo;
1196 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", new_mp_data->fd, new_mp_data->ret_fd);
1200 new_mp_data->data_bo = data_bo;
1201 new_mp_data->data_fd = tfd[1];
1203 CAM_LOG_VERBOSE("bo[%p], fd[%d]",
1204 new_mp_data->data_bo, new_mp_data->data_fd);
1207 for (i = 0 ; i < num_buffer_fd ; i++) {
1208 new_mp_data->buffer_bo[i] = buffer_bo[i];
1209 new_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
1211 CAM_LOG_VERBOSE(" [%d] bo[%p], fd[%d]",
1212 i, new_mp_data->buffer_bo[i], new_mp_data->buffer_fd[i]);
1215 for (i = num_buffer_fd ; i < MUSE_NUM_FD ; i++)
1216 new_mp_data->buffer_fd[i] = CAMERA_FD_INIT;
1218 new_mp_data->data_fd = CAMERA_FD_INIT;
1221 *mp_data = new_mp_data;
1223 CAM_LOG_DEBUG("mp_data %p", new_mp_data);
1228 static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1232 if (!mp_data || !cb_info) {
1233 CAM_LOG_ERROR("NULL pointer %p %p", mp_data, cb_info);
1237 CAM_LOG_VERBOSE("tfd[%d], ret fd[%d]", mp_data->fd, mp_data->ret_fd);
1239 /* release imported bo and close fd */
1240 for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
1241 CAM_LOG_VERBOSE(" release buffer[%d] fd[%d],bo[%p]",
1242 i, mp_data->buffer_fd[i], mp_data->buffer_bo[i]);
1244 tbm_bo_unref(mp_data->buffer_bo[i]);
1246 if (CAMERA_IS_FD_VALID(mp_data->buffer_fd[i]))
1247 close(mp_data->buffer_fd[i]);
1249 CAM_LOG_WARNING("invalid fd[%d] for buffer[%d]", mp_data->buffer_fd[i], i);
1252 if (mp_data->data_bo) {
1253 CAM_LOG_VERBOSE("release data_fd[%d],data_bo[%p]",
1254 mp_data->data_fd, mp_data->data_bo);
1256 tbm_bo_unref(mp_data->data_bo);
1258 if (CAMERA_IS_FD_VALID(mp_data->data_fd))
1259 close(mp_data->data_fd);
1261 CAM_LOG_WARNING("invalid data_fd[%d]", mp_data->data_fd);
1264 CAM_LOG_VERBOSE("release fd[%d],bo[%p]", mp_data->fd, mp_data->bo);
1266 tbm_bo_unref(mp_data->bo);
1268 if (CAMERA_IS_FD_VALID(mp_data->fd))
1271 CAM_LOG_WARNING("invalid fd[%d]", mp_data->fd);
1274 _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
1280 static tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data)
1283 int ret = CAMERA_ERROR_NONE;
1284 uint32_t tbm_format = 0;
1285 tbm_bo bos[BUFFER_MAX_PLANE_NUM] = {NULL, };
1286 tbm_surface_info_s tsurf_info;
1288 if (!stream || !mp_data) {
1289 CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data);
1293 if (mp_data->num_buffer_fd < 1 && !mp_data->data_bo) {
1294 CAM_LOG_ERROR("No valid data");
1298 ret = _camera_get_tbm_format(stream->format, &tbm_format);
1299 if (ret != CAMERA_ERROR_NONE)
1302 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1304 if (mp_data->num_buffer_fd > 0) {
1305 for (i = 0 ; i < mp_data->num_buffer_fd ; i++)
1306 bos[i] = mp_data->buffer_bo[i];
1308 bos[0] = mp_data->data_bo;
1311 tsurf_info.width = stream->width;
1312 tsurf_info.height = stream->height;
1313 tsurf_info.format = tbm_format;
1314 tsurf_info.bpp = tbm_surface_internal_get_bpp(tbm_format);
1315 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(tbm_format);
1317 switch (tbm_format) {
1318 case TBM_FORMAT_NV12: /* fall through */
1319 case TBM_FORMAT_NV21: /* fall through */
1320 case TBM_FORMAT_YUV420: /* fall through */
1321 case TBM_FORMAT_YVU420: /* fall through */
1322 case TBM_FORMAT_UYVY: /* fall through */
1323 case TBM_FORMAT_YUYV:
1324 for (i = 0 ; i < (int)tsurf_info.num_planes ; i++) {
1325 tsurf_info.planes[i].stride = stream->stride[i];
1326 tsurf_info.planes[i].size = stream->stride[i] * stream->elevation[i];
1327 if (i != 0 && mp_data->num_buffer_fd <= 1)
1328 tsurf_info.planes[i].offset = tsurf_info.planes[i - 1].offset + tsurf_info.planes[i - 1].size;
1329 tsurf_info.size += tsurf_info.planes[i].size;
1331 CAM_LOG_VERBOSE("[plane:%d] st[%d], el[%d], size[%d]",
1332 i, stream->stride[i], stream->elevation[i], tsurf_info.planes[i].size);
1336 case TBM_FORMAT_RGB565: /* fall through */
1337 case TBM_FORMAT_RGB888: /* fall through */
1338 case TBM_FORMAT_RGBA8888: /* fall through */
1339 case TBM_FORMAT_ARGB8888:
1340 tsurf_info.planes[0].size = stream->data.rgb.length_data;
1341 tsurf_info.planes[0].offset = 0;
1342 tsurf_info.size = stream->data.rgb.length_data;
1345 CAM_LOG_ERROR("Not supported format[%d]", stream->format);
1350 return tbm_surface_internal_create_with_bos(&tsurf_info, bos,
1351 mp_data->num_buffer_fd > 0 ? mp_data->num_buffer_fd : 1);
1355 static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
1357 int ret = CAMERA_ERROR_NONE;
1358 int pkt_fmt_width = 0;
1359 int pkt_fmt_height = 0;
1360 bool make_pkt_fmt = false;
1361 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1362 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1364 if (!cb_info || !stream) {
1365 CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
1366 return CAMERA_ERROR_INVALID_PARAMETER;
1369 ret = _camera_get_media_packet_mimetype(stream->format, &mimetype);
1370 if (ret != CAMERA_ERROR_NONE)
1373 /* check media packet format */
1374 if (cb_info->pkt_fmt) {
1375 media_format_get_video_info(cb_info->pkt_fmt,
1376 &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1378 CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
1379 pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
1381 if (pkt_fmt_mimetype != mimetype ||
1382 pkt_fmt_width != stream->width ||
1383 pkt_fmt_height != stream->height) {
1384 CAM_LOG_WARNING("change fmt[previous:0x%x,%dx%d]",
1385 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1387 media_format_unref(cb_info->pkt_fmt);
1388 cb_info->pkt_fmt = NULL;
1389 make_pkt_fmt = true;
1392 make_pkt_fmt = true;
1395 /* create packet format */
1397 CAM_LOG_WARNING("make new fmt - 0x%x, %dx%d",
1398 mimetype, stream->width, stream->height);
1400 ret = media_format_create(&cb_info->pkt_fmt);
1401 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1402 CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
1403 return CAMERA_ERROR_INVALID_OPERATION;
1406 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1407 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1408 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1409 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1410 CAM_LOG_ERROR("media format set failed 0x%x", ret);
1411 return CAMERA_ERROR_INVALID_OPERATION;
1415 return CAMERA_ERROR_NONE;
1419 static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
1420 camera_media_packet_data *mp_data, media_packet_h *packet)
1422 media_packet_h pkt = NULL;
1423 tbm_surface_h tsurf = NULL;
1424 int ret = CAMERA_ERROR_NONE;
1426 if (!cb_info || !stream || !mp_data || !packet) {
1427 CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
1428 cb_info, stream, mp_data, packet);
1429 return CAMERA_ERROR_INVALID_PARAMETER;
1432 ret = __camera_update_media_packet_format(cb_info, stream);
1433 if (ret != CAMERA_ERROR_NONE)
1436 if (stream->data_type == MM_CAM_STREAM_DATA_ENCODED) {
1437 ret = media_packet_new_from_external_memory(cb_info->pkt_fmt,
1438 stream->data.encoded.data, stream->data.encoded.length_data,
1439 (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
1443 if (!stream->data.encoded.is_delta_frame)
1444 media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
1446 if (stream->data.encoded.is_header_included) {
1447 media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
1448 CAM_LOG_INFO("Codec config in buffer");
1452 tsurf = __camera_get_tbm_surface(stream, mp_data);
1454 CAM_LOG_ERROR("get tbm surface failed");
1455 ret = CAMERA_ERROR_INVALID_OPERATION;
1456 goto _PACKET_CREATE_FAILED;
1459 ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
1460 tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
1461 (void *)cb_info, &pkt);
1464 if (ret != MEDIA_PACKET_ERROR_NONE) {
1465 CAM_LOG_ERROR("media_packet_new[t:%d] failed 0x%x", stream->data_type, ret);
1466 goto _PACKET_CREATE_FAILED;
1469 ret = media_packet_set_extra(pkt, (void *)mp_data);
1470 if (ret != MEDIA_PACKET_ERROR_NONE) {
1471 CAM_LOG_ERROR("media_packet_set_extra failed");
1472 goto _PACKET_CREATE_FAILED;
1475 if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
1476 CAM_LOG_WARNING("media_packet_set_pts failed");
1478 if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
1479 CAM_LOG_WARNING("media_packet_set_rotate_method failed");
1481 CAM_LOG_VERBOSE("new media packet[%p], tbm surface[%p]", pkt, tsurf);
1485 return CAMERA_ERROR_NONE;
1487 _PACKET_CREATE_FAILED:
1489 tbm_surface_destroy(tsurf);
1491 media_packet_unref(pkt);
1493 return CAMERA_ERROR_INVALID_OPERATION;
1496 void _camera_media_packet_dispose(media_packet_h pkt, void *user_data)
1499 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1500 camera_media_packet_data *mp_data = NULL;
1501 tbm_surface_h tsurf = NULL;
1503 if (!pkt || !cb_info) {
1504 CAM_LOG_ERROR("NULL pointer %p %p", pkt, cb_info);
1508 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1509 if (ret != MEDIA_PACKET_ERROR_NONE || !mp_data) {
1510 CAM_LOG_ERROR("media_packet_get_extra failed 0x%x", ret);
1514 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1516 CAM_LOG_VERBOSE("media packet[%p] - mp_data[%p],tsurf[%p]",
1517 pkt, mp_data, tsurf);
1520 tbm_surface_destroy(tsurf);
1522 g_mutex_lock(&cb_info->mp_data_lock);
1523 __camera_release_media_packet_data(mp_data, cb_info);
1524 g_mutex_unlock(&cb_info->mp_data_lock);
1527 static void __camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
1531 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&cb_info->user_cb_lock[event]);
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 if (cb_info->user_cb[event] == NULL) {
1541 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1542 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1543 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1544 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1545 CAM_LOG_WARNING("NULL callback for event %d, return here", event);
1549 /* return buffer message should be sent for some events.
1550 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1551 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1552 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1553 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1558 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1564 muse_camera_msg_get(previous, recv_msg);
1565 muse_camera_msg_get(current, recv_msg);
1566 muse_camera_msg_get(by_policy, recv_msg);
1568 CAM_LOG_INFO("STATE CHANGE - previous %d, current %d, by_policy %d",
1569 previous, current, by_policy);
1571 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1572 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1575 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1579 muse_camera_msg_get(state, recv_msg);
1581 CAM_LOG_INFO("FOCUS state - %d", state);
1583 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1586 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1587 CAM_LOG_INFO("CAPTURE_COMPLETED");
1588 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1590 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1591 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1592 __camera_event_handler_preview(cb_info, recv_msg, tfd);
1595 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1599 muse_camera_msg_get(percent, recv_msg);
1601 CAM_LOG_INFO("HDR progress - %d %%", percent);
1603 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1606 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1612 muse_camera_msg_get(policy, recv_msg);
1613 muse_camera_msg_get(previous, recv_msg);
1614 muse_camera_msg_get(current, recv_msg);
1616 CAM_LOG_WARNING("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1618 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1619 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1622 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1627 muse_camera_msg_get(policy, recv_msg);
1628 muse_camera_msg_get(state, recv_msg);
1630 CAM_LOG_WARNING("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1632 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1633 (camera_state_e)state, cb_info->user_data[event]);
1636 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1637 __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
1639 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1642 int current_state = 0;
1644 muse_camera_msg_get(error, recv_msg);
1645 muse_camera_msg_get(current_state, recv_msg);
1647 CAM_LOG_ERROR("ERROR - error 0x%x, current_state %d", error, current_state);
1649 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1650 (camera_state_e)current_state, cb_info->user_data[event]);
1654 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1656 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1657 muse_camera_msg_get(param1, recv_msg);
1658 muse_camera_msg_get(param2, recv_msg);
1660 CAM_LOG_DEBUG("event[%d] SUPPORTED[%d],[%d]", event, param1, param2);
1662 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1663 cb_info->user_cb[event] = NULL;
1664 cb_info->user_data[event] = NULL;
1665 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1668 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1670 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1672 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1674 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1676 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1678 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1680 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1682 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1684 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1686 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1688 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1690 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1692 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1695 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1697 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1698 muse_camera_msg_get(param1, recv_msg);
1700 CAM_LOG_DEBUG("event[%d], SUPPORTED[%d] ", event, param1);
1702 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1703 cb_info->user_cb[event] = NULL;
1704 cb_info->user_data[event] = NULL;
1705 CAM_LOG_WARNING("stop foreach callback for event %d", event);
1709 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1710 __camera_event_handler_capture(cb_info, recv_msg, tfd);
1713 CAM_LOG_WARNING("unhandled event %d", event);
1718 static gboolean __camera_idle_event_callback(gpointer data)
1720 camera_cb_info_s *cb_info = NULL;
1721 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1723 if (cam_idle_event == NULL) {
1724 CAM_LOG_ERROR("cam_idle_event is NULL");
1729 g_mutex_lock(&g_cam_idle_event_lock);
1731 cb_info = cam_idle_event->cb_info;
1732 if (cb_info == NULL) {
1733 CAM_LOG_WARNING("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1734 g_mutex_unlock(&g_cam_idle_event_lock);
1735 goto IDLE_EVENT_CALLBACK_DONE;
1738 /* remove event from list */
1739 if (cb_info->idle_event_list)
1740 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1742 g_mutex_unlock(&g_cam_idle_event_lock);
1745 __camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
1747 IDLE_EVENT_CALLBACK_DONE:
1749 g_free(cam_idle_event);
1750 cam_idle_event = NULL;
1755 static gpointer __camera_msg_handler_func(gpointer data)
1759 camera_message_s *cam_msg = NULL;
1760 camera_idle_event_s *cam_idle_event = NULL;
1761 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1762 camera_cb_info_s *cb_info = NULL;
1763 GThread *thread = NULL;
1765 if (!handler_info || !handler_info->cb_info) {
1766 CAM_LOG_ERROR("NULL handler %p", handler_info);
1770 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1771 type = handler_info->type;
1772 thread = handler_info->thread;
1774 CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
1776 g_mutex_lock(&handler_info->lock);
1778 while (g_atomic_int_get(&handler_info->running)) {
1779 if (g_queue_is_empty(handler_info->queue)) {
1780 CAM_LOG_VERBOSE("t[%d] signal wait...", type);
1781 g_cond_wait(&handler_info->cond, &handler_info->lock);
1782 CAM_LOG_VERBOSE("t[%d] signal received", type);
1784 if (g_atomic_int_get(&handler_info->running) == 0) {
1785 CAM_LOG_INFO("t:%d stop event thread", type);
1790 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1792 g_mutex_unlock(&handler_info->lock);
1794 if (cam_msg == NULL) {
1795 CAM_LOG_ERROR("t:%d NULL message", type);
1796 g_mutex_lock(&handler_info->lock);
1802 if (api < MUSE_CAMERA_API_MAX) {
1805 g_mutex_lock(&cb_info->api_lock[api]);
1807 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1808 if (cb_info->api_waiting[api] > 0) {
1809 cb_info->api_ret[api] = ret;
1811 if (cb_info->api_activating[api] < 0) {
1812 CAM_LOG_WARNING("api[%d] invalid activating[%d]",
1813 api, cb_info->api_activating[api]);
1815 cb_info->api_activating[api] = 0;
1818 cb_info->api_activating[api]++;
1820 CAM_LOG_DEBUG("t[%d] camera api[%d] - return[0x%x]", type, api, ret);
1822 g_cond_broadcast(&cb_info->api_cond[api]);
1824 CAM_LOG_WARNING("no waiting for this api [%d]", api);
1827 CAM_LOG_ERROR("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1830 g_mutex_unlock(&cb_info->api_lock[api]);
1831 } else if (api == MUSE_CAMERA_CB_EVENT) {
1832 if (cam_msg->event == MUSE_CAMERA_EVENT_TYPE_INTERRUPTED) {
1833 CAM_LOG_WARNING("INTERRUPTED, release thread for preview cb");
1834 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1837 switch (cam_msg->event_class) {
1838 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1839 __camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
1841 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1842 cam_idle_event = g_new0(camera_idle_event_s, 1);
1843 if (cam_idle_event == NULL) {
1844 CAM_LOG_ERROR("t:%d cam_idle_event alloc failed", type);
1848 cam_idle_event->event = cam_msg->event;
1849 cam_idle_event->cb_info = cb_info;
1851 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1852 memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
1854 CAM_LOG_DEBUG("t[%d] add camera event[%d, %p] to IDLE",
1855 type, cam_msg->event, cam_idle_event);
1857 g_mutex_lock(&g_cam_idle_event_lock);
1858 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1859 g_mutex_unlock(&g_cam_idle_event_lock);
1861 g_idle_add_full(G_PRIORITY_DEFAULT,
1862 (GSourceFunc)__camera_idle_event_callback,
1863 (gpointer)cam_idle_event,
1867 CAM_LOG_ERROR("t:%d not handled event class %d", type, cam_msg->event_class);
1871 CAM_LOG_ERROR("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1876 g_mutex_lock(&handler_info->lock);
1879 /* remove remained event */
1880 while (!g_queue_is_empty(handler_info->queue)) {
1881 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1883 CAM_LOG_INFO("t:%d remove message %p", type, cam_msg);
1884 __camera_release_tfd(cam_msg->tfd);
1887 CAM_LOG_WARNING("t:%d NULL message", type);
1891 g_mutex_unlock(&handler_info->lock);
1893 CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
1899 static void __camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1901 camera_idle_event_s *cam_idle_event = NULL;
1903 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&g_cam_idle_event_lock);
1905 if (cb_info == NULL) {
1906 CAM_LOG_ERROR("cb_info is NULL");
1910 if (cb_info->idle_event_list == NULL) {
1911 CAM_LOG_INFO("No remained idle event");
1915 list = cb_info->idle_event_list;
1918 cam_idle_event = list->data;
1919 list = g_list_next(list);
1921 if (!cam_idle_event) {
1922 CAM_LOG_WARNING("Fail to remove idle event. The event is NULL");
1926 if (g_idle_remove_by_data(cam_idle_event)) {
1927 CAM_LOG_WARNING("remove idle event %p done", cam_idle_event);
1929 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1931 g_free(cam_idle_event);
1936 CAM_LOG_WARNING("set NULL cb_info for event %p %d, it will be freed on idle callback",
1937 cam_idle_event, cam_idle_event->event);
1939 cam_idle_event->cb_info = NULL;
1941 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1944 g_list_free(cb_info->idle_event_list);
1945 cb_info->idle_event_list = NULL;
1949 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
1951 camera_message_s *cam_msg = NULL;
1953 if (!cb_info || !msg) {
1954 CAM_LOG_ERROR("NULL pointer %p %p", cb_info, msg);
1958 cam_msg = g_new0(camera_message_s, 1);
1960 CAM_LOG_ERROR("failed to alloc cam_msg for [%s]", msg);
1965 cam_msg->event = event;
1966 cam_msg->event_class = event_class;
1969 memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
1971 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1973 CAM_LOG_DEBUG("add message to queue : api[%d], event[%d], event_class[%d]",
1974 api, event, event_class);
1976 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1977 if (!cb_info->preview_cb_info.thread) {
1978 LOGI("The thread for preview cb is not created yet, create it now");
1979 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1980 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", cb_info)) {
1981 CAM_LOG_ERROR("failed to create thread for preview cb");
1987 g_mutex_lock(&cb_info->preview_cb_info.lock);
1988 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1989 g_cond_signal(&cb_info->preview_cb_info.cond);
1990 g_mutex_unlock(&cb_info->preview_cb_info.lock);
1991 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1992 g_mutex_lock(&cb_info->capture_cb_info.lock);
1993 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1994 g_cond_signal(&cb_info->capture_cb_info.cond);
1995 g_mutex_unlock(&cb_info->capture_cb_info.lock);
1997 g_mutex_lock(&cb_info->msg_handler_info.lock);
1998 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1999 g_cond_signal(&cb_info->msg_handler_info.cond);
2000 g_mutex_unlock(&cb_info->msg_handler_info.lock);
2007 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
2009 int ret = CAMERA_ERROR_NONE;
2013 int event_class = -1;
2017 if (!cb_info || !msg) {
2018 CAM_LOG_ERROR("invalid ptr %p %p", cb_info, msg);
2022 CAM_LOG_DEBUG("msg[%s]", msg);
2024 if (!muse_camera_msg_get(api, msg)) {
2025 CAM_LOG_ERROR("failed to get camera api");
2029 if (api == MUSE_CAMERA_CB_EVENT) {
2030 if (!muse_camera_msg_get(event, msg) ||
2031 !muse_camera_msg_get(event_class, msg)) {
2032 CAM_LOG_ERROR("failed to get camera event or event_class [%s]", msg);
2036 if (!muse_camera_msg_get(api_class, msg)) {
2037 CAM_LOG_ERROR("failed to get camera api_class [%s]", msg);
2042 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
2043 if (api >= MUSE_CAMERA_API_MAX) {
2044 CAM_LOG_ERROR("invalid api %d", api);
2048 if (!muse_camera_msg_get(ret, msg)) {
2049 CAM_LOG_ERROR("failed to get camera ret");
2053 g_mutex_lock(&cb_info->api_lock[api]);
2056 case MUSE_CAMERA_API_CREATE:
2057 if (ret != CAMERA_ERROR_NONE) {
2058 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2059 CAM_LOG_ERROR("camera create error 0x%x. close client cb handler", ret);
2062 case MUSE_CAMERA_API_DESTROY:
2063 if (ret == CAMERA_ERROR_NONE) {
2064 g_atomic_int_set(&cb_info->msg_recv_running, 0);
2065 CAM_LOG_INFO("camera destroy done. close client cb handler");
2069 muse_camera_msg_get(get_type, msg);
2070 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2071 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2072 muse_camera_msg_get(get_index, msg);
2075 case MUSE_CAMERA_GET_TYPE_INT:
2076 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2078 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2079 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2080 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2082 case MUSE_CAMERA_GET_TYPE_ARRAY:
2084 case MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA:
2085 muse_core_msg_deserialize("get_value",
2086 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2087 CAM_LOG_INFO("get display roi %d,%d,%dx%d",
2088 cb_info->get_display_roi_area[0],
2089 cb_info->get_display_roi_area[1],
2090 cb_info->get_display_roi_area[2],
2091 cb_info->get_display_roi_area[3]);
2093 case MUSE_CAMERA_API_ATTR_GET_GEOTAG:
2094 muse_core_msg_deserialize("get_value",
2095 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2096 CAM_LOG_INFO("get geotag %lf, %lf, %lf",
2097 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2099 case MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT:
2100 muse_core_msg_deserialize("get_value",
2101 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_extra_preview_stream_format);
2102 CAM_LOG_INFO("get extra preview stream format %d,%dx%d,%d",
2103 cb_info->get_extra_preview_stream_format[0],
2104 cb_info->get_extra_preview_stream_format[1],
2105 cb_info->get_extra_preview_stream_format[2],
2106 cb_info->get_extra_preview_stream_format[3]);
2109 CAM_LOG_WARNING("unknown api[%d]", api);
2113 case MUSE_CAMERA_GET_TYPE_STRING:
2114 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2117 CAM_LOG_WARNING("unknown type %d", get_type);
2124 if (cb_info->api_waiting[api] > 0) {
2125 cb_info->api_ret[api] = ret;
2127 if (cb_info->api_activating[api] < 0) {
2128 CAM_LOG_WARNING("api[%d] invalid activating[%d]",
2129 api, cb_info->api_activating[api]);
2131 cb_info->api_activating[api] = 0;
2134 cb_info->api_activating[api]++;
2136 g_cond_broadcast(&cb_info->api_cond[api]);
2138 CAM_LOG_WARNING("no waiting for this api [%d]", api);
2141 g_mutex_unlock(&cb_info->api_lock[api]);
2142 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2143 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
2145 CAM_LOG_WARNING("unknown camera api %d, class %d", api, api_class);
2150 static gpointer __camera_msg_recv_func(gpointer data)
2153 int recv_length = 0;
2154 int tfd[MUSE_NUM_FD] = {CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT, CAMERA_FD_INIT};
2155 char *recv_msg = NULL;
2156 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2159 CAM_LOG_ERROR("cb_info NULL");
2163 CAM_LOG_INFO("start - fd : %d", cb_info->fd);
2165 recv_msg = cb_info->recv_msg;
2167 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2168 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2169 tfd[i] = CAMERA_FD_INIT;
2171 recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
2172 if (recv_length <= 0) {
2173 cb_info->is_server_connected = FALSE;
2174 CAM_LOG_ERROR("receive msg failed - server disconnected");
2178 if (CAMERA_IS_FD_VALID(tfd[0]))
2179 CAM_LOG_DEBUG("tfd[%d/%d/%d/%d]", tfd[0], tfd[1], tfd[2], tfd[3]);
2181 recv_msg[recv_length] = '\0';
2183 CAM_LOG_VERBOSE("recv msg[%s], length[%d]", recv_msg, recv_length);
2185 __camera_process_msg(cb_info, recv_msg, tfd);
2188 CAM_LOG_INFO("client cb exit - server connected %d", cb_info->is_server_connected);
2191 if (!cb_info->is_server_connected) {
2192 char *error_msg = NULL;
2194 if (cb_info->bufmgr == NULL) {
2195 CAM_LOG_ERROR("No need to send error(handle is not created)");
2199 if (cb_info->fd < 0) {
2200 CAM_LOG_ERROR("fd is closed in client side");
2204 /* send error msg for server disconnection */
2205 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2206 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2207 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2211 CAM_LOG_ERROR("error_msg failed");
2215 __camera_add_msg_to_queue(cb_info,
2216 MUSE_CAMERA_CB_EVENT,
2217 MUSE_CAMERA_EVENT_TYPE_ERROR,
2218 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2222 muse_core_msg_free(error_msg);
2225 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2226 if (cb_info->api_waiting[i])
2227 g_cond_broadcast(&cb_info->api_cond[i]);
2230 CAM_LOG_ERROR("add error msg for service disconnection done");
2238 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2239 int type, const char *thread_name, camera_cb_info_s *cb_info)
2241 if (!handler_info || !thread_name || !cb_info) {
2242 CAM_LOG_ERROR("t:%d NULL %p %p %p",
2243 type, handler_info, thread_name, cb_info);
2247 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->lock);
2249 if (handler_info->thread) {
2250 CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
2254 CAM_LOG_INFO("t:%d [%s]", type, thread_name);
2256 handler_info->type = type;
2257 handler_info->queue = g_queue_new();
2258 if (handler_info->queue == NULL) {
2259 CAM_LOG_ERROR("t:%d queue failed", type);
2263 handler_info->cb_info = (void *)cb_info;
2264 g_atomic_int_set(&handler_info->running, 1);
2266 handler_info->thread = g_thread_try_new(thread_name,
2267 __camera_msg_handler_func, (gpointer)handler_info, NULL);
2268 if (handler_info->thread == NULL) {
2269 CAM_LOG_ERROR("t:%d thread failed", type);
2271 g_queue_free(handler_info->queue);
2272 handler_info->queue = NULL;
2277 CAM_LOG_INFO("t:%d done[thread:%p]", type, handler_info->thread);
2283 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2285 GThread *thread = NULL;
2287 if (!handler_info) {
2288 CAM_LOG_ERROR("NULL handler");
2292 g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->lock);
2294 if (!handler_info->thread) {
2295 CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
2299 thread = handler_info->thread;
2300 handler_info->thread = NULL;
2302 CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
2304 g_atomic_int_set(&handler_info->running, 0);
2305 g_cond_signal(&handler_info->cond);
2307 g_clear_pointer(&locker, g_mutex_locker_free);
2309 g_thread_join(thread);
2311 g_queue_free(handler_info->queue);
2312 handler_info->queue = NULL;
2314 CAM_LOG_INFO("t:%d done", handler_info->type);
2318 static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
2323 CAM_LOG_ERROR("NULL cb_info");
2327 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2328 g_mutex_init(&cb_info->api_lock[i]);
2329 g_cond_init(&cb_info->api_cond[i]);
2332 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2333 g_mutex_init(&cb_info->user_cb_lock[i]);
2335 g_mutex_init(&cb_info->fd_lock);
2336 g_mutex_init(&cb_info->mp_data_lock);
2337 g_mutex_init(&cb_info->bridge_lock);
2339 g_mutex_init(&cb_info->msg_handler_info.lock);
2340 g_mutex_init(&cb_info->preview_cb_info.lock);
2341 g_mutex_init(&cb_info->capture_cb_info.lock);
2342 g_cond_init(&cb_info->msg_handler_info.cond);
2343 g_cond_init(&cb_info->preview_cb_info.cond);
2344 g_cond_init(&cb_info->capture_cb_info.cond);
2346 CAM_LOG_INFO("done");
2350 static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
2355 CAM_LOG_ERROR("NULL cb_info");
2359 g_mutex_clear(&cb_info->msg_handler_info.lock);
2360 g_mutex_clear(&cb_info->preview_cb_info.lock);
2361 g_mutex_clear(&cb_info->capture_cb_info.lock);
2362 g_cond_clear(&cb_info->msg_handler_info.cond);
2363 g_cond_clear(&cb_info->preview_cb_info.cond);
2364 g_cond_clear(&cb_info->capture_cb_info.cond);
2366 g_mutex_clear(&cb_info->fd_lock);
2367 g_mutex_clear(&cb_info->mp_data_lock);
2368 g_mutex_clear(&cb_info->bridge_lock);
2370 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2371 g_mutex_clear(&cb_info->user_cb_lock[i]);
2373 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2374 g_mutex_clear(&cb_info->api_lock[i]);
2375 g_cond_clear(&cb_info->api_cond[i]);
2378 CAM_LOG_INFO("done");
2382 static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
2384 camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
2386 new_info->stream_id = stream_id;
2387 new_info->total = g_new0(monitoring_info_sub_s, 1);
2388 new_info->interval = g_new0(monitoring_info_sub_s, 1);
2389 new_info->timer_calling = g_timer_new();
2390 new_info->timer_interval = g_timer_new();
2392 CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
2398 static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
2403 g_timer_destroy(info->timer_calling);
2404 g_timer_destroy(info->timer_interval);
2405 g_free(info->total);
2406 g_free(info->interval);
2408 CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
2414 static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
2417 camera_cb_info_s *cb_info = NULL;
2419 g_return_val_if_fail(sockfd > 0, NULL);
2421 cb_info = g_new0(camera_cb_info_s, 1);
2423 CAM_LOG_ERROR("cb_info failed");
2427 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2429 __camera_mutex_cond_init(cb_info);
2431 /* message handler thread */
2432 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2433 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "cam:msg_handler", cb_info)) {
2434 CAM_LOG_ERROR("msg_handler_info failed");
2438 /* message handler thread for capture callback */
2439 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2440 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "cam:capture_cb", cb_info)) {
2441 CAM_LOG_ERROR("capture_cb_info failed");
2445 cb_info->fd = sockfd;
2447 /* message receive thread */
2448 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2449 cb_info->msg_recv_thread = g_thread_try_new("cam:msg_recv",
2450 __camera_msg_recv_func, (gpointer)cb_info, NULL);
2451 if (cb_info->msg_recv_thread == NULL) {
2452 CAM_LOG_ERROR("message receive thread creation failed");
2457 for (i = 0 ; i < MUSE_NUM_FD ; i++)
2458 cb_info->fds[i] = CAMERA_FD_INIT;
2460 cb_info->is_server_connected = TRUE;
2462 cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
2463 cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
2464 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2465 cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
2471 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2472 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2474 __camera_mutex_cond_clear(cb_info);
2485 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
2490 CAM_LOG_ERROR("NULL cb_info");
2494 CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2496 g_thread_join(cb_info->msg_recv_thread);
2497 cb_info->msg_recv_thread = NULL;
2499 CAM_LOG_INFO("msg_recv thread removed");
2501 /* destroy msg handler threads */
2502 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2503 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2504 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2506 __camera_mutex_cond_clear(cb_info);
2508 if (CAMERA_IS_FD_VALID(cb_info->fd)) {
2509 muse_client_close(cb_info->fd);
2510 cb_info->fd = CAMERA_FD_INIT;
2513 if (cb_info->bufmgr) {
2514 tbm_bufmgr_deinit(cb_info->bufmgr);
2515 cb_info->bufmgr = NULL;
2517 if (cb_info->pkt_fmt) {
2518 media_format_unref(cb_info->pkt_fmt);
2519 cb_info->pkt_fmt = NULL;
2522 if (cb_info->dp_interface) {
2523 mm_display_interface_deinit(cb_info->dp_interface);
2524 cb_info->dp_interface = NULL;
2527 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
2528 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
2529 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2530 __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
2536 int _camera_start_evas_rendering(camera_h camera)
2538 camera_cli_s *pc = (camera_cli_s *)camera;
2540 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2542 CAM_LOG_INFO("start");
2544 if (!pc->cb_info->is_evas_render) {
2545 CAM_LOG_ERROR("EVAS surface is not set");
2546 return CAMERA_ERROR_NONE;
2549 /* set evas render flag as RUN */
2550 pc->cb_info->run_evas_render = true;
2552 return CAMERA_ERROR_NONE;
2556 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2558 int ret = CAMERA_ERROR_NONE;
2559 camera_cli_s *pc = (camera_cli_s *)camera;
2561 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2563 CAM_LOG_INFO("stop - keep screen %d", keep_screen);
2565 if (!pc->cb_info->is_evas_render) {
2566 CAM_LOG_ERROR("EVAS surface is not set");
2567 return CAMERA_ERROR_NONE;
2570 /* set evas render flag as STOP and release buffers */
2571 pc->cb_info->run_evas_render = false;
2573 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2574 if (ret == MM_ERROR_NONE) {
2575 ret = CAMERA_ERROR_NONE;
2577 CAM_LOG_ERROR("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2578 ret = CAMERA_ERROR_INVALID_OPERATION;
2585 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2587 int ret = CAMERA_ERROR_NONE;
2588 int sock_fd = CAMERA_FD_INIT;
2589 int module_index = -1;
2591 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2593 /* create muse connection */
2594 if (!key || !value) {
2595 CAM_LOG_ERROR("NULL pointer");
2596 return CAMERA_ERROR_INVALID_PARAMETER;
2599 sock_fd = muse_client_new();
2601 CAM_LOG_ERROR("muse_client_new failed");
2602 return CAMERA_ERROR_INVALID_OPERATION;
2605 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2606 CAM_LOG_ERROR("muse client get module index failed");
2607 ret = CAMERA_ERROR_INVALID_OPERATION;
2611 msg = muse_core_msg_new(api,
2612 MUSE_TYPE_INT, "module", module_index,
2613 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2616 CAM_LOG_ERROR("msg failed");
2617 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2621 ret = muse_core_msg_send(sock_fd, msg);
2623 muse_core_msg_free(msg);
2627 CAM_LOG_ERROR("send msg failed");
2628 ret = CAMERA_ERROR_INVALID_OPERATION;
2632 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2634 CAM_LOG_ERROR("recv msg failed %d", errno);
2635 ret = CAMERA_ERROR_INVALID_OPERATION;
2639 if (!muse_camera_msg_get(ret, recv_msg)) {
2640 CAM_LOG_ERROR("failed to get return value from msg [%s]", recv_msg);
2641 ret = CAMERA_ERROR_INVALID_OPERATION;
2645 if (ret == CAMERA_ERROR_NONE)
2646 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2648 CAM_LOG_INFO("api %d - value %d", api, *value);
2651 if (CAMERA_IS_FD_VALID(sock_fd)) {
2652 muse_client_close(sock_fd);
2653 sock_fd = CAMERA_FD_INIT;
2660 int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera)
2662 int sock_fd = CAMERA_FD_INIT;
2663 char *send_msg = NULL;
2665 int ret = CAMERA_ERROR_NONE;
2666 camera_cli_s *pc = NULL;
2667 tbm_bufmgr bufmgr = NULL;
2669 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2670 int module_index = -1;
2671 int device_type = (int)device;
2673 CAM_LOG_INFO("device %d, is_network %d", device, is_network);
2675 sock_fd = muse_client_new();
2677 CAM_LOG_ERROR("muse_client_new failed - returned fd %d", sock_fd);
2678 ret = CAMERA_ERROR_INVALID_OPERATION;
2682 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2683 CAM_LOG_ERROR("muse client get module index failed");
2684 ret = CAMERA_ERROR_INVALID_OPERATION;
2688 send_msg = muse_core_msg_new(api,
2689 MUSE_TYPE_INT, "module", module_index,
2690 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2691 MUSE_TYPE_INT, "is_network", (int)is_network,
2695 CAM_LOG_ERROR("NULL msg");
2696 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2700 send_ret = muse_core_msg_send(sock_fd, send_msg);
2702 muse_core_msg_free(send_msg);
2706 CAM_LOG_ERROR("send msg failed %d", errno);
2707 ret = CAMERA_ERROR_INVALID_OPERATION;
2711 pc = g_new0(camera_cli_s, 1);
2713 CAM_LOG_ERROR("camera_cli_s alloc failed");
2714 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2718 bufmgr = tbm_bufmgr_init(-1);
2719 if (bufmgr == NULL) {
2720 CAM_LOG_ERROR("get tbm bufmgr failed");
2721 ret = CAMERA_ERROR_INVALID_OPERATION;
2725 pc->cb_info = __camera_client_callback_new(sock_fd);
2726 if (pc->cb_info == NULL) {
2727 CAM_LOG_ERROR("cb_info alloc failed");
2728 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2732 sock_fd = CAMERA_FD_INIT;
2734 CAM_LOG_INFO("cb info : %d", pc->cb_info->fd);
2736 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2738 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2740 if (ret == CAMERA_ERROR_NONE) {
2741 int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2742 int user_buffer_supported = 0;
2743 int log_level = CAMERA_LOG_LEVEL_INFO;
2744 intptr_t handle = 0;
2746 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2748 CAM_LOG_ERROR("Receiving Handle Failed!!");
2749 ret = CAMERA_ERROR_INVALID_OPERATION;
2753 muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
2754 muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
2755 muse_camera_msg_get(log_level, pc->cb_info->recv_msg);
2757 pc->remote_handle = handle;
2758 pc->cb_info->bufmgr = bufmgr;
2759 pc->cb_info->preview_format = preview_format;
2760 pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
2761 pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
2762 pc->cb_info->is_network = is_network;
2763 g_camera_log_level = log_level;
2765 CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
2766 preview_format, user_buffer_supported, g_camera_log_level);
2769 CAM_LOG_ERROR("NULL out handle");
2770 ret= CAMERA_ERROR_INVALID_PARAMETER;
2774 *camera = (camera_h)pc;
2776 /* get display interface handle */
2777 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2778 CAM_LOG_WARNING("display interface init failed");
2787 tbm_bufmgr_deinit(bufmgr);
2791 if (CAMERA_IS_FD_VALID(sock_fd)) {
2792 muse_client_close(sock_fd);
2793 sock_fd = CAMERA_FD_INIT;
2798 int temp_fd = pc->cb_info->fd;
2800 /* pc->cb_info->fd should be closed,
2801 because g_thread_join for msg_recv_thread is not returned
2802 in __camera_client_callback_destroy. */
2803 if (CAMERA_IS_FD_VALID(temp_fd)) {
2804 pc->cb_info->fd = CAMERA_FD_INIT;
2805 muse_client_close(temp_fd);
2808 __camera_client_callback_destroy(pc->cb_info);
2815 CAM_LOG_ERROR("camera create error : 0x%x", ret);
2822 int camera_create(camera_device_e device, camera_h *camera)
2824 return _camera_create_private(device, false, camera);
2828 int camera_change_device(camera_h camera, camera_device_e device)
2831 int ret = CAMERA_ERROR_NONE;
2832 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2833 camera_cli_s *pc = (camera_cli_s *)camera;
2834 camera_msg_param param;
2836 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2838 CAMERA_MSG_PARAM_SET(param, INT, device);
2840 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2842 if (ret == CAMERA_ERROR_NONE) {
2843 /* reset callback and user data */
2844 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2845 pc->cb_info->user_cb[i] = NULL;
2846 pc->cb_info->user_data[i] = NULL;
2854 int camera_destroy(camera_h camera)
2856 int ret = CAMERA_ERROR_NONE;
2857 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2858 camera_cli_s *pc = (camera_cli_s *)camera;
2860 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2862 CAM_LOG_INFO("Enter");
2864 if (pc->cb_info->is_server_connected)
2865 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2867 CAM_LOG_WARNING("server disconnected. release resource without send message.");
2869 if (ret == CAMERA_ERROR_NONE) {
2870 __camera_deactivate_idle_event_all(pc->cb_info);
2871 __camera_client_callback_destroy(pc->cb_info);
2878 CAM_LOG_INFO("ret : 0x%x", ret);
2883 int camera_start_preview(camera_h camera)
2886 int ret = CAMERA_ERROR_NONE;
2888 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2889 camera_cli_s *pc = (camera_cli_s *)camera;
2890 camera_state_e current_state = CAMERA_STATE_NONE;
2892 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2894 CAM_LOG_INFO("Enter : preview format %d, display type %d",
2895 pc->cb_info->preview_format, pc->cb_info->dp_info.type);
2897 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2898 pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
2899 CAM_LOG_ERROR("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2900 pc->cb_info->dp_info.type);
2901 return CAMERA_ERROR_INVALID_OPERATION;
2904 ret = camera_get_state(camera, ¤t_state);
2905 if (ret != CAMERA_ERROR_NONE) {
2906 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2910 if (current_state == CAMERA_STATE_CREATED) {
2911 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
2912 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
2913 for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
2914 __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
2916 if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
2917 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
2918 CAM_LOG_ERROR("preview_cb_info failed");
2919 return CAMERA_ERROR_INVALID_OPERATION;
2922 if (pc->cb_info->user_buffer_supported) {
2923 if (!__camera_allocate_preview_buffer(camera)) {
2924 ret = CAMERA_ERROR_INVALID_OPERATION;
2928 fds = pc->cb_info->fds;
2932 pc->cb_info->invoke_preview_cb = TRUE;
2934 _camera_msg_send(api, fds, pc->cb_info, &ret,
2935 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
2936 CAMERA_CB_NO_TIMEOUT);
2938 CAMERA_CB_TIMEOUT_FOR_PREVIEW);
2940 if (ret != CAMERA_ERROR_NONE)
2943 if (pc->cb_info->is_evas_render) {
2944 ret = _camera_start_evas_rendering(camera);
2945 if (ret != CAMERA_ERROR_NONE) {
2946 CAM_LOG_ERROR("stop preview because of error");
2947 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
2952 CAM_LOG_INFO("done");
2954 return CAMERA_ERROR_NONE;
2957 if (current_state == CAMERA_STATE_CREATED) {
2958 if (pc->cb_info->user_buffer_supported)
2959 __camera_release_preview_buffer(camera);
2961 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
2964 CAM_LOG_ERROR("failed : 0x%x", ret);
2970 int camera_stop_preview(camera_h camera)
2972 int ret = CAMERA_ERROR_NONE;
2973 camera_cli_s *pc = (camera_cli_s *)camera;
2974 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2975 camera_state_e current_state = CAMERA_STATE_NONE;
2977 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
2979 CAM_LOG_INFO("Enter");
2982 if (pc->cb_info->is_evas_render) {
2983 ret = camera_get_state(camera, ¤t_state);
2984 if (ret != CAMERA_ERROR_NONE) {
2985 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
2989 if (current_state == CAMERA_STATE_PREVIEW) {
2990 ret = _camera_stop_evas_rendering(camera, false);
2991 if (ret != CAMERA_ERROR_NONE)
2997 pc->cb_info->invoke_preview_cb = FALSE;
2999 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3001 if (ret == CAMERA_ERROR_NONE) {
3002 if (pc->cb_info->user_buffer_supported)
3003 __camera_release_preview_buffer(camera);
3005 /* release remained message for preview callback */
3006 __destroy_msg_handler_thread(&pc->cb_info->preview_cb_info);
3007 } else if (current_state == CAMERA_STATE_PREVIEW) {
3008 CAM_LOG_WARNING("restart evas rendering");
3009 _camera_start_evas_rendering(camera);
3012 CAM_LOG_INFO("ret : 0x%x", ret);
3018 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
3020 int ret = CAMERA_ERROR_NONE;
3021 camera_cli_s *pc = (camera_cli_s *)camera;
3022 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
3024 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3026 CAM_LOG_INFO("Enter");
3028 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3029 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3031 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3032 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3034 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3036 CAM_LOG_INFO("ret : 0x%x", ret);
3042 bool camera_is_supported_continuous_capture(camera_h camera)
3044 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
3048 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)
3050 int ret = CAMERA_ERROR_NONE;
3051 camera_cli_s *pc = (camera_cli_s *)camera;
3052 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
3053 camera_msg_param param;
3056 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3058 CAM_LOG_INFO("Enter");
3060 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
3061 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
3063 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
3064 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
3066 value = (count << 16) | interval;
3067 CAMERA_MSG_PARAM_SET(param, INT, value);
3069 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3071 CAM_LOG_INFO("ret : 0x%x", ret);
3077 int camera_stop_continuous_capture(camera_h camera)
3079 int ret = CAMERA_ERROR_NONE;
3080 camera_cli_s *pc = (camera_cli_s *)camera;
3081 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
3083 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3085 CAM_LOG_INFO("Enter");
3087 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3089 CAM_LOG_INFO("ret : 0x%x", ret);
3095 bool camera_is_supported_face_detection(camera_h camera)
3097 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
3101 bool camera_is_supported_zero_shutter_lag(camera_h camera)
3103 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
3107 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3109 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
3113 bool camera_is_supported_extra_preview(camera_h camera)
3115 return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
3119 int camera_get_device_count(camera_h camera, int *device_count)
3121 int ret = CAMERA_ERROR_NONE;
3122 camera_cli_s *pc = (camera_cli_s *)camera;
3123 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3125 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3127 CAM_LOG_INFO("Enter");
3129 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3131 if (ret == CAMERA_ERROR_NONE)
3132 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3134 CAM_LOG_INFO("ret : 0x%x", ret);
3139 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3141 int ret = CAMERA_ERROR_NONE;
3142 camera_cli_s *pc = (camera_cli_s *)camera;
3143 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3145 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3147 CAM_LOG_INFO("Enter");
3149 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3151 if (ret == CAMERA_ERROR_NONE) {
3152 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3154 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3155 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3157 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3160 CAM_LOG_INFO("ret : 0x%x", ret);
3165 int camera_stop_face_detection(camera_h camera)
3167 int ret = CAMERA_ERROR_NONE;
3168 camera_cli_s *pc = (camera_cli_s *)camera;
3169 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3171 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3173 CAM_LOG_INFO("Enter");
3175 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3177 if (ret == CAMERA_ERROR_NONE) {
3178 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3180 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3181 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3183 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3186 CAM_LOG_INFO("ret : 0x%x", ret);
3191 int camera_get_state(camera_h camera, camera_state_e *state)
3193 int ret = CAMERA_ERROR_NONE;
3194 camera_cli_s *pc = (camera_cli_s *)camera;
3195 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3197 if (!pc || !pc->cb_info || !state) {
3198 CAM_LOG_ERROR("NULL pointer %p %p", pc, state);
3199 return CAMERA_ERROR_INVALID_PARAMETER;
3202 CAM_LOG_INFO("Enter");
3204 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3206 if (ret == CAMERA_ERROR_NONE)
3207 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3209 CAM_LOG_INFO("ret : 0x%x", ret);
3214 int camera_start_focusing(camera_h camera, bool continuous)
3216 int ret = CAMERA_ERROR_NONE;
3217 camera_cli_s *pc = (camera_cli_s *)camera;
3218 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3219 camera_msg_param param;
3220 int is_continuous = (int)continuous;
3222 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3224 CAM_LOG_INFO("Enter");
3226 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3228 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3230 CAM_LOG_INFO("ret : 0x%x", ret);
3235 int camera_cancel_focusing(camera_h camera)
3237 int ret = CAMERA_ERROR_NONE;
3238 camera_cli_s *pc = (camera_cli_s *)camera;
3239 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3241 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3243 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
3245 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3247 CAM_LOG_INFO("ret : 0x%x", ret);
3253 int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
3255 int mm_ret = MM_ERROR_NONE;
3256 int ret = CAMERA_ERROR_NONE;
3257 camera_cli_s *pc = (camera_cli_s *)camera;
3258 camera_cb_info_s *cb_info = NULL;
3259 camera_state_e current_state = CAMERA_STATE_NONE;
3260 camera_msg_param param;
3261 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3262 muse_camera_display_info_s *dp_info = NULL;
3264 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3266 if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
3267 CAM_LOG_ERROR("invalid type %d", type);
3268 return CAMERA_ERROR_INVALID_PARAMETER;
3271 if (type != MM_DISPLAY_TYPE_NONE && display == NULL) {
3272 CAM_LOG_ERROR("display type[%d] is not NONE, but display handle is NULL", type);
3273 return CAMERA_ERROR_INVALID_PARAMETER;
3276 cb_info = (camera_cb_info_s *)pc->cb_info;
3277 dp_info = &cb_info->dp_info;
3279 ret = camera_get_state(camera, ¤t_state);
3280 if (ret != CAMERA_ERROR_NONE) {
3281 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3285 if (current_state != CAMERA_STATE_CREATED) {
3286 CAM_LOG_ERROR("INVALID_STATE : current %d", current_state);
3287 return CAMERA_ERROR_INVALID_STATE;
3290 CAM_LOG_INFO("Enter - type : %d, display : %p", type, display);
3292 if (type != MM_DISPLAY_TYPE_NONE) {
3293 /* check display interface handle */
3294 if (!cb_info->dp_interface) {
3295 CAM_LOG_ERROR("display interface not supported");
3296 return CAMERA_ERROR_NOT_SUPPORTED;
3299 mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
3300 if (mm_ret == (int)MM_ERROR_NOT_SUPPORT_API) {
3301 CAM_LOG_ERROR("[NOT_SUPPORTED] type %d", type);
3302 return CAMERA_ERROR_NOT_SUPPORTED;
3303 } else if (mm_ret != MM_ERROR_NONE) {
3304 CAM_LOG_ERROR("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
3305 return CAMERA_ERROR_INVALID_OPERATION;
3308 if (type == MM_DISPLAY_TYPE_OVERLAY || type == MM_DISPLAY_TYPE_OVERLAY_EXT) {
3309 mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
3311 CAM_LOG_INFO("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
3312 ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
3313 dp_info->window_rect.width, dp_info->window_rect.height);
3314 } else if (type == MM_DISPLAY_TYPE_EVAS) {
3316 camera_flip_e flip = CAMERA_FLIP_NONE;
3317 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3318 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3325 camera_get_display_flip(camera, &flip);
3326 camera_get_display_mode(camera, &mode);
3327 camera_get_display_rotation(camera, &rotation);
3328 camera_is_display_visible(camera, &visible);
3330 CAM_LOG_INFO("current setting : flip %d, mode %d, rotation %d, visible %d",
3331 flip, mode, rotation, visible);
3333 mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3334 mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3335 mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3336 mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3338 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3339 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3340 CAM_LOG_INFO("current setting : roi %d,%d,%dx%d", x, y, width, height);
3341 mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3347 if (mm_ret != MM_ERROR_NONE) {
3348 CAM_LOG_ERROR("mm_ret 0x%x failed", mm_ret);
3349 return CAMERA_ERROR_INVALID_OPERATION;
3352 dp_info->type = type;
3354 CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
3356 _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3358 if (ret == CAMERA_ERROR_NONE)
3359 cb_info->is_evas_render = (type == MM_DISPLAY_TYPE_EVAS) ? TRUE : FALSE;
3365 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3367 CAM_LOG_INFO("type %d, display %p", type, display);
3368 return _camera_set_display(camera, (mm_display_type_e)type, display);
3372 int camera_set_preview_resolution(camera_h camera, int width, int height)
3374 int ret = CAMERA_ERROR_NONE;
3375 camera_state_e current_state = CAMERA_STATE_NONE;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3377 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3378 camera_msg_param param;
3381 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3383 if (pc->cb_info->is_evas_render) {
3384 ret = camera_get_state(camera, ¤t_state);
3385 if (ret != CAMERA_ERROR_NONE) {
3386 CAM_LOG_ERROR("failed to get current state 0x%x", ret);
3390 if (current_state == CAMERA_STATE_PREVIEW) {
3391 ret = _camera_stop_evas_rendering(camera, true);
3392 if (ret != CAMERA_ERROR_NONE)
3397 value = (width << 16) | height;
3398 CAMERA_MSG_PARAM_SET(param, INT, value);
3400 CAM_LOG_INFO("%dx%d -> 0x%x", width, height, value);
3402 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3404 CAM_LOG_INFO("ret : 0x%x", ret);
3406 if (current_state == CAMERA_STATE_PREVIEW) {
3407 CAM_LOG_WARNING("restart evas rendering");
3408 _camera_start_evas_rendering(camera);
3415 int camera_set_capture_resolution(camera_h camera, int width, int height)
3417 int ret = CAMERA_ERROR_NONE;
3418 camera_cli_s *pc = (camera_cli_s *)camera;
3419 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3420 camera_msg_param param;
3423 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3425 CAM_LOG_INFO("Enter");
3427 value = (width << 16) | height;
3428 CAMERA_MSG_PARAM_SET(param, INT, value);
3430 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3432 CAM_LOG_INFO("ret : 0x%x", ret);
3438 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3440 int ret = CAMERA_ERROR_NONE;
3441 int set_format = (int)format;
3442 camera_cli_s *pc = (camera_cli_s *)camera;
3443 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3444 camera_msg_param param;
3446 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3448 CAM_LOG_INFO("Enter - format %d", set_format);
3450 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3454 CAM_LOG_INFO("ret : 0x%x", ret);
3460 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3462 int ret = CAMERA_ERROR_NONE;
3463 int set_format = (int)format;
3464 camera_msg_param param;
3465 camera_cli_s *pc = (camera_cli_s *)camera;
3466 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3468 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3470 CAM_LOG_INFO("Enter - format %d", set_format);
3472 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3474 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3476 if (ret == CAMERA_ERROR_NONE)
3477 pc->cb_info->preview_format = set_format;
3479 CAM_LOG_INFO("ret : 0x%x", ret);
3485 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3487 int ret = CAMERA_ERROR_NONE;
3488 camera_cli_s *pc = (camera_cli_s *)camera;
3489 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3491 if (!pc || !pc->cb_info || !width || !height) {
3492 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3493 return CAMERA_ERROR_INVALID_PARAMETER;
3496 CAM_LOG_INFO("Enter");
3498 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3500 if (ret == CAMERA_ERROR_NONE) {
3501 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3502 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3505 CAM_LOG_INFO("ret : 0x%x", ret);
3511 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3513 int ret = CAMERA_ERROR_NONE;
3514 int set_rotation = (int)rotation;
3515 camera_cli_s *pc = (camera_cli_s *)camera;
3516 camera_msg_param param;
3518 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3520 if (pc->cb_info->is_evas_render) {
3521 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3522 if (ret != MM_ERROR_NONE) {
3523 CAM_LOG_ERROR("failed to set rotation for evas surface 0x%x", ret);
3524 return CAMERA_ERROR_INVALID_OPERATION;
3528 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3530 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3536 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3538 int ret = CAMERA_ERROR_NONE;
3539 camera_cli_s *pc = (camera_cli_s *)camera;
3541 if (!pc || !pc->cb_info || !rotation) {
3542 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
3543 return CAMERA_ERROR_INVALID_PARAMETER;
3546 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3548 if (ret == CAMERA_ERROR_NONE)
3549 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3555 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3557 int ret = CAMERA_ERROR_NONE;
3558 int set_flip = (int)flip;
3559 camera_cli_s *pc = (camera_cli_s *)camera;
3560 camera_msg_param param;
3562 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3564 if (pc->cb_info->is_evas_render) {
3565 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3566 if (ret != MM_ERROR_NONE) {
3567 CAM_LOG_ERROR("failed to set flip for evas surface 0x%x", ret);
3568 return CAMERA_ERROR_INVALID_OPERATION;
3572 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3574 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3580 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3582 int ret = CAMERA_ERROR_NONE;
3583 camera_cli_s *pc = (camera_cli_s *)camera;
3585 if (!pc || !pc->cb_info || !flip) {
3586 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
3587 return CAMERA_ERROR_INVALID_PARAMETER;
3590 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3592 if (ret == CAMERA_ERROR_NONE)
3593 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3599 int camera_set_display_visible(camera_h camera, bool visible)
3601 int ret = CAMERA_ERROR_NONE;
3602 int set_visible = (int)visible;
3603 camera_cli_s *pc = (camera_cli_s *)camera;
3604 camera_msg_param param;
3606 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3608 if (pc->cb_info->is_evas_render) {
3609 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3610 if (ret != MM_ERROR_NONE) {
3611 CAM_LOG_ERROR("failed to set visible for evas surface 0x%x", ret);
3612 return CAMERA_ERROR_INVALID_OPERATION;
3616 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3618 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3624 int camera_is_display_visible(camera_h camera, bool *visible)
3626 int ret = CAMERA_ERROR_NONE;
3627 camera_cli_s *pc = (camera_cli_s *)camera;
3629 if (!pc || !pc->cb_info || !visible) {
3630 CAM_LOG_ERROR("NULL pointer %p %p", pc, visible);
3631 return CAMERA_ERROR_INVALID_PARAMETER;
3634 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3636 if (ret == CAMERA_ERROR_NONE)
3637 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3643 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3645 int ret = CAMERA_ERROR_NONE;
3646 int set_mode = (int)mode;
3647 camera_cli_s *pc = (camera_cli_s *)camera;
3648 camera_msg_param param;
3650 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3652 if (pc->cb_info->is_evas_render) {
3653 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3654 if (ret != MM_ERROR_NONE) {
3655 CAM_LOG_ERROR("failed to set geometry for evas surface 0x%x", ret);
3656 return CAMERA_ERROR_INVALID_OPERATION;
3660 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3662 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3668 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3670 int ret = CAMERA_ERROR_NONE;
3671 camera_cli_s *pc = (camera_cli_s *)camera;
3673 if (!pc || !pc->cb_info || !mode) {
3674 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
3675 return CAMERA_ERROR_INVALID_PARAMETER;
3678 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3680 if (ret == CAMERA_ERROR_NONE)
3681 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3687 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3689 int ret = CAMERA_ERROR_NONE;
3690 int set_hint = (int)hint;
3691 camera_cli_s *pc = (camera_cli_s *)camera;
3692 camera_msg_param param;
3694 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3696 CAM_LOG_INFO("Enter - hint %d", set_hint);
3698 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3700 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3706 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3708 int ret = CAMERA_ERROR_NONE;
3709 camera_cli_s *pc = (camera_cli_s *)camera;
3710 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3712 if (!pc || !pc->cb_info || !hint) {
3713 CAM_LOG_ERROR("NULL pointer %p %p", pc, hint);
3714 return CAMERA_ERROR_INVALID_PARAMETER;
3717 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3719 if (ret == CAMERA_ERROR_NONE) {
3720 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3721 CAM_LOG_INFO("display reuse hint %d", *hint);
3728 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3730 int ret = CAMERA_ERROR_NONE;
3731 camera_cli_s *pc = (camera_cli_s *)camera;
3732 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3734 if (!pc || !pc->cb_info || !width || !height) {
3735 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
3736 return CAMERA_ERROR_INVALID_PARAMETER;
3739 CAM_LOG_INFO("Enter");
3741 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3743 if (ret == CAMERA_ERROR_NONE) {
3744 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3745 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3748 CAM_LOG_INFO("ret : 0x%x", ret);
3754 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3760 if (!pc || !pc->cb_info || !format) {
3761 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3765 CAM_LOG_INFO("Enter");
3767 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3769 if (ret == CAMERA_ERROR_NONE)
3770 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3772 CAM_LOG_INFO("ret : 0x%x", ret);
3778 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3780 int ret = CAMERA_ERROR_NONE;
3781 camera_cli_s *pc = (camera_cli_s *)camera;
3782 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3784 if (!pc || !pc->cb_info || !format) {
3785 CAM_LOG_ERROR("NULL pointer %p %p", pc, format);
3786 return CAMERA_ERROR_INVALID_PARAMETER;
3789 CAM_LOG_INFO("Enter");
3791 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3793 if (ret == CAMERA_ERROR_NONE)
3794 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3796 CAM_LOG_INFO("ret : 0x%x", ret);
3802 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3808 if (!pc || !pc->cb_info || !facing_direction) {
3809 CAM_LOG_ERROR("NULL pointer %p %p", pc, facing_direction);
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3813 CAM_LOG_INFO("Enter");
3815 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE)
3818 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3820 CAM_LOG_INFO("ret : 0x%x", ret);
3826 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3828 int ret = CAMERA_ERROR_NONE;
3829 camera_cli_s *pc = (camera_cli_s *)camera;
3830 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3832 if (!pc || !pc->cb_info || !callback) {
3833 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3834 return CAMERA_ERROR_INVALID_PARAMETER;
3837 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
3838 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
3840 CAM_LOG_INFO("Enter");
3842 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3844 if (ret == CAMERA_ERROR_NONE) {
3845 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3847 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3848 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3850 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3853 CAM_LOG_INFO("ret : 0x%x", ret);
3859 int camera_unset_preview_cb(camera_h camera)
3861 int ret = CAMERA_ERROR_NONE;
3862 camera_cli_s *pc = (camera_cli_s *)camera;
3863 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3865 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3866 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
3867 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
3869 CAM_LOG_INFO("Enter");
3871 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3873 if (ret == CAMERA_ERROR_NONE) {
3874 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3876 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3877 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3879 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3882 CAM_LOG_INFO("ret : 0x%x", ret);
3888 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3890 int ret = CAMERA_ERROR_NONE;
3891 camera_cli_s *pc = (camera_cli_s *)camera;
3892 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3894 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3896 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3897 CAM_LOG_ERROR("NOT SUPPORTED");
3898 return CAMERA_ERROR_NOT_SUPPORTED;
3901 if (callback == NULL) {
3902 CAM_LOG_ERROR("NULL callback");
3903 return CAMERA_ERROR_INVALID_PARAMETER;
3906 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
3907 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
3909 CAM_LOG_INFO("Enter");
3911 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3913 if (ret == CAMERA_ERROR_NONE) {
3914 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3916 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3917 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3919 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3922 CAM_LOG_INFO("ret : 0x%x", ret);
3928 int camera_unset_media_packet_preview_cb(camera_h camera)
3930 int ret = CAMERA_ERROR_NONE;
3931 camera_cli_s *pc = (camera_cli_s *)camera;
3932 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3934 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
3936 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3937 CAM_LOG_ERROR("NOT SUPPORTED");
3938 return CAMERA_ERROR_NOT_SUPPORTED;
3941 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
3942 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
3944 CAM_LOG_INFO("Enter");
3946 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3948 if (ret == CAMERA_ERROR_NONE) {
3949 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3951 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3952 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3954 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3957 CAM_LOG_INFO("ret : 0x%x", ret);
3963 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3965 int ret = CAMERA_ERROR_NONE;
3966 camera_cli_s *pc = (camera_cli_s *)camera;
3967 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3969 if (!pc || !pc->cb_info || !callback) {
3970 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
3971 return CAMERA_ERROR_INVALID_PARAMETER;
3974 CAM_LOG_INFO("Enter");
3976 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3978 if (ret == CAMERA_ERROR_NONE) {
3979 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3981 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3982 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3984 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3987 CAM_LOG_INFO("ret : 0x%x", ret);
3993 int camera_unset_state_changed_cb(camera_h camera)
3995 int ret = CAMERA_ERROR_NONE;
3996 camera_cli_s *pc = (camera_cli_s *)camera;
3997 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3999 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4001 CAM_LOG_INFO("Enter");
4003 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4005 if (ret == CAMERA_ERROR_NONE) {
4006 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4008 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4009 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4011 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4014 CAM_LOG_INFO("ret : 0x%x", ret);
4020 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4022 int ret = CAMERA_ERROR_NONE;
4023 camera_cli_s *pc = (camera_cli_s *)camera;
4024 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4026 if (!pc || !pc->cb_info || !callback) {
4027 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4028 return CAMERA_ERROR_INVALID_PARAMETER;
4031 CAM_LOG_INFO("Enter");
4033 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4035 if (ret == CAMERA_ERROR_NONE) {
4036 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4041 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4044 CAM_LOG_INFO("ret : 0x%x", ret);
4050 int camera_unset_interrupted_cb(camera_h camera)
4052 int ret = CAMERA_ERROR_NONE;
4053 camera_cli_s *pc = (camera_cli_s *)camera;
4054 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4056 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4058 CAM_LOG_INFO("Enter");
4060 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4062 if (ret == CAMERA_ERROR_NONE) {
4063 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4065 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4066 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4068 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4071 CAM_LOG_INFO("ret : 0x%x", ret);
4077 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4079 int ret = CAMERA_ERROR_NONE;
4080 camera_cli_s *pc = (camera_cli_s *)camera;
4081 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4083 if (!pc || !pc->cb_info || !callback) {
4084 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4085 return CAMERA_ERROR_INVALID_PARAMETER;
4088 CAM_LOG_INFO("Enter");
4090 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4092 if (ret == CAMERA_ERROR_NONE) {
4093 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4095 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4096 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4098 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4101 CAM_LOG_INFO("ret : 0x%x", ret);
4107 int camera_unset_interrupt_started_cb(camera_h camera)
4109 int ret = CAMERA_ERROR_NONE;
4110 camera_cli_s *pc = (camera_cli_s *)camera;
4111 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4113 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4115 CAM_LOG_INFO("Enter");
4117 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4119 if (ret == CAMERA_ERROR_NONE) {
4120 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4122 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4123 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4125 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4128 CAM_LOG_INFO("ret : 0x%x", ret);
4134 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4136 int ret = CAMERA_ERROR_NONE;
4137 camera_cli_s *pc = (camera_cli_s *)camera;
4138 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4140 if (!pc || !pc->cb_info || !callback) {
4141 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4142 return CAMERA_ERROR_INVALID_PARAMETER;
4145 CAM_LOG_INFO("Enter");
4147 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4149 if (ret == CAMERA_ERROR_NONE) {
4150 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4152 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4153 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4155 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4158 CAM_LOG_INFO("ret : 0x%x", ret);
4164 int camera_unset_focus_changed_cb(camera_h camera)
4166 int ret = CAMERA_ERROR_NONE;
4167 camera_cli_s *pc = (camera_cli_s *)camera;
4168 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4170 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4172 CAM_LOG_INFO("Enter");
4174 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4176 if (ret == CAMERA_ERROR_NONE) {
4177 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4179 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4180 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4182 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4185 CAM_LOG_INFO("ret : 0x%x", ret);
4191 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4193 int ret = CAMERA_ERROR_NONE;
4194 camera_cli_s *pc = (camera_cli_s *)camera;
4195 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4197 if (!pc || !pc->cb_info || !callback) {
4198 CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
4199 return CAMERA_ERROR_INVALID_PARAMETER;
4202 CAM_LOG_INFO("Enter");
4204 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4206 if (ret == CAMERA_ERROR_NONE) {
4207 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4209 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4210 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4212 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4215 CAM_LOG_INFO("ret : 0x%x", ret);
4221 int camera_unset_error_cb(camera_h camera)
4223 int ret = CAMERA_ERROR_NONE;
4224 camera_cli_s *pc = (camera_cli_s *)camera;
4225 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4227 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4229 CAM_LOG_INFO("Enter");
4231 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4233 if (ret == CAMERA_ERROR_NONE) {
4234 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4236 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4237 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4239 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4242 CAM_LOG_INFO("ret : 0x%x", ret);
4248 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4250 int ret = CAMERA_ERROR_NONE;
4251 camera_cli_s *pc = (camera_cli_s *)camera;
4252 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4254 if (!pc || !pc->cb_info || !foreach_cb) {
4255 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4256 return CAMERA_ERROR_INVALID_PARAMETER;
4259 CAM_LOG_INFO("Enter");
4261 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4262 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4264 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4266 CAM_LOG_INFO("ret : 0x%x", ret);
4272 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4274 int ret = CAMERA_ERROR_NONE;
4275 camera_cli_s *pc = (camera_cli_s *)camera;
4276 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4278 if (!pc || !pc->cb_info || !foreach_cb) {
4279 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4280 return CAMERA_ERROR_INVALID_PARAMETER;
4283 CAM_LOG_INFO("Enter");
4285 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4286 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4288 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4290 CAM_LOG_INFO("ret : 0x%x", ret);
4296 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4298 int ret = CAMERA_ERROR_NONE;
4299 camera_cli_s *pc = (camera_cli_s *)camera;
4300 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4302 if (!pc || !pc->cb_info || !foreach_cb) {
4303 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4304 return CAMERA_ERROR_INVALID_PARAMETER;
4307 CAM_LOG_INFO("Enter");
4309 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4310 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4312 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4314 CAM_LOG_INFO("ret : 0x%x", ret);
4320 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4322 int ret = CAMERA_ERROR_NONE;
4323 camera_cli_s *pc = (camera_cli_s *)camera;
4324 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4326 if (!pc || !pc->cb_info || !foreach_cb) {
4327 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4328 return CAMERA_ERROR_INVALID_PARAMETER;
4331 CAM_LOG_INFO("Enter");
4333 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4334 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4336 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4338 CAM_LOG_INFO("ret : 0x%x", ret);
4344 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4346 int ret = CAMERA_ERROR_NONE;
4347 camera_cli_s *pc = (camera_cli_s *)camera;
4348 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4350 if (!pc || !pc->cb_info || !width || !height) {
4351 CAM_LOG_ERROR("NULL pointer %p %p %p", pc, width, height);
4352 return CAMERA_ERROR_INVALID_PARAMETER;
4355 CAM_LOG_INFO("Enter");
4356 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4358 if (ret == CAMERA_ERROR_NONE) {
4359 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4360 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4363 CAM_LOG_INFO("ret : 0x%x", ret);
4369 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4371 int ret = CAMERA_ERROR_NONE;
4372 camera_cli_s *pc = (camera_cli_s *)camera;
4373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4375 if (!pc || !pc->cb_info || !angle) {
4376 CAM_LOG_ERROR("NULL pointer %p %p", pc, angle);
4377 return CAMERA_ERROR_INVALID_PARAMETER;
4380 CAM_LOG_INFO("Enter");
4382 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4384 if (ret == CAMERA_ERROR_NONE)
4385 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4387 CAM_LOG_INFO("ret : 0x%x", ret);
4393 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4395 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
4399 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4401 int ret = CAMERA_ERROR_NONE;
4402 camera_cli_s *pc = (camera_cli_s *)camera;
4403 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4405 if (!pc || !pc->cb_info || !mode) {
4406 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
4407 return CAMERA_ERROR_INVALID_PARAMETER;
4410 CAM_LOG_INFO("Enter");
4412 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4414 if (ret == CAMERA_ERROR_NONE)
4415 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4417 CAM_LOG_INFO("ret : 0x%x", ret);
4423 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4425 int ret = CAMERA_ERROR_NONE;
4426 camera_cli_s *pc = (camera_cli_s *)camera;
4427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4429 if (!pc || !pc->cb_info || !foreach_cb) {
4430 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 CAM_LOG_INFO("Enter");
4436 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4437 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4439 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4441 CAM_LOG_INFO("Finish, return :%x", ret);
4447 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4449 int ret = CAMERA_ERROR_NONE;
4450 camera_cli_s *pc = (camera_cli_s *)camera;
4451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4452 camera_msg_param param;
4453 int set_fps = (int)fps;
4455 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4457 CAM_LOG_INFO("Enter");
4459 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4461 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4463 CAM_LOG_INFO("ret : 0x%x", ret);
4469 int camera_attr_set_image_quality(camera_h camera, int quality)
4471 int ret = CAMERA_ERROR_NONE;
4472 camera_cli_s *pc = (camera_cli_s *)camera;
4473 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4474 camera_msg_param param;
4476 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4478 CAM_LOG_INFO("Enter");
4480 CAMERA_MSG_PARAM_SET(param, INT, quality);
4482 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4484 CAM_LOG_INFO("ret : 0x%x", ret);
4490 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4492 int ret = CAMERA_ERROR_NONE;
4493 camera_cli_s *pc = (camera_cli_s *)camera;
4494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4496 if (!pc || !pc->cb_info || !fps) {
4497 CAM_LOG_ERROR("NULL pointer %p %p", pc, fps);
4498 return CAMERA_ERROR_INVALID_PARAMETER;
4501 CAM_LOG_INFO("Enter");
4503 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4505 if (ret == CAMERA_ERROR_NONE)
4506 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4508 CAM_LOG_INFO("ret : 0x%x", ret);
4514 int camera_attr_get_image_quality(camera_h camera, int *quality)
4516 int ret = CAMERA_ERROR_NONE;
4517 camera_cli_s *pc = (camera_cli_s *)camera;
4518 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4520 if (!pc || !pc->cb_info || !quality) {
4521 CAM_LOG_ERROR("NULL pointer %p %p", pc, quality);
4522 return CAMERA_ERROR_INVALID_PARAMETER;
4525 CAM_LOG_INFO("Enter");
4527 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4529 if (ret == CAMERA_ERROR_NONE)
4530 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4532 CAM_LOG_INFO("ret : 0x%x", ret);
4538 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4540 int ret = CAMERA_ERROR_NONE;
4541 camera_cli_s *pc = (camera_cli_s *)camera;
4542 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4544 if (!pc || !pc->cb_info || !bitrate) {
4545 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
4546 return CAMERA_ERROR_INVALID_PARAMETER;
4549 CAM_LOG_INFO("Enter");
4551 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4553 if (ret == CAMERA_ERROR_NONE)
4554 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4556 CAM_LOG_INFO("ret : 0x%x", ret);
4562 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4564 int ret = CAMERA_ERROR_NONE;
4565 camera_cli_s *pc = (camera_cli_s *)camera;
4566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4567 camera_msg_param param;
4568 int set_bitrate = bitrate;
4570 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4572 CAM_LOG_INFO("Enter");
4574 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4576 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4578 CAM_LOG_INFO("ret : 0x%x", ret);
4584 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4586 int ret = CAMERA_ERROR_NONE;
4587 camera_cli_s *pc = (camera_cli_s *)camera;
4588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4590 if (!pc || !pc->cb_info || !interval) {
4591 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
4592 return CAMERA_ERROR_INVALID_PARAMETER;
4595 CAM_LOG_INFO("Enter");
4597 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4599 if (ret == CAMERA_ERROR_NONE)
4600 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4602 CAM_LOG_INFO("ret : 0x%x", ret);
4608 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4610 int ret = CAMERA_ERROR_NONE;
4611 camera_cli_s *pc = (camera_cli_s *)camera;
4612 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4613 camera_msg_param param;
4614 int set_gop_interval = interval;
4616 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4618 CAM_LOG_INFO("Enter");
4620 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4622 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4624 CAM_LOG_INFO("ret : 0x%x", ret);
4630 int camera_attr_set_zoom(camera_h camera, int zoom)
4632 int ret = CAMERA_ERROR_NONE;
4633 camera_cli_s *pc = (camera_cli_s *)camera;
4634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4635 camera_msg_param param;
4637 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4639 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4641 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4643 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4645 CAM_LOG_INFO("ret : 0x%x", ret);
4651 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4653 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
4657 int camera_attr_set_af_area(camera_h camera, int x, int y)
4659 int ret = CAMERA_ERROR_NONE;
4660 camera_cli_s *pc = (camera_cli_s *)camera;
4661 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4662 camera_msg_param param;
4665 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4667 CAM_LOG_INFO("Enter - %d,%d", x, y);
4669 value = (x << 16) | y;
4670 CAMERA_MSG_PARAM_SET(param, INT, value);
4672 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4674 CAM_LOG_INFO("ret : 0x%x", ret);
4680 int camera_attr_clear_af_area(camera_h camera)
4682 int ret = CAMERA_ERROR_NONE;
4683 camera_cli_s *pc = (camera_cli_s *)camera;
4684 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4686 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4688 CAM_LOG_INFO("Enter");
4690 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4692 CAM_LOG_INFO("ret : 0x%x", ret);
4698 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4700 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
4704 int camera_attr_set_exposure(camera_h camera, int value)
4706 int ret = CAMERA_ERROR_NONE;
4707 camera_cli_s *pc = (camera_cli_s *)camera;
4708 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4709 camera_msg_param param;
4711 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4713 CAM_LOG_INFO("Enter");
4715 CAMERA_MSG_PARAM_SET(param, INT, value);
4717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4719 CAM_LOG_INFO("ret : 0x%x", ret);
4725 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4727 int ret = CAMERA_ERROR_NONE;
4728 camera_cli_s *pc = (camera_cli_s *)camera;
4729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4730 camera_msg_param param;
4731 int set_iso = (int)iso;
4733 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4735 CAM_LOG_INFO("Enter");
4737 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4739 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4741 CAM_LOG_INFO("ret : 0x%x", ret);
4747 int camera_attr_set_gain(camera_h camera, int level)
4749 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_GAIN, level);
4753 int camera_attr_set_brightness(camera_h camera, int level)
4755 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS, level);
4759 int camera_attr_set_contrast(camera_h camera, int level)
4761 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_CONTRAST, level);
4765 int camera_attr_set_hue(camera_h camera, int level)
4767 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_HUE, level);
4771 int camera_attr_set_saturation(camera_h camera, int level)
4773 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_SATURATION, level);
4777 int camera_attr_set_sharpness(camera_h camera, int level)
4779 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_SHARPNESS, level);
4783 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4785 int ret = CAMERA_ERROR_NONE;
4786 camera_cli_s *pc = (camera_cli_s *)camera;
4787 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4788 camera_msg_param param;
4789 int set_whitebalance = (int)wb;
4791 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4793 CAM_LOG_INFO("Enter");
4795 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4797 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4799 CAM_LOG_INFO("ret : 0x%x", ret);
4805 int camera_attr_set_whitebalance_temperature(camera_h camera, int temperature)
4807 int ret = CAMERA_ERROR_NONE;
4808 camera_cli_s *pc = (camera_cli_s *)camera;
4809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE_TEMPERATURE;
4810 camera_msg_param param;
4812 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4814 CAM_LOG_INFO("Enter");
4816 CAMERA_MSG_PARAM_SET(param, INT, temperature);
4818 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4820 CAM_LOG_INFO("ret : 0x%x", ret);
4826 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4828 int ret = CAMERA_ERROR_NONE;
4829 camera_cli_s *pc = (camera_cli_s *)camera;
4830 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4831 camera_msg_param param;
4832 int set_effect = (int)effect;
4834 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4836 CAM_LOG_INFO("Enter");
4838 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4840 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4842 CAM_LOG_INFO("ret : 0x%x", ret);
4848 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4850 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
4854 int camera_attr_enable_tag(camera_h camera, bool enable)
4856 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
4860 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4862 int ret = CAMERA_ERROR_NONE;
4863 camera_cli_s *pc = (camera_cli_s *)camera;
4864 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4865 camera_msg_param param;
4867 if (!pc || !pc->cb_info || !description) {
4868 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
4869 return CAMERA_ERROR_INVALID_PARAMETER;
4872 CAM_LOG_INFO("Enter");
4874 CAMERA_MSG_PARAM_SET(param, STRING, description);
4876 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4878 CAM_LOG_INFO("ret : 0x%x", ret);
4884 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4886 int ret = CAMERA_ERROR_NONE;
4887 camera_cli_s *pc = (camera_cli_s *)camera;
4888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4889 camera_msg_param param;
4890 int set_orientation = (int)orientation;
4892 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4894 CAM_LOG_INFO("Enter");
4896 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4898 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4900 CAM_LOG_INFO("ret : 0x%x", ret);
4906 int camera_attr_set_tag_software(camera_h camera, const char *software)
4908 int ret = CAMERA_ERROR_NONE;
4909 camera_cli_s *pc = (camera_cli_s *)camera;
4910 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4911 camera_msg_param param;
4913 if (!pc || !pc->cb_info || !software) {
4914 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
4915 return CAMERA_ERROR_INVALID_PARAMETER;
4918 CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
4920 CAMERA_MSG_PARAM_SET(param, STRING, software);
4922 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4924 CAM_LOG_INFO("ret : 0x%x", ret);
4930 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4932 int ret = CAMERA_ERROR_NONE;
4933 camera_cli_s *pc = (camera_cli_s *)camera;
4934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4935 double set_geotag[3] = {latitude, longitude, altitude};
4939 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4941 CAM_LOG_INFO("Enter");
4943 length = sizeof(set_geotag) / sizeof(int) + \
4944 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4946 msg = muse_core_msg_new(api,
4947 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4950 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
4956 int camera_attr_remove_geotag(camera_h camera)
4958 int ret = CAMERA_ERROR_NONE;
4959 camera_cli_s *pc = (camera_cli_s *)camera;
4960 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4962 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
4964 CAM_LOG_INFO("Enter");
4966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4968 CAM_LOG_INFO("ret : 0x%x", ret);
4974 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4976 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
4980 int camera_attr_get_zoom(camera_h camera, int *zoom)
4982 int ret = CAMERA_ERROR_NONE;
4983 camera_cli_s *pc = (camera_cli_s *)camera;
4984 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4986 if (!pc || !pc->cb_info || !zoom) {
4987 CAM_LOG_ERROR("NULL pointer %p %p", pc, zoom);
4988 return CAMERA_ERROR_INVALID_PARAMETER;
4991 CAM_LOG_INFO("Enter");
4993 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4995 if (ret == CAMERA_ERROR_NONE)
4996 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4998 CAM_LOG_INFO("ret : 0x%x", ret);
5004 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5006 return _camera_attr_get_range(camera,
5007 MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE,
5008 MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE,
5013 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5015 int ret = CAMERA_ERROR_NONE;
5016 camera_cli_s *pc = (camera_cli_s *)camera;
5017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5019 if (!pc || !pc->cb_info || !mode) {
5020 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5021 return CAMERA_ERROR_INVALID_PARAMETER;
5024 CAM_LOG_INFO("Enter");
5026 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5028 if (ret == CAMERA_ERROR_NONE)
5029 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5031 CAM_LOG_INFO("ret : 0x%x", ret);
5037 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5039 int ret = CAMERA_ERROR_NONE;
5040 camera_cli_s *pc = (camera_cli_s *)camera;
5041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5043 if (!pc || !pc->cb_info || !mode) {
5044 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5045 return CAMERA_ERROR_INVALID_PARAMETER;
5048 CAM_LOG_INFO("Enter");
5050 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5052 if (ret == CAMERA_ERROR_NONE)
5053 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5055 CAM_LOG_INFO("ret : 0x%x", ret);
5061 int camera_attr_get_exposure(camera_h camera, int *value)
5063 int ret = CAMERA_ERROR_NONE;
5064 camera_cli_s *pc = (camera_cli_s *)camera;
5065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5067 if (!pc || !pc->cb_info || !value) {
5068 CAM_LOG_ERROR("NULL pointer %p %p", pc, value);
5069 return CAMERA_ERROR_INVALID_PARAMETER;
5072 CAM_LOG_INFO("Enter");
5074 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5076 if (ret == CAMERA_ERROR_NONE)
5077 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5079 CAM_LOG_INFO("ret : 0x%x", ret);
5085 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5087 return _camera_attr_get_range(camera,
5088 MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE,
5089 MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE,
5094 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5096 int ret = CAMERA_ERROR_NONE;
5097 camera_cli_s *pc = (camera_cli_s *)camera;
5098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5100 if (!pc || !pc->cb_info || !iso) {
5101 CAM_LOG_ERROR("NULL pointer %p %p", pc, iso);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5105 CAM_LOG_INFO("Enter");
5107 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE)
5110 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5112 CAM_LOG_INFO("ret : 0x%x", ret);
5118 int camera_attr_get_gain(camera_h camera, int *level)
5120 return _camera_attr_get_level(camera,
5121 MUSE_CAMERA_API_ATTR_GET_GAIN,
5122 MUSE_CAMERA_GET_INT_GAIN,
5127 int camera_attr_get_gain_range(camera_h camera, int *min, int *max)
5129 return _camera_attr_get_range(camera,
5130 MUSE_CAMERA_API_ATTR_GET_GAIN_RANGE,
5131 MUSE_CAMERA_GET_INT_PAIR_GAIN_RANGE,
5136 int camera_attr_get_gain_step(camera_h camera, int *step)
5138 int ret = CAMERA_ERROR_NONE;
5139 camera_cli_s *pc = (camera_cli_s *)camera;
5140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GAIN_STEP;
5142 if (!pc || !pc->cb_info || !step) {
5143 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5144 return CAMERA_ERROR_INVALID_PARAMETER;
5147 CAM_LOG_INFO("Enter");
5149 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5151 if (ret == CAMERA_ERROR_NONE)
5152 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_GAIN_STEP];
5154 CAM_LOG_INFO("ret : 0x%x", ret);
5160 int camera_attr_get_brightness(camera_h camera, int *level)
5162 return _camera_attr_get_level(camera,
5163 MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS,
5164 MUSE_CAMERA_GET_INT_BRIGHTNESS,
5169 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5171 return _camera_attr_get_range(camera,
5172 MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE,
5173 MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE,
5178 int camera_attr_get_contrast(camera_h camera, int *level)
5180 return _camera_attr_get_level(camera,
5181 MUSE_CAMERA_API_ATTR_GET_CONTRAST,
5182 MUSE_CAMERA_GET_INT_CONTRAST,
5187 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5189 return _camera_attr_get_range(camera,
5190 MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE,
5191 MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE,
5196 int camera_attr_get_hue(camera_h camera, int *level)
5198 return _camera_attr_get_level(camera,
5199 MUSE_CAMERA_API_ATTR_GET_HUE,
5200 MUSE_CAMERA_GET_INT_HUE,
5205 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5207 return _camera_attr_get_range(camera,
5208 MUSE_CAMERA_API_ATTR_GET_HUE_RANGE,
5209 MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE,
5214 int camera_attr_get_saturation(camera_h camera, int *level)
5216 return _camera_attr_get_level(camera,
5217 MUSE_CAMERA_API_ATTR_GET_SATURATION,
5218 MUSE_CAMERA_GET_INT_SATURATION,
5223 int camera_attr_get_saturation_range(camera_h camera, int *min, int *max)
5225 return _camera_attr_get_range(camera,
5226 MUSE_CAMERA_API_ATTR_GET_SATURATION_RANGE,
5227 MUSE_CAMERA_GET_INT_PAIR_SATURATION_RANGE,
5232 int camera_attr_get_sharpness(camera_h camera, int *level)
5234 return _camera_attr_get_level(camera,
5235 MUSE_CAMERA_API_ATTR_GET_SHARPNESS,
5236 MUSE_CAMERA_GET_INT_SHARPNESS,
5241 int camera_attr_get_sharpness_range(camera_h camera, int *min, int *max)
5243 return _camera_attr_get_range(camera,
5244 MUSE_CAMERA_API_ATTR_GET_SHARPNESS_RANGE,
5245 MUSE_CAMERA_GET_INT_PAIR_SHARPNESS_RANGE,
5250 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5252 int ret = CAMERA_ERROR_NONE;
5253 camera_cli_s *pc = (camera_cli_s *)camera;
5254 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5256 if (!pc || !pc->cb_info || !wb) {
5257 CAM_LOG_ERROR("NULL pointer %p %p", pc, wb);
5258 return CAMERA_ERROR_INVALID_PARAMETER;
5261 CAM_LOG_INFO("Enter");
5263 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5265 if (ret == CAMERA_ERROR_NONE)
5266 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5268 CAM_LOG_INFO("ret : 0x%x", ret);
5274 int camera_attr_get_whitebalance_temperature(camera_h camera, int *temperature)
5276 int ret = CAMERA_ERROR_NONE;
5277 camera_cli_s *pc = (camera_cli_s *)camera;
5278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE;
5280 if (!pc || !pc->cb_info || !temperature) {
5281 CAM_LOG_ERROR("NULL pointer %p %p", pc, temperature);
5282 return CAMERA_ERROR_INVALID_PARAMETER;
5285 CAM_LOG_INFO("Enter");
5287 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5289 if (ret == CAMERA_ERROR_NONE)
5290 *temperature = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE];
5292 CAM_LOG_INFO("ret : 0x%x", ret);
5298 int camera_attr_get_whitebalance_temperature_range(camera_h camera, int *min, int *max)
5300 return _camera_attr_get_range(camera,
5301 MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_RANGE,
5302 MUSE_CAMERA_GET_INT_PAIR_WHITE_BALANCE_TEMPERATURE_RANGE,
5307 int camera_attr_get_whitebalance_temperature_step(camera_h camera, int *step)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE_TEMPERATURE_STEP;
5313 if (!pc || !pc->cb_info || !step) {
5314 CAM_LOG_ERROR("NULL pointer %p %p", pc, step);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5318 CAM_LOG_INFO("Enter");
5320 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE_TEMPERATURE_STEP];
5325 CAM_LOG_INFO("ret : 0x%x", ret);
5331 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5337 if (!pc || !pc->cb_info || !effect) {
5338 CAM_LOG_ERROR("NULL pointer %p %p", pc, effect);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5342 CAM_LOG_INFO("Enter");
5344 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE)
5347 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5349 CAM_LOG_INFO("ret : 0x%x", ret);
5355 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5357 int ret = CAMERA_ERROR_NONE;
5358 camera_cli_s *pc = (camera_cli_s *)camera;
5359 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5361 if (!pc || !pc->cb_info || !mode) {
5362 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5363 return CAMERA_ERROR_INVALID_PARAMETER;
5366 CAM_LOG_INFO("Enter");
5368 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5370 if (ret == CAMERA_ERROR_NONE)
5371 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5373 CAM_LOG_INFO("ret : 0x%x", ret);
5379 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5381 int ret = CAMERA_ERROR_NONE;
5382 camera_cli_s *pc = (camera_cli_s *)camera;
5383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5385 if (!pc || !pc->cb_info || !enable) {
5386 CAM_LOG_ERROR("NULL pointer %p %p", pc, enable);
5387 return CAMERA_ERROR_INVALID_PARAMETER;
5390 CAM_LOG_INFO("Enter");
5392 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5394 if (ret == CAMERA_ERROR_NONE)
5395 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5397 CAM_LOG_INFO("ret : 0x%x", ret);
5403 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5405 int ret = CAMERA_ERROR_NONE;
5406 camera_cli_s *pc = (camera_cli_s *)camera;
5407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5409 if (!pc || !pc->cb_info || !description) {
5410 CAM_LOG_ERROR("NULL pointer %p %p", pc, description);
5411 return CAMERA_ERROR_INVALID_PARAMETER;
5414 CAM_LOG_INFO("Enter");
5416 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5418 if (ret == CAMERA_ERROR_NONE)
5419 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5421 CAM_LOG_INFO("ret : 0x%x", ret);
5427 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5429 int ret = CAMERA_ERROR_NONE;
5430 camera_cli_s *pc = (camera_cli_s *)camera;
5431 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5433 if (!pc || !pc->cb_info || !orientation) {
5434 CAM_LOG_ERROR("NULL pointer %p %p", pc, orientation);
5435 return CAMERA_ERROR_INVALID_PARAMETER;
5438 CAM_LOG_INFO("Enter");
5440 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5442 if (ret == CAMERA_ERROR_NONE)
5443 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5445 CAM_LOG_INFO("ret : 0x%x", ret);
5451 int camera_attr_get_tag_software(camera_h camera, char **software)
5453 int ret = CAMERA_ERROR_NONE;
5454 camera_cli_s *pc = (camera_cli_s *)camera;
5455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5457 if (!pc || !pc->cb_info || !software) {
5458 CAM_LOG_ERROR("NULL pointer %p %p", pc, software);
5459 return CAMERA_ERROR_INVALID_PARAMETER;
5462 CAM_LOG_INFO("Enter");
5464 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5466 if (ret == CAMERA_ERROR_NONE)
5467 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5469 CAM_LOG_INFO("ret : 0x%x", ret);
5475 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5477 int ret = CAMERA_ERROR_NONE;
5478 camera_cli_s *pc = (camera_cli_s *)camera;
5479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5481 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5482 CAM_LOG_ERROR("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5483 return CAMERA_ERROR_INVALID_PARAMETER;
5486 CAM_LOG_INFO("Enter");
5488 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5490 if (ret == CAMERA_ERROR_NONE) {
5491 *latitude = pc->cb_info->get_geotag[0];
5492 *longitude = pc->cb_info->get_geotag[1];
5493 *altitude = pc->cb_info->get_geotag[2];
5496 CAM_LOG_INFO("ret : 0x%x", ret);
5502 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5504 int ret = CAMERA_ERROR_NONE;
5505 camera_cli_s *pc = (camera_cli_s *)camera;
5506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5508 if (!pc || !pc->cb_info || !mode) {
5509 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5510 return CAMERA_ERROR_INVALID_PARAMETER;
5513 CAM_LOG_INFO("Enter");
5515 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5517 if (ret == CAMERA_ERROR_NONE)
5518 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5520 CAM_LOG_INFO("ret : 0x%x", ret);
5526 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5528 int ret = CAMERA_ERROR_NONE;
5529 int get_flash_state = 0;
5532 CAM_LOG_ERROR("NULL pointer");
5533 return CAMERA_ERROR_INVALID_PARAMETER;
5536 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5537 (int)device, "get_flash_state", &get_flash_state);
5539 if (ret == CAMERA_ERROR_NONE) {
5540 *state = (camera_flash_state_e)get_flash_state;
5541 CAM_LOG_INFO("flash state %d", *state);
5543 CAM_LOG_ERROR("failed 0x%x", ret);
5550 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5552 int ret = CAMERA_ERROR_NONE;
5553 camera_cli_s *pc = (camera_cli_s *)camera;
5554 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5556 if (!pc || !pc->cb_info || !foreach_cb) {
5557 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5558 return CAMERA_ERROR_INVALID_PARAMETER;
5561 CAM_LOG_INFO("Enter");
5563 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5564 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5566 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5568 CAM_LOG_INFO("ret : 0x%x", ret);
5574 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5576 int ret = CAMERA_ERROR_NONE;
5577 camera_cli_s *pc = (camera_cli_s *)camera;
5578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5580 if (!pc || !pc->cb_info || !foreach_cb) {
5581 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5582 return CAMERA_ERROR_INVALID_PARAMETER;
5585 CAM_LOG_INFO("Enter");
5587 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5588 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5590 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5592 CAM_LOG_INFO("ret : 0x%x", ret);
5598 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5600 int ret = CAMERA_ERROR_NONE;
5601 camera_cli_s *pc = (camera_cli_s *)camera;
5602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5604 if (!pc || !pc->cb_info || !foreach_cb) {
5605 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5606 return CAMERA_ERROR_INVALID_PARAMETER;
5609 CAM_LOG_INFO("Enter");
5611 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5612 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5614 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5616 CAM_LOG_INFO("ret : 0x%x", ret);
5622 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5624 int ret = CAMERA_ERROR_NONE;
5625 camera_cli_s *pc = (camera_cli_s *)camera;
5626 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5628 if (!pc || !pc->cb_info || !foreach_cb) {
5629 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5630 return CAMERA_ERROR_INVALID_PARAMETER;
5633 CAM_LOG_INFO("Enter");
5635 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5636 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5638 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5640 CAM_LOG_INFO("ret : 0x%x", ret);
5646 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5648 int ret = CAMERA_ERROR_NONE;
5649 camera_cli_s *pc = (camera_cli_s *)camera;
5650 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5652 if (!pc || !pc->cb_info || !foreach_cb) {
5653 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5654 return CAMERA_ERROR_INVALID_PARAMETER;
5657 CAM_LOG_INFO("Enter");
5659 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5660 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5662 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5664 CAM_LOG_INFO("ret : 0x%x", ret);
5670 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5672 int ret = CAMERA_ERROR_NONE;
5673 camera_cli_s *pc = (camera_cli_s *)camera;
5674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5676 if (!pc || !pc->cb_info || !foreach_cb) {
5677 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5678 return CAMERA_ERROR_INVALID_PARAMETER;
5681 CAM_LOG_INFO("Enter");
5683 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5684 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5686 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5688 CAM_LOG_INFO("ret : 0x%x", ret);
5694 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5696 int ret = CAMERA_ERROR_NONE;
5697 camera_cli_s *pc = (camera_cli_s *)camera;
5698 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5700 if (!pc || !pc->cb_info || !foreach_cb) {
5701 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5702 return CAMERA_ERROR_INVALID_PARAMETER;
5705 CAM_LOG_INFO("Enter");
5707 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5708 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5710 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5712 CAM_LOG_INFO("ret : 0x%x", ret);
5718 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5720 int ret = CAMERA_ERROR_NONE;
5721 camera_cli_s *pc = (camera_cli_s *)camera;
5722 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5724 if (!pc || !pc->cb_info || !foreach_cb) {
5725 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5726 return CAMERA_ERROR_INVALID_PARAMETER;
5729 CAM_LOG_INFO("Enter");
5731 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5732 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5734 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5736 CAM_LOG_INFO("Enter, handle :%td", pc->remote_handle);
5742 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)
5744 int ret = CAMERA_ERROR_NONE;
5745 camera_cli_s *pc = (camera_cli_s *)camera;
5746 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5747 camera_msg_param param;
5750 if (!pc || !pc->cb_info || !foreach_cb) {
5751 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5752 return CAMERA_ERROR_INVALID_PARAMETER;
5755 CAM_LOG_INFO("Enter");
5757 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5758 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5760 value = (width << 16) | height;
5761 CAMERA_MSG_PARAM_SET(param, INT, value);
5763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5765 CAM_LOG_INFO("ret : 0x%x", ret);
5771 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5773 int ret = CAMERA_ERROR_NONE;
5774 camera_cli_s *pc = (camera_cli_s *)camera;
5775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5777 if (!pc || !pc->cb_info || !foreach_cb) {
5778 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5779 return CAMERA_ERROR_INVALID_PARAMETER;
5782 CAM_LOG_INFO("Enter");
5784 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5785 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5787 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5789 CAM_LOG_INFO("ret : 0x%x", ret);
5795 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5797 int ret = CAMERA_ERROR_NONE;
5798 camera_cli_s *pc = (camera_cli_s *)camera;
5799 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5801 if (!pc || !pc->cb_info || !foreach_cb) {
5802 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
5803 return CAMERA_ERROR_INVALID_PARAMETER;
5806 CAM_LOG_INFO("Enter");
5808 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5809 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5811 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5813 CAM_LOG_INFO("ret : 0x%x", ret);
5819 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5824 camera_msg_param param;
5825 int set_rotation = (int)rotation;
5827 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5829 CAM_LOG_INFO("Enter");
5831 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5833 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5835 CAM_LOG_INFO("ret : 0x%x", ret);
5841 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5843 int ret = CAMERA_ERROR_NONE;
5844 camera_cli_s *pc = (camera_cli_s *)camera;
5845 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5847 if (!pc || !pc->cb_info || !rotation) {
5848 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
5849 return CAMERA_ERROR_INVALID_PARAMETER;
5852 CAM_LOG_INFO("Enter");
5854 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5856 if (ret == CAMERA_ERROR_NONE)
5857 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5859 CAM_LOG_INFO("ret : 0x%x", ret);
5865 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5867 int ret = CAMERA_ERROR_NONE;
5868 camera_cli_s *pc = (camera_cli_s *)camera;
5869 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5870 camera_msg_param param;
5871 int set_flip = (int)flip;
5873 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5875 CAM_LOG_INFO("Enter");
5877 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5879 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5881 CAM_LOG_INFO("ret : 0x%x", ret);
5887 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5889 int ret = CAMERA_ERROR_NONE;
5890 camera_cli_s *pc = (camera_cli_s *)camera;
5891 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5893 if (!pc || !pc->cb_info || !flip) {
5894 CAM_LOG_ERROR("NULL pointer %p %p", pc, flip);
5895 return CAMERA_ERROR_INVALID_PARAMETER;
5898 CAM_LOG_INFO("Enter");
5900 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5902 if (ret == CAMERA_ERROR_NONE)
5903 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5905 CAM_LOG_INFO("ret : 0x%x", ret);
5910 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5912 return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
5916 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5922 if (!pc || !pc->cb_info || !mode) {
5923 CAM_LOG_ERROR("NULL pointer %p %p", pc, mode);
5924 return CAMERA_ERROR_INVALID_PARAMETER;
5927 CAM_LOG_INFO("Enter");
5929 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5931 if (ret == CAMERA_ERROR_NONE)
5932 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5934 CAM_LOG_INFO("ret : 0x%x", ret);
5940 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5942 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
5946 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5948 int ret = CAMERA_ERROR_NONE;
5949 camera_cli_s *pc = (camera_cli_s *)camera;
5950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5952 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5954 CAM_LOG_INFO("Enter");
5956 if (!camera_attr_is_supported_hdr_capture(camera)) {
5957 CAM_LOG_ERROR("HDR not supported");
5958 return CAMERA_ERROR_NOT_SUPPORTED;
5962 CAM_LOG_ERROR("NULL callback");
5963 return CAMERA_ERROR_INVALID_PARAMETER;
5966 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5968 if (ret == CAMERA_ERROR_NONE) {
5969 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5971 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5972 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5974 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5977 CAM_LOG_INFO("ret : 0x%x", ret);
5983 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5985 int ret = CAMERA_ERROR_NONE;
5986 camera_cli_s *pc = (camera_cli_s *)camera;
5987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5989 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
5991 CAM_LOG_INFO("Enter");
5993 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5995 if (ret == CAMERA_ERROR_NONE) {
5996 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6001 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6004 CAM_LOG_INFO("ret : 0x%x", ret);
6010 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6012 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
6016 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6018 int ret = CAMERA_ERROR_NONE;
6019 camera_cli_s *pc = (camera_cli_s *)camera;
6020 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6022 if (!pc || !pc->cb_info || !enabled) {
6023 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6024 return CAMERA_ERROR_INVALID_PARAMETER;
6027 CAM_LOG_INFO("Enter");
6029 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6031 if (ret == CAMERA_ERROR_NONE)
6032 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6034 CAM_LOG_INFO("ret : 0x%x", ret);
6040 bool camera_attr_is_supported_anti_shake(camera_h camera)
6042 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
6046 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6048 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
6052 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6054 int ret = CAMERA_ERROR_NONE;
6055 camera_cli_s *pc = (camera_cli_s *)camera;
6056 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6058 if (!pc || !pc->cb_info || !enabled) {
6059 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6060 return CAMERA_ERROR_INVALID_PARAMETER;
6063 CAM_LOG_INFO("Enter");
6065 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6067 if (ret == CAMERA_ERROR_NONE)
6068 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6070 CAM_LOG_INFO("ret : 0x%x", ret);
6076 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6078 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
6082 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6084 return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
6088 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6094 if (!pc || !pc->cb_info || !enabled) {
6095 CAM_LOG_ERROR("NULL pointer %p %p", pc, enabled);
6096 return CAMERA_ERROR_INVALID_PARAMETER;
6099 CAM_LOG_INFO("Enter");
6101 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6103 if (ret == CAMERA_ERROR_NONE)
6104 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6106 CAM_LOG_INFO("ret : 0x%x", ret);
6112 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6114 return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
6118 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6120 int ret = CAMERA_ERROR_NONE;
6121 camera_cli_s *pc = (camera_cli_s *)camera;
6122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6123 camera_msg_param param;
6124 int set_disable = (int)disable;
6126 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6128 CAM_LOG_INFO("Enter");
6130 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6132 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6134 CAM_LOG_INFO("ret : 0x%x", ret);
6140 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6142 int ret = CAMERA_ERROR_NONE;
6143 camera_cli_s *pc = (camera_cli_s *)camera;
6144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6145 camera_msg_param param0;
6146 camera_msg_param param1;
6148 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6150 CAM_LOG_INFO("Enter");
6152 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6153 CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
6155 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6156 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6158 CAM_LOG_INFO("ret : 0x%x", ret);
6164 int camera_attr_get_pan(camera_h camera, int *pan_step)
6166 int ret = CAMERA_ERROR_NONE;
6167 camera_cli_s *pc = (camera_cli_s *)camera;
6168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6170 if (!pc || !pc->cb_info || !pan_step) {
6171 CAM_LOG_ERROR("NULL pointer %p %p", pc, pan_step);
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6175 CAM_LOG_INFO("Enter");
6177 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6179 if (ret == CAMERA_ERROR_NONE)
6180 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6182 CAM_LOG_INFO("ret : 0x%x", ret);
6188 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6190 return _camera_attr_get_range(camera,
6191 MUSE_CAMERA_API_ATTR_GET_PAN_RANGE,
6192 MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE,
6197 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6199 int ret = CAMERA_ERROR_NONE;
6200 camera_cli_s *pc = (camera_cli_s *)camera;
6201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6202 camera_msg_param param0;
6203 camera_msg_param param1;
6205 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6207 CAM_LOG_INFO("Enter");
6209 CAMERA_MSG_PARAM_SET(param0, INT, move_type);
6210 CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
6212 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6213 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6215 CAM_LOG_INFO("ret : 0x%x", ret);
6221 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6223 int ret = CAMERA_ERROR_NONE;
6224 camera_cli_s *pc = (camera_cli_s *)camera;
6225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6227 if (!pc || !pc->cb_info || !tilt_step) {
6228 CAM_LOG_ERROR("NULL pointer %p %p", pc, tilt_step);
6229 return CAMERA_ERROR_INVALID_PARAMETER;
6232 CAM_LOG_INFO("Enter");
6234 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6236 if (ret == CAMERA_ERROR_NONE)
6237 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6239 CAM_LOG_INFO("ret : 0x%x", ret);
6245 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6247 return _camera_attr_get_range(camera,
6248 MUSE_CAMERA_API_ATTR_GET_TILT_RANGE,
6249 MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE,
6254 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6256 int ret = CAMERA_ERROR_NONE;
6257 camera_cli_s *pc = (camera_cli_s *)camera;
6258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6259 camera_msg_param param;
6260 int set_ptz_type = (int)ptz_type;
6262 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6264 CAM_LOG_INFO("Enter");
6266 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6268 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6270 CAM_LOG_INFO("ret : 0x%x", ret);
6276 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6278 int ret = CAMERA_ERROR_NONE;
6279 camera_cli_s *pc = (camera_cli_s *)camera;
6280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6282 if (!pc || !pc->cb_info || !foreach_cb) {
6283 CAM_LOG_ERROR("NULL pointer %p %p", pc, foreach_cb);
6284 return CAMERA_ERROR_INVALID_PARAMETER;
6287 CAM_LOG_INFO("Enter");
6289 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6290 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6292 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6294 CAM_LOG_INFO("ret : 0x%x", ret);
6300 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6302 int ret = CAMERA_ERROR_NONE;
6303 camera_cli_s *pc = (camera_cli_s *)camera;
6304 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6305 int set_display_roi_area[4] = {x, y, width, height};
6309 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6311 CAM_LOG_INFO("Enter");
6313 if (pc->cb_info->is_evas_render) {
6314 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6315 if (ret != MM_ERROR_NONE) {
6316 CAM_LOG_ERROR("mm_evas_renderer_set_roi_area error 0x%x", ret);
6317 return CAMERA_ERROR_INVALID_OPERATION;
6321 length = sizeof(set_display_roi_area) / sizeof(int) + \
6322 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6324 msg = muse_core_msg_new(api,
6325 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6328 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6334 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6336 camera_cli_s *pc = (camera_cli_s *)camera;
6337 int ret = CAMERA_ERROR_NONE;
6338 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6340 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6341 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6342 return CAMERA_ERROR_INVALID_PARAMETER;
6345 CAM_LOG_INFO("Enter");
6347 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6349 if (ret == CAMERA_ERROR_NONE) {
6350 *x = pc->cb_info->get_display_roi_area[0];
6351 *y = pc->cb_info->get_display_roi_area[1];
6352 *width = pc->cb_info->get_display_roi_area[2];
6353 *height = pc->cb_info->get_display_roi_area[3];
6356 CAM_LOG_INFO("ret : 0x%x", ret);
6362 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6364 int ret = CAMERA_ERROR_NONE;
6365 int get_device_state = 0;
6368 CAM_LOG_ERROR("NULL pointer");
6369 return CAMERA_ERROR_INVALID_PARAMETER;
6372 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6373 (int)device, "get_device_state", &get_device_state);
6375 if (ret == CAMERA_ERROR_NONE) {
6376 *state = (camera_device_state_e)get_device_state;
6377 CAM_LOG_INFO("device state %d", *state);
6379 CAM_LOG_ERROR("failed 0x%x", ret);
6386 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6388 int ret = CAMERA_ERROR_NONE;
6389 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6390 camera_cb_info *info = NULL;
6391 g_autoptr(GMutexLocker) locker = NULL;
6393 if (!callback || !cb_id) {
6394 CAM_LOG_ERROR("invalid pointer %p %p", callback, cb_id);
6395 return CAMERA_ERROR_INVALID_PARAMETER;
6398 /* check camera support */
6399 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6400 if (ret != CAMERA_ERROR_NONE) {
6401 CAM_LOG_ERROR("get device state failed");
6405 locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
6407 info = g_new0(camera_cb_info, 1);
6409 CAM_LOG_ERROR("info failed");
6410 return CAMERA_ERROR_OUT_OF_MEMORY;
6413 info->id = ++g_cam_dev_state_changed_cb_id;
6414 info->callback = (void *)callback;
6415 info->user_data = user_data;
6419 /* subscribe dbus signal for camera state change */
6420 if (!g_cam_dev_state_changed_cb_conn) {
6421 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6422 if (!g_cam_dev_state_changed_cb_conn) {
6423 CAM_LOG_ERROR("failed to get gdbus connection");
6424 ret = CAMERA_ERROR_INVALID_OPERATION;
6428 CAM_LOG_INFO("subscribe signal %s - %s - %s",
6429 MM_CAMCORDER_DBUS_OBJECT,
6430 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6431 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6433 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6434 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6435 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6436 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6437 CAM_LOG_ERROR("failed to get gdbus connection");
6438 ret = CAMERA_ERROR_INVALID_OPERATION;
6442 CAM_LOG_INFO("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6445 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6447 CAM_LOG_INFO("callback id %d", info->id);
6450 if (ret != CAMERA_ERROR_NONE) {
6456 if (g_cam_dev_state_changed_cb_conn) {
6457 g_object_unref(g_cam_dev_state_changed_cb_conn);
6458 g_cam_dev_state_changed_cb_conn = NULL;
6466 int camera_remove_device_state_changed_cb(int cb_id)
6468 int ret = CAMERA_ERROR_NONE;
6469 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6470 GList *tmp_list = NULL;
6471 camera_cb_info *info = NULL;
6472 g_autoptr(GMutexLocker) locker = NULL;
6474 /* check camera support */
6475 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6476 if (ret != CAMERA_ERROR_NONE) {
6477 CAM_LOG_ERROR("get device state failed");
6481 locker = g_mutex_locker_new(&g_cam_dev_state_changed_cb_lock);
6483 if (!g_cam_dev_state_changed_cb_list) {
6484 CAM_LOG_ERROR("there is no callback info");
6485 return CAMERA_ERROR_INVALID_OPERATION;
6488 tmp_list = g_cam_dev_state_changed_cb_list;
6491 info = tmp_list->data;
6492 tmp_list = tmp_list->next;
6495 CAM_LOG_WARNING("NULL info");
6499 if (info->id == cb_id) {
6500 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6505 if (!g_cam_dev_state_changed_cb_list) {
6506 /* no remained callback */
6507 if (g_cam_dev_state_changed_cb_conn) {
6508 /* unsubscribe signal */
6509 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6510 g_cam_dev_state_changed_cb_subscribe_id = 0;
6512 /* unref connection */
6513 g_object_unref(g_cam_dev_state_changed_cb_conn);
6514 g_cam_dev_state_changed_cb_conn = NULL;
6518 CAM_LOG_INFO("id %d callback removed", cb_id);
6519 ret = CAMERA_ERROR_NONE;
6521 return CAMERA_ERROR_NONE;
6525 CAM_LOG_ERROR("id %d callback not found", cb_id);
6527 return CAMERA_ERROR_INVALID_PARAMETER;
6532 int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
6534 int ret = CAMERA_ERROR_NONE;
6535 camera_cli_s *pc = (camera_cli_s *)camera;
6536 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
6537 g_autoptr(GMutexLocker) locker = NULL;
6539 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6541 locker = g_mutex_locker_new(&pc->cb_info->bridge_lock);
6543 if (pc->cb_info->bridge) {
6544 CAM_LOG_ERROR("media bridge[%p] is already set", pc->cb_info->bridge);
6545 return CAMERA_ERROR_INVALID_OPERATION;
6548 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6549 if (ret != CAMERA_ERROR_NONE) {
6550 CAM_LOG_ERROR("set media bridge failed[0x%x]", ret);
6554 pc->cb_info->bridge = bridge;
6556 CAM_LOG_INFO("[%p] set media bridge[%p]", camera, bridge);
6558 return CAMERA_ERROR_NONE;
6562 int camera_media_bridge_unset_bridge(camera_h camera)
6564 int ret = CAMERA_ERROR_NONE;
6565 camera_cli_s *pc = (camera_cli_s *)camera;
6566 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
6567 g_autoptr(GMutexLocker) locker = NULL;
6569 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6571 locker = g_mutex_locker_new(&pc->cb_info->bridge_lock);
6573 if (!pc->cb_info->bridge) {
6574 CAM_LOG_ERROR("no media bridge");
6575 return CAMERA_ERROR_INVALID_OPERATION;
6578 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6579 if (ret != CAMERA_ERROR_NONE) {
6580 CAM_LOG_ERROR("unset media bridge failed[0x%x]", ret);
6584 CAM_LOG_INFO("[%p] unset media bridge[%p]", camera, pc->cb_info->bridge);
6586 pc->cb_info->bridge = NULL;
6588 return CAMERA_ERROR_NONE;
6593 int camera_create_network(camera_device_e device, camera_h *camera)
6595 return _camera_create_private(device, true, camera);
6599 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
6601 int ret = CAMERA_ERROR_NONE;
6602 camera_cli_s *pc = (camera_cli_s *)camera;
6603 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
6605 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6607 if (!camera_is_supported_extra_preview(camera)) {
6608 CAM_LOG_ERROR("extra preview is not supported");
6609 return CAMERA_ERROR_NOT_SUPPORTED;
6613 CAM_LOG_ERROR("NULL callback");
6614 return CAMERA_ERROR_INVALID_PARAMETER;
6617 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
6618 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
6620 CAM_LOG_INFO("Enter");
6622 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6624 if (ret == CAMERA_ERROR_NONE) {
6625 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6627 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = callback;
6628 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = user_data;
6630 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6633 CAM_LOG_INFO("ret : 0x%x", ret);
6639 int camera_unset_extra_preview_cb(camera_h camera)
6641 int ret = CAMERA_ERROR_NONE;
6642 camera_cli_s *pc = (camera_cli_s *)camera;
6643 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
6645 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6647 if (!camera_is_supported_extra_preview(camera)) {
6648 CAM_LOG_ERROR("extra preview is not supported");
6649 return CAMERA_ERROR_NOT_SUPPORTED;
6652 CAMERA_CHECK_THREAD_RETURN_VAL(pc->cb_info->preview_cb_info.thread,
6653 CAMERA_ERROR_INVALID_OPERATION, "should not be called within a invoked callback");
6655 CAM_LOG_INFO("Enter");
6657 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6659 if (ret == CAMERA_ERROR_NONE) {
6660 g_mutex_lock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6662 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6663 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW] = NULL;
6665 g_mutex_unlock(&pc->cb_info->user_cb_lock[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
6668 CAM_LOG_INFO("ret : 0x%x", ret);
6674 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)
6676 int ret = CAMERA_ERROR_NONE;
6677 int stream_format[4] = {pixel_format, width, height, fps};
6679 camera_cli_s *pc = (camera_cli_s *)camera;
6680 muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
6682 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6684 CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
6685 stream_id, pixel_format, width, height, fps);
6687 msg = muse_core_msg_new(api,
6688 MUSE_TYPE_INT, "stream_id", stream_id,
6689 MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
6692 _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
6698 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)
6700 int ret = CAMERA_ERROR_NONE;
6701 camera_cli_s *pc = (camera_cli_s *)camera;
6702 camera_msg_param param;
6703 muse_camera_api_e api = MUSE_CAMERA_API_GET_EXTRA_PREVIEW_STREAM_FORMAT;
6705 if (!pc || !pc->cb_info || !pixel_format || !width || !height || !fps) {
6706 CAM_LOG_ERROR("NULL pointer %p %p %p %p %p", pc, pixel_format, width, height, fps);
6707 return CAMERA_ERROR_INVALID_PARAMETER;
6710 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6712 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6714 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6716 if (ret == CAMERA_ERROR_NONE) {
6717 *pixel_format = (camera_pixel_format_e)pc->cb_info->get_extra_preview_stream_format[0];
6718 *width = pc->cb_info->get_extra_preview_stream_format[1];
6719 *height = pc->cb_info->get_extra_preview_stream_format[2];
6720 *fps = pc->cb_info->get_extra_preview_stream_format[3];
6723 CAM_LOG_INFO("ret : 0x%x", ret);
6729 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate)
6731 int ret = CAMERA_ERROR_NONE;
6732 camera_cli_s *pc = (camera_cli_s *)camera;
6733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_BITRATE;
6734 camera_msg_param param0;
6735 camera_msg_param param1;
6737 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6739 CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
6741 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6742 CAMERA_MSG_PARAM_SET(param1, INT, bitrate);
6744 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6745 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6747 CAM_LOG_INFO("ret : 0x%x", ret);
6753 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate)
6755 int ret = CAMERA_ERROR_NONE;
6756 camera_cli_s *pc = (camera_cli_s *)camera;
6757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_BITRATE;
6758 camera_msg_param param;
6760 if (!pc || !pc->cb_info || !bitrate) {
6761 CAM_LOG_ERROR("NULL pointer %p %p", pc, bitrate);
6762 return CAMERA_ERROR_INVALID_PARAMETER;
6765 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6767 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6769 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6771 if (ret == CAMERA_ERROR_NONE) {
6772 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_BITRATE];
6773 CAM_LOG_INFO("get bitrate[%d] for stream[%d]", *bitrate, stream_id);
6775 CAM_LOG_ERROR("get bitrate failed for stream[%d] : 0x%x", stream_id, ret);
6782 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval)
6784 int ret = CAMERA_ERROR_NONE;
6785 camera_cli_s *pc = (camera_cli_s *)camera;
6786 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXTRA_PREVIEW_GOP_INTERVAL;
6787 camera_msg_param param0;
6788 camera_msg_param param1;
6790 CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
6792 CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
6794 CAMERA_MSG_PARAM_SET(param0, INT, stream_id);
6795 CAMERA_MSG_PARAM_SET(param1, INT, interval);
6797 _camera_msg_send_param2_int(api, pc->cb_info, &ret,
6798 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
6800 CAM_LOG_INFO("ret : 0x%x", ret);
6806 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval)
6808 int ret = CAMERA_ERROR_NONE;
6809 camera_cli_s *pc = (camera_cli_s *)camera;
6810 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXTRA_PREVIEW_GOP_INTERVAL;
6811 camera_msg_param param;
6813 if (!pc || !pc->cb_info || !interval) {
6814 CAM_LOG_ERROR("NULL pointer %p %p", pc, interval);
6815 return CAMERA_ERROR_INVALID_PARAMETER;
6818 CAM_LOG_INFO("Enter - stream[%d]", stream_id);
6820 CAMERA_MSG_PARAM_SET(param, INT, stream_id);
6822 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6824 if (ret == CAMERA_ERROR_NONE) {
6825 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXTRA_PREVIEW_GOP_INTERVAL];
6826 CAM_LOG_INFO("get GOP interval[%d] for stream[%d]", *interval, stream_id);
6828 CAM_LOG_ERROR("get GOP interval failed for stream[%d] : 0x%x", stream_id, ret);
6835 int camera_attr_get_preview_frame_rotation(camera_h camera, camera_rotation_e *rotation)
6837 camera_cli_s *pc = (camera_cli_s *)camera;
6839 if (!pc || !pc->cb_info || !rotation) {
6840 CAM_LOG_ERROR("NULL pointer %p %p", pc, rotation);
6841 return CAMERA_ERROR_INVALID_PARAMETER;
6844 if (!pc->cb_info->stream_data) {
6845 CAM_LOG_ERROR("no stream data, maybe it's not in preview callback");
6846 return CAMERA_ERROR_INVALID_OPERATION;
6849 *rotation = pc->cb_info->stream_data->rotation;
6851 CAM_LOG_DEBUG("frame rotation[%d]", *rotation);
6853 return CAMERA_ERROR_NONE;
6857 int camera_attr_set_focus_level(camera_h camera, int level)
6859 return _camera_attr_set_level(camera, MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL, level);
6863 int camera_attr_get_focus_level(camera_h camera, int *level)
6865 return _camera_attr_get_level(camera,
6866 MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL,
6867 MUSE_CAMERA_GET_INT_FOCUS_LEVEL,
6872 int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max)
6874 return _camera_attr_get_range(camera,
6875 MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL_RANGE,
6876 MUSE_CAMERA_GET_INT_PAIR_FOCUS_LEVEL_RANGE,
6881 int _camera_get_log_level(void)
6883 return g_camera_log_level;
6887 int _camera_attr_set_level(camera_h camera, muse_camera_api_e api, int level)
6889 int ret = CAMERA_ERROR_NONE;
6890 camera_cli_s *pc = (camera_cli_s *)camera;
6891 camera_msg_param param;
6893 if (!pc || !pc->cb_info) {
6894 CAM_LOG_ERROR("api[%d] NULL handle", api);
6895 return CAMERA_ERROR_INVALID_PARAMETER;
6898 CAM_LOG_INFO("api[%d] Enter - level[%d]", api, level);
6900 CAMERA_MSG_PARAM_SET(param, INT, level);
6902 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6904 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);
6910 int _camera_attr_get_level(camera_h camera, muse_camera_api_e api, muse_camera_get_int_e get_index, int *level)
6912 int ret = CAMERA_ERROR_NONE;
6913 camera_cli_s *pc = (camera_cli_s *)camera;
6915 if (!pc || !pc->cb_info || !level) {
6916 CAM_LOG_ERROR("api[%d] NULL param[%p,%p]", api, pc, level);
6917 return CAMERA_ERROR_INVALID_PARAMETER;
6920 if (get_index >= MUSE_CAMERA_GET_INT_NUM) {
6921 CAM_LOG_ERROR("api[%d] INVALID index[%d]", api, get_index);
6922 return CAMERA_ERROR_INVALID_OPERATION;
6925 CAM_LOG_INFO("api[%d] Enter", api);
6927 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6929 if (ret == CAMERA_ERROR_NONE) {
6930 *level = pc->cb_info->get_int[get_index];
6931 CAM_LOG_INFO("api[%d] level[%d]", api, *level);
6934 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);
6940 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)
6942 int ret = CAMERA_ERROR_NONE;
6943 camera_cli_s *pc = (camera_cli_s *)camera;
6945 if (!pc || !pc->cb_info || !min || !max) {
6946 CAM_LOG_ERROR("api[%d] NULL param[%p,%p,%p]", api, pc, min, max);
6947 return CAMERA_ERROR_INVALID_PARAMETER;
6950 if (get_index >= MUSE_CAMERA_GET_INT_PAIR_NUM) {
6951 CAM_LOG_ERROR("api[%d] INVALID index[%d]", api, get_index);
6952 return CAMERA_ERROR_INVALID_OPERATION;
6955 CAM_LOG_INFO("api[%d] Enter", api);
6957 _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6959 if (ret == CAMERA_ERROR_NONE) {
6960 *min = pc->cb_info->get_int_pair[get_index][0];
6961 *max = pc->cb_info->get_int_pair[get_index][1];
6962 CAM_LOG_INFO("api[%d] min[%d], max[%d]", api, *min, *max);
6965 CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret);