2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <Elementary.h>
31 #include <tbm_surface_internal.h>
33 #include <Ecore_Wayland.h>
34 #include <wayland-client.h>
35 #include <tizen-extension-client-protocol.h>
36 #ifdef TIZEN_FEATURE_EVAS_RENDERER
37 #include <mm_evas_renderer.h>
38 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
44 #define LOG_TAG "TIZEN_N_CAMERA"
46 /* for device changed callback */
47 static GMutex g_cam_dev_state_changed_cb_lock;
48 static GList *g_cam_dev_state_changed_cb_list;
49 static int g_cam_dev_state_changed_cb_id;
50 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
51 static guint g_cam_dev_state_changed_cb_subscribe_id;
53 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
54 int *ret, int timeout);
55 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
56 int *ret, camera_msg_param *param, int timeout);
57 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
58 static void _camera_release_imported_bo(tbm_bo *bo);
59 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
60 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
61 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
62 camera_media_packet_data *mp_data, media_packet_h *packet);
63 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
64 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
65 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
68 static void __global(void *data, struct wl_registry *registry,
69 uint32_t name, const char *interface, uint32_t version)
71 struct tizen_surface **tz_surface = NULL;
78 tz_surface = (struct tizen_surface **)data;
81 LOGW("NULL interface");
85 /*LOGI("interface %s", interface);*/
87 if (strcmp(interface, "tizen_surface") == 0) {
88 LOGD("binding tizen surface for wayland");
90 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
91 if (*tz_surface == NULL)
92 LOGE("failed to bind");
100 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
106 static const struct wl_registry_listener _camera_wl_registry_listener = {
111 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
118 *((unsigned int *)data) = id;
120 LOGD("[CLIENT] got parent_id [%u] from server", id);
125 static const struct tizen_resource_listener _camera_tz_resource_listener = {
129 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
131 int ret = CAMERA_ERROR_NONE;
132 Ecore_Wl_Window *window = NULL;
133 struct wl_display *display = NULL;
134 struct wl_display *display_wrapper = NULL;
135 struct wl_surface *surface = NULL;
136 struct wl_registry *registry = NULL;
137 struct wl_event_queue *queue = NULL;
138 struct tizen_surface *tz_surface = NULL;
139 struct tizen_resource *tz_resource = NULL;
141 if (!obj || !wl_info) {
142 LOGE("NULL parameter %p %p", obj, wl_info);
143 return CAMERA_ERROR_INVALID_OPERATION;
146 window = elm_win_wl_window_get(obj);
148 LOGE("failed to get wayland window");
149 ret = CAMERA_ERROR_INVALID_OPERATION;
153 ecore_wl_window_video_has(window, EINA_TRUE);
155 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
157 LOGE("failed to get wayland surface");
158 ret = CAMERA_ERROR_INVALID_OPERATION;
162 display = (struct wl_display *)ecore_wl_display_get();
164 LOGE("failed to get wayland display");
165 ret = CAMERA_ERROR_INVALID_OPERATION;
169 display_wrapper = wl_proxy_create_wrapper(display);
170 if (!display_wrapper) {
171 LOGE("failed to create wl display wrapper");
172 ret = CAMERA_ERROR_INVALID_OPERATION;
176 queue = wl_display_create_queue(display);
178 LOGE("failed to create wl display queue");
179 ret = CAMERA_ERROR_INVALID_OPERATION;
183 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
185 registry = wl_display_get_registry(display_wrapper);
187 LOGE("failed to get wayland registry");
188 ret = CAMERA_ERROR_INVALID_OPERATION;
192 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
194 wl_display_dispatch_queue(display, queue);
195 wl_display_roundtrip_queue(display, queue);
198 LOGE("failed to get tizen surface");
199 ret = CAMERA_ERROR_INVALID_OPERATION;
203 /* Get parent_id which is unique in a entire systemw. */
204 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
206 LOGE("failed to get tizen resurce");
207 ret = CAMERA_ERROR_INVALID_OPERATION;
211 wl_info->parent_id = 0;
213 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
215 wl_display_roundtrip_queue(display, queue);
217 if (wl_info->parent_id > 0) {
219 Ecore_Evas *ecore_evas = NULL;
220 ret = CAMERA_ERROR_NONE;
222 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
223 &wl_info->window_width, &wl_info->window_height);
225 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
227 rotation = ecore_evas_rotation_get(ecore_evas);
228 if (rotation == 90 || rotation == 270) {
229 int temp = wl_info->window_width;
231 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
233 wl_info->window_width = wl_info->window_height;
234 wl_info->window_height = temp;
237 LOGW("failed to get ecore_evas.. skip rotation check");
240 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
241 obj, rotation, wl_info->parent_id,
242 wl_info->window_x, wl_info->window_y,
243 wl_info->window_width, wl_info->window_height);
245 ret = CAMERA_ERROR_INVALID_OPERATION;
246 LOGE("failed to get parent id");
251 tizen_surface_destroy(tz_surface);
256 tizen_resource_destroy(tz_resource);
261 wl_registry_destroy(registry);
266 wl_event_queue_destroy(queue);
270 if (display_wrapper) {
271 wl_proxy_wrapper_destroy(display_wrapper);
272 display_wrapper = NULL;
279 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
282 api < 0 || api >= MUSE_CAMERA_API_MAX) {
283 LOGE("invalid param %p %d", cb_info, api);
287 g_mutex_lock(&(cb_info->api_mutex[api]));
288 cb_info->api_waiting[api] += value;
289 g_mutex_unlock(&(cb_info->api_mutex[api]));
291 /*LOGD("api %d, value %d, waiting %d",
292 api, value, cb_info->api_waiting[api]);*/
298 static void __camera_device_state_changed_cb(GDBusConnection *connection,
299 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
300 const gchar *signal_name, GVariant *param, gpointer user_data)
303 camera_device_e device = CAMERA_DEVICE_CAMERA0;
304 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
305 GList *tmp_list = NULL;
306 camera_cb_info *info = NULL;
308 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
310 if (!g_cam_dev_state_changed_cb_list || !param) {
311 LOGW("no callback or NULL param %p", param);
315 /* get device and state */
316 g_variant_get(param, "(i)", &value);
318 device = value >> 16;
319 state = 0x0000ffff & value;
321 LOGD("device %d, state %d", device, state);
323 tmp_list = g_cam_dev_state_changed_cb_list;
326 info = (camera_cb_info *)tmp_list->data;
329 if (info->callback) {
330 LOGD("start id[%d] callback", info->id);
331 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
332 LOGD("returned id[%d] callback", info->id);
334 LOGW("NULL callback for id %d", info->id);
338 tmp_list = tmp_list->next;
342 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
348 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
352 int num_buffer_key = 0;
353 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
356 unsigned char *buf_pos = NULL;
357 camera_msg_param param;
360 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
361 tbm_bo_handle bo_handle = {.ptr = NULL};
362 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
363 tbm_bo data_bo = NULL;
364 tbm_bo_handle data_bo_handle = {.ptr = NULL};
366 camera_preview_data_s frame;
367 camera_stream_data_s *stream = NULL;
368 camera_media_packet_data *mp_data = NULL;
369 media_packet_h pkt = NULL;
370 #ifdef TIZEN_FEATURE_EVAS_RENDERER
371 media_packet_h pkt_evas = NULL;
372 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
374 if (!cb_info || !recv_msg) {
375 LOGE("invalid param %p %p", cb_info, recv_msg);
379 muse_camera_msg_get(tbm_key, recv_msg);
380 muse_camera_msg_get(num_buffer_key, recv_msg);
381 muse_camera_msg_get_array(buffer_key, recv_msg);
382 muse_camera_msg_get(data_key, recv_msg);
384 memset(&frame, 0x0, sizeof(camera_preview_data_s));
387 LOGE("invalid key %d", tbm_key);
391 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
393 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
394 LOGE("invalid num buffer key %d", num_buffer_key);
395 goto _PREVIEW_CB_HANDLER_DONE;
399 /* import tbm data_bo and get virtual address */
400 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
401 LOGE("failed to import data key %d", data_key);
402 goto _PREVIEW_CB_HANDLER_DONE;
406 /* import tbm bo and get virtual address */
407 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
408 LOGE("failed to import key %d", tbm_key);
409 goto _PREVIEW_CB_HANDLER_DONE;
412 buf_pos = (unsigned char *)bo_handle.ptr;
414 /* get stream info */
415 stream = (camera_stream_data_s *)buf_pos;
417 for (i = 0 ; i < num_buffer_key ; i++) {
418 /* import buffer bo and get virtual address */
419 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
420 LOGE("failed to import buffer key %d", buffer_key[i]);
421 goto _PREVIEW_CB_HANDLER_DONE;
425 /* call preview callback */
426 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
427 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
429 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
430 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
433 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
434 #ifdef TIZEN_FEATURE_EVAS_RENDERER
435 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
437 if (ret == CAMERA_ERROR_NONE) {
438 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
439 if (ret != CAMERA_ERROR_NONE) {
440 LOGE("create pkt for evas failed");
441 _camera_media_packet_data_release(mp_data, cb_info);
445 #else /* TIZEN_FEATURE_EVAS_RENDERER */
446 LOGW("evas renderer is not supported");
447 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
450 /* call media packet callback */
451 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
452 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
454 if (ret == CAMERA_ERROR_NONE) {
455 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
457 if (ret == CAMERA_ERROR_NONE) {
458 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
459 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
461 _camera_media_packet_data_release(mp_data, cb_info);
467 #ifdef TIZEN_FEATURE_EVAS_RENDERER
468 /* call evas renderer */
470 g_mutex_lock(&cb_info->evas_mutex);
471 if (cb_info->run_evas_render) {
472 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
474 LOGW("evas renderer is stopped, skip this buffer...");
475 media_packet_destroy(pkt_evas);
478 g_mutex_unlock(&cb_info->evas_mutex);
480 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
482 /* send message for preview callback return */
483 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
484 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
486 _PREVIEW_CB_HANDLER_DONE:
487 if (mp_data == NULL) {
488 /* release imported bo */
489 for (i = 0 ; i < num_buffer_key ; i++)
490 _camera_release_imported_bo(&buffer_bo[i]);
492 /* unmap and unref tbm bo */
493 _camera_release_imported_bo(&data_bo);
494 _camera_release_imported_bo(&bo);
497 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
499 /*LOGD("return buffer Done");*/
506 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
509 int tbm_key_main = 0;
510 int tbm_key_post = 0;
511 int tbm_key_thumb = 0;
512 unsigned char *buf_pos = NULL;
514 camera_msg_param param;
515 camera_image_data_s *rImage = NULL;
516 camera_image_data_s *rPostview = NULL;
517 camera_image_data_s *rThumbnail = NULL;
519 tbm_bo bo_main = NULL;
520 tbm_bo bo_post = NULL;
521 tbm_bo bo_thumb = NULL;
522 tbm_bo_handle bo_main_handle = {.ptr = NULL};
523 tbm_bo_handle bo_post_handle = {.ptr = NULL};
524 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
526 if (!cb_info || !recv_msg) {
527 LOGE("invalid param %p %p", cb_info, recv_msg);
531 muse_camera_msg_get(tbm_key_main, recv_msg);
532 muse_camera_msg_get(tbm_key_post, recv_msg);
533 muse_camera_msg_get(tbm_key_thumb, recv_msg);
536 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
537 tbm_key_main, tbm_key_post, tbm_key_thumb);
540 if (tbm_key_main <= 0) {
541 LOGE("invalid key %d", tbm_key_main);
542 goto _CAPTURE_CB_HANDLER_DONE;
545 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
546 LOGW("NULL callback");
547 goto _CAPTURE_CB_HANDLER_DONE;
550 /* import tbm bo and get virtual address */
551 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
552 LOGE("failed to import key [%d] for main", tbm_key_main);
553 goto _CAPTURE_CB_HANDLER_DONE;
556 buf_pos = (unsigned char *)bo_main_handle.ptr;
557 rImage = (camera_image_data_s *)buf_pos;
558 rImage->data = buf_pos + sizeof(camera_image_data_s);
559 if (rImage->exif && rImage->exif_size > 0) {
560 rImage->exif = rImage->data + rImage->size;
563 rImage->exif_size = 0;
566 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
567 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
569 if (tbm_key_post > 0) {
570 /* import tbm bo and get virtual address */
571 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
572 buf_pos = (unsigned char *)bo_post_handle.ptr;
573 rPostview = (camera_image_data_s *)buf_pos;
574 LOGD("rPostview->size : %d", rPostview->size);
575 rPostview->data = buf_pos + sizeof(camera_image_data_s);
577 LOGE("failed to import key [%d] for postview", tbm_key_post);
581 if (tbm_key_thumb > 0) {
582 /* import tbm bo and get virtual address */
583 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
584 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
585 rThumbnail = (camera_image_data_s *)buf_pos;
586 LOGD("rThumbnail->size : %d", rThumbnail->size);
587 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
589 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
593 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
594 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
596 _CAPTURE_CB_HANDLER_DONE:
598 if (tbm_key_main > 0) {
599 _camera_release_imported_bo(&bo_main);
601 tbm_key = tbm_key_main;
602 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
604 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
607 if (tbm_key_post > 0) {
608 _camera_release_imported_bo(&bo_post);
610 tbm_key = tbm_key_post;
611 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
613 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
616 if (tbm_key_thumb > 0) {
617 _camera_release_imported_bo(&bo_thumb);
619 tbm_key = tbm_key_thumb;
620 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
622 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
625 LOGD("return buffer done");
631 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
635 camera_detected_face_s *faces = NULL;
636 camera_msg_param param;
639 tbm_bo_handle bo_handle = {.ptr = NULL};
641 if (!cb_info || !recv_msg) {
642 LOGE("invalid param %p %p", cb_info, recv_msg);
646 muse_camera_msg_get(count, recv_msg);
647 muse_camera_msg_get(tbm_key, recv_msg);
649 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
650 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
654 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
656 faces = bo_handle.ptr;
660 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
661 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
664 _camera_release_imported_bo(&bo);
666 LOGW("skip face detection message [count %d, key %d, cb %p",
667 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
672 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
673 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
674 /*LOGD("return buffer done");*/
681 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
683 tbm_bo tmp_bo = NULL;
684 tbm_bo_handle tmp_bo_handle = {NULL, };
686 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
687 LOGE("invalid parameter - %p %p %p, key %d",
688 bufmgr, bo, bo_handle, tbm_key);
692 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
693 if (tmp_bo == NULL) {
694 LOGE("import failed - key %d", tbm_key);
698 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
699 if (tmp_bo_handle.ptr == NULL) {
700 LOGE("map failed %p", tmp_bo);
701 tbm_bo_unref(tmp_bo);
706 tbm_bo_unmap(tmp_bo);
708 /* set bo and bo_handle */
710 *bo_handle = tmp_bo_handle;
715 static void _camera_release_imported_bo(tbm_bo *bo)
728 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
730 int ret = CAMERA_ERROR_NONE;
733 /*LOGD("Enter api : %d", api);*/
735 if (!cb_info->is_server_connected) {
736 LOGE("server is disconnected");
737 return CAMERA_ERROR_SERVICE_DISCONNECTED;
740 g_mutex_lock(&(cb_info->api_mutex[api]));
742 if (cb_info->api_activating[api] == 0) {
743 if (time_out == CAMERA_CB_NO_TIMEOUT) {
744 LOGW("wait for api %d", api);
745 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
746 ret = cb_info->api_ret[api];
747 cb_info->api_activating[api] = 0;
748 LOGW("api %d returned 0x%x", api, ret);
750 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
751 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
752 ret = cb_info->api_ret[api];
753 cb_info->api_activating[api] = 0;
754 /*LOGD("return value : 0x%x", ret);*/
756 ret = CAMERA_ERROR_INVALID_OPERATION;
757 LOGE("api %d was TIMED OUT!", api);
761 ret = cb_info->api_ret[api];
762 cb_info->api_activating[api] = 0;
764 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
767 g_mutex_unlock(&(cb_info->api_mutex[api]));
769 if (ret != CAMERA_ERROR_NONE) {
770 LOGE("api %d : error 0x%x", api, ret);
772 if (ret == CAMERA_ERROR_SOUND_POLICY)
773 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
774 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
775 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
776 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
777 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
784 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
785 int *ret, int timeout)
791 LOGE("NULL info - api %d", api);
794 *ret = CAMERA_ERROR_INVALID_PARAMETER;
799 msg = muse_core_msg_new(api, NULL);
801 LOGE("msg failed: api %d", api);
804 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
809 /*LOGD("send msg %s", msg);*/
811 if (cb_info->is_server_connected) {
812 __camera_update_api_waiting(cb_info, api, 1);
814 g_mutex_lock(&cb_info->fd_lock);
815 send_ret = muse_core_msg_send(cb_info->fd, msg);
816 g_mutex_unlock(&cb_info->fd_lock);
820 LOGE("msg send failed");
822 *ret = CAMERA_ERROR_INVALID_OPERATION;
825 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
828 __camera_update_api_waiting(cb_info, api, -1);
830 muse_core_msg_free(msg);
836 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
837 int *ret, camera_msg_param *param, int timeout)
842 if (!cb_info || !param) {
843 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
846 *ret = CAMERA_ERROR_INVALID_PARAMETER;
851 /*LOGD("type %d, name %s", param->type, param->name);*/
853 switch (param->type) {
855 msg = muse_core_msg_new(api,
856 param->type, param->name, param->value.value_INT,
859 case MUSE_TYPE_STRING:
860 msg = muse_core_msg_new(api,
861 param->type, param->name, param->value.value_STRING,
865 LOGE("unknown type %d", param->type);
870 LOGE("msg failed: api %d", api);
873 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
878 /*LOGD("send msg %s", msg);*/
880 if (cb_info->is_server_connected) {
881 __camera_update_api_waiting(cb_info, api, 1);
883 g_mutex_lock(&cb_info->fd_lock);
884 send_ret = muse_core_msg_send(cb_info->fd, msg);
885 g_mutex_unlock(&cb_info->fd_lock);
889 LOGE("msg send failed");
892 *ret = CAMERA_ERROR_INVALID_OPERATION;
895 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
898 __camera_update_api_waiting(cb_info, api, -1);
900 muse_core_msg_free(msg);
906 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
908 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
909 in_format >= MM_PIXEL_FORMAT_NUM ||
910 out_format == NULL) {
911 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
912 return CAMERA_ERROR_INVALID_PARAMETER;
916 case MM_PIXEL_FORMAT_NV12:
917 case MM_PIXEL_FORMAT_NV12T:
918 *out_format = TBM_FORMAT_NV12;
920 case MM_PIXEL_FORMAT_NV16:
921 *out_format = TBM_FORMAT_NV16;
923 case MM_PIXEL_FORMAT_NV21:
924 *out_format = TBM_FORMAT_NV21;
926 case MM_PIXEL_FORMAT_YUYV:
927 *out_format = TBM_FORMAT_YUYV;
929 case MM_PIXEL_FORMAT_UYVY:
930 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
931 *out_format = TBM_FORMAT_UYVY;
933 case MM_PIXEL_FORMAT_422P:
934 *out_format = TBM_FORMAT_YUV422;
936 case MM_PIXEL_FORMAT_I420:
937 *out_format = TBM_FORMAT_YUV420;
939 case MM_PIXEL_FORMAT_YV12:
940 *out_format = TBM_FORMAT_YVU420;
942 case MM_PIXEL_FORMAT_RGB565:
943 *out_format = TBM_FORMAT_RGB565;
945 case MM_PIXEL_FORMAT_RGB888:
946 *out_format = TBM_FORMAT_RGB888;
948 case MM_PIXEL_FORMAT_RGBA:
949 *out_format = TBM_FORMAT_RGBA8888;
951 case MM_PIXEL_FORMAT_ARGB:
952 *out_format = TBM_FORMAT_ARGB8888;
955 LOGE("invalid in_format %d", in_format);
956 return CAMERA_ERROR_INVALID_PARAMETER;
959 return CAMERA_ERROR_NONE;
963 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
965 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
966 in_format >= MM_PIXEL_FORMAT_NUM ||
968 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
969 return CAMERA_ERROR_INVALID_PARAMETER;
973 case MM_PIXEL_FORMAT_NV12:
974 case MM_PIXEL_FORMAT_NV12T:
975 *mimetype = MEDIA_FORMAT_NV12;
977 case MM_PIXEL_FORMAT_NV16:
978 *mimetype = MEDIA_FORMAT_NV16;
980 case MM_PIXEL_FORMAT_NV21:
981 *mimetype = MEDIA_FORMAT_NV21;
983 case MM_PIXEL_FORMAT_YUYV:
984 *mimetype = MEDIA_FORMAT_YUYV;
986 case MM_PIXEL_FORMAT_UYVY:
987 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
988 *mimetype = MEDIA_FORMAT_UYVY;
990 case MM_PIXEL_FORMAT_422P:
991 *mimetype = MEDIA_FORMAT_422P;
993 case MM_PIXEL_FORMAT_I420:
994 *mimetype = MEDIA_FORMAT_I420;
996 case MM_PIXEL_FORMAT_YV12:
997 *mimetype = MEDIA_FORMAT_YV12;
999 case MM_PIXEL_FORMAT_RGB565:
1000 *mimetype = MEDIA_FORMAT_RGB565;
1002 case MM_PIXEL_FORMAT_RGB888:
1003 *mimetype = MEDIA_FORMAT_RGB888;
1005 case MM_PIXEL_FORMAT_RGBA:
1006 *mimetype = MEDIA_FORMAT_RGBA;
1008 case MM_PIXEL_FORMAT_ARGB:
1009 *mimetype = MEDIA_FORMAT_ARGB;
1012 LOGE("invalid in_format %d", in_format);
1013 return CAMERA_ERROR_INVALID_PARAMETER;
1016 return CAMERA_ERROR_NONE;
1019 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
1020 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1023 unsigned char *buf_pos = NULL;
1025 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1026 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1030 /* set frame info */
1031 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1032 frame->format = MM_PIXEL_FORMAT_UYVY;
1034 frame->format = stream->format;
1036 frame->width = stream->width;
1037 frame->height = stream->height;
1038 frame->timestamp = stream->timestamp;
1039 frame->num_of_planes = stream->num_planes;
1041 if (num_buffer_key == 0) {
1043 if (!data_bo_handle || !data_bo_handle->ptr) {
1044 LOGE("NULL pointer");
1048 buf_pos = data_bo_handle->ptr;
1050 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1051 frame->data.encoded_plane.data = buf_pos;
1052 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1053 total_size = stream->data.encoded.length_data;
1055 switch (stream->num_planes) {
1057 frame->data.single_plane.yuv = buf_pos;
1058 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1059 total_size = stream->data.yuv420.length_yuv;
1062 frame->data.double_plane.y = buf_pos;
1063 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1064 buf_pos += stream->data.yuv420sp.length_y;
1065 frame->data.double_plane.uv = buf_pos;
1066 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1067 total_size = stream->data.yuv420sp.length_y + \
1068 stream->data.yuv420sp.length_uv;
1071 frame->data.triple_plane.y = buf_pos;
1072 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1073 buf_pos += stream->data.yuv420p.length_y;
1074 frame->data.triple_plane.u = buf_pos;
1075 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1076 buf_pos += stream->data.yuv420p.length_u;
1077 frame->data.triple_plane.v = buf_pos;
1078 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1079 total_size = stream->data.yuv420p.length_y + \
1080 stream->data.yuv420p.length_u + \
1081 stream->data.yuv420p.length_v;
1089 switch (stream->num_planes) {
1091 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1092 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1093 total_size = stream->data.yuv420.length_yuv;
1096 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1097 if (stream->num_planes == (unsigned int)num_buffer_key)
1098 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1100 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1101 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1102 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1103 total_size = stream->data.yuv420sp.length_y + \
1104 stream->data.yuv420sp.length_uv;
1107 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1108 if (stream->num_planes == (unsigned int)num_buffer_key) {
1109 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1110 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1112 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1113 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1115 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1116 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1117 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1118 total_size = stream->data.yuv420p.length_y + \
1119 stream->data.yuv420p.length_u + \
1120 stream->data.yuv420p.length_v;
1128 LOGD("format %d, %dx%d, size %d plane num %d",
1129 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1135 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
1136 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1139 int ret = CAMERA_ERROR_NONE;
1140 camera_media_packet_data *tmp_mp_data = NULL;
1142 if (*mp_data == NULL) {
1143 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1145 tmp_mp_data->tbm_key = tbm_key;
1146 tmp_mp_data->num_buffer_key = num_buffer_key;
1147 tmp_mp_data->bo = bo;
1148 tmp_mp_data->data_bo = data_bo;
1149 tmp_mp_data->ref_cnt++;
1151 for (i = 0 ; i < num_buffer_key ; i++)
1152 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1154 *mp_data = tmp_mp_data;
1155 /*LOGD("mp_data %p", tmp_mp_data);*/
1157 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1158 LOGE("failed to alloc media packet data");
1161 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1167 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1171 camera_msg_param param;
1173 if (!mp_data || !cb_info) {
1174 LOGE("NULL pointer %p %p", mp_data, cb_info);
1178 if (mp_data->ref_cnt > 1) {
1180 LOGD("ref count %d", mp_data->ref_cnt);
1182 /* release imported bo */
1183 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1184 tbm_bo_unref(mp_data->buffer_bo[i]);
1185 mp_data->buffer_bo[i] = NULL;
1189 _camera_release_imported_bo(&mp_data->bo);
1190 _camera_release_imported_bo(&mp_data->data_bo);
1193 tbm_key = mp_data->tbm_key;
1195 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1197 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1206 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1207 camera_media_packet_data *mp_data, media_packet_h *packet)
1209 media_packet_h pkt = NULL;
1210 bool make_pkt_fmt = false;
1211 tbm_surface_h tsurf = NULL;
1212 tbm_surface_info_s tsurf_info;
1213 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1214 uint32_t bo_format = 0;
1217 int num_buffer_key = 0;
1218 tbm_bo *buffer_bo = NULL;
1220 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1221 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1222 cb_info, stream, mp_data, packet);
1223 return CAMERA_ERROR_INVALID_PARAMETER;
1226 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1227 buffer_bo = mp_data->buffer_bo;
1228 num_buffer_key = mp_data->num_buffer_key;
1230 /* create tbm surface */
1231 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1232 tsurf_info.planes[i].stride = stream->stride[i];
1234 /* get tbm surface format */
1235 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1236 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1238 if (ret == CAMERA_ERROR_NONE) {
1239 tsurf_info.width = stream->width;
1240 tsurf_info.height = stream->height;
1241 tsurf_info.format = bo_format;
1242 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1243 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1245 if (num_buffer_key > 0) {
1246 switch (bo_format) {
1247 case TBM_FORMAT_NV12:
1248 case TBM_FORMAT_NV21:
1249 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1250 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1251 tsurf_info.planes[0].offset = 0;
1252 if (num_buffer_key == 1)
1253 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1254 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1256 case TBM_FORMAT_YUV420:
1257 case TBM_FORMAT_YVU420:
1258 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1259 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1260 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1261 tsurf_info.planes[0].offset = 0;
1262 if (num_buffer_key == 1) {
1263 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1264 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1266 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1268 case TBM_FORMAT_UYVY:
1269 case TBM_FORMAT_YUYV:
1270 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1271 tsurf_info.planes[0].offset = 0;
1272 tsurf_info.size = tsurf_info.planes[0].size;
1278 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1279 } else if (mp_data->data_bo) {
1280 switch (bo_format) {
1281 case TBM_FORMAT_NV12:
1282 case TBM_FORMAT_NV21:
1283 tsurf_info.planes[0].size = stream->width * stream->height;
1284 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1285 tsurf_info.planes[0].offset = 0;
1286 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1287 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1289 case TBM_FORMAT_YUV420:
1290 case TBM_FORMAT_YVU420:
1291 tsurf_info.planes[0].size = stream->width * stream->height;
1292 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1293 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1294 tsurf_info.planes[0].offset = 0;
1295 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1296 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1297 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1299 case TBM_FORMAT_UYVY:
1300 case TBM_FORMAT_YUYV:
1301 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1302 tsurf_info.planes[0].offset = 0;
1303 tsurf_info.size = tsurf_info.planes[0].size;
1309 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1311 /*LOGD("tbm surface %p", tsurf);*/
1315 /* check media packet format */
1316 if (cb_info->pkt_fmt) {
1317 int pkt_fmt_width = 0;
1318 int pkt_fmt_height = 0;
1319 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1321 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1322 if (pkt_fmt_mimetype != mimetype ||
1323 pkt_fmt_width != stream->width ||
1324 pkt_fmt_height != stream->height) {
1325 LOGW("change fmt: current 0x%x, %dx%d",
1326 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1327 media_format_unref(cb_info->pkt_fmt);
1328 cb_info->pkt_fmt = NULL;
1329 make_pkt_fmt = true;
1332 make_pkt_fmt = true;
1335 /* create packet format */
1337 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1338 ret = media_format_create(&cb_info->pkt_fmt);
1339 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1340 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1341 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1342 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1343 LOGW("media_format_set : 0x%x", ret);
1345 LOGW("media_format_create failed 0x%x", ret);
1349 /* create media packet */
1350 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1351 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1352 (void *)cb_info, &pkt);
1353 if (ret != MEDIA_PACKET_ERROR_NONE) {
1354 LOGE("media_packet_create failed 0x%x", ret);
1355 tbm_surface_destroy(tsurf);
1359 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1360 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1364 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1365 /* set media packet data */
1366 ret = media_packet_set_extra(pkt, (void *)mp_data);
1367 if (ret != MEDIA_PACKET_ERROR_NONE) {
1368 LOGE("media_packet_set_extra failed");
1370 _camera_media_packet_data_release(mp_data, cb_info);
1373 media_packet_destroy(pkt);
1376 /* set timestamp : msec -> nsec */
1377 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1378 LOGW("media_packet_set_pts failed");
1387 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1390 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1391 camera_media_packet_data *mp_data = NULL;
1392 tbm_surface_h tsurf = NULL;
1394 if (!pkt || !cb_info) {
1395 LOGE("NULL pointer %p %p", pkt, cb_info);
1396 return MEDIA_PACKET_FINALIZE;
1399 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1400 if (ret != MEDIA_PACKET_ERROR_NONE) {
1401 LOGE("media_packet_get_extra failed 0x%x", ret);
1402 return MEDIA_PACKET_FINALIZE;
1405 /*LOGD("mp_data %p", mp_data);*/
1407 g_mutex_lock(&cb_info->mp_data_mutex);
1409 _camera_media_packet_data_release(mp_data, cb_info);
1412 g_mutex_unlock(&cb_info->mp_data_mutex);
1414 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1415 if (ret != MEDIA_PACKET_ERROR_NONE)
1416 LOGE("get tbm_surface failed 0x%x", ret);
1419 tbm_surface_destroy(tsurf);
1423 return MEDIA_PACKET_FINALIZE;
1426 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1431 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1432 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1436 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1438 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1440 if (cb_info->user_cb[event] == NULL) {
1441 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1442 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1443 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1444 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1445 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1446 LOGW("NULL callback for event %d, return here", event);
1450 /* return buffer message should be sent for some events.
1451 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1452 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1453 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1454 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1459 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1465 muse_camera_msg_get(previous, recv_msg);
1466 muse_camera_msg_get(current, recv_msg);
1467 muse_camera_msg_get(by_policy, recv_msg);
1469 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1470 previous, current, by_policy);
1472 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1473 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1476 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1480 muse_camera_msg_get(state, recv_msg);
1482 LOGD("FOCUS state - %d", state);
1484 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1487 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1488 LOGD("CAPTURE_COMPLETED");
1489 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1491 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1492 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1493 __camera_event_handler_preview(cb_info, recv_msg);
1495 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1499 muse_camera_msg_get(percent, recv_msg);
1501 LOGD("HDR progress - %d %%", percent);
1503 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1506 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1512 muse_camera_msg_get(policy, recv_msg);
1513 muse_camera_msg_get(previous, recv_msg);
1514 muse_camera_msg_get(current, recv_msg);
1516 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1517 policy, previous, current);
1519 if (policy == CAMERA_POLICY_SOUND)
1520 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1521 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1522 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1523 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1524 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1526 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1527 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1530 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1535 muse_camera_msg_get(policy, recv_msg);
1536 muse_camera_msg_get(state, recv_msg);
1538 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1540 if (policy == CAMERA_POLICY_SOUND)
1541 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1542 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1543 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1544 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1545 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1547 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1548 (camera_state_e)state, cb_info->user_data[event]);
1551 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1552 __camera_event_handler_face_detection(cb_info, recv_msg);
1554 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1557 int current_state = 0;
1559 muse_camera_msg_get(error, recv_msg);
1560 muse_camera_msg_get(current_state, recv_msg);
1562 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1564 if (error == CAMERA_ERROR_SOUND_POLICY)
1565 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1566 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1567 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1568 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1569 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1571 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1572 (camera_state_e)current_state, cb_info->user_data[event]);
1575 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1577 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1578 muse_camera_msg_get(param1, recv_msg);
1579 muse_camera_msg_get(param2, recv_msg);
1581 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1583 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1584 cb_info->user_cb[event] = NULL;
1585 cb_info->user_data[event] = NULL;
1586 LOGW("stop foreach callback for event %d", event);
1589 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1591 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1593 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1595 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1597 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1599 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1601 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1603 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1605 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1607 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1609 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1611 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1613 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1615 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1617 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1618 muse_camera_msg_get(param1, recv_msg);
1620 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1622 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1623 cb_info->user_cb[event] = NULL;
1624 cb_info->user_data[event] = NULL;
1625 LOGW("stop foreach callback for event %d", event);
1628 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1629 __camera_event_handler_capture(cb_info, recv_msg);
1632 LOGW("unhandled event %d", event);
1636 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1641 static bool _camera_idle_event_callback(void *data)
1643 camera_cb_info_s *cb_info = NULL;
1644 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1646 if (cam_idle_event == NULL) {
1647 LOGE("cam_idle_event is NULL");
1652 g_mutex_lock(&cam_idle_event->event_mutex);
1654 cb_info = cam_idle_event->cb_info;
1655 if (cb_info == NULL) {
1656 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1657 goto IDLE_EVENT_CALLBACK_DONE;
1660 /* remove event from list */
1661 g_mutex_lock(&cb_info->idle_event_mutex);
1663 if (cb_info->idle_event_list)
1664 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1666 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1667 g_mutex_unlock(&cb_info->idle_event_mutex);
1670 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1672 /* send signal for waiting thread */
1673 g_cond_signal(&cb_info->idle_event_cond);
1675 IDLE_EVENT_CALLBACK_DONE:
1676 /* unlock and release event */
1677 g_mutex_unlock(&cam_idle_event->event_mutex);
1678 g_mutex_clear(&cam_idle_event->event_mutex);
1680 g_free(cam_idle_event);
1681 cam_idle_event = NULL;
1686 static void *_camera_msg_handler_func(gpointer data)
1690 camera_message_s *cam_msg = NULL;
1691 camera_idle_event_s *cam_idle_event = NULL;
1692 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1693 camera_cb_info_s *cb_info = NULL;
1695 if (!handler_info || !handler_info->cb_info) {
1696 LOGE("NULL handler %p", handler_info);
1700 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1701 type = handler_info->type;
1703 LOGD("t:%d start", type);
1705 g_mutex_lock(&handler_info->mutex);
1707 while (g_atomic_int_get(&handler_info->running)) {
1708 if (g_queue_is_empty(handler_info->queue)) {
1709 /*LOGD("t:%d signal wait...", type);*/
1710 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1711 /*LOGD("t:%d signal received", type);*/
1713 if (g_atomic_int_get(&handler_info->running) == 0) {
1714 LOGD("t:%d stop event thread", type);
1719 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1721 g_mutex_unlock(&handler_info->mutex);
1723 if (cam_msg == NULL) {
1724 LOGE("t:%d NULL message", type);
1725 g_mutex_lock(&handler_info->mutex);
1731 if (api < MUSE_CAMERA_API_MAX) {
1734 g_mutex_lock(&cb_info->api_mutex[api]);
1736 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1737 if (cb_info->api_waiting[api] > 0) {
1738 cb_info->api_ret[api] = ret;
1739 cb_info->api_activating[api] = 1;
1741 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1743 g_cond_signal(&cb_info->api_cond[api]);
1745 LOGW("no waiting for this api [%d]", api);
1748 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1751 g_mutex_unlock(&cb_info->api_mutex[api]);
1752 } else if (api == MUSE_CAMERA_CB_EVENT) {
1753 switch (cam_msg->event_class) {
1754 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1755 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1757 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1758 cam_idle_event = g_new0(camera_idle_event_s, 1);
1759 if (cam_idle_event == NULL) {
1760 LOGE("t:%d cam_idle_event alloc failed", type);
1764 cam_idle_event->event = cam_msg->event;
1765 cam_idle_event->cb_info = cb_info;
1766 g_mutex_init(&cam_idle_event->event_mutex);
1767 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1769 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1771 g_mutex_lock(&cb_info->idle_event_mutex);
1772 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1773 g_mutex_unlock(&cb_info->idle_event_mutex);
1775 g_idle_add_full(G_PRIORITY_DEFAULT,
1776 (GSourceFunc)_camera_idle_event_callback,
1777 (gpointer)cam_idle_event,
1781 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1785 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1791 g_mutex_lock(&handler_info->mutex);
1794 /* remove remained event */
1795 while (!g_queue_is_empty(handler_info->queue)) {
1796 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1798 LOGD("t:%d remove camera message %p", type, cam_msg);
1802 LOGW("t:%d NULL camera message", type);
1806 g_mutex_unlock(&handler_info->mutex);
1808 LOGD("t:%d return", type);
1814 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1816 camera_idle_event_s *cam_idle_event = NULL;
1818 gint64 end_time = 0;
1820 if (cb_info == NULL) {
1821 LOGE("cb_info is NULL");
1825 g_mutex_lock(&cb_info->idle_event_mutex);
1827 if (cb_info->idle_event_list == NULL) {
1828 LOGD("No remained idle event");
1829 g_mutex_unlock(&cb_info->idle_event_mutex);
1833 list = cb_info->idle_event_list;
1836 cam_idle_event = list->data;
1837 list = g_list_next(list);
1839 if (!cam_idle_event) {
1840 LOGW("Fail to remove idle event. The event is NULL");
1844 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1845 LOGW("lock failed, %p event is calling now", cam_idle_event);
1847 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1849 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1850 LOGW("signal received");
1857 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1858 cam_idle_event, cam_idle_event->event);
1860 cam_idle_event->cb_info = NULL;
1862 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1864 g_mutex_unlock(&cam_idle_event->event_mutex);
1867 g_list_free(cb_info->idle_event_list);
1868 cb_info->idle_event_list = NULL;
1870 g_mutex_unlock(&cb_info->idle_event_mutex);
1876 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1878 camera_message_s *cam_msg = NULL;
1880 if (!cb_info || !msg) {
1881 LOGE("NULL pointer %p %p", cb_info, msg);
1885 cam_msg = g_new0(camera_message_s, 1);
1887 LOGE("failed to alloc cam_msg for [%s]", msg);
1892 cam_msg->event = event;
1893 cam_msg->event_class = event_class;
1895 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1897 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1899 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1900 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1901 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1902 g_cond_signal(&cb_info->preview_cb_info.cond);
1903 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1904 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1905 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1906 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1907 g_cond_signal(&cb_info->capture_cb_info.cond);
1908 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1910 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1911 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1912 g_cond_signal(&cb_info->msg_handler_info.cond);
1913 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1922 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1924 int ret = CAMERA_ERROR_NONE;
1928 int event_class = -1;
1932 if (!cb_info || !msg) {
1933 LOGE("invalid ptr %p %p", cb_info, msg);
1937 /*LOGD("msg [%s]", msg);*/
1939 if (!muse_camera_msg_get(api, msg)) {
1940 LOGE("failed to get camera api");
1944 if (api == MUSE_CAMERA_CB_EVENT) {
1945 if (!muse_camera_msg_get(event, msg) ||
1946 !muse_camera_msg_get(event_class, msg)) {
1947 LOGE("failed to get camera event or event_class [%s]", msg);
1951 if (!muse_camera_msg_get(api_class, msg)) {
1952 LOGE("failed to get camera api_class [%s]", msg);
1957 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1958 if (api >= MUSE_CAMERA_API_MAX) {
1959 LOGE("invalid api %d", api);
1963 if (!muse_camera_msg_get(ret, msg)) {
1964 LOGE("failed to get camera ret");
1968 g_mutex_lock(&cb_info->api_mutex[api]);
1971 case MUSE_CAMERA_API_CREATE:
1972 if (ret != CAMERA_ERROR_NONE) {
1973 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1974 LOGE("camera create error 0x%x. close client cb handler", ret);
1977 case MUSE_CAMERA_API_DESTROY:
1978 if (ret == CAMERA_ERROR_NONE) {
1979 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1980 LOGD("camera destroy done. close client cb handler");
1984 muse_camera_msg_get(get_type, msg);
1985 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1986 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1987 muse_camera_msg_get(get_index, msg);
1990 case MUSE_CAMERA_GET_TYPE_INT:
1991 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1993 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1994 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1995 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1997 case MUSE_CAMERA_GET_TYPE_ARRAY:
1998 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1999 muse_core_msg_deserialize("get_value",
2000 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2001 LOGD("get display roi %d,%d,%dx%d",
2002 cb_info->get_display_roi_area[0],
2003 cb_info->get_display_roi_area[1],
2004 cb_info->get_display_roi_area[2],
2005 cb_info->get_display_roi_area[3]);
2007 muse_core_msg_deserialize("get_value",
2008 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2009 LOGD("get geotag %lf, %lf, %lf",
2010 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2013 case MUSE_CAMERA_GET_TYPE_STRING:
2014 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2017 LOGW("unknown type %d", get_type);
2024 if (cb_info->api_waiting[api] > 0) {
2025 cb_info->api_ret[api] = ret;
2026 cb_info->api_activating[api] = 1;
2028 g_cond_signal(&cb_info->api_cond[api]);
2030 LOGW("no waiting for this api [%d]", api);
2033 g_mutex_unlock(&cb_info->api_mutex[api]);
2034 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2035 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
2037 LOGW("unknown camera api %d, class %d", api, api_class);
2044 static void *_camera_msg_recv_func(gpointer data)
2046 int recv_length = 0;
2047 int single_length = 0;
2048 int remained_length = 0;
2049 char *recv_msg = NULL;
2050 char *single_msg = NULL;
2051 char *remained_msg = NULL;
2055 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2058 LOGE("cb_info NULL");
2064 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2066 LOGE("single_msg malloc failed");
2070 recv_msg = cb_info->recv_msg;
2072 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2073 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2074 if (recv_length <= 0) {
2075 cb_info->is_server_connected = FALSE;
2076 LOGE("receive msg failed - server disconnected");
2084 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2086 /* Need to split the combined entering msgs */
2087 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2088 if (recv_msg[cur_pos] == '}') {
2089 single_length = cur_pos - prev_pos + 1;
2091 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2092 /* check remained msg */
2093 if (remained_length > 0) {
2095 strncpy(single_msg, remained_msg, remained_length);
2096 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2097 single_msg[remained_length + single_length] = '\0';
2100 remained_msg = NULL;
2102 strncpy(single_msg, recv_msg + prev_pos, single_length);
2103 single_msg[single_length] = '\0';
2104 LOGE("lost msg [%s], skip...", single_msg);
2107 remained_length = 0;
2109 strncpy(single_msg, recv_msg + prev_pos, single_length);
2110 single_msg[single_length] = '\0';
2113 if (single_msg[0] == '{') {
2115 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2116 /* process each message */
2117 __camera_process_msg(cb_info, single_msg);
2119 LOGE("invalid msg [%s]", single_msg);
2122 LOGE("too long message [len %d] skip...", single_length);
2125 prev_pos = cur_pos + 1;
2129 /* check incompleted message */
2130 if (recv_msg[recv_length - 1] != '}') {
2131 remained_length = recv_length - prev_pos;
2133 LOGW("incompleted message [len %d]", remained_length);
2137 remained_msg = NULL;
2140 remained_msg = (char *)malloc(remained_length + 1);
2142 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2143 remained_msg[remained_length] = '\0';
2145 LOGE("failed to alloc for remained msg");
2148 remained_length = 0;
2152 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2154 if (!cb_info->is_server_connected) {
2155 /* send error msg for server disconnection */
2156 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2157 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2158 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2162 LOGE("error_msg failed");
2163 goto CB_HANDLER_EXIT;
2166 __camera_add_msg_to_queue(cb_info,
2167 MUSE_CAMERA_CB_EVENT,
2168 MUSE_CAMERA_EVENT_TYPE_ERROR,
2169 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2172 muse_core_msg_free(error_msg);
2175 LOGE("add error msg for service disconnection done");
2186 remained_msg = NULL;
2193 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2194 int type, const char *thread_name, camera_cb_info_s *cb_info)
2196 if (!handler_info || !thread_name || !cb_info) {
2197 LOGE("t:%d NULL %p %p %p",
2198 type, handler_info, thread_name, cb_info);
2204 handler_info->type = type;
2205 handler_info->queue = g_queue_new();
2206 if (handler_info->queue == NULL) {
2207 LOGE("t:%d queue failed", type);
2211 g_mutex_init(&handler_info->mutex);
2212 g_cond_init(&handler_info->cond);
2214 handler_info->cb_info = (void *)cb_info;
2215 g_atomic_int_set(&handler_info->running, 1);
2217 handler_info->thread = g_thread_try_new(thread_name,
2218 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2219 if (handler_info->thread == NULL) {
2220 LOGE("t:%d thread failed", type);
2222 g_mutex_clear(&handler_info->mutex);
2223 g_cond_clear(&handler_info->cond);
2224 g_queue_free(handler_info->queue);
2225 handler_info->queue = NULL;
2230 LOGD("t:%d done", type);
2236 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2240 if (!handler_info) {
2241 LOGE("NULL handler");
2245 if (!handler_info->thread) {
2246 LOGW("thread is not created");
2250 type = handler_info->type;
2252 LOGD("t:%d thread %p", type, handler_info->thread);
2254 g_mutex_lock(&handler_info->mutex);
2255 g_atomic_int_set(&handler_info->running, 0);
2256 g_cond_signal(&handler_info->cond);
2257 g_mutex_unlock(&handler_info->mutex);
2259 g_thread_join(handler_info->thread);
2260 handler_info->thread = NULL;
2262 g_mutex_clear(&handler_info->mutex);
2263 g_cond_clear(&handler_info->cond);
2264 g_queue_free(handler_info->queue);
2265 handler_info->queue = NULL;
2267 LOGD("t:%d done", type);
2273 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2275 camera_cb_info_s *cb_info = NULL;
2278 g_return_val_if_fail(sockfd > 0, NULL);
2280 cb_info = g_new0(camera_cb_info_s, 1);
2281 if (cb_info == NULL) {
2282 LOGE("cb_info failed");
2286 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2288 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2289 g_mutex_init(&cb_info->api_mutex[i]);
2290 g_cond_init(&cb_info->api_cond[i]);
2293 g_mutex_init(&cb_info->fd_lock);
2294 g_mutex_init(&cb_info->idle_event_mutex);
2295 g_cond_init(&cb_info->idle_event_cond);
2296 g_mutex_init(&cb_info->mp_data_mutex);
2297 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2298 g_mutex_init(&cb_info->evas_mutex);
2299 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2301 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2302 g_mutex_init(&cb_info->user_cb_mutex[i]);
2304 /* message handler thread */
2305 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2306 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2307 LOGE("msg_handler_info failed");
2311 /* message handler thread for preview callback */
2312 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2313 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2314 LOGE("preview_cb_info failed");
2318 /* message handler thread for capture callback */
2319 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2320 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2321 LOGE("capture_cb_info failed");
2325 cb_info->fd = sockfd;
2326 cb_info->preview_cb_flag = 0;
2327 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2328 cb_info->evas_info = NULL;
2329 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2331 /* message receive thread */
2332 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2333 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2334 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2335 if (cb_info->msg_recv_thread == NULL) {
2336 LOGE("message receive thread creation failed");
2340 cb_info->is_server_connected = TRUE;
2346 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2347 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2348 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2350 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2351 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2353 g_mutex_clear(&cb_info->fd_lock);
2354 g_mutex_clear(&cb_info->idle_event_mutex);
2355 g_cond_clear(&cb_info->idle_event_cond);
2356 g_mutex_clear(&cb_info->mp_data_mutex);
2357 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2358 g_mutex_clear(&cb_info->evas_mutex);
2359 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2361 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2362 g_mutex_clear(&cb_info->api_mutex[i]);
2363 g_cond_clear(&cb_info->api_cond[i]);
2373 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2377 g_return_if_fail(cb_info != NULL);
2379 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2381 g_thread_join(cb_info->msg_recv_thread);
2382 cb_info->msg_recv_thread = NULL;
2384 LOGD("msg_recv thread removed");
2386 /* destroy msg handler threads */
2387 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2388 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2389 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2391 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2392 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2394 g_mutex_clear(&cb_info->fd_lock);
2395 g_mutex_clear(&cb_info->idle_event_mutex);
2396 g_cond_clear(&cb_info->idle_event_cond);
2397 g_mutex_clear(&cb_info->mp_data_mutex);
2398 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2399 g_mutex_clear(&cb_info->evas_mutex);
2400 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2402 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2403 g_mutex_clear(&cb_info->api_mutex[i]);
2404 g_cond_clear(&cb_info->api_cond[i]);
2407 if (cb_info->fd > -1) {
2408 muse_client_close(cb_info->fd);
2412 if (cb_info->bufmgr) {
2413 tbm_bufmgr_deinit(cb_info->bufmgr);
2414 cb_info->bufmgr = NULL;
2416 if (cb_info->pkt_fmt) {
2417 media_format_unref(cb_info->pkt_fmt);
2418 cb_info->pkt_fmt = NULL;
2421 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2422 if (cb_info->evas_info)
2423 mm_evas_renderer_destroy(&cb_info->evas_info);
2424 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2426 cb_info->preview_cb_flag = 0;
2435 int _camera_start_evas_rendering(camera_h camera)
2437 int ret = CAMERA_ERROR_NONE;
2438 camera_cli_s *pc = (camera_cli_s *)camera;
2440 if (!pc || !pc->cb_info) {
2441 LOGE("NULL handle");
2442 return CAMERA_ERROR_INVALID_PARAMETER;
2447 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2448 LOGE("EVAS surface is not set");
2449 return CAMERA_ERROR_NONE;
2452 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2453 g_mutex_lock(&pc->cb_info->evas_mutex);
2455 /* set evas render flag as RUN */
2456 pc->cb_info->run_evas_render = true;
2457 ret = CAMERA_ERROR_NONE;
2459 g_mutex_unlock(&pc->cb_info->evas_mutex);
2460 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2461 LOGW("evas renderer is not supported");
2462 ret = CAMERA_ERROR_NOT_SUPPORTED;
2463 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2469 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2471 int ret = CAMERA_ERROR_NONE;
2472 camera_cli_s *pc = (camera_cli_s *)camera;
2474 if (!pc || !pc->cb_info) {
2475 LOGE("NULL handle");
2476 return CAMERA_ERROR_INVALID_PARAMETER;
2479 LOGD("stop - keep screen %d", keep_screen);
2481 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2482 LOGE("EVAS surface is not set");
2483 return CAMERA_ERROR_NONE;
2486 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2487 g_mutex_lock(&pc->cb_info->evas_mutex);
2489 /* set evas render flag as STOP and release buffers */
2490 pc->cb_info->run_evas_render = false;
2492 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2493 if (ret != MM_ERROR_NONE) {
2494 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2495 ret = CAMERA_ERROR_INVALID_OPERATION;
2498 g_mutex_unlock(&pc->cb_info->evas_mutex);
2499 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2500 LOGW("evas renderer is not supported");
2501 ret = CAMERA_ERROR_NOT_SUPPORTED;
2502 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2508 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2510 int ret = CAMERA_ERROR_NONE;
2513 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2515 /* create muse connection */
2516 if (!key || !value) {
2517 LOGE("NULL pointer");
2518 return CAMERA_ERROR_INVALID_PARAMETER;
2521 sock_fd = muse_client_new();
2523 LOGE("muse_client_new failed");
2524 return CAMERA_ERROR_INVALID_OPERATION;
2527 msg = muse_core_msg_new(api,
2528 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2529 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2533 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2537 ret = muse_core_msg_send(sock_fd, msg);
2539 muse_core_msg_free(msg);
2543 LOGE("send msg failed");
2544 ret = CAMERA_ERROR_INVALID_OPERATION;
2548 ret = muse_core_msg_recv(sock_fd, recv_msg);
2550 LOGE("recv msg failed %d", errno);
2551 ret = CAMERA_ERROR_INVALID_OPERATION;
2555 if (!muse_camera_msg_get(ret, recv_msg)) {
2556 LOGE("failed to get return value from msg [%s]", recv_msg);
2557 ret = CAMERA_ERROR_INVALID_OPERATION;
2561 if (ret == CAMERA_ERROR_NONE)
2562 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2564 LOGD("api %d - value %d", api, *value);
2568 muse_client_close(sock_fd);
2576 int camera_create(camera_device_e device, camera_h *camera)
2579 char *send_msg = NULL;
2581 int ret = CAMERA_ERROR_NONE;
2583 camera_cli_s *pc = NULL;
2584 tbm_bufmgr bufmgr = NULL;
2586 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2587 muse_core_api_module_e muse_module = MUSE_CAMERA;
2588 int device_type = (int)device;
2591 LOGE("NULL pointer");
2592 return CAMERA_ERROR_INVALID_PARAMETER;
2595 sock_fd = muse_client_new();
2597 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2598 ret = CAMERA_ERROR_INVALID_OPERATION;
2604 send_msg = muse_core_msg_new(api,
2605 MUSE_TYPE_INT, "module", muse_module,
2606 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2607 MUSE_TYPE_INT, "pid", pid,
2612 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2616 send_ret = muse_core_msg_send(sock_fd, send_msg);
2618 muse_core_msg_free(send_msg);
2622 LOGE("send msg failed %d", errno);
2623 ret = CAMERA_ERROR_INVALID_OPERATION;
2627 pc = g_new0(camera_cli_s, 1);
2629 LOGE("camera_cli_s alloc failed");
2630 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2634 bufmgr = tbm_bufmgr_init(-1);
2635 if (bufmgr == NULL) {
2636 LOGE("get tbm bufmgr failed");
2637 ret = CAMERA_ERROR_INVALID_OPERATION;
2641 pc->cb_info = _camera_client_callback_new(sock_fd);
2642 if (pc->cb_info == NULL) {
2643 LOGE("cb_info alloc failed");
2644 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2650 LOGD("cb info : %d", pc->cb_info->fd);
2652 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2654 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2656 if (ret == CAMERA_ERROR_NONE) {
2657 intptr_t handle = 0;
2658 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2660 LOGE("Receiving Handle Failed!!");
2661 ret = CAMERA_ERROR_INVALID_OPERATION;
2665 pc->remote_handle = handle;
2666 pc->cb_info->bufmgr = bufmgr;
2668 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2669 if (ret != CAMERA_ERROR_NONE) {
2670 LOGE("init display failed 0x%x", ret);
2674 LOGD("camera create 0x%x", pc->remote_handle);
2675 *camera = (camera_h)pc;
2684 tbm_bufmgr_deinit(bufmgr);
2689 muse_client_close(sock_fd);
2695 _camera_client_callback_destroy(pc->cb_info);
2702 LOGE("camera create error : 0x%x", ret);
2708 int camera_change_device(camera_h camera, camera_device_e device)
2711 int ret = CAMERA_ERROR_NONE;
2712 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2713 camera_cli_s *pc = (camera_cli_s *)camera;
2714 camera_msg_param param;
2716 if (!pc || !pc->cb_info) {
2717 LOGE("NULL handle");
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2721 CAMERA_MSG_PARAM_SET(param, INT, device);
2723 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2725 if (ret == CAMERA_ERROR_NONE) {
2726 /* reset callback and user data */
2727 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2728 pc->cb_info->user_cb[i] = NULL;
2729 pc->cb_info->user_data[i] = NULL;
2731 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2738 int camera_destroy(camera_h camera)
2740 int ret = CAMERA_ERROR_NONE;
2741 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2742 camera_cli_s *pc = (camera_cli_s *)camera;
2744 if (!pc || !pc->cb_info) {
2745 LOGE("NULL handle");
2746 return CAMERA_ERROR_INVALID_PARAMETER;
2751 if (pc->cb_info->is_server_connected)
2752 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2754 LOGW("server disconnected. release resource without send message.");
2756 if (ret == CAMERA_ERROR_NONE) {
2757 _camera_deactivate_idle_event_all(pc->cb_info);
2758 _camera_client_callback_destroy(pc->cb_info);
2768 int camera_start_preview(camera_h camera)
2770 int ret = CAMERA_ERROR_NONE;
2771 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2772 camera_cli_s *pc = (camera_cli_s *)camera;
2774 if (!pc || !pc->cb_info) {
2775 LOGE("NULL handle");
2776 return CAMERA_ERROR_INVALID_PARAMETER;
2781 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2782 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2783 ret = _camera_start_evas_rendering(camera);
2784 if (ret != CAMERA_ERROR_NONE) {
2785 LOGE("stop preview because of error");
2786 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2790 LOGD("ret : 0x%x", ret);
2796 int camera_stop_preview(camera_h camera)
2798 int ret = CAMERA_ERROR_NONE;
2799 camera_cli_s *pc = (camera_cli_s *)camera;
2800 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2801 camera_state_e current_state = CAMERA_STATE_NONE;
2803 if (!pc || !pc->cb_info) {
2804 LOGE("NULL handle");
2805 return CAMERA_ERROR_INVALID_PARAMETER;
2810 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2811 ret = camera_get_state(camera, ¤t_state);
2812 if (ret != CAMERA_ERROR_NONE) {
2813 LOGE("failed to get current state 0x%x", ret);
2817 if (current_state == CAMERA_STATE_PREVIEW) {
2818 ret = _camera_stop_evas_rendering(camera, false);
2819 if (ret != CAMERA_ERROR_NONE)
2824 /* send stop preview message */
2825 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2827 if (ret != CAMERA_ERROR_NONE &&
2828 current_state == CAMERA_STATE_PREVIEW) {
2829 LOGW("restart evas rendering");
2830 _camera_start_evas_rendering(camera);
2833 LOGD("ret : 0x%x", ret);
2839 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2841 int ret = CAMERA_ERROR_NONE;
2842 camera_cli_s *pc = (camera_cli_s *)camera;
2843 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2845 if (!pc || !pc->cb_info) {
2846 LOGE("NULL handle");
2847 return CAMERA_ERROR_INVALID_PARAMETER;
2852 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2853 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2855 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2856 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2858 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2860 LOGD("ret : 0x%x", ret);
2866 bool camera_is_supported_continuous_capture(camera_h camera)
2868 int ret = CAMERA_ERROR_NONE;
2869 camera_cli_s *pc = (camera_cli_s *)camera;
2870 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2872 if (!pc || !pc->cb_info) {
2873 LOGE("NULL handle");
2874 return CAMERA_ERROR_INVALID_PARAMETER;
2879 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2882 LOGE("error is occurred 0x%x", ret);
2886 LOGD("ret : %d", ret);
2892 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)
2894 int ret = CAMERA_ERROR_NONE;
2895 camera_cli_s *pc = (camera_cli_s *)camera;
2896 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2897 camera_msg_param param;
2900 if (!pc || !pc->cb_info) {
2901 LOGE("NULL handle");
2902 return CAMERA_ERROR_INVALID_PARAMETER;
2907 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2908 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2913 value = (count << 16) | interval;
2914 CAMERA_MSG_PARAM_SET(param, INT, value);
2916 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2918 LOGD("ret : 0x%x", ret);
2924 int camera_stop_continuous_capture(camera_h camera)
2926 int ret = CAMERA_ERROR_NONE;
2927 camera_cli_s *pc = (camera_cli_s *)camera;
2928 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2930 if (!pc || !pc->cb_info) {
2931 LOGE("NULL handle");
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2939 LOGD("ret : 0x%x", ret);
2945 bool camera_is_supported_face_detection(camera_h camera)
2947 int ret = CAMERA_ERROR_NONE;
2948 camera_cli_s *pc = (camera_cli_s *)camera;
2949 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2951 if (!pc || !pc->cb_info) {
2952 LOGE("NULL handle");
2953 return CAMERA_ERROR_INVALID_PARAMETER;
2958 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2961 LOGE("error is occurred 0x%x", ret);
2965 LOGD("ret : %d", ret);
2971 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2973 int ret = CAMERA_ERROR_NONE;
2974 camera_cli_s *pc = (camera_cli_s *)camera;
2975 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2977 if (!pc || !pc->cb_info) {
2978 LOGE("NULL handle");
2979 return CAMERA_ERROR_INVALID_PARAMETER;
2984 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2987 LOGE("error is occurred 0x%x", ret);
2991 LOGD("ret : %d", ret);
2997 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2999 int ret = CAMERA_ERROR_NONE;
3000 camera_cli_s *pc = (camera_cli_s *)camera;
3001 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
3003 if (!pc || !pc->cb_info) {
3004 LOGE("NULL handle");
3005 return CAMERA_ERROR_INVALID_PARAMETER;
3010 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3013 LOGE("error is occurred 0x%x", ret);
3017 LOGD("ret : %d", ret);
3022 int camera_get_device_count(camera_h camera, int *device_count)
3024 int ret = CAMERA_ERROR_NONE;
3025 camera_cli_s *pc = (camera_cli_s *)camera;
3026 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3028 if (!pc || !pc->cb_info) {
3029 LOGE("NULL handle");
3030 return CAMERA_ERROR_INVALID_PARAMETER;
3035 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3037 if (ret == CAMERA_ERROR_NONE)
3038 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3040 LOGD("ret : 0x%x", ret);
3045 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3047 int ret = CAMERA_ERROR_NONE;
3048 camera_cli_s *pc = (camera_cli_s *)camera;
3049 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3051 if (!pc || !pc->cb_info) {
3052 LOGE("NULL handle");
3053 return CAMERA_ERROR_INVALID_PARAMETER;
3058 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3060 if (ret == CAMERA_ERROR_NONE) {
3061 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3063 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3064 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3066 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3069 LOGD("ret : 0x%x", ret);
3074 int camera_stop_face_detection(camera_h camera)
3076 int ret = CAMERA_ERROR_NONE;
3077 camera_cli_s *pc = (camera_cli_s *)camera;
3078 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3080 if (!pc || !pc->cb_info) {
3081 LOGE("NULL handle");
3082 return CAMERA_ERROR_INVALID_PARAMETER;
3087 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3089 if (ret == CAMERA_ERROR_NONE) {
3090 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3092 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3093 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3095 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3098 LOGD("ret : 0x%x", ret);
3103 int camera_get_state(camera_h camera, camera_state_e *state)
3105 int ret = CAMERA_ERROR_NONE;
3106 camera_cli_s *pc = (camera_cli_s *)camera;
3107 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3109 if (!pc || !pc->cb_info || !state) {
3110 LOGE("NULL pointer %p %p", pc, state);
3111 return CAMERA_ERROR_INVALID_PARAMETER;
3116 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3118 if (ret == CAMERA_ERROR_NONE)
3119 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3121 LOGD("ret : 0x%x", ret);
3126 int camera_start_focusing(camera_h camera, bool continuous)
3128 int ret = CAMERA_ERROR_NONE;
3129 camera_cli_s *pc = (camera_cli_s *)camera;
3130 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3131 camera_msg_param param;
3132 int is_continuous = (int)continuous;
3134 if (!pc || !pc->cb_info) {
3135 LOGE("NULL handle");
3136 return CAMERA_ERROR_INVALID_PARAMETER;
3141 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3143 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3145 LOGD("ret : 0x%x", ret);
3150 int camera_cancel_focusing(camera_h camera)
3152 int ret = CAMERA_ERROR_NONE;
3153 camera_cli_s *pc = (camera_cli_s *)camera;
3154 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3156 if (!pc || !pc->cb_info) {
3157 LOGE("NULL handle");
3158 return CAMERA_ERROR_INVALID_PARAMETER;
3161 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3163 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3165 LOGD("ret : 0x%x", ret);
3170 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3172 int ret = CAMERA_ERROR_NONE;
3173 void *set_display_handle = NULL;
3174 Evas_Object *obj = NULL;
3175 const char *object_type = NULL;
3176 camera_cli_s *pc = (camera_cli_s *)camera;
3177 camera_cb_info_s *cb_info = NULL;
3178 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3179 camera_state_e current_state = CAMERA_STATE_NONE;
3180 camera_msg_param param;
3184 if (!pc || !pc->cb_info) {
3185 LOGE("NULL handle");
3186 return CAMERA_ERROR_INVALID_PARAMETER;
3189 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3190 LOGE("invalid type %d", type);
3191 return CAMERA_ERROR_INVALID_PARAMETER;
3194 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3195 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3196 return CAMERA_ERROR_INVALID_PARAMETER;
3199 cb_info = (camera_cb_info_s *)pc->cb_info;
3201 ret = camera_get_state(camera, ¤t_state);
3202 if (ret != CAMERA_ERROR_NONE) {
3203 LOGE("failed to get current state 0x%x", ret);
3207 if (current_state != CAMERA_STATE_CREATED) {
3208 LOGE("INVALID_STATE : current %d", current_state);
3209 return CAMERA_ERROR_INVALID_STATE;
3212 LOGD("Enter - display : %p", display);
3214 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3215 set_display_handle = 0;
3216 LOGD("display type NONE");
3218 obj = (Evas_Object *)display;
3219 object_type = evas_object_type_get(obj);
3221 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3222 /* get wayland parent id */
3223 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3224 LOGE("failed to get wayland info");
3225 return CAMERA_ERROR_INVALID_OPERATION;
3228 set_display_handle = (void *)&pc->wl_info;
3229 LOGD("display type OVERLAY : handle %p", set_display_handle);
3230 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3231 /* evas object surface */
3232 set_display_handle = (void *)display;
3233 LOGD("display type EVAS : handle %p", set_display_handle);
3235 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3236 g_mutex_lock(&cb_info->evas_mutex);
3238 if (cb_info->evas_info) {
3239 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3240 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3241 if (ret != MM_ERROR_NONE) {
3242 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3243 g_mutex_unlock(&cb_info->evas_mutex);
3244 return CAMERA_ERROR_INVALID_OPERATION;
3248 /* create evas renderer */
3249 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3250 if (ret == MM_ERROR_NONE) {
3251 camera_flip_e flip = CAMERA_FLIP_NONE;
3252 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3253 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3260 camera_get_display_flip(camera, &flip);
3261 camera_get_display_mode(camera, &mode);
3262 camera_get_display_rotation(camera, &rotation);
3263 camera_is_display_visible(camera, &visible);
3264 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3266 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3267 flip, mode, rotation, visible, x, y, width, height);
3269 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3270 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3271 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3272 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3274 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3275 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3278 g_mutex_unlock(&cb_info->evas_mutex);
3280 if (ret != MM_ERROR_NONE) {
3281 LOGE("mm_evas_renderer error 0x%x", ret);
3282 return CAMERA_ERROR_INVALID_OPERATION;
3284 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3285 LOGE("EVAS surface is not supported");
3286 return CAMERA_ERROR_NOT_SUPPORTED;
3287 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3289 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3290 return CAMERA_ERROR_INVALID_PARAMETER;
3293 LOGE("failed to get evas object type from %p", obj);
3294 return CAMERA_ERROR_INVALID_PARAMETER;
3298 pc->display_handle = (intptr_t)set_display_handle;
3300 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3303 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3304 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3306 msg = muse_core_msg_new(api,
3307 MUSE_TYPE_INT, "type", type,
3308 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3311 LOGE("msg creation failed: api %d", api);
3312 return CAMERA_ERROR_OUT_OF_MEMORY;
3315 if (pc->cb_info->is_server_connected) {
3316 __camera_update_api_waiting(pc->cb_info, api, 1);
3318 g_mutex_lock(&pc->cb_info->fd_lock);
3319 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3320 g_mutex_unlock(&pc->cb_info->fd_lock);
3324 LOGE("message send failed");
3325 ret = CAMERA_ERROR_INVALID_OPERATION;
3327 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3330 __camera_update_api_waiting(pc->cb_info, api, -1);
3332 muse_core_msg_free(msg);
3334 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3335 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3336 pc->wl_info.window_width, pc->wl_info.window_height);
3338 CAMERA_MSG_PARAM_SET(param, INT, type);
3340 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3343 if (ret != CAMERA_ERROR_NONE)
3344 LOGE("set display error 0x%x", ret);
3345 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3346 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3352 int camera_set_preview_resolution(camera_h camera, int width, int height)
3354 int ret = CAMERA_ERROR_NONE;
3355 camera_state_e current_state = CAMERA_STATE_NONE;
3356 camera_cli_s *pc = (camera_cli_s *)camera;
3357 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3358 camera_msg_param param;
3361 if (!pc || !pc->cb_info) {
3362 LOGE("NULL handle");
3363 return CAMERA_ERROR_INVALID_PARAMETER;
3366 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3367 ret = camera_get_state(camera, ¤t_state);
3368 if (ret != CAMERA_ERROR_NONE) {
3369 LOGE("failed to get current state 0x%x", ret);
3373 if (current_state == CAMERA_STATE_PREVIEW) {
3374 ret = _camera_stop_evas_rendering(camera, true);
3375 if (ret != CAMERA_ERROR_NONE)
3380 value = (width << 16) | height;
3381 CAMERA_MSG_PARAM_SET(param, INT, value);
3383 LOGD("%dx%d -> 0x%x", width, height, value);
3385 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3387 LOGD("ret : 0x%x", ret);
3389 if (current_state == CAMERA_STATE_PREVIEW) {
3390 LOGW("restart evas rendering");
3391 _camera_start_evas_rendering(camera);
3398 int camera_set_capture_resolution(camera_h camera, int width, int height)
3400 int ret = CAMERA_ERROR_NONE;
3401 camera_cli_s *pc = (camera_cli_s *)camera;
3402 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3403 camera_msg_param param;
3406 if (!pc || !pc->cb_info) {
3407 LOGE("NULL handle");
3408 return CAMERA_ERROR_INVALID_PARAMETER;
3413 value = (width << 16) | height;
3414 CAMERA_MSG_PARAM_SET(param, INT, value);
3416 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3418 LOGD("ret : 0x%x", ret);
3424 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3426 int ret = CAMERA_ERROR_NONE;
3427 int set_format = (int)format;
3428 camera_cli_s *pc = (camera_cli_s *)camera;
3429 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3430 camera_msg_param param;
3432 if (!pc || !pc->cb_info) {
3433 LOGE("NULL handle");
3434 return CAMERA_ERROR_INVALID_PARAMETER;
3437 LOGD("Enter - format %d", set_format);
3439 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3441 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3443 LOGD("ret : 0x%x", ret);
3449 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3451 int ret = CAMERA_ERROR_NONE;
3452 int set_format = (int)format;
3453 camera_msg_param param;
3454 camera_cli_s *pc = (camera_cli_s *)camera;
3455 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3457 if (!pc || !pc->cb_info) {
3458 LOGE("NULL handle");
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 LOGD("Enter - capture_format %d", set_format);
3464 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3468 LOGD("ret : 0x%x", ret);
3474 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3476 int ret = CAMERA_ERROR_NONE;
3477 camera_cli_s *pc = (camera_cli_s *)camera;
3478 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3480 if (!pc || !pc->cb_info || !width || !height) {
3481 LOGE("NULL pointer %p %p %p", pc, width, height);
3482 return CAMERA_ERROR_INVALID_PARAMETER;
3487 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3489 if (ret == CAMERA_ERROR_NONE) {
3490 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3491 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3494 LOGD("ret : 0x%x", ret);
3500 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3502 int ret = CAMERA_ERROR_NONE;
3503 int set_rotation = (int)rotation;
3504 camera_cli_s *pc = (camera_cli_s *)camera;
3505 camera_msg_param param;
3507 if (!pc || !pc->cb_info) {
3508 LOGE("NULL handle");
3509 return CAMERA_ERROR_INVALID_PARAMETER;
3512 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3513 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3514 g_mutex_lock(&pc->cb_info->evas_mutex);
3516 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3518 g_mutex_unlock(&pc->cb_info->evas_mutex);
3520 if (ret != MM_ERROR_NONE) {
3521 LOGE("failed to set rotation for evas surface 0x%x", ret);
3522 return CAMERA_ERROR_INVALID_OPERATION;
3525 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3527 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3529 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3535 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3537 int ret = CAMERA_ERROR_NONE;
3538 camera_cli_s *pc = (camera_cli_s *)camera;
3540 if (!pc || !pc->cb_info || !rotation) {
3541 LOGE("NULL pointer %p %p", pc, rotation);
3542 return CAMERA_ERROR_INVALID_PARAMETER;
3545 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3547 if (ret == CAMERA_ERROR_NONE)
3548 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3554 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3556 int ret = CAMERA_ERROR_NONE;
3557 int set_flip = (int)flip;
3558 camera_cli_s *pc = (camera_cli_s *)camera;
3559 camera_msg_param param;
3561 if (!pc || !pc->cb_info) {
3562 LOGE("NULL handle");
3563 return CAMERA_ERROR_INVALID_PARAMETER;
3566 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3567 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3568 g_mutex_lock(&pc->cb_info->evas_mutex);
3570 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3572 g_mutex_unlock(&pc->cb_info->evas_mutex);
3574 if (ret != MM_ERROR_NONE) {
3575 LOGE("failed to set flip for evas surface 0x%x", ret);
3576 return CAMERA_ERROR_INVALID_OPERATION;
3579 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3581 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3583 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3589 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3591 int ret = CAMERA_ERROR_NONE;
3592 camera_cli_s *pc = (camera_cli_s *)camera;
3594 if (!pc || !pc->cb_info || !flip) {
3595 LOGE("NULL pointer %p %p", pc, flip);
3596 return CAMERA_ERROR_INVALID_PARAMETER;
3599 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3601 if (ret == CAMERA_ERROR_NONE)
3602 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3608 int camera_set_display_visible(camera_h camera, bool visible)
3610 int ret = CAMERA_ERROR_NONE;
3611 int set_visible = (int)visible;
3612 camera_cli_s *pc = (camera_cli_s *)camera;
3613 camera_msg_param param;
3615 if (!pc || !pc->cb_info) {
3616 LOGE("NULL handle");
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3620 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3621 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3622 g_mutex_lock(&pc->cb_info->evas_mutex);
3624 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3626 g_mutex_unlock(&pc->cb_info->evas_mutex);
3628 if (ret != MM_ERROR_NONE) {
3629 LOGE("failed to set visible for evas surface 0x%x", ret);
3630 return CAMERA_ERROR_INVALID_OPERATION;
3633 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3635 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3637 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3643 int camera_is_display_visible(camera_h camera, bool *visible)
3645 int ret = CAMERA_ERROR_NONE;
3646 camera_cli_s *pc = (camera_cli_s *)camera;
3648 if (!pc || !pc->cb_info || !visible) {
3649 LOGE("NULL pointer %p %p", pc, visible);
3650 return CAMERA_ERROR_INVALID_PARAMETER;
3653 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3655 if (ret == CAMERA_ERROR_NONE)
3656 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3662 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3664 int ret = CAMERA_ERROR_NONE;
3665 int set_mode = (int)mode;
3666 camera_cli_s *pc = (camera_cli_s *)camera;
3667 camera_msg_param param;
3669 if (!pc || !pc->cb_info) {
3670 LOGE("NULL handle");
3671 return CAMERA_ERROR_INVALID_PARAMETER;
3674 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3675 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3676 g_mutex_lock(&pc->cb_info->evas_mutex);
3678 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3680 g_mutex_unlock(&pc->cb_info->evas_mutex);
3682 if (ret != MM_ERROR_NONE) {
3683 LOGE("failed to set geometry for evas surface 0x%x", ret);
3684 return CAMERA_ERROR_INVALID_OPERATION;
3687 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3689 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3691 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3697 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3699 int ret = CAMERA_ERROR_NONE;
3700 camera_cli_s *pc = (camera_cli_s *)camera;
3702 if (!pc || !pc->cb_info || !mode) {
3703 LOGE("NULL pointer %p %p", pc, mode);
3704 return CAMERA_ERROR_INVALID_PARAMETER;
3707 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3709 if (ret == CAMERA_ERROR_NONE)
3710 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3716 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3718 int ret = CAMERA_ERROR_NONE;
3719 int set_hint = (int)hint;
3720 camera_cli_s *pc = (camera_cli_s *)camera;
3721 camera_msg_param param;
3723 if (!pc || !pc->cb_info) {
3724 LOGE("NULL handle");
3725 return CAMERA_ERROR_INVALID_PARAMETER;
3728 LOGD("Enter - hint %d", set_hint);
3730 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3732 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3738 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3740 int ret = CAMERA_ERROR_NONE;
3741 camera_cli_s *pc = (camera_cli_s *)camera;
3742 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3744 if (!pc || !pc->cb_info || !hint) {
3745 LOGE("NULL pointer %p %p", pc, hint);
3746 return CAMERA_ERROR_INVALID_PARAMETER;
3749 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3751 if (ret == CAMERA_ERROR_NONE) {
3752 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3753 LOGD("display reuse hint %d", *hint);
3760 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3762 int ret = CAMERA_ERROR_NONE;
3763 camera_cli_s *pc = (camera_cli_s *)camera;
3764 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3766 if (!pc || !pc->cb_info || !width || !height) {
3767 LOGE("NULL pointer %p %p %p", pc, width, height);
3768 return CAMERA_ERROR_INVALID_PARAMETER;
3773 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3775 if (ret == CAMERA_ERROR_NONE) {
3776 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3777 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3780 LOGD("ret : 0x%x", ret);
3786 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3788 int ret = CAMERA_ERROR_NONE;
3789 camera_cli_s *pc = (camera_cli_s *)camera;
3790 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3792 if (!pc || !pc->cb_info || !format) {
3793 LOGE("NULL pointer %p %p", pc, format);
3794 return CAMERA_ERROR_INVALID_PARAMETER;
3799 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3801 if (ret == CAMERA_ERROR_NONE)
3802 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3804 LOGD("ret : 0x%x", ret);
3810 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3812 int ret = CAMERA_ERROR_NONE;
3813 camera_cli_s *pc = (camera_cli_s *)camera;
3814 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3816 if (!pc || !pc->cb_info || !format) {
3817 LOGE("NULL pointer %p %p", pc, format);
3818 return CAMERA_ERROR_INVALID_PARAMETER;
3823 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3825 if (ret == CAMERA_ERROR_NONE)
3826 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3828 LOGD("ret : 0x%x", ret);
3834 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3836 int ret = CAMERA_ERROR_NONE;
3837 camera_cli_s *pc = (camera_cli_s *)camera;
3838 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3840 if (!pc || !pc->cb_info || !facing_direction) {
3841 LOGE("NULL pointer %p %p", pc, facing_direction);
3842 return CAMERA_ERROR_INVALID_PARAMETER;
3847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3849 if (ret == CAMERA_ERROR_NONE)
3850 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3852 LOGD("ret : 0x%x", ret);
3858 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3860 int ret = CAMERA_ERROR_NONE;
3861 camera_cli_s *pc = (camera_cli_s *)camera;
3862 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3864 if (!pc || !pc->cb_info || !callback) {
3865 LOGE("NULL pointer %p %p", pc, callback);
3866 return CAMERA_ERROR_INVALID_PARAMETER;
3871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3873 if (ret == CAMERA_ERROR_NONE) {
3874 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3876 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3877 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3879 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3881 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3884 LOGD("ret : 0x%x", ret);
3890 int camera_unset_preview_cb(camera_h camera)
3892 int ret = CAMERA_ERROR_NONE;
3893 camera_cli_s *pc = (camera_cli_s *)camera;
3894 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3896 if (!pc || !pc->cb_info) {
3897 LOGE("NULL handle");
3898 return CAMERA_ERROR_INVALID_PARAMETER;
3903 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3905 if (ret == CAMERA_ERROR_NONE) {
3906 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3911 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3913 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3916 LOGD("ret : 0x%x", ret);
3922 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3928 if (!pc || !pc->cb_info) {
3929 LOGE("NULL handle");
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3933 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3934 LOGE("NOT SUPPORTED");
3935 return CAMERA_ERROR_NOT_SUPPORTED;
3938 if (callback == NULL) {
3939 LOGE("NULL callback");
3940 return CAMERA_ERROR_INVALID_PARAMETER;
3945 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3947 if (ret == CAMERA_ERROR_NONE) {
3948 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3950 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3951 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3953 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3956 LOGD("ret : 0x%x", ret);
3962 int camera_unset_media_packet_preview_cb(camera_h camera)
3964 int ret = CAMERA_ERROR_NONE;
3965 camera_cli_s *pc = (camera_cli_s *)camera;
3966 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3968 if (!pc || !pc->cb_info) {
3969 LOGE("NULL handle");
3970 return CAMERA_ERROR_INVALID_PARAMETER;
3975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3977 if (ret == CAMERA_ERROR_NONE) {
3978 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3980 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3981 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3983 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3986 LOGD("ret : 0x%x", ret);
3992 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3994 int ret = CAMERA_ERROR_NONE;
3995 camera_cli_s *pc = (camera_cli_s *)camera;
3996 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3998 if (!pc || !pc->cb_info || !callback) {
3999 LOGE("NULL pointer %p %p", pc, callback);
4000 return CAMERA_ERROR_INVALID_PARAMETER;
4005 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4007 if (ret == CAMERA_ERROR_NONE) {
4008 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4010 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
4011 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
4013 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4016 LOGD("ret : 0x%x", ret);
4022 int camera_unset_state_changed_cb(camera_h camera)
4024 int ret = CAMERA_ERROR_NONE;
4025 camera_cli_s *pc = (camera_cli_s *)camera;
4026 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
4028 if (!pc || !pc->cb_info) {
4029 LOGE("NULL handle");
4030 return CAMERA_ERROR_INVALID_PARAMETER;
4035 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4037 if (ret == CAMERA_ERROR_NONE) {
4038 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4040 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4041 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4043 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4046 LOGD("ret : 0x%x", ret);
4052 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4054 int ret = CAMERA_ERROR_NONE;
4055 camera_cli_s *pc = (camera_cli_s *)camera;
4056 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4058 if (!pc || !pc->cb_info || !callback) {
4059 LOGE("NULL pointer %p %p", pc, callback);
4060 return CAMERA_ERROR_INVALID_PARAMETER;
4065 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4067 if (ret == CAMERA_ERROR_NONE) {
4068 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4070 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4071 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4073 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4076 LOGD("ret : 0x%x", ret);
4082 int camera_unset_interrupted_cb(camera_h camera)
4084 int ret = CAMERA_ERROR_NONE;
4085 camera_cli_s *pc = (camera_cli_s *)camera;
4086 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4088 if (!pc || !pc->cb_info) {
4089 LOGE("NULL handle");
4090 return CAMERA_ERROR_INVALID_PARAMETER;
4095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4097 if (ret == CAMERA_ERROR_NONE) {
4098 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4100 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4101 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4103 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4106 LOGD("ret : 0x%x", ret);
4112 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4114 int ret = CAMERA_ERROR_NONE;
4115 camera_cli_s *pc = (camera_cli_s *)camera;
4116 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4118 if (!pc || !pc->cb_info || !callback) {
4119 LOGE("NULL pointer %p %p", pc, callback);
4120 return CAMERA_ERROR_INVALID_PARAMETER;
4125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4127 if (ret == CAMERA_ERROR_NONE) {
4128 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4130 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4131 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4133 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4136 LOGD("ret : 0x%x", ret);
4142 int camera_unset_interrupt_started_cb(camera_h camera)
4144 int ret = CAMERA_ERROR_NONE;
4145 camera_cli_s *pc = (camera_cli_s *)camera;
4146 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4148 if (!pc || !pc->cb_info) {
4149 LOGE("NULL handle");
4150 return CAMERA_ERROR_INVALID_PARAMETER;
4155 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4157 if (ret == CAMERA_ERROR_NONE) {
4158 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4160 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4161 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4163 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4166 LOGD("ret : 0x%x", ret);
4172 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4174 int ret = CAMERA_ERROR_NONE;
4175 camera_cli_s *pc = (camera_cli_s *)camera;
4176 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4178 if (!pc || !pc->cb_info || !callback) {
4179 LOGE("NULL pointer %p %p", pc, callback);
4180 return CAMERA_ERROR_INVALID_PARAMETER;
4185 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4187 if (ret == CAMERA_ERROR_NONE) {
4188 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4190 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4191 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4193 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4196 LOGD("ret : 0x%x", ret);
4202 int camera_unset_focus_changed_cb(camera_h camera)
4204 int ret = CAMERA_ERROR_NONE;
4205 camera_cli_s *pc = (camera_cli_s *)camera;
4206 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4208 if (!pc || !pc->cb_info) {
4209 LOGE("NULL handle");
4210 return CAMERA_ERROR_INVALID_PARAMETER;
4215 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4217 if (ret == CAMERA_ERROR_NONE) {
4218 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4220 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4221 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4223 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4226 LOGD("ret : 0x%x", ret);
4232 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4234 int ret = CAMERA_ERROR_NONE;
4235 camera_cli_s *pc = (camera_cli_s *)camera;
4236 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4238 if (!pc || !pc->cb_info || !callback) {
4239 LOGE("NULL pointer %p %p", pc, callback);
4240 return CAMERA_ERROR_INVALID_PARAMETER;
4245 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4247 if (ret == CAMERA_ERROR_NONE) {
4248 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4250 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4251 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4253 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4256 LOGD("ret : 0x%x", ret);
4262 int camera_unset_error_cb(camera_h camera)
4264 int ret = CAMERA_ERROR_NONE;
4265 camera_cli_s *pc = (camera_cli_s *)camera;
4266 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4268 if (!pc || !pc->cb_info) {
4269 LOGE("NULL handle");
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4277 if (ret == CAMERA_ERROR_NONE) {
4278 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4280 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4281 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4283 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4286 LOGD("ret : 0x%x", ret);
4292 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4294 int ret = CAMERA_ERROR_NONE;
4295 camera_cli_s *pc = (camera_cli_s *)camera;
4296 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4298 if (!pc || !pc->cb_info || !foreach_cb) {
4299 LOGE("NULL pointer %p %p", pc, foreach_cb);
4300 return CAMERA_ERROR_INVALID_PARAMETER;
4305 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4306 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4308 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4310 LOGD("ret : 0x%x", ret);
4316 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4318 int ret = CAMERA_ERROR_NONE;
4319 camera_cli_s *pc = (camera_cli_s *)camera;
4320 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4322 if (!pc || !pc->cb_info || !foreach_cb) {
4323 LOGE("NULL pointer %p %p", pc, foreach_cb);
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4329 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4330 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4332 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4334 LOGD("ret : 0x%x", ret);
4340 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4342 int ret = CAMERA_ERROR_NONE;
4343 camera_cli_s *pc = (camera_cli_s *)camera;
4344 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4346 if (!pc || !pc->cb_info || !foreach_cb) {
4347 LOGE("NULL pointer %p %p", pc, foreach_cb);
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4353 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4354 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4356 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4358 LOGD("ret : 0x%x", ret);
4364 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4366 int ret = CAMERA_ERROR_NONE;
4367 camera_cli_s *pc = (camera_cli_s *)camera;
4368 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4370 if (!pc || !pc->cb_info || !foreach_cb) {
4371 LOGE("NULL pointer %p %p", pc, foreach_cb);
4372 return CAMERA_ERROR_INVALID_PARAMETER;
4377 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4378 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4382 LOGD("ret : 0x%x", ret);
4388 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4390 int ret = CAMERA_ERROR_NONE;
4391 camera_cli_s *pc = (camera_cli_s *)camera;
4392 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4394 if (!pc || !pc->cb_info || !width || !height) {
4395 LOGE("NULL pointer %p %p %p", pc, width, height);
4396 return CAMERA_ERROR_INVALID_PARAMETER;
4400 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4402 if (ret == CAMERA_ERROR_NONE) {
4403 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4404 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4407 LOGD("ret : 0x%x", ret);
4413 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4415 int ret = CAMERA_ERROR_NONE;
4416 camera_cli_s *pc = (camera_cli_s *)camera;
4417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4419 if (!pc || !pc->cb_info || !angle) {
4420 LOGE("NULL pointer %p %p", pc, angle);
4421 return CAMERA_ERROR_INVALID_PARAMETER;
4426 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4428 if (ret == CAMERA_ERROR_NONE)
4429 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4431 LOGD("ret : 0x%x", ret);
4437 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4439 int ret = CAMERA_ERROR_NONE;
4440 camera_cli_s *pc = (camera_cli_s *)camera;
4441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4442 camera_msg_param param;
4443 int set_mode = (int)mode;
4445 if (!pc || !pc->cb_info) {
4446 LOGE("NULL handle");
4447 return CAMERA_ERROR_INVALID_PARAMETER;
4452 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4454 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4456 LOGD("ret : 0x%x", ret);
4462 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4464 int ret = CAMERA_ERROR_NONE;
4465 camera_cli_s *pc = (camera_cli_s *)camera;
4466 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4468 if (!pc || !pc->cb_info || !mode) {
4469 LOGE("NULL pointer %p %p", pc, mode);
4470 return CAMERA_ERROR_INVALID_PARAMETER;
4475 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4477 if (ret == CAMERA_ERROR_NONE)
4478 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4480 LOGD("ret : 0x%x", ret);
4486 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4488 int ret = CAMERA_ERROR_NONE;
4489 camera_cli_s *pc = (camera_cli_s *)camera;
4490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4492 if (!pc || !pc->cb_info || !foreach_cb) {
4493 LOGE("NULL pointer %p %p", pc, foreach_cb);
4494 return CAMERA_ERROR_INVALID_PARAMETER;
4499 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4500 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4502 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4504 LOGD("Finish, return :%x", ret);
4510 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4512 int ret = CAMERA_ERROR_NONE;
4513 camera_cli_s *pc = (camera_cli_s *)camera;
4514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4515 camera_msg_param param;
4516 int set_fps = (int)fps;
4518 if (!pc || !pc->cb_info) {
4519 LOGE("NULL handle");
4520 return CAMERA_ERROR_INVALID_PARAMETER;
4525 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4527 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4529 LOGD("ret : 0x%x", ret);
4535 int camera_attr_set_image_quality(camera_h camera, int quality)
4537 int ret = CAMERA_ERROR_NONE;
4538 camera_cli_s *pc = (camera_cli_s *)camera;
4539 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4540 camera_msg_param param;
4542 if (!pc || !pc->cb_info) {
4543 LOGE("NULL handle");
4544 return CAMERA_ERROR_INVALID_PARAMETER;
4549 CAMERA_MSG_PARAM_SET(param, INT, quality);
4551 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4553 LOGD("ret : 0x%x", ret);
4559 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4561 int ret = CAMERA_ERROR_NONE;
4562 camera_cli_s *pc = (camera_cli_s *)camera;
4563 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4565 if (!pc || !pc->cb_info || !fps) {
4566 LOGE("NULL pointer %p %p", pc, fps);
4567 return CAMERA_ERROR_INVALID_PARAMETER;
4572 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4574 if (ret == CAMERA_ERROR_NONE)
4575 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4577 LOGD("ret : 0x%x", ret);
4583 int camera_attr_get_image_quality(camera_h camera, int *quality)
4585 int ret = CAMERA_ERROR_NONE;
4586 camera_cli_s *pc = (camera_cli_s *)camera;
4587 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4589 if (!pc || !pc->cb_info || !quality) {
4590 LOGE("NULL pointer %p %p", pc, quality);
4591 return CAMERA_ERROR_INVALID_PARAMETER;
4596 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4598 if (ret == CAMERA_ERROR_NONE)
4599 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4601 LOGD("ret : 0x%x", ret);
4607 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4609 int ret = CAMERA_ERROR_NONE;
4610 camera_cli_s *pc = (camera_cli_s *)camera;
4611 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4613 if (!pc || !pc->cb_info || !bitrate) {
4614 LOGE("NULL pointer %p %p", pc, bitrate);
4615 return CAMERA_ERROR_INVALID_PARAMETER;
4620 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4622 if (ret == CAMERA_ERROR_NONE)
4623 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4625 LOGD("ret : 0x%x", ret);
4631 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4633 int ret = CAMERA_ERROR_NONE;
4634 camera_cli_s *pc = (camera_cli_s *)camera;
4635 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4636 camera_msg_param param;
4637 int set_bitrate = bitrate;
4639 if (!pc || !pc->cb_info) {
4640 LOGE("NULL handle");
4641 return CAMERA_ERROR_INVALID_PARAMETER;
4646 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4648 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4650 LOGD("ret : 0x%x", ret);
4656 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4658 int ret = CAMERA_ERROR_NONE;
4659 camera_cli_s *pc = (camera_cli_s *)camera;
4660 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4662 if (!pc || !pc->cb_info || !interval) {
4663 LOGE("NULL pointer %p %p", pc, interval);
4664 return CAMERA_ERROR_INVALID_PARAMETER;
4669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4671 if (ret == CAMERA_ERROR_NONE)
4672 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4674 LOGD("ret : 0x%x", ret);
4680 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
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_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4685 camera_msg_param param;
4686 int set_gop_interval = interval;
4688 if (!pc || !pc->cb_info) {
4689 LOGE("NULL handle");
4690 return CAMERA_ERROR_INVALID_PARAMETER;
4695 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4697 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4699 LOGD("ret : 0x%x", ret);
4705 int camera_attr_set_zoom(camera_h camera, int zoom)
4707 int ret = CAMERA_ERROR_NONE;
4708 camera_cli_s *pc = (camera_cli_s *)camera;
4709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4710 camera_msg_param param;
4712 if (!pc || !pc->cb_info) {
4713 LOGE("NULL handle");
4714 return CAMERA_ERROR_INVALID_PARAMETER;
4717 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4719 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4723 LOGD("ret : 0x%x", ret);
4729 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4731 int ret = CAMERA_ERROR_NONE;
4732 camera_cli_s *pc = (camera_cli_s *)camera;
4733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4734 camera_msg_param param;
4735 int set_mode = (int)mode;
4737 if (!pc || !pc->cb_info) {
4738 LOGE("NULL handle");
4739 return CAMERA_ERROR_INVALID_PARAMETER;
4742 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4744 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4746 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4752 int camera_attr_set_af_area(camera_h camera, int x, int y)
4754 int ret = CAMERA_ERROR_NONE;
4755 camera_cli_s *pc = (camera_cli_s *)camera;
4756 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4757 camera_msg_param param;
4760 if (!pc || !pc->cb_info) {
4761 LOGE("NULL handle");
4762 return CAMERA_ERROR_INVALID_PARAMETER;
4765 LOGD("Enter - %d,%d", x, y);
4767 value = (x << 16) | y;
4768 CAMERA_MSG_PARAM_SET(param, INT, value);
4770 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4772 LOGD("ret : 0x%x", ret);
4778 int camera_attr_clear_af_area(camera_h camera)
4780 int ret = CAMERA_ERROR_NONE;
4781 camera_cli_s *pc = (camera_cli_s *)camera;
4782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4784 if (!pc || !pc->cb_info) {
4785 LOGE("NULL handle");
4786 return CAMERA_ERROR_INVALID_PARAMETER;
4791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4793 LOGD("ret : 0x%x", ret);
4799 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4801 int ret = CAMERA_ERROR_NONE;
4802 camera_cli_s *pc = (camera_cli_s *)camera;
4803 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4804 camera_msg_param param;
4805 int set_mode = (int)mode;
4807 if (!pc || !pc->cb_info) {
4808 LOGE("NULL handle");
4809 return CAMERA_ERROR_INVALID_PARAMETER;
4814 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4816 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4818 LOGD("ret : 0x%x", ret);
4824 int camera_attr_set_exposure(camera_h camera, int value)
4826 int ret = CAMERA_ERROR_NONE;
4827 camera_cli_s *pc = (camera_cli_s *)camera;
4828 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4829 camera_msg_param param;
4831 if (!pc || !pc->cb_info) {
4832 LOGE("NULL handle");
4833 return CAMERA_ERROR_INVALID_PARAMETER;
4838 CAMERA_MSG_PARAM_SET(param, INT, value);
4840 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4842 LOGD("ret : 0x%x", ret);
4848 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4850 int ret = CAMERA_ERROR_NONE;
4851 camera_cli_s *pc = (camera_cli_s *)camera;
4852 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4853 camera_msg_param param;
4854 int set_iso = (int)iso;
4856 if (!pc || !pc->cb_info) {
4857 LOGE("NULL handle");
4858 return CAMERA_ERROR_INVALID_PARAMETER;
4863 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4865 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4867 LOGD("ret : 0x%x", ret);
4873 int camera_attr_set_brightness(camera_h camera, int level)
4875 int ret = CAMERA_ERROR_NONE;
4876 camera_cli_s *pc = (camera_cli_s *)camera;
4877 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4878 camera_msg_param param;
4880 if (!pc || !pc->cb_info) {
4881 LOGE("NULL handle");
4882 return CAMERA_ERROR_INVALID_PARAMETER;
4887 CAMERA_MSG_PARAM_SET(param, INT, level);
4889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4891 LOGD("ret : 0x%x", ret);
4897 int camera_attr_set_contrast(camera_h camera, int level)
4899 int ret = CAMERA_ERROR_NONE;
4900 camera_cli_s *pc = (camera_cli_s *)camera;
4901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4902 camera_msg_param param;
4904 if (!pc || !pc->cb_info) {
4905 LOGE("NULL handle");
4906 return CAMERA_ERROR_INVALID_PARAMETER;
4911 CAMERA_MSG_PARAM_SET(param, INT, level);
4913 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4915 LOGD("ret : 0x%x", ret);
4921 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4923 int ret = CAMERA_ERROR_NONE;
4924 camera_cli_s *pc = (camera_cli_s *)camera;
4925 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4926 camera_msg_param param;
4927 int set_whitebalance = (int)wb;
4929 if (!pc || !pc->cb_info) {
4930 LOGE("NULL handle");
4931 return CAMERA_ERROR_INVALID_PARAMETER;
4936 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4938 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4940 LOGD("ret : 0x%x", ret);
4946 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4948 int ret = CAMERA_ERROR_NONE;
4949 camera_cli_s *pc = (camera_cli_s *)camera;
4950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4951 camera_msg_param param;
4952 int set_effect = (int)effect;
4954 if (!pc || !pc->cb_info) {
4955 LOGE("NULL handle");
4956 return CAMERA_ERROR_INVALID_PARAMETER;
4961 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4963 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4965 LOGD("ret : 0x%x", ret);
4971 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4973 int ret = CAMERA_ERROR_NONE;
4974 camera_cli_s *pc = (camera_cli_s *)camera;
4975 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4976 camera_msg_param param;
4977 int set_mode = (int)mode;
4979 if (!pc || !pc->cb_info) {
4980 LOGE("NULL handle");
4981 return CAMERA_ERROR_INVALID_PARAMETER;
4986 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4988 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4990 LOGD("ret : 0x%x", ret);
4996 int camera_attr_enable_tag(camera_h camera, bool enable)
4998 int ret = CAMERA_ERROR_NONE;
4999 camera_cli_s *pc = (camera_cli_s *)camera;
5000 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
5001 camera_msg_param param;
5002 int set_enable = (int)enable;
5004 if (!pc || !pc->cb_info) {
5005 LOGE("NULL handle");
5006 return CAMERA_ERROR_INVALID_PARAMETER;
5011 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5013 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5015 LOGD("ret : 0x%x", ret);
5021 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
5023 int ret = CAMERA_ERROR_NONE;
5024 camera_cli_s *pc = (camera_cli_s *)camera;
5025 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
5026 camera_msg_param param;
5028 if (!pc || !pc->cb_info || !description) {
5029 LOGE("NULL pointer %p %p", pc, description);
5030 return CAMERA_ERROR_INVALID_PARAMETER;
5035 CAMERA_MSG_PARAM_SET(param, STRING, description);
5037 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5039 LOGD("ret : 0x%x", ret);
5045 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
5047 int ret = CAMERA_ERROR_NONE;
5048 camera_cli_s *pc = (camera_cli_s *)camera;
5049 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
5050 camera_msg_param param;
5051 int set_orientation = (int)orientation;
5053 if (!pc || !pc->cb_info) {
5054 LOGE("NULL handle");
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5060 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
5062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5064 LOGD("ret : 0x%x", ret);
5070 int camera_attr_set_tag_software(camera_h camera, const char *software)
5072 int ret = CAMERA_ERROR_NONE;
5073 camera_cli_s *pc = (camera_cli_s *)camera;
5074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
5075 camera_msg_param param;
5077 if (!pc || !pc->cb_info || !software) {
5078 LOGE("NULL pointer %p %p", pc, software);
5079 return CAMERA_ERROR_INVALID_PARAMETER;
5082 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5084 CAMERA_MSG_PARAM_SET(param, STRING, software);
5086 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5088 LOGD("ret : 0x%x", ret);
5094 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
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_SET_GEOTAG;
5099 double set_geotag[3] = {latitude, longitude, altitude};
5104 if (!pc || !pc->cb_info) {
5105 LOGE("NULL handle");
5106 return CAMERA_ERROR_INVALID_PARAMETER;
5111 length = sizeof(set_geotag) / sizeof(int) + \
5112 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5114 msg = muse_core_msg_new(api,
5115 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5118 LOGE("msg creation failed: api %d", api);
5119 return CAMERA_ERROR_OUT_OF_MEMORY;
5122 if (pc->cb_info->is_server_connected) {
5123 __camera_update_api_waiting(pc->cb_info, api, 1);
5125 g_mutex_lock(&pc->cb_info->fd_lock);
5126 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5127 g_mutex_unlock(&pc->cb_info->fd_lock);
5131 LOGE("message send failed");
5132 ret = CAMERA_ERROR_INVALID_OPERATION;
5134 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5137 __camera_update_api_waiting(pc->cb_info, api, -1);
5139 muse_core_msg_free(msg);
5141 LOGD("ret : 0x%x", ret);
5147 int camera_attr_remove_geotag(camera_h camera)
5149 int ret = CAMERA_ERROR_NONE;
5150 camera_cli_s *pc = (camera_cli_s *)camera;
5151 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5153 if (!pc || !pc->cb_info) {
5154 LOGE("NULL handle");
5155 return CAMERA_ERROR_INVALID_PARAMETER;
5160 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5162 LOGD("ret : 0x%x", ret);
5168 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5170 int ret = CAMERA_ERROR_NONE;
5171 camera_cli_s *pc = (camera_cli_s *)camera;
5172 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5173 camera_msg_param param;
5174 int set_mode = (int)mode;
5176 if (!pc || !pc->cb_info) {
5177 LOGE("NULL handle");
5178 return CAMERA_ERROR_INVALID_PARAMETER;
5183 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5185 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5187 LOGD("ret : 0x%x", ret);
5193 int camera_attr_get_zoom(camera_h camera, int *zoom)
5195 int ret = CAMERA_ERROR_NONE;
5196 camera_cli_s *pc = (camera_cli_s *)camera;
5197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5199 if (!pc || !pc->cb_info || !zoom) {
5200 LOGE("NULL pointer %p %p", pc, zoom);
5201 return CAMERA_ERROR_INVALID_PARAMETER;
5206 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5208 if (ret == CAMERA_ERROR_NONE)
5209 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5211 LOGD("ret : 0x%x", ret);
5217 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5219 int ret = CAMERA_ERROR_NONE;
5220 camera_cli_s *pc = (camera_cli_s *)camera;
5221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5223 if (!pc || !pc->cb_info || !min || !max) {
5224 LOGE("NULL pointer %p %p %p", pc, min, max);
5225 return CAMERA_ERROR_INVALID_PARAMETER;
5230 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5232 if (ret == CAMERA_ERROR_NONE) {
5233 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5234 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5237 LOGD("ret : 0x%x", ret);
5243 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5245 int ret = CAMERA_ERROR_NONE;
5246 camera_cli_s *pc = (camera_cli_s *)camera;
5247 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5249 if (!pc || !pc->cb_info || !mode) {
5250 LOGE("NULL pointer %p %p", pc, mode);
5251 return CAMERA_ERROR_INVALID_PARAMETER;
5256 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5258 if (ret == CAMERA_ERROR_NONE)
5259 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5261 LOGD("ret : 0x%x", ret);
5267 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5269 int ret = CAMERA_ERROR_NONE;
5270 camera_cli_s *pc = (camera_cli_s *)camera;
5271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5273 if (!pc || !pc->cb_info || !mode) {
5274 LOGE("NULL pointer %p %p", pc, mode);
5275 return CAMERA_ERROR_INVALID_PARAMETER;
5280 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5282 if (ret == CAMERA_ERROR_NONE)
5283 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5285 LOGD("ret : 0x%x", ret);
5291 int camera_attr_get_exposure(camera_h camera, int *value)
5293 int ret = CAMERA_ERROR_NONE;
5294 camera_cli_s *pc = (camera_cli_s *)camera;
5295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5297 if (!pc || !pc->cb_info || !value) {
5298 LOGE("NULL pointer %p %p", pc, value);
5299 return CAMERA_ERROR_INVALID_PARAMETER;
5304 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5306 if (ret == CAMERA_ERROR_NONE)
5307 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5317 int ret = CAMERA_ERROR_NONE;
5318 camera_cli_s *pc = (camera_cli_s *)camera;
5319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5321 if (!pc || !pc->cb_info || !min || !max) {
5322 LOGE("NULL pointer %p %p %p", pc, min, max);
5323 return CAMERA_ERROR_INVALID_PARAMETER;
5328 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5330 if (ret == CAMERA_ERROR_NONE) {
5331 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5332 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5335 LOGD("ret : 0x%x", ret);
5341 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5343 int ret = CAMERA_ERROR_NONE;
5344 camera_cli_s *pc = (camera_cli_s *)camera;
5345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5347 if (!pc || !pc->cb_info || !iso) {
5348 LOGE("NULL pointer %p %p", pc, iso);
5349 return CAMERA_ERROR_INVALID_PARAMETER;
5354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5356 if (ret == CAMERA_ERROR_NONE)
5357 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5359 LOGD("ret : 0x%x", ret);
5365 int camera_attr_get_brightness(camera_h camera, int *level)
5367 int ret = CAMERA_ERROR_NONE;
5368 camera_cli_s *pc = (camera_cli_s *)camera;
5369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5371 if (!pc || !pc->cb_info || !level) {
5372 LOGE("NULL pointer %p %p", pc, level);
5373 return CAMERA_ERROR_INVALID_PARAMETER;
5378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5380 if (ret == CAMERA_ERROR_NONE)
5381 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5383 LOGD("ret : 0x%x", ret);
5389 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5391 int ret = CAMERA_ERROR_NONE;
5392 camera_cli_s *pc = (camera_cli_s *)camera;
5393 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5395 if (!pc || !pc->cb_info || !min || !max) {
5396 LOGE("NULL pointer %p %p %p", pc, min, max);
5397 return CAMERA_ERROR_INVALID_PARAMETER;
5402 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5404 if (ret == CAMERA_ERROR_NONE) {
5405 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5406 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5409 LOGD("ret : 0x%x", ret);
5415 int camera_attr_get_contrast(camera_h camera, int *level)
5417 int ret = CAMERA_ERROR_NONE;
5418 camera_cli_s *pc = (camera_cli_s *)camera;
5419 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5421 if (!pc || !pc->cb_info || !level) {
5422 LOGE("NULL pointer %p %p", pc, level);
5423 return CAMERA_ERROR_INVALID_PARAMETER;
5428 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5430 if (ret == CAMERA_ERROR_NONE)
5431 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5433 LOGD("ret : 0x%x", ret);
5439 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5441 int ret = CAMERA_ERROR_NONE;
5442 camera_cli_s *pc = (camera_cli_s *)camera;
5443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5445 if (!pc || !pc->cb_info || !min || !max) {
5446 LOGE("NULL pointer %p %p %p", pc, min, max);
5447 return CAMERA_ERROR_INVALID_PARAMETER;
5452 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5454 if (ret == CAMERA_ERROR_NONE) {
5455 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5456 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5457 LOGD("min %d, max %d", *min, *max);
5460 LOGD("ret : 0x%x", ret);
5466 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5468 int ret = CAMERA_ERROR_NONE;
5469 camera_cli_s *pc = (camera_cli_s *)camera;
5470 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5472 if (!pc || !pc->cb_info || !wb) {
5473 LOGE("NULL pointer %p %p", pc, wb);
5474 return CAMERA_ERROR_INVALID_PARAMETER;
5479 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5481 if (ret == CAMERA_ERROR_NONE)
5482 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5484 LOGD("ret : 0x%x", ret);
5490 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5492 int ret = CAMERA_ERROR_NONE;
5493 camera_cli_s *pc = (camera_cli_s *)camera;
5494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5496 if (!pc || !pc->cb_info || !effect) {
5497 LOGE("NULL pointer %p %p", pc, effect);
5498 return CAMERA_ERROR_INVALID_PARAMETER;
5503 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5505 if (ret == CAMERA_ERROR_NONE)
5506 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5508 LOGD("ret : 0x%x", ret);
5514 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5516 int ret = CAMERA_ERROR_NONE;
5517 camera_cli_s *pc = (camera_cli_s *)camera;
5518 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5520 if (!pc || !pc->cb_info || !mode) {
5521 LOGE("NULL pointer %p %p", pc, mode);
5522 return CAMERA_ERROR_INVALID_PARAMETER;
5527 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5529 if (ret == CAMERA_ERROR_NONE)
5530 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5532 LOGD("ret : 0x%x", ret);
5538 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5540 int ret = CAMERA_ERROR_NONE;
5541 camera_cli_s *pc = (camera_cli_s *)camera;
5542 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5544 if (!pc || !pc->cb_info || !enable) {
5545 LOGE("NULL pointer %p %p", pc, enable);
5546 return CAMERA_ERROR_INVALID_PARAMETER;
5551 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5553 if (ret == CAMERA_ERROR_NONE)
5554 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5556 LOGD("ret : 0x%x", ret);
5562 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5564 int ret = CAMERA_ERROR_NONE;
5565 camera_cli_s *pc = (camera_cli_s *)camera;
5566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5568 if (!pc || !pc->cb_info || !description) {
5569 LOGE("NULL pointer %p %p", pc, description);
5570 return CAMERA_ERROR_INVALID_PARAMETER;
5575 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5577 if (ret == CAMERA_ERROR_NONE)
5578 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5580 LOGD("ret : 0x%x", ret);
5586 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5588 int ret = CAMERA_ERROR_NONE;
5589 camera_cli_s *pc = (camera_cli_s *)camera;
5590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5592 if (!pc || !pc->cb_info || !orientation) {
5593 LOGE("NULL pointer %p %p", pc, orientation);
5594 return CAMERA_ERROR_INVALID_PARAMETER;
5599 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5601 if (ret == CAMERA_ERROR_NONE)
5602 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5604 LOGD("ret : 0x%x", ret);
5610 int camera_attr_get_tag_software(camera_h camera, char **software)
5612 int ret = CAMERA_ERROR_NONE;
5613 camera_cli_s *pc = (camera_cli_s *)camera;
5614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5616 if (!pc || !pc->cb_info || !software) {
5617 LOGE("NULL pointer %p %p", pc, software);
5618 return CAMERA_ERROR_INVALID_PARAMETER;
5623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5625 if (ret == CAMERA_ERROR_NONE)
5626 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5628 LOGD("ret : 0x%x", ret);
5634 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5636 int ret = CAMERA_ERROR_NONE;
5637 camera_cli_s *pc = (camera_cli_s *)camera;
5638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5640 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5641 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5642 return CAMERA_ERROR_INVALID_PARAMETER;
5647 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5649 if (ret == CAMERA_ERROR_NONE) {
5650 *latitude = pc->cb_info->get_geotag[0];
5651 *longitude = pc->cb_info->get_geotag[1];
5652 *altitude = pc->cb_info->get_geotag[2];
5655 LOGD("ret : 0x%x", ret);
5661 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5663 int ret = CAMERA_ERROR_NONE;
5664 camera_cli_s *pc = (camera_cli_s *)camera;
5665 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5667 if (!pc || !pc->cb_info || !mode) {
5668 LOGE("NULL pointer %p %p", pc, mode);
5669 return CAMERA_ERROR_INVALID_PARAMETER;
5674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5676 if (ret == CAMERA_ERROR_NONE)
5677 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5679 LOGD("ret : 0x%x", ret);
5685 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5687 int ret = CAMERA_ERROR_NONE;
5688 int get_flash_state = 0;
5691 LOGE("NULL pointer");
5692 return CAMERA_ERROR_INVALID_PARAMETER;
5695 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5696 (int)device, "get_flash_state", &get_flash_state);
5698 if (ret == CAMERA_ERROR_NONE) {
5699 *state = (camera_flash_state_e)get_flash_state;
5700 LOGD("flash state %d", *state);
5702 LOGE("failed 0x%x", ret);
5709 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5711 int ret = CAMERA_ERROR_NONE;
5712 camera_cli_s *pc = (camera_cli_s *)camera;
5713 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5715 if (!pc || !pc->cb_info || !foreach_cb) {
5716 LOGE("NULL pointer %p %p", pc, foreach_cb);
5717 return CAMERA_ERROR_INVALID_PARAMETER;
5722 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5723 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5725 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5727 LOGD("ret : 0x%x", ret);
5733 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5735 int ret = CAMERA_ERROR_NONE;
5736 camera_cli_s *pc = (camera_cli_s *)camera;
5737 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5739 if (!pc || !pc->cb_info || !foreach_cb) {
5740 LOGE("NULL pointer %p %p", pc, foreach_cb);
5741 return CAMERA_ERROR_INVALID_PARAMETER;
5746 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5747 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5749 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5751 LOGD("ret : 0x%x", ret);
5757 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5759 int ret = CAMERA_ERROR_NONE;
5760 camera_cli_s *pc = (camera_cli_s *)camera;
5761 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5763 if (!pc || !pc->cb_info || !foreach_cb) {
5764 LOGE("NULL pointer %p %p", pc, foreach_cb);
5765 return CAMERA_ERROR_INVALID_PARAMETER;
5770 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5771 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5773 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5775 LOGD("ret : 0x%x", ret);
5781 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5783 int ret = CAMERA_ERROR_NONE;
5784 camera_cli_s *pc = (camera_cli_s *)camera;
5785 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5787 if (!pc || !pc->cb_info || !foreach_cb) {
5788 LOGE("NULL pointer %p %p", pc, foreach_cb);
5789 return CAMERA_ERROR_INVALID_PARAMETER;
5794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5799 LOGD("ret : 0x%x", ret);
5805 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5807 int ret = CAMERA_ERROR_NONE;
5808 camera_cli_s *pc = (camera_cli_s *)camera;
5809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5811 if (!pc || !pc->cb_info || !foreach_cb) {
5812 LOGE("NULL pointer %p %p", pc, foreach_cb);
5813 return CAMERA_ERROR_INVALID_PARAMETER;
5818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5821 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5823 LOGD("ret : 0x%x", ret);
5829 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5831 int ret = CAMERA_ERROR_NONE;
5832 camera_cli_s *pc = (camera_cli_s *)camera;
5833 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5835 if (!pc || !pc->cb_info || !foreach_cb) {
5836 LOGE("NULL pointer %p %p", pc, foreach_cb);
5837 return CAMERA_ERROR_INVALID_PARAMETER;
5842 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5843 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5847 LOGD("ret : 0x%x", ret);
5853 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5855 int ret = CAMERA_ERROR_NONE;
5856 camera_cli_s *pc = (camera_cli_s *)camera;
5857 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5859 if (!pc || !pc->cb_info || !foreach_cb) {
5860 LOGE("NULL pointer %p %p", pc, foreach_cb);
5861 return CAMERA_ERROR_INVALID_PARAMETER;
5866 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5867 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5869 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5871 LOGD("ret : 0x%x", ret);
5877 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5879 int ret = CAMERA_ERROR_NONE;
5880 camera_cli_s *pc = (camera_cli_s *)camera;
5881 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5883 if (!pc || !pc->cb_info || !foreach_cb) {
5884 LOGE("NULL pointer %p %p", pc, foreach_cb);
5885 return CAMERA_ERROR_INVALID_PARAMETER;
5890 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5891 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5895 LOGD("Enter, handle :%x", pc->remote_handle);
5901 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)
5903 int ret = CAMERA_ERROR_NONE;
5904 camera_cli_s *pc = (camera_cli_s *)camera;
5905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5906 camera_msg_param param;
5909 if (!pc || !pc->cb_info || !foreach_cb) {
5910 LOGE("NULL pointer %p %p", pc, foreach_cb);
5911 return CAMERA_ERROR_INVALID_PARAMETER;
5916 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5917 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5919 value = (width << 16) | height;
5920 CAMERA_MSG_PARAM_SET(param, INT, value);
5922 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5924 LOGD("ret : 0x%x", ret);
5930 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5932 int ret = CAMERA_ERROR_NONE;
5933 camera_cli_s *pc = (camera_cli_s *)camera;
5934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5936 if (!pc || !pc->cb_info || !foreach_cb) {
5937 LOGE("NULL pointer %p %p", pc, foreach_cb);
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5943 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5944 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5948 LOGD("ret : 0x%x", ret);
5954 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5956 int ret = CAMERA_ERROR_NONE;
5957 camera_cli_s *pc = (camera_cli_s *)camera;
5958 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5960 if (!pc || !pc->cb_info || !foreach_cb) {
5961 LOGE("NULL pointer %p %p", pc, foreach_cb);
5962 return CAMERA_ERROR_INVALID_PARAMETER;
5967 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5968 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5972 LOGD("ret : 0x%x", ret);
5978 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5980 int ret = CAMERA_ERROR_NONE;
5981 camera_cli_s *pc = (camera_cli_s *)camera;
5982 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5983 camera_msg_param param;
5984 int set_rotation = (int)rotation;
5986 if (!pc || !pc->cb_info) {
5987 LOGE("NULL handle");
5988 return CAMERA_ERROR_INVALID_PARAMETER;
5993 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5995 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5997 LOGD("ret : 0x%x", ret);
6003 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6005 int ret = CAMERA_ERROR_NONE;
6006 camera_cli_s *pc = (camera_cli_s *)camera;
6007 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6009 if (!pc || !pc->cb_info || !rotation) {
6010 LOGE("NULL pointer %p %p", pc, rotation);
6011 return CAMERA_ERROR_INVALID_PARAMETER;
6016 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6018 if (ret == CAMERA_ERROR_NONE)
6019 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6021 LOGD("ret : 0x%x", ret);
6027 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6032 camera_msg_param param;
6033 int set_flip = (int)flip;
6035 if (!pc || !pc->cb_info) {
6036 LOGE("NULL handle");
6037 return CAMERA_ERROR_INVALID_PARAMETER;
6042 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6044 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6046 LOGD("ret : 0x%x", ret);
6052 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
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_GET_STREAM_FLIP;
6058 if (!pc || !pc->cb_info || !flip) {
6059 LOGE("NULL pointer %p %p", pc, flip);
6060 return CAMERA_ERROR_INVALID_PARAMETER;
6065 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6067 if (ret == CAMERA_ERROR_NONE)
6068 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6070 LOGD("ret : 0x%x", ret);
6075 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6077 int ret = CAMERA_ERROR_NONE;
6078 camera_cli_s *pc = (camera_cli_s *)camera;
6079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6080 camera_msg_param param;
6081 int set_mode = (int)mode;
6083 if (!pc || !pc->cb_info) {
6084 LOGE("NULL handle");
6085 return CAMERA_ERROR_INVALID_PARAMETER;
6090 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6092 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6094 LOGD("ret : 0x%x", ret);
6100 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6102 int ret = CAMERA_ERROR_NONE;
6103 camera_cli_s *pc = (camera_cli_s *)camera;
6104 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6106 if (!pc || !pc->cb_info || !mode) {
6107 LOGE("NULL pointer %p %p", pc, mode);
6108 return CAMERA_ERROR_INVALID_PARAMETER;
6113 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 if (ret == CAMERA_ERROR_NONE)
6116 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6118 LOGD("ret : 0x%x", ret);
6124 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6126 int ret = CAMERA_ERROR_NONE;
6127 camera_cli_s *pc = (camera_cli_s *)camera;
6128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6130 if (!pc || !pc->cb_info) {
6131 LOGE("NULL handle");
6132 return CAMERA_ERROR_INVALID_PARAMETER;
6137 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6140 LOGE("error is occurred 0x%x", ret);
6144 LOGD("ret : %d", ret);
6150 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6152 int ret = CAMERA_ERROR_NONE;
6153 camera_cli_s *pc = (camera_cli_s *)camera;
6154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6156 if (!pc || !pc->cb_info) {
6157 LOGE("NULL handle");
6158 return CAMERA_ERROR_INVALID_PARAMETER;
6163 if (!camera_attr_is_supported_hdr_capture(camera)) {
6164 LOGE("HDR not supported");
6165 return CAMERA_ERROR_NOT_SUPPORTED;
6169 LOGE("NULL callback");
6170 return CAMERA_ERROR_INVALID_PARAMETER;
6173 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6175 if (ret == CAMERA_ERROR_NONE) {
6176 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6178 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6179 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6181 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6184 LOGD("ret : 0x%x", ret);
6190 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6192 int ret = CAMERA_ERROR_NONE;
6193 camera_cli_s *pc = (camera_cli_s *)camera;
6194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6196 if (!pc || !pc->cb_info) {
6197 LOGE("NULL handle");
6198 return CAMERA_ERROR_INVALID_PARAMETER;
6203 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6205 if (ret == CAMERA_ERROR_NONE) {
6206 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6208 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6209 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6211 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6214 LOGD("ret : 0x%x", ret);
6220 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6222 int ret = CAMERA_ERROR_NONE;
6223 camera_cli_s *pc = (camera_cli_s *)camera;
6224 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6225 camera_msg_param param;
6226 int set_enable = (int)enable;
6228 if (!pc || !pc->cb_info) {
6229 LOGE("NULL handle");
6230 return CAMERA_ERROR_INVALID_PARAMETER;
6235 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6237 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6239 LOGD("ret : 0x%x", ret);
6245 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6247 int ret = CAMERA_ERROR_NONE;
6248 camera_cli_s *pc = (camera_cli_s *)camera;
6249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6251 if (!pc || !pc->cb_info || !enabled) {
6252 LOGE("NULL pointer %p %p", pc, enabled);
6253 return CAMERA_ERROR_INVALID_PARAMETER;
6258 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6260 if (ret == CAMERA_ERROR_NONE)
6261 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6263 LOGD("ret : 0x%x", ret);
6269 bool camera_attr_is_supported_anti_shake(camera_h camera)
6271 int ret = CAMERA_ERROR_NONE;
6272 camera_cli_s *pc = (camera_cli_s *)camera;
6273 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6275 if (!pc || !pc->cb_info) {
6276 LOGE("NULL handle");
6277 return CAMERA_ERROR_INVALID_PARAMETER;
6282 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6285 LOGE("error is occurred 0x%x", ret);
6289 LOGD("ret : %d", ret);
6295 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6297 int ret = CAMERA_ERROR_NONE;
6298 camera_cli_s *pc = (camera_cli_s *)camera;
6299 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6300 camera_msg_param param;
6301 int set_enable = (int)enable;
6303 if (!pc || !pc->cb_info) {
6304 LOGE("NULL handle");
6305 return CAMERA_ERROR_INVALID_PARAMETER;
6310 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6312 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6314 LOGD("ret : 0x%x", ret);
6320 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6322 int ret = CAMERA_ERROR_NONE;
6323 camera_cli_s *pc = (camera_cli_s *)camera;
6324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6326 if (!pc || !pc->cb_info || !enabled) {
6327 LOGE("NULL pointer %p %p", pc, enabled);
6328 return CAMERA_ERROR_INVALID_PARAMETER;
6333 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6335 if (ret == CAMERA_ERROR_NONE)
6336 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6338 LOGD("ret : 0x%x", ret);
6344 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6346 int ret = CAMERA_ERROR_NONE;
6347 camera_cli_s *pc = (camera_cli_s *)camera;
6348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6350 if (!pc || !pc->cb_info) {
6351 LOGE("NULL handle");
6352 return CAMERA_ERROR_INVALID_PARAMETER;
6357 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6360 LOGE("error is occurred 0x%x", ret);
6364 LOGD("ret : %d", ret);
6370 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6372 int ret = CAMERA_ERROR_NONE;
6373 camera_cli_s *pc = (camera_cli_s *)camera;
6374 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6375 camera_msg_param param;
6376 int set_enable = (int)enable;
6378 if (!pc || !pc->cb_info) {
6379 LOGE("NULL handle");
6380 return CAMERA_ERROR_INVALID_PARAMETER;
6385 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6387 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6389 LOGD("ret : 0x%x", ret);
6395 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6397 int ret = CAMERA_ERROR_NONE;
6398 camera_cli_s *pc = (camera_cli_s *)camera;
6399 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6401 if (!pc || !pc->cb_info || !enabled) {
6402 LOGE("NULL pointer %p %p", pc, enabled);
6403 return CAMERA_ERROR_INVALID_PARAMETER;
6408 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6410 if (ret == CAMERA_ERROR_NONE)
6411 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6413 LOGD("ret : 0x%x", ret);
6419 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6421 int ret = CAMERA_ERROR_NONE;
6422 camera_cli_s *pc = (camera_cli_s *)camera;
6423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6425 if (!pc || !pc->cb_info) {
6426 LOGE("NULL handle");
6427 return CAMERA_ERROR_INVALID_PARAMETER;
6432 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6435 LOGE("error is occurred 0x%x", ret);
6439 LOGD("ret : %d", ret);
6445 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6447 int ret = CAMERA_ERROR_NONE;
6448 camera_cli_s *pc = (camera_cli_s *)camera;
6449 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6450 camera_msg_param param;
6451 int set_disable = (int)disable;
6453 if (!pc || !pc->cb_info) {
6454 LOGE("NULL handle");
6455 return CAMERA_ERROR_INVALID_PARAMETER;
6460 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6462 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6464 LOGD("ret : 0x%x", ret);
6470 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6472 int ret = CAMERA_ERROR_NONE;
6473 camera_cli_s *pc = (camera_cli_s *)camera;
6474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6475 camera_msg_param param;
6476 int set_move_type = (int)move_type;
6479 if (!pc || !pc->cb_info) {
6480 LOGE("NULL handle");
6481 return CAMERA_ERROR_INVALID_PARAMETER;
6486 value = (set_move_type << 16) | pan_step;
6487 CAMERA_MSG_PARAM_SET(param, INT, value);
6489 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6491 LOGD("ret : 0x%x", ret);
6497 int camera_attr_get_pan(camera_h camera, int *pan_step)
6499 int ret = CAMERA_ERROR_NONE;
6500 camera_cli_s *pc = (camera_cli_s *)camera;
6501 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6503 if (!pc || !pc->cb_info || !pan_step) {
6504 LOGE("NULL pointer %p %p", pc, pan_step);
6505 return CAMERA_ERROR_INVALID_PARAMETER;
6510 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6512 if (ret == CAMERA_ERROR_NONE)
6513 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6515 LOGD("ret : 0x%x", ret);
6521 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6523 int ret = CAMERA_ERROR_NONE;
6524 camera_cli_s *pc = (camera_cli_s *)camera;
6525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6527 if (!pc || !pc->cb_info || !min || !max) {
6528 LOGE("NULL pointer %p %p %p", pc, min, max);
6529 return CAMERA_ERROR_INVALID_PARAMETER;
6534 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6536 if (ret == CAMERA_ERROR_NONE) {
6537 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6538 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6541 LOGD("ret : 0x%x", ret);
6547 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6549 int ret = CAMERA_ERROR_NONE;
6550 camera_cli_s *pc = (camera_cli_s *)camera;
6551 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6552 camera_msg_param param;
6553 int set_move_type = (int)move_type;
6556 if (!pc || !pc->cb_info) {
6557 LOGE("NULL handle");
6558 return CAMERA_ERROR_INVALID_PARAMETER;
6563 value = (set_move_type << 16) | tilt_step;
6564 CAMERA_MSG_PARAM_SET(param, INT, value);
6566 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6568 LOGD("ret : 0x%x", ret);
6574 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6576 int ret = CAMERA_ERROR_NONE;
6577 camera_cli_s *pc = (camera_cli_s *)camera;
6578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6580 if (!pc || !pc->cb_info || !tilt_step) {
6581 LOGE("NULL pointer %p %p", pc, tilt_step);
6582 return CAMERA_ERROR_INVALID_PARAMETER;
6587 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6589 if (ret == CAMERA_ERROR_NONE)
6590 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6592 LOGD("ret : 0x%x", ret);
6598 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6600 int ret = CAMERA_ERROR_NONE;
6601 camera_cli_s *pc = (camera_cli_s *)camera;
6602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6604 if (!pc || !pc->cb_info || !min || !max) {
6605 LOGE("NULL pointer %p %p %p", pc, min, max);
6606 return CAMERA_ERROR_INVALID_PARAMETER;
6611 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6613 if (ret == CAMERA_ERROR_NONE) {
6614 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6615 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6618 LOGD("ret : 0x%x", ret);
6624 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6626 int ret = CAMERA_ERROR_NONE;
6627 camera_cli_s *pc = (camera_cli_s *)camera;
6628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6629 camera_msg_param param;
6630 int set_ptz_type = (int)ptz_type;
6632 if (!pc || !pc->cb_info) {
6633 LOGE("NULL handle");
6634 return CAMERA_ERROR_INVALID_PARAMETER;
6639 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6641 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6643 LOGD("ret : 0x%x", ret);
6649 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6651 int ret = CAMERA_ERROR_NONE;
6652 camera_cli_s *pc = (camera_cli_s *)camera;
6653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6655 if (!pc || !pc->cb_info || !foreach_cb) {
6656 LOGE("NULL pointer %p %p", pc, foreach_cb);
6657 return CAMERA_ERROR_INVALID_PARAMETER;
6662 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6663 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6667 LOGD("ret : 0x%x", ret);
6673 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6675 int ret = CAMERA_ERROR_NONE;
6676 camera_cli_s *pc = (camera_cli_s *)camera;
6677 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6678 int set_display_roi_area[4] = {x, y, width, height};
6683 if (!pc || !pc->cb_info) {
6684 LOGE("NULL handle");
6685 return CAMERA_ERROR_INVALID_PARAMETER;
6690 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6691 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6692 g_mutex_lock(&pc->cb_info->evas_mutex);
6694 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6696 g_mutex_unlock(&pc->cb_info->evas_mutex);
6698 if (ret != MM_ERROR_NONE) {
6699 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6700 return CAMERA_ERROR_INVALID_OPERATION;
6703 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6705 length = sizeof(set_display_roi_area) / sizeof(int) + \
6706 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6708 msg = muse_core_msg_new(api,
6709 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6712 LOGE("msg creation failed: api %d", api);
6713 return CAMERA_ERROR_OUT_OF_MEMORY;
6716 if (pc->cb_info->is_server_connected) {
6717 __camera_update_api_waiting(pc->cb_info, api, 1);
6719 g_mutex_lock(&pc->cb_info->fd_lock);
6720 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6721 g_mutex_unlock(&pc->cb_info->fd_lock);
6725 LOGE("message send failed");
6726 ret = CAMERA_ERROR_INVALID_OPERATION;
6728 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6731 __camera_update_api_waiting(pc->cb_info, api, -1);
6733 muse_core_msg_free(msg);
6735 LOGD("ret : 0x%x", ret);
6741 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6743 camera_cli_s *pc = (camera_cli_s *)camera;
6744 int ret = CAMERA_ERROR_NONE;
6745 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6747 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6748 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6749 return CAMERA_ERROR_INVALID_PARAMETER;
6754 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6756 if (ret == CAMERA_ERROR_NONE) {
6757 *x = pc->cb_info->get_display_roi_area[0];
6758 *y = pc->cb_info->get_display_roi_area[1];
6759 *width = pc->cb_info->get_display_roi_area[2];
6760 *height = pc->cb_info->get_display_roi_area[3];
6763 LOGD("ret : 0x%x", ret);
6769 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6771 int ret = CAMERA_ERROR_NONE;
6772 int get_device_state = 0;
6775 LOGE("NULL pointer");
6776 return CAMERA_ERROR_INVALID_PARAMETER;
6779 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6780 (int)device, "get_device_state", &get_device_state);
6782 if (ret == CAMERA_ERROR_NONE) {
6783 *state = (camera_device_state_e)get_device_state;
6784 LOGD("device state %d", *state);
6786 LOGE("failed 0x%x", ret);
6793 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6795 int ret = CAMERA_ERROR_NONE;
6796 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6797 camera_cb_info *info = NULL;
6799 if (!callback || !cb_id) {
6800 LOGE("invalid pointer %p %p", callback, cb_id);
6801 return CAMERA_ERROR_INVALID_PARAMETER;
6804 /* check camera support */
6805 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6806 if (ret != CAMERA_ERROR_NONE) {
6807 LOGE("get device state failed");
6811 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6813 info = g_new0(camera_cb_info, 1);
6815 LOGE("info failed");
6816 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6820 info->id = ++g_cam_dev_state_changed_cb_id;
6821 info->callback = (void *)callback;
6822 info->user_data = user_data;
6826 /* subscribe dbus signal for camera state change */
6827 if (!g_cam_dev_state_changed_cb_conn) {
6828 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6829 if (!g_cam_dev_state_changed_cb_conn) {
6830 LOGE("failed to get gdbus connection");
6831 ret = CAMERA_ERROR_INVALID_OPERATION;
6835 LOGD("subscribe signal %s - %s - %s",
6836 MM_CAMCORDER_DBUS_OBJECT,
6837 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6838 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6840 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6841 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6842 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6843 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6844 LOGE("failed to get gdbus connection");
6845 ret = CAMERA_ERROR_INVALID_OPERATION;
6849 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6852 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6854 LOGD("callback id %d", info->id);
6857 if (ret != CAMERA_ERROR_NONE) {
6863 if (g_cam_dev_state_changed_cb_conn) {
6864 g_object_unref(g_cam_dev_state_changed_cb_conn);
6865 g_cam_dev_state_changed_cb_conn = NULL;
6869 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6875 int camera_remove_device_state_changed_cb(int cb_id)
6877 int ret = CAMERA_ERROR_NONE;
6878 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6879 GList *tmp_list = NULL;
6880 camera_cb_info *info = NULL;
6882 /* check camera support */
6883 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6884 if (ret != CAMERA_ERROR_NONE) {
6885 LOGE("get device state failed");
6889 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6891 if (!g_cam_dev_state_changed_cb_list) {
6892 LOGE("there is no callback info");
6893 ret = CAMERA_ERROR_INVALID_OPERATION;
6897 tmp_list = g_cam_dev_state_changed_cb_list;
6900 info = tmp_list->data;
6901 tmp_list = tmp_list->next;
6908 if (info->id == cb_id) {
6909 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6914 if (!g_cam_dev_state_changed_cb_list) {
6915 /* no remained callback */
6916 if (g_cam_dev_state_changed_cb_conn) {
6917 /* unsubscribe signal */
6918 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6919 g_cam_dev_state_changed_cb_subscribe_id = 0;
6921 /* unref connection */
6922 g_object_unref(g_cam_dev_state_changed_cb_conn);
6923 g_cam_dev_state_changed_cb_conn = NULL;
6927 LOGD("id %d callback removed", cb_id);
6928 ret = CAMERA_ERROR_NONE;
6934 LOGE("id %d callback not found", cb_id);
6935 ret = CAMERA_ERROR_INVALID_PARAMETER;
6938 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);