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 < BUFFER_MAX_PLANE_NUM ; 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_idle_remove_by_data(cam_idle_event)) {
1845 LOGW("remove idle event %p done", cam_idle_event);
1847 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1849 g_mutex_clear(&cam_idle_event->event_mutex);
1850 g_free(cam_idle_event);
1851 cam_idle_event = NULL;
1856 LOGW("remove idle event %p failed", cam_idle_event);
1858 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1859 LOGW("lock failed, %p event is calling now", cam_idle_event);
1861 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1863 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1864 LOGW("signal received");
1871 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1872 cam_idle_event, cam_idle_event->event);
1874 cam_idle_event->cb_info = NULL;
1876 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1878 g_mutex_unlock(&cam_idle_event->event_mutex);
1881 g_list_free(cb_info->idle_event_list);
1882 cb_info->idle_event_list = NULL;
1884 g_mutex_unlock(&cb_info->idle_event_mutex);
1890 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1892 camera_message_s *cam_msg = NULL;
1894 if (!cb_info || !msg) {
1895 LOGE("NULL pointer %p %p", cb_info, msg);
1899 cam_msg = g_new0(camera_message_s, 1);
1901 LOGE("failed to alloc cam_msg for [%s]", msg);
1906 cam_msg->event = event;
1907 cam_msg->event_class = event_class;
1909 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1911 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1913 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1914 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1915 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1916 g_cond_signal(&cb_info->preview_cb_info.cond);
1917 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1918 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1919 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1920 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1921 g_cond_signal(&cb_info->capture_cb_info.cond);
1922 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1924 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1925 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1926 g_cond_signal(&cb_info->msg_handler_info.cond);
1927 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1936 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1938 int ret = CAMERA_ERROR_NONE;
1942 int event_class = -1;
1946 if (!cb_info || !msg) {
1947 LOGE("invalid ptr %p %p", cb_info, msg);
1951 /*LOGD("msg [%s]", msg);*/
1953 if (!muse_camera_msg_get(api, msg)) {
1954 LOGE("failed to get camera api");
1958 if (api == MUSE_CAMERA_CB_EVENT) {
1959 if (!muse_camera_msg_get(event, msg) ||
1960 !muse_camera_msg_get(event_class, msg)) {
1961 LOGE("failed to get camera event or event_class [%s]", msg);
1965 if (!muse_camera_msg_get(api_class, msg)) {
1966 LOGE("failed to get camera api_class [%s]", msg);
1971 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1972 if (api >= MUSE_CAMERA_API_MAX) {
1973 LOGE("invalid api %d", api);
1977 if (!muse_camera_msg_get(ret, msg)) {
1978 LOGE("failed to get camera ret");
1982 g_mutex_lock(&cb_info->api_mutex[api]);
1985 case MUSE_CAMERA_API_CREATE:
1986 if (ret != CAMERA_ERROR_NONE) {
1987 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1988 LOGE("camera create error 0x%x. close client cb handler", ret);
1991 case MUSE_CAMERA_API_DESTROY:
1992 if (ret == CAMERA_ERROR_NONE) {
1993 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1994 LOGD("camera destroy done. close client cb handler");
1998 muse_camera_msg_get(get_type, msg);
1999 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
2000 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
2001 muse_camera_msg_get(get_index, msg);
2004 case MUSE_CAMERA_GET_TYPE_INT:
2005 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
2007 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
2008 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
2009 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
2011 case MUSE_CAMERA_GET_TYPE_ARRAY:
2012 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
2013 muse_core_msg_deserialize("get_value",
2014 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
2015 LOGD("get display roi %d,%d,%dx%d",
2016 cb_info->get_display_roi_area[0],
2017 cb_info->get_display_roi_area[1],
2018 cb_info->get_display_roi_area[2],
2019 cb_info->get_display_roi_area[3]);
2021 muse_core_msg_deserialize("get_value",
2022 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2023 LOGD("get geotag %lf, %lf, %lf",
2024 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2027 case MUSE_CAMERA_GET_TYPE_STRING:
2028 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2031 LOGW("unknown type %d", get_type);
2038 if (cb_info->api_waiting[api] > 0) {
2039 cb_info->api_ret[api] = ret;
2040 cb_info->api_activating[api] = 1;
2042 g_cond_signal(&cb_info->api_cond[api]);
2044 LOGW("no waiting for this api [%d]", api);
2047 g_mutex_unlock(&cb_info->api_mutex[api]);
2048 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2049 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
2051 LOGW("unknown camera api %d, class %d", api, api_class);
2058 static void *_camera_msg_recv_func(gpointer data)
2060 int recv_length = 0;
2061 int single_length = 0;
2062 int remained_length = 0;
2063 char *recv_msg = NULL;
2064 char *single_msg = NULL;
2065 char *remained_msg = NULL;
2069 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2072 LOGE("cb_info NULL");
2078 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2080 LOGE("single_msg malloc failed");
2084 recv_msg = cb_info->recv_msg;
2086 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2087 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2088 if (recv_length <= 0) {
2089 cb_info->is_server_connected = FALSE;
2090 LOGE("receive msg failed - server disconnected");
2098 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2100 /* Need to split the combined entering msgs */
2101 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2102 if (recv_msg[cur_pos] == '}') {
2103 single_length = cur_pos - prev_pos + 1;
2105 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2106 /* check remained msg */
2107 if (remained_length > 0) {
2109 strncpy(single_msg, remained_msg, remained_length);
2110 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2111 single_msg[remained_length + single_length] = '\0';
2114 remained_msg = NULL;
2116 strncpy(single_msg, recv_msg + prev_pos, single_length);
2117 single_msg[single_length] = '\0';
2118 LOGE("lost msg [%s], skip...", single_msg);
2121 remained_length = 0;
2123 strncpy(single_msg, recv_msg + prev_pos, single_length);
2124 single_msg[single_length] = '\0';
2127 if (single_msg[0] == '{') {
2129 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2130 /* process each message */
2131 __camera_process_msg(cb_info, single_msg);
2133 LOGE("invalid msg [%s]", single_msg);
2136 LOGE("too long message [len %d] skip...", single_length);
2139 prev_pos = cur_pos + 1;
2143 /* check incompleted message */
2144 if (recv_msg[recv_length - 1] != '}') {
2145 remained_length = recv_length - prev_pos;
2147 LOGW("incompleted message [len %d]", remained_length);
2151 remained_msg = NULL;
2154 remained_msg = (char *)malloc(remained_length + 1);
2156 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2157 remained_msg[remained_length] = '\0';
2159 LOGE("failed to alloc for remained msg");
2162 remained_length = 0;
2166 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2168 if (!cb_info->is_server_connected) {
2169 /* send error msg for server disconnection */
2170 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2171 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2172 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2176 LOGE("error_msg failed");
2177 goto CB_HANDLER_EXIT;
2180 __camera_add_msg_to_queue(cb_info,
2181 MUSE_CAMERA_CB_EVENT,
2182 MUSE_CAMERA_EVENT_TYPE_ERROR,
2183 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2186 muse_core_msg_free(error_msg);
2189 LOGE("add error msg for service disconnection done");
2200 remained_msg = NULL;
2207 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2208 int type, const char *thread_name, camera_cb_info_s *cb_info)
2210 if (!handler_info || !thread_name || !cb_info) {
2211 LOGE("t:%d NULL %p %p %p",
2212 type, handler_info, thread_name, cb_info);
2218 handler_info->type = type;
2219 handler_info->queue = g_queue_new();
2220 if (handler_info->queue == NULL) {
2221 LOGE("t:%d queue failed", type);
2225 g_mutex_init(&handler_info->mutex);
2226 g_cond_init(&handler_info->cond);
2228 handler_info->cb_info = (void *)cb_info;
2229 g_atomic_int_set(&handler_info->running, 1);
2231 handler_info->thread = g_thread_try_new(thread_name,
2232 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2233 if (handler_info->thread == NULL) {
2234 LOGE("t:%d thread failed", type);
2236 g_mutex_clear(&handler_info->mutex);
2237 g_cond_clear(&handler_info->cond);
2238 g_queue_free(handler_info->queue);
2239 handler_info->queue = NULL;
2244 LOGD("t:%d done", type);
2250 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2254 if (!handler_info) {
2255 LOGE("NULL handler");
2259 if (!handler_info->thread) {
2260 LOGW("thread is not created");
2264 type = handler_info->type;
2266 LOGD("t:%d thread %p", type, handler_info->thread);
2268 g_mutex_lock(&handler_info->mutex);
2269 g_atomic_int_set(&handler_info->running, 0);
2270 g_cond_signal(&handler_info->cond);
2271 g_mutex_unlock(&handler_info->mutex);
2273 g_thread_join(handler_info->thread);
2274 handler_info->thread = NULL;
2276 g_mutex_clear(&handler_info->mutex);
2277 g_cond_clear(&handler_info->cond);
2278 g_queue_free(handler_info->queue);
2279 handler_info->queue = NULL;
2281 LOGD("t:%d done", type);
2287 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2289 camera_cb_info_s *cb_info = NULL;
2292 g_return_val_if_fail(sockfd > 0, NULL);
2294 cb_info = g_new0(camera_cb_info_s, 1);
2295 if (cb_info == NULL) {
2296 LOGE("cb_info failed");
2300 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2302 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2303 g_mutex_init(&cb_info->api_mutex[i]);
2304 g_cond_init(&cb_info->api_cond[i]);
2307 g_mutex_init(&cb_info->fd_lock);
2308 g_mutex_init(&cb_info->idle_event_mutex);
2309 g_cond_init(&cb_info->idle_event_cond);
2310 g_mutex_init(&cb_info->mp_data_mutex);
2311 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2312 g_mutex_init(&cb_info->evas_mutex);
2313 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2315 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2316 g_mutex_init(&cb_info->user_cb_mutex[i]);
2318 /* message handler thread */
2319 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2320 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2321 LOGE("msg_handler_info failed");
2325 /* message handler thread for preview callback */
2326 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2327 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2328 LOGE("preview_cb_info failed");
2332 /* message handler thread for capture callback */
2333 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2334 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2335 LOGE("capture_cb_info failed");
2339 cb_info->fd = sockfd;
2340 cb_info->preview_cb_flag = 0;
2341 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2342 cb_info->evas_info = NULL;
2343 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2345 /* message receive thread */
2346 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2347 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2348 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2349 if (cb_info->msg_recv_thread == NULL) {
2350 LOGE("message receive thread creation failed");
2354 cb_info->is_server_connected = TRUE;
2360 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2361 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2362 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2364 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2365 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2367 g_mutex_clear(&cb_info->fd_lock);
2368 g_mutex_clear(&cb_info->idle_event_mutex);
2369 g_cond_clear(&cb_info->idle_event_cond);
2370 g_mutex_clear(&cb_info->mp_data_mutex);
2371 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2372 g_mutex_clear(&cb_info->evas_mutex);
2373 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2375 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2376 g_mutex_clear(&cb_info->api_mutex[i]);
2377 g_cond_clear(&cb_info->api_cond[i]);
2387 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2391 g_return_if_fail(cb_info != NULL);
2393 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2395 g_thread_join(cb_info->msg_recv_thread);
2396 cb_info->msg_recv_thread = NULL;
2398 LOGD("msg_recv thread removed");
2400 /* destroy msg handler threads */
2401 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2402 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2403 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2405 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2406 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2408 g_mutex_clear(&cb_info->fd_lock);
2409 g_mutex_clear(&cb_info->idle_event_mutex);
2410 g_cond_clear(&cb_info->idle_event_cond);
2411 g_mutex_clear(&cb_info->mp_data_mutex);
2412 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2413 g_mutex_clear(&cb_info->evas_mutex);
2414 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2416 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2417 g_mutex_clear(&cb_info->api_mutex[i]);
2418 g_cond_clear(&cb_info->api_cond[i]);
2421 if (cb_info->fd > -1) {
2422 muse_client_close(cb_info->fd);
2426 if (cb_info->bufmgr) {
2427 tbm_bufmgr_deinit(cb_info->bufmgr);
2428 cb_info->bufmgr = NULL;
2430 if (cb_info->pkt_fmt) {
2431 media_format_unref(cb_info->pkt_fmt);
2432 cb_info->pkt_fmt = NULL;
2435 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2436 if (cb_info->evas_info)
2437 mm_evas_renderer_destroy(&cb_info->evas_info);
2438 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2440 cb_info->preview_cb_flag = 0;
2449 int _camera_start_evas_rendering(camera_h camera)
2451 int ret = CAMERA_ERROR_NONE;
2452 camera_cli_s *pc = (camera_cli_s *)camera;
2454 if (!pc || !pc->cb_info) {
2455 LOGE("NULL handle");
2456 return CAMERA_ERROR_INVALID_PARAMETER;
2461 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2462 LOGE("EVAS surface is not set");
2463 return CAMERA_ERROR_NONE;
2466 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2467 g_mutex_lock(&pc->cb_info->evas_mutex);
2469 /* set evas render flag as RUN */
2470 pc->cb_info->run_evas_render = true;
2471 ret = CAMERA_ERROR_NONE;
2473 g_mutex_unlock(&pc->cb_info->evas_mutex);
2474 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2475 LOGW("evas renderer is not supported");
2476 ret = CAMERA_ERROR_NOT_SUPPORTED;
2477 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2483 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2485 int ret = CAMERA_ERROR_NONE;
2486 camera_cli_s *pc = (camera_cli_s *)camera;
2488 if (!pc || !pc->cb_info) {
2489 LOGE("NULL handle");
2490 return CAMERA_ERROR_INVALID_PARAMETER;
2493 LOGD("stop - keep screen %d", keep_screen);
2495 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2496 LOGE("EVAS surface is not set");
2497 return CAMERA_ERROR_NONE;
2500 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2501 g_mutex_lock(&pc->cb_info->evas_mutex);
2503 /* set evas render flag as STOP and release buffers */
2504 pc->cb_info->run_evas_render = false;
2506 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2507 if (ret != MM_ERROR_NONE) {
2508 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2509 ret = CAMERA_ERROR_INVALID_OPERATION;
2512 g_mutex_unlock(&pc->cb_info->evas_mutex);
2513 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2514 LOGW("evas renderer is not supported");
2515 ret = CAMERA_ERROR_NOT_SUPPORTED;
2516 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2522 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2524 int ret = CAMERA_ERROR_NONE;
2527 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2529 /* create muse connection */
2530 if (!key || !value) {
2531 LOGE("NULL pointer");
2532 return CAMERA_ERROR_INVALID_PARAMETER;
2535 sock_fd = muse_client_new();
2537 LOGE("muse_client_new failed");
2538 return CAMERA_ERROR_INVALID_OPERATION;
2541 msg = muse_core_msg_new(api,
2542 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2543 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2547 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2551 ret = muse_core_msg_send(sock_fd, msg);
2553 muse_core_msg_free(msg);
2557 LOGE("send msg failed");
2558 ret = CAMERA_ERROR_INVALID_OPERATION;
2562 ret = muse_core_msg_recv(sock_fd, recv_msg);
2564 LOGE("recv msg failed %d", errno);
2565 ret = CAMERA_ERROR_INVALID_OPERATION;
2569 if (!muse_camera_msg_get(ret, recv_msg)) {
2570 LOGE("failed to get return value from msg [%s]", recv_msg);
2571 ret = CAMERA_ERROR_INVALID_OPERATION;
2575 if (ret == CAMERA_ERROR_NONE)
2576 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2578 LOGD("api %d - value %d", api, *value);
2582 muse_client_close(sock_fd);
2590 int camera_create(camera_device_e device, camera_h *camera)
2593 char *send_msg = NULL;
2595 int ret = CAMERA_ERROR_NONE;
2597 camera_cli_s *pc = NULL;
2598 tbm_bufmgr bufmgr = NULL;
2600 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2601 muse_core_api_module_e muse_module = MUSE_CAMERA;
2602 int device_type = (int)device;
2605 LOGE("NULL pointer");
2606 return CAMERA_ERROR_INVALID_PARAMETER;
2609 sock_fd = muse_client_new();
2611 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2612 ret = CAMERA_ERROR_INVALID_OPERATION;
2618 send_msg = muse_core_msg_new(api,
2619 MUSE_TYPE_INT, "module", muse_module,
2620 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2621 MUSE_TYPE_INT, "pid", pid,
2626 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2630 send_ret = muse_core_msg_send(sock_fd, send_msg);
2632 muse_core_msg_free(send_msg);
2636 LOGE("send msg failed %d", errno);
2637 ret = CAMERA_ERROR_INVALID_OPERATION;
2641 pc = g_new0(camera_cli_s, 1);
2643 LOGE("camera_cli_s alloc failed");
2644 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2648 bufmgr = tbm_bufmgr_init(-1);
2649 if (bufmgr == NULL) {
2650 LOGE("get tbm bufmgr failed");
2651 ret = CAMERA_ERROR_INVALID_OPERATION;
2655 pc->cb_info = _camera_client_callback_new(sock_fd);
2656 if (pc->cb_info == NULL) {
2657 LOGE("cb_info alloc failed");
2658 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2664 LOGD("cb info : %d", pc->cb_info->fd);
2666 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2668 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2670 if (ret == CAMERA_ERROR_NONE) {
2671 intptr_t handle = 0;
2672 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2674 LOGE("Receiving Handle Failed!!");
2675 ret = CAMERA_ERROR_INVALID_OPERATION;
2679 pc->remote_handle = handle;
2680 pc->cb_info->bufmgr = bufmgr;
2682 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2683 if (ret != CAMERA_ERROR_NONE) {
2684 LOGE("init display failed 0x%x", ret);
2688 LOGD("camera create 0x%x", pc->remote_handle);
2689 *camera = (camera_h)pc;
2698 tbm_bufmgr_deinit(bufmgr);
2703 muse_client_close(sock_fd);
2709 _camera_client_callback_destroy(pc->cb_info);
2716 LOGE("camera create error : 0x%x", ret);
2722 int camera_change_device(camera_h camera, camera_device_e device)
2725 int ret = CAMERA_ERROR_NONE;
2726 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2727 camera_cli_s *pc = (camera_cli_s *)camera;
2728 camera_msg_param param;
2730 if (!pc || !pc->cb_info) {
2731 LOGE("NULL handle");
2732 return CAMERA_ERROR_INVALID_PARAMETER;
2735 CAMERA_MSG_PARAM_SET(param, INT, device);
2737 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2739 if (ret == CAMERA_ERROR_NONE) {
2740 /* reset callback and user data */
2741 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2742 pc->cb_info->user_cb[i] = NULL;
2743 pc->cb_info->user_data[i] = NULL;
2745 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2752 int camera_destroy(camera_h camera)
2754 int ret = CAMERA_ERROR_NONE;
2755 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2756 camera_cli_s *pc = (camera_cli_s *)camera;
2758 if (!pc || !pc->cb_info) {
2759 LOGE("NULL handle");
2760 return CAMERA_ERROR_INVALID_PARAMETER;
2765 if (pc->cb_info->is_server_connected)
2766 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2768 LOGW("server disconnected. release resource without send message.");
2770 if (ret == CAMERA_ERROR_NONE) {
2771 _camera_deactivate_idle_event_all(pc->cb_info);
2772 _camera_client_callback_destroy(pc->cb_info);
2779 LOGD("ret : 0x%x", ret);
2784 int camera_start_preview(camera_h camera)
2786 int ret = CAMERA_ERROR_NONE;
2787 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2788 camera_cli_s *pc = (camera_cli_s *)camera;
2790 if (!pc || !pc->cb_info) {
2791 LOGE("NULL handle");
2792 return CAMERA_ERROR_INVALID_PARAMETER;
2797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2798 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2799 ret = _camera_start_evas_rendering(camera);
2800 if (ret != CAMERA_ERROR_NONE) {
2801 LOGE("stop preview because of error");
2802 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2806 LOGD("ret : 0x%x", ret);
2812 int camera_stop_preview(camera_h camera)
2814 int ret = CAMERA_ERROR_NONE;
2815 camera_cli_s *pc = (camera_cli_s *)camera;
2816 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2817 camera_state_e current_state = CAMERA_STATE_NONE;
2819 if (!pc || !pc->cb_info) {
2820 LOGE("NULL handle");
2821 return CAMERA_ERROR_INVALID_PARAMETER;
2826 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2827 ret = camera_get_state(camera, ¤t_state);
2828 if (ret != CAMERA_ERROR_NONE) {
2829 LOGE("failed to get current state 0x%x", ret);
2833 if (current_state == CAMERA_STATE_PREVIEW) {
2834 ret = _camera_stop_evas_rendering(camera, false);
2835 if (ret != CAMERA_ERROR_NONE)
2840 /* send stop preview message */
2841 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2843 if (ret != CAMERA_ERROR_NONE &&
2844 current_state == CAMERA_STATE_PREVIEW) {
2845 LOGW("restart evas rendering");
2846 _camera_start_evas_rendering(camera);
2849 LOGD("ret : 0x%x", ret);
2855 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2857 int ret = CAMERA_ERROR_NONE;
2858 camera_cli_s *pc = (camera_cli_s *)camera;
2859 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2861 if (!pc || !pc->cb_info) {
2862 LOGE("NULL handle");
2863 return CAMERA_ERROR_INVALID_PARAMETER;
2868 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2869 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2871 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2872 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2874 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2876 LOGD("ret : 0x%x", ret);
2882 bool camera_is_supported_continuous_capture(camera_h camera)
2884 int ret = CAMERA_ERROR_NONE;
2885 camera_cli_s *pc = (camera_cli_s *)camera;
2886 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2888 if (!pc || !pc->cb_info) {
2889 LOGE("NULL handle");
2890 return CAMERA_ERROR_INVALID_PARAMETER;
2895 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2898 LOGE("error is occurred 0x%x", ret);
2902 LOGD("ret : %d", ret);
2908 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)
2910 int ret = CAMERA_ERROR_NONE;
2911 camera_cli_s *pc = (camera_cli_s *)camera;
2912 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2913 camera_msg_param param;
2916 if (!pc || !pc->cb_info) {
2917 LOGE("NULL handle");
2918 return CAMERA_ERROR_INVALID_PARAMETER;
2923 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2924 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2926 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2927 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2929 value = (count << 16) | interval;
2930 CAMERA_MSG_PARAM_SET(param, INT, value);
2932 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2934 LOGD("ret : 0x%x", ret);
2940 int camera_stop_continuous_capture(camera_h camera)
2942 int ret = CAMERA_ERROR_NONE;
2943 camera_cli_s *pc = (camera_cli_s *)camera;
2944 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2946 if (!pc || !pc->cb_info) {
2947 LOGE("NULL handle");
2948 return CAMERA_ERROR_INVALID_PARAMETER;
2953 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2955 LOGD("ret : 0x%x", ret);
2961 bool camera_is_supported_face_detection(camera_h camera)
2963 int ret = CAMERA_ERROR_NONE;
2964 camera_cli_s *pc = (camera_cli_s *)camera;
2965 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2967 if (!pc || !pc->cb_info) {
2968 LOGE("NULL handle");
2969 return CAMERA_ERROR_INVALID_PARAMETER;
2974 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2977 LOGE("error is occurred 0x%x", ret);
2981 LOGD("ret : %d", ret);
2987 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2989 int ret = CAMERA_ERROR_NONE;
2990 camera_cli_s *pc = (camera_cli_s *)camera;
2991 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2993 if (!pc || !pc->cb_info) {
2994 LOGE("NULL handle");
2995 return CAMERA_ERROR_INVALID_PARAMETER;
3000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3003 LOGE("error is occurred 0x%x", ret);
3007 LOGD("ret : %d", ret);
3013 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
3015 int ret = CAMERA_ERROR_NONE;
3016 camera_cli_s *pc = (camera_cli_s *)camera;
3017 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
3019 if (!pc || !pc->cb_info) {
3020 LOGE("NULL handle");
3021 return CAMERA_ERROR_INVALID_PARAMETER;
3026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3029 LOGE("error is occurred 0x%x", ret);
3033 LOGD("ret : %d", ret);
3038 int camera_get_device_count(camera_h camera, int *device_count)
3040 int ret = CAMERA_ERROR_NONE;
3041 camera_cli_s *pc = (camera_cli_s *)camera;
3042 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3044 if (!pc || !pc->cb_info) {
3045 LOGE("NULL handle");
3046 return CAMERA_ERROR_INVALID_PARAMETER;
3051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3053 if (ret == CAMERA_ERROR_NONE)
3054 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3056 LOGD("ret : 0x%x", ret);
3061 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3063 int ret = CAMERA_ERROR_NONE;
3064 camera_cli_s *pc = (camera_cli_s *)camera;
3065 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3067 if (!pc || !pc->cb_info) {
3068 LOGE("NULL handle");
3069 return CAMERA_ERROR_INVALID_PARAMETER;
3074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3076 if (ret == CAMERA_ERROR_NONE) {
3077 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3082 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3085 LOGD("ret : 0x%x", ret);
3090 int camera_stop_face_detection(camera_h camera)
3092 int ret = CAMERA_ERROR_NONE;
3093 camera_cli_s *pc = (camera_cli_s *)camera;
3094 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3096 if (!pc || !pc->cb_info) {
3097 LOGE("NULL handle");
3098 return CAMERA_ERROR_INVALID_PARAMETER;
3103 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3105 if (ret == CAMERA_ERROR_NONE) {
3106 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3108 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3109 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3111 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3114 LOGD("ret : 0x%x", ret);
3119 int camera_get_state(camera_h camera, camera_state_e *state)
3121 int ret = CAMERA_ERROR_NONE;
3122 camera_cli_s *pc = (camera_cli_s *)camera;
3123 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3125 if (!pc || !pc->cb_info || !state) {
3126 LOGE("NULL pointer %p %p", pc, state);
3127 return CAMERA_ERROR_INVALID_PARAMETER;
3132 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3134 if (ret == CAMERA_ERROR_NONE)
3135 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3137 LOGD("ret : 0x%x", ret);
3142 int camera_start_focusing(camera_h camera, bool continuous)
3144 int ret = CAMERA_ERROR_NONE;
3145 camera_cli_s *pc = (camera_cli_s *)camera;
3146 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3147 camera_msg_param param;
3148 int is_continuous = (int)continuous;
3150 if (!pc || !pc->cb_info) {
3151 LOGE("NULL handle");
3152 return CAMERA_ERROR_INVALID_PARAMETER;
3157 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3159 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3161 LOGD("ret : 0x%x", ret);
3166 int camera_cancel_focusing(camera_h camera)
3168 int ret = CAMERA_ERROR_NONE;
3169 camera_cli_s *pc = (camera_cli_s *)camera;
3170 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3172 if (!pc || !pc->cb_info) {
3173 LOGE("NULL handle");
3174 return CAMERA_ERROR_INVALID_PARAMETER;
3177 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3179 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3181 LOGD("ret : 0x%x", ret);
3186 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3188 int ret = CAMERA_ERROR_NONE;
3189 void *set_display_handle = NULL;
3190 Evas_Object *obj = NULL;
3191 const char *object_type = NULL;
3192 camera_cli_s *pc = (camera_cli_s *)camera;
3193 camera_cb_info_s *cb_info = NULL;
3194 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3195 camera_state_e current_state = CAMERA_STATE_NONE;
3196 camera_msg_param param;
3200 if (!pc || !pc->cb_info) {
3201 LOGE("NULL handle");
3202 return CAMERA_ERROR_INVALID_PARAMETER;
3205 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3206 LOGE("invalid type %d", type);
3207 return CAMERA_ERROR_INVALID_PARAMETER;
3210 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3211 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3212 return CAMERA_ERROR_INVALID_PARAMETER;
3215 cb_info = (camera_cb_info_s *)pc->cb_info;
3217 ret = camera_get_state(camera, ¤t_state);
3218 if (ret != CAMERA_ERROR_NONE) {
3219 LOGE("failed to get current state 0x%x", ret);
3223 if (current_state != CAMERA_STATE_CREATED) {
3224 LOGE("INVALID_STATE : current %d", current_state);
3225 return CAMERA_ERROR_INVALID_STATE;
3228 LOGD("Enter - display : %p", display);
3230 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3231 set_display_handle = 0;
3232 LOGD("display type NONE");
3234 obj = (Evas_Object *)display;
3235 object_type = evas_object_type_get(obj);
3237 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3238 /* get wayland parent id */
3239 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3240 LOGE("failed to get wayland info");
3241 return CAMERA_ERROR_INVALID_OPERATION;
3244 set_display_handle = (void *)&pc->wl_info;
3245 LOGD("display type OVERLAY : handle %p", set_display_handle);
3246 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3247 /* evas object surface */
3248 set_display_handle = (void *)display;
3249 LOGD("display type EVAS : handle %p", set_display_handle);
3251 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3252 g_mutex_lock(&cb_info->evas_mutex);
3254 if (cb_info->evas_info) {
3255 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3256 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3257 if (ret != MM_ERROR_NONE) {
3258 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3259 g_mutex_unlock(&cb_info->evas_mutex);
3260 return CAMERA_ERROR_INVALID_OPERATION;
3264 /* create evas renderer */
3265 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3266 if (ret == MM_ERROR_NONE) {
3267 camera_flip_e flip = CAMERA_FLIP_NONE;
3268 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3269 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3276 camera_get_display_flip(camera, &flip);
3277 camera_get_display_mode(camera, &mode);
3278 camera_get_display_rotation(camera, &rotation);
3279 camera_is_display_visible(camera, &visible);
3280 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3282 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3283 flip, mode, rotation, visible, x, y, width, height);
3285 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3286 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3287 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3288 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3290 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3291 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3294 g_mutex_unlock(&cb_info->evas_mutex);
3296 if (ret != MM_ERROR_NONE) {
3297 LOGE("mm_evas_renderer error 0x%x", ret);
3298 return CAMERA_ERROR_INVALID_OPERATION;
3300 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3301 LOGE("EVAS surface is not supported");
3302 return CAMERA_ERROR_NOT_SUPPORTED;
3303 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3305 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3309 LOGE("failed to get evas object type from %p", obj);
3310 return CAMERA_ERROR_INVALID_PARAMETER;
3314 pc->display_handle = (intptr_t)set_display_handle;
3316 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3319 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3320 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3322 msg = muse_core_msg_new(api,
3323 MUSE_TYPE_INT, "type", type,
3324 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3327 LOGE("msg creation failed: api %d", api);
3328 return CAMERA_ERROR_OUT_OF_MEMORY;
3331 if (pc->cb_info->is_server_connected) {
3332 __camera_update_api_waiting(pc->cb_info, api, 1);
3334 g_mutex_lock(&pc->cb_info->fd_lock);
3335 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3336 g_mutex_unlock(&pc->cb_info->fd_lock);
3340 LOGE("message send failed");
3341 ret = CAMERA_ERROR_INVALID_OPERATION;
3343 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3346 __camera_update_api_waiting(pc->cb_info, api, -1);
3348 muse_core_msg_free(msg);
3350 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3351 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3352 pc->wl_info.window_width, pc->wl_info.window_height);
3354 CAMERA_MSG_PARAM_SET(param, INT, type);
3356 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3359 if (ret != CAMERA_ERROR_NONE)
3360 LOGE("set display error 0x%x", ret);
3361 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3362 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3368 int camera_set_preview_resolution(camera_h camera, int width, int height)
3370 int ret = CAMERA_ERROR_NONE;
3371 camera_state_e current_state = CAMERA_STATE_NONE;
3372 camera_cli_s *pc = (camera_cli_s *)camera;
3373 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3374 camera_msg_param param;
3377 if (!pc || !pc->cb_info) {
3378 LOGE("NULL handle");
3379 return CAMERA_ERROR_INVALID_PARAMETER;
3382 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3383 ret = camera_get_state(camera, ¤t_state);
3384 if (ret != CAMERA_ERROR_NONE) {
3385 LOGE("failed to get current state 0x%x", ret);
3389 if (current_state == CAMERA_STATE_PREVIEW) {
3390 ret = _camera_stop_evas_rendering(camera, true);
3391 if (ret != CAMERA_ERROR_NONE)
3396 value = (width << 16) | height;
3397 CAMERA_MSG_PARAM_SET(param, INT, value);
3399 LOGD("%dx%d -> 0x%x", width, height, value);
3401 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3403 LOGD("ret : 0x%x", ret);
3405 if (current_state == CAMERA_STATE_PREVIEW) {
3406 LOGW("restart evas rendering");
3407 _camera_start_evas_rendering(camera);
3414 int camera_set_capture_resolution(camera_h camera, int width, int height)
3416 int ret = CAMERA_ERROR_NONE;
3417 camera_cli_s *pc = (camera_cli_s *)camera;
3418 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3419 camera_msg_param param;
3422 if (!pc || !pc->cb_info) {
3423 LOGE("NULL handle");
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3429 value = (width << 16) | height;
3430 CAMERA_MSG_PARAM_SET(param, INT, value);
3432 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3434 LOGD("ret : 0x%x", ret);
3440 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3442 int ret = CAMERA_ERROR_NONE;
3443 int set_format = (int)format;
3444 camera_cli_s *pc = (camera_cli_s *)camera;
3445 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3446 camera_msg_param param;
3448 if (!pc || !pc->cb_info) {
3449 LOGE("NULL handle");
3450 return CAMERA_ERROR_INVALID_PARAMETER;
3453 LOGD("Enter - format %d", set_format);
3455 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3457 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3459 LOGD("ret : 0x%x", ret);
3465 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3467 int ret = CAMERA_ERROR_NONE;
3468 int set_format = (int)format;
3469 camera_msg_param param;
3470 camera_cli_s *pc = (camera_cli_s *)camera;
3471 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3473 if (!pc || !pc->cb_info) {
3474 LOGE("NULL handle");
3475 return CAMERA_ERROR_INVALID_PARAMETER;
3478 LOGD("Enter - capture_format %d", set_format);
3480 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3482 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3484 LOGD("ret : 0x%x", ret);
3490 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3492 int ret = CAMERA_ERROR_NONE;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3494 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3496 if (!pc || !pc->cb_info || !width || !height) {
3497 LOGE("NULL pointer %p %p %p", pc, width, height);
3498 return CAMERA_ERROR_INVALID_PARAMETER;
3503 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3505 if (ret == CAMERA_ERROR_NONE) {
3506 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3507 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3510 LOGD("ret : 0x%x", ret);
3516 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3518 int ret = CAMERA_ERROR_NONE;
3519 int set_rotation = (int)rotation;
3520 camera_cli_s *pc = (camera_cli_s *)camera;
3521 camera_msg_param param;
3523 if (!pc || !pc->cb_info) {
3524 LOGE("NULL handle");
3525 return CAMERA_ERROR_INVALID_PARAMETER;
3528 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3529 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3530 g_mutex_lock(&pc->cb_info->evas_mutex);
3532 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3534 g_mutex_unlock(&pc->cb_info->evas_mutex);
3536 if (ret != MM_ERROR_NONE) {
3537 LOGE("failed to set rotation for evas surface 0x%x", ret);
3538 return CAMERA_ERROR_INVALID_OPERATION;
3541 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3543 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3545 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3551 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3553 int ret = CAMERA_ERROR_NONE;
3554 camera_cli_s *pc = (camera_cli_s *)camera;
3556 if (!pc || !pc->cb_info || !rotation) {
3557 LOGE("NULL pointer %p %p", pc, rotation);
3558 return CAMERA_ERROR_INVALID_PARAMETER;
3561 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3563 if (ret == CAMERA_ERROR_NONE)
3564 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3570 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3572 int ret = CAMERA_ERROR_NONE;
3573 int set_flip = (int)flip;
3574 camera_cli_s *pc = (camera_cli_s *)camera;
3575 camera_msg_param param;
3577 if (!pc || !pc->cb_info) {
3578 LOGE("NULL handle");
3579 return CAMERA_ERROR_INVALID_PARAMETER;
3582 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3583 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3584 g_mutex_lock(&pc->cb_info->evas_mutex);
3586 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3588 g_mutex_unlock(&pc->cb_info->evas_mutex);
3590 if (ret != MM_ERROR_NONE) {
3591 LOGE("failed to set flip for evas surface 0x%x", ret);
3592 return CAMERA_ERROR_INVALID_OPERATION;
3595 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3597 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3599 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3605 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3607 int ret = CAMERA_ERROR_NONE;
3608 camera_cli_s *pc = (camera_cli_s *)camera;
3610 if (!pc || !pc->cb_info || !flip) {
3611 LOGE("NULL pointer %p %p", pc, flip);
3612 return CAMERA_ERROR_INVALID_PARAMETER;
3615 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3617 if (ret == CAMERA_ERROR_NONE)
3618 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3624 int camera_set_display_visible(camera_h camera, bool visible)
3626 int ret = CAMERA_ERROR_NONE;
3627 int set_visible = (int)visible;
3628 camera_cli_s *pc = (camera_cli_s *)camera;
3629 camera_msg_param param;
3631 if (!pc || !pc->cb_info) {
3632 LOGE("NULL handle");
3633 return CAMERA_ERROR_INVALID_PARAMETER;
3636 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3637 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3638 g_mutex_lock(&pc->cb_info->evas_mutex);
3640 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3642 g_mutex_unlock(&pc->cb_info->evas_mutex);
3644 if (ret != MM_ERROR_NONE) {
3645 LOGE("failed to set visible for evas surface 0x%x", ret);
3646 return CAMERA_ERROR_INVALID_OPERATION;
3649 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3651 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3653 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3659 int camera_is_display_visible(camera_h camera, bool *visible)
3661 int ret = CAMERA_ERROR_NONE;
3662 camera_cli_s *pc = (camera_cli_s *)camera;
3664 if (!pc || !pc->cb_info || !visible) {
3665 LOGE("NULL pointer %p %p", pc, visible);
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3669 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3671 if (ret == CAMERA_ERROR_NONE)
3672 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3678 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3680 int ret = CAMERA_ERROR_NONE;
3681 int set_mode = (int)mode;
3682 camera_cli_s *pc = (camera_cli_s *)camera;
3683 camera_msg_param param;
3685 if (!pc || !pc->cb_info) {
3686 LOGE("NULL handle");
3687 return CAMERA_ERROR_INVALID_PARAMETER;
3690 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3691 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3692 g_mutex_lock(&pc->cb_info->evas_mutex);
3694 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3696 g_mutex_unlock(&pc->cb_info->evas_mutex);
3698 if (ret != MM_ERROR_NONE) {
3699 LOGE("failed to set geometry for evas surface 0x%x", ret);
3700 return CAMERA_ERROR_INVALID_OPERATION;
3703 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3705 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3707 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3713 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3715 int ret = CAMERA_ERROR_NONE;
3716 camera_cli_s *pc = (camera_cli_s *)camera;
3718 if (!pc || !pc->cb_info || !mode) {
3719 LOGE("NULL pointer %p %p", pc, mode);
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3723 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3725 if (ret == CAMERA_ERROR_NONE)
3726 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3732 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3734 int ret = CAMERA_ERROR_NONE;
3735 int set_hint = (int)hint;
3736 camera_cli_s *pc = (camera_cli_s *)camera;
3737 camera_msg_param param;
3739 if (!pc || !pc->cb_info) {
3740 LOGE("NULL handle");
3741 return CAMERA_ERROR_INVALID_PARAMETER;
3744 LOGD("Enter - hint %d", set_hint);
3746 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3748 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3754 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3760 if (!pc || !pc->cb_info || !hint) {
3761 LOGE("NULL pointer %p %p", pc, hint);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3765 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3767 if (ret == CAMERA_ERROR_NONE) {
3768 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3769 LOGD("display reuse hint %d", *hint);
3776 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3778 int ret = CAMERA_ERROR_NONE;
3779 camera_cli_s *pc = (camera_cli_s *)camera;
3780 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3782 if (!pc || !pc->cb_info || !width || !height) {
3783 LOGE("NULL pointer %p %p %p", pc, width, height);
3784 return CAMERA_ERROR_INVALID_PARAMETER;
3789 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3791 if (ret == CAMERA_ERROR_NONE) {
3792 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3793 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3796 LOGD("ret : 0x%x", ret);
3802 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3808 if (!pc || !pc->cb_info || !format) {
3809 LOGE("NULL pointer %p %p", pc, format);
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3815 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE)
3818 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3820 LOGD("ret : 0x%x", ret);
3826 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3828 int ret = CAMERA_ERROR_NONE;
3829 camera_cli_s *pc = (camera_cli_s *)camera;
3830 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3832 if (!pc || !pc->cb_info || !format) {
3833 LOGE("NULL pointer %p %p", pc, format);
3834 return CAMERA_ERROR_INVALID_PARAMETER;
3839 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3841 if (ret == CAMERA_ERROR_NONE)
3842 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3844 LOGD("ret : 0x%x", ret);
3850 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3852 int ret = CAMERA_ERROR_NONE;
3853 camera_cli_s *pc = (camera_cli_s *)camera;
3854 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3856 if (!pc || !pc->cb_info || !facing_direction) {
3857 LOGE("NULL pointer %p %p", pc, facing_direction);
3858 return CAMERA_ERROR_INVALID_PARAMETER;
3863 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3865 if (ret == CAMERA_ERROR_NONE)
3866 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3868 LOGD("ret : 0x%x", ret);
3874 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3876 int ret = CAMERA_ERROR_NONE;
3877 camera_cli_s *pc = (camera_cli_s *)camera;
3878 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3880 if (!pc || !pc->cb_info || !callback) {
3881 LOGE("NULL pointer %p %p", pc, callback);
3882 return CAMERA_ERROR_INVALID_PARAMETER;
3887 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3889 if (ret == CAMERA_ERROR_NONE) {
3890 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3895 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3897 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3900 LOGD("ret : 0x%x", ret);
3906 int camera_unset_preview_cb(camera_h camera)
3908 int ret = CAMERA_ERROR_NONE;
3909 camera_cli_s *pc = (camera_cli_s *)camera;
3910 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3912 if (!pc || !pc->cb_info) {
3913 LOGE("NULL handle");
3914 return CAMERA_ERROR_INVALID_PARAMETER;
3919 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3921 if (ret == CAMERA_ERROR_NONE) {
3922 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3924 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3925 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3927 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3929 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3932 LOGD("ret : 0x%x", ret);
3938 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3940 int ret = CAMERA_ERROR_NONE;
3941 camera_cli_s *pc = (camera_cli_s *)camera;
3942 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3944 if (!pc || !pc->cb_info) {
3945 LOGE("NULL handle");
3946 return CAMERA_ERROR_INVALID_PARAMETER;
3949 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3950 LOGE("NOT SUPPORTED");
3951 return CAMERA_ERROR_NOT_SUPPORTED;
3954 if (callback == NULL) {
3955 LOGE("NULL callback");
3956 return CAMERA_ERROR_INVALID_PARAMETER;
3961 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3963 if (ret == CAMERA_ERROR_NONE) {
3964 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3966 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3967 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3969 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3972 LOGD("ret : 0x%x", ret);
3978 int camera_unset_media_packet_preview_cb(camera_h camera)
3980 int ret = CAMERA_ERROR_NONE;
3981 camera_cli_s *pc = (camera_cli_s *)camera;
3982 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3984 if (!pc || !pc->cb_info) {
3985 LOGE("NULL handle");
3986 return CAMERA_ERROR_INVALID_PARAMETER;
3991 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3993 if (ret == CAMERA_ERROR_NONE) {
3994 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3996 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3997 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3999 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
4002 LOGD("ret : 0x%x", ret);
4008 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
4010 int ret = CAMERA_ERROR_NONE;
4011 camera_cli_s *pc = (camera_cli_s *)camera;
4012 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
4014 if (!pc || !pc->cb_info || !callback) {
4015 LOGE("NULL pointer %p %p", pc, callback);
4016 return CAMERA_ERROR_INVALID_PARAMETER;
4021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4023 if (ret == CAMERA_ERROR_NONE) {
4024 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
4027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
4029 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4032 LOGD("ret : 0x%x", ret);
4038 int camera_unset_state_changed_cb(camera_h camera)
4040 int ret = CAMERA_ERROR_NONE;
4041 camera_cli_s *pc = (camera_cli_s *)camera;
4042 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
4044 if (!pc || !pc->cb_info) {
4045 LOGE("NULL handle");
4046 return CAMERA_ERROR_INVALID_PARAMETER;
4051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 if (ret == CAMERA_ERROR_NONE) {
4054 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4059 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4062 LOGD("ret : 0x%x", ret);
4068 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4070 int ret = CAMERA_ERROR_NONE;
4071 camera_cli_s *pc = (camera_cli_s *)camera;
4072 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4074 if (!pc || !pc->cb_info || !callback) {
4075 LOGE("NULL pointer %p %p", pc, callback);
4076 return CAMERA_ERROR_INVALID_PARAMETER;
4081 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4083 if (ret == CAMERA_ERROR_NONE) {
4084 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4086 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4087 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4089 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4092 LOGD("ret : 0x%x", ret);
4098 int camera_unset_interrupted_cb(camera_h camera)
4100 int ret = CAMERA_ERROR_NONE;
4101 camera_cli_s *pc = (camera_cli_s *)camera;
4102 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4104 if (!pc || !pc->cb_info) {
4105 LOGE("NULL handle");
4106 return CAMERA_ERROR_INVALID_PARAMETER;
4111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4113 if (ret == CAMERA_ERROR_NONE) {
4114 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4116 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4117 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4119 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4122 LOGD("ret : 0x%x", ret);
4128 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4130 int ret = CAMERA_ERROR_NONE;
4131 camera_cli_s *pc = (camera_cli_s *)camera;
4132 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4134 if (!pc || !pc->cb_info || !callback) {
4135 LOGE("NULL pointer %p %p", pc, callback);
4136 return CAMERA_ERROR_INVALID_PARAMETER;
4141 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4143 if (ret == CAMERA_ERROR_NONE) {
4144 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4146 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4147 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4149 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4152 LOGD("ret : 0x%x", ret);
4158 int camera_unset_interrupt_started_cb(camera_h camera)
4160 int ret = CAMERA_ERROR_NONE;
4161 camera_cli_s *pc = (camera_cli_s *)camera;
4162 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4164 if (!pc || !pc->cb_info) {
4165 LOGE("NULL handle");
4166 return CAMERA_ERROR_INVALID_PARAMETER;
4171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4173 if (ret == CAMERA_ERROR_NONE) {
4174 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4176 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4177 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4179 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4182 LOGD("ret : 0x%x", ret);
4188 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4190 int ret = CAMERA_ERROR_NONE;
4191 camera_cli_s *pc = (camera_cli_s *)camera;
4192 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4194 if (!pc || !pc->cb_info || !callback) {
4195 LOGE("NULL pointer %p %p", pc, callback);
4196 return CAMERA_ERROR_INVALID_PARAMETER;
4201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4203 if (ret == CAMERA_ERROR_NONE) {
4204 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4206 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4207 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4209 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4212 LOGD("ret : 0x%x", ret);
4218 int camera_unset_focus_changed_cb(camera_h camera)
4220 int ret = CAMERA_ERROR_NONE;
4221 camera_cli_s *pc = (camera_cli_s *)camera;
4222 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4224 if (!pc || !pc->cb_info) {
4225 LOGE("NULL handle");
4226 return CAMERA_ERROR_INVALID_PARAMETER;
4231 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4233 if (ret == CAMERA_ERROR_NONE) {
4234 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4236 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4237 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4239 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4242 LOGD("ret : 0x%x", ret);
4248 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4250 int ret = CAMERA_ERROR_NONE;
4251 camera_cli_s *pc = (camera_cli_s *)camera;
4252 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4254 if (!pc || !pc->cb_info || !callback) {
4255 LOGE("NULL pointer %p %p", pc, callback);
4256 return CAMERA_ERROR_INVALID_PARAMETER;
4261 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4263 if (ret == CAMERA_ERROR_NONE) {
4264 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4266 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4267 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4269 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4272 LOGD("ret : 0x%x", ret);
4278 int camera_unset_error_cb(camera_h camera)
4280 int ret = CAMERA_ERROR_NONE;
4281 camera_cli_s *pc = (camera_cli_s *)camera;
4282 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4284 if (!pc || !pc->cb_info) {
4285 LOGE("NULL handle");
4286 return CAMERA_ERROR_INVALID_PARAMETER;
4291 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4293 if (ret == CAMERA_ERROR_NONE) {
4294 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4296 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4297 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4299 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4302 LOGD("ret : 0x%x", ret);
4308 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4310 int ret = CAMERA_ERROR_NONE;
4311 camera_cli_s *pc = (camera_cli_s *)camera;
4312 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4314 if (!pc || !pc->cb_info || !foreach_cb) {
4315 LOGE("NULL pointer %p %p", pc, foreach_cb);
4316 return CAMERA_ERROR_INVALID_PARAMETER;
4321 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4322 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4324 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4326 LOGD("ret : 0x%x", ret);
4332 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4334 int ret = CAMERA_ERROR_NONE;
4335 camera_cli_s *pc = (camera_cli_s *)camera;
4336 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4338 if (!pc || !pc->cb_info || !foreach_cb) {
4339 LOGE("NULL pointer %p %p", pc, foreach_cb);
4340 return CAMERA_ERROR_INVALID_PARAMETER;
4345 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4346 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4348 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4350 LOGD("ret : 0x%x", ret);
4356 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4358 int ret = CAMERA_ERROR_NONE;
4359 camera_cli_s *pc = (camera_cli_s *)camera;
4360 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4362 if (!pc || !pc->cb_info || !foreach_cb) {
4363 LOGE("NULL pointer %p %p", pc, foreach_cb);
4364 return CAMERA_ERROR_INVALID_PARAMETER;
4369 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4370 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4372 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4374 LOGD("ret : 0x%x", ret);
4380 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4382 int ret = CAMERA_ERROR_NONE;
4383 camera_cli_s *pc = (camera_cli_s *)camera;
4384 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4386 if (!pc || !pc->cb_info || !foreach_cb) {
4387 LOGE("NULL pointer %p %p", pc, foreach_cb);
4388 return CAMERA_ERROR_INVALID_PARAMETER;
4393 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4394 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4396 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4398 LOGD("ret : 0x%x", ret);
4404 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4406 int ret = CAMERA_ERROR_NONE;
4407 camera_cli_s *pc = (camera_cli_s *)camera;
4408 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4410 if (!pc || !pc->cb_info || !width || !height) {
4411 LOGE("NULL pointer %p %p %p", pc, width, height);
4412 return CAMERA_ERROR_INVALID_PARAMETER;
4416 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4418 if (ret == CAMERA_ERROR_NONE) {
4419 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4420 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4423 LOGD("ret : 0x%x", ret);
4429 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4431 int ret = CAMERA_ERROR_NONE;
4432 camera_cli_s *pc = (camera_cli_s *)camera;
4433 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4435 if (!pc || !pc->cb_info || !angle) {
4436 LOGE("NULL pointer %p %p", pc, angle);
4437 return CAMERA_ERROR_INVALID_PARAMETER;
4442 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4444 if (ret == CAMERA_ERROR_NONE)
4445 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4447 LOGD("ret : 0x%x", ret);
4453 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4455 int ret = CAMERA_ERROR_NONE;
4456 camera_cli_s *pc = (camera_cli_s *)camera;
4457 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4458 camera_msg_param param;
4459 int set_mode = (int)mode;
4461 if (!pc || !pc->cb_info) {
4462 LOGE("NULL handle");
4463 return CAMERA_ERROR_INVALID_PARAMETER;
4468 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4470 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4472 LOGD("ret : 0x%x", ret);
4478 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4480 int ret = CAMERA_ERROR_NONE;
4481 camera_cli_s *pc = (camera_cli_s *)camera;
4482 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4484 if (!pc || !pc->cb_info || !mode) {
4485 LOGE("NULL pointer %p %p", pc, mode);
4486 return CAMERA_ERROR_INVALID_PARAMETER;
4491 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4493 if (ret == CAMERA_ERROR_NONE)
4494 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4496 LOGD("ret : 0x%x", ret);
4502 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4504 int ret = CAMERA_ERROR_NONE;
4505 camera_cli_s *pc = (camera_cli_s *)camera;
4506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4508 if (!pc || !pc->cb_info || !foreach_cb) {
4509 LOGE("NULL pointer %p %p", pc, foreach_cb);
4510 return CAMERA_ERROR_INVALID_PARAMETER;
4515 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4516 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4518 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4520 LOGD("Finish, return :%x", ret);
4526 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4528 int ret = CAMERA_ERROR_NONE;
4529 camera_cli_s *pc = (camera_cli_s *)camera;
4530 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4531 camera_msg_param param;
4532 int set_fps = (int)fps;
4534 if (!pc || !pc->cb_info) {
4535 LOGE("NULL handle");
4536 return CAMERA_ERROR_INVALID_PARAMETER;
4541 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4543 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4545 LOGD("ret : 0x%x", ret);
4551 int camera_attr_set_image_quality(camera_h camera, int quality)
4553 int ret = CAMERA_ERROR_NONE;
4554 camera_cli_s *pc = (camera_cli_s *)camera;
4555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4556 camera_msg_param param;
4558 if (!pc || !pc->cb_info) {
4559 LOGE("NULL handle");
4560 return CAMERA_ERROR_INVALID_PARAMETER;
4565 CAMERA_MSG_PARAM_SET(param, INT, quality);
4567 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4569 LOGD("ret : 0x%x", ret);
4575 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4577 int ret = CAMERA_ERROR_NONE;
4578 camera_cli_s *pc = (camera_cli_s *)camera;
4579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4581 if (!pc || !pc->cb_info || !fps) {
4582 LOGE("NULL pointer %p %p", pc, fps);
4583 return CAMERA_ERROR_INVALID_PARAMETER;
4588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4590 if (ret == CAMERA_ERROR_NONE)
4591 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4593 LOGD("ret : 0x%x", ret);
4599 int camera_attr_get_image_quality(camera_h camera, int *quality)
4601 int ret = CAMERA_ERROR_NONE;
4602 camera_cli_s *pc = (camera_cli_s *)camera;
4603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4605 if (!pc || !pc->cb_info || !quality) {
4606 LOGE("NULL pointer %p %p", pc, quality);
4607 return CAMERA_ERROR_INVALID_PARAMETER;
4612 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4614 if (ret == CAMERA_ERROR_NONE)
4615 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4617 LOGD("ret : 0x%x", ret);
4623 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4625 int ret = CAMERA_ERROR_NONE;
4626 camera_cli_s *pc = (camera_cli_s *)camera;
4627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4629 if (!pc || !pc->cb_info || !bitrate) {
4630 LOGE("NULL pointer %p %p", pc, bitrate);
4631 return CAMERA_ERROR_INVALID_PARAMETER;
4636 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4638 if (ret == CAMERA_ERROR_NONE)
4639 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4641 LOGD("ret : 0x%x", ret);
4647 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4649 int ret = CAMERA_ERROR_NONE;
4650 camera_cli_s *pc = (camera_cli_s *)camera;
4651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4652 camera_msg_param param;
4653 int set_bitrate = bitrate;
4655 if (!pc || !pc->cb_info) {
4656 LOGE("NULL handle");
4657 return CAMERA_ERROR_INVALID_PARAMETER;
4662 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4664 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4666 LOGD("ret : 0x%x", ret);
4672 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4674 int ret = CAMERA_ERROR_NONE;
4675 camera_cli_s *pc = (camera_cli_s *)camera;
4676 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4678 if (!pc || !pc->cb_info || !interval) {
4679 LOGE("NULL pointer %p %p", pc, interval);
4680 return CAMERA_ERROR_INVALID_PARAMETER;
4685 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4687 if (ret == CAMERA_ERROR_NONE)
4688 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4690 LOGD("ret : 0x%x", ret);
4696 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4698 int ret = CAMERA_ERROR_NONE;
4699 camera_cli_s *pc = (camera_cli_s *)camera;
4700 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4701 camera_msg_param param;
4702 int set_gop_interval = interval;
4704 if (!pc || !pc->cb_info) {
4705 LOGE("NULL handle");
4706 return CAMERA_ERROR_INVALID_PARAMETER;
4711 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4713 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4715 LOGD("ret : 0x%x", ret);
4721 int camera_attr_set_zoom(camera_h camera, int zoom)
4723 int ret = CAMERA_ERROR_NONE;
4724 camera_cli_s *pc = (camera_cli_s *)camera;
4725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4726 camera_msg_param param;
4728 if (!pc || !pc->cb_info) {
4729 LOGE("NULL handle");
4730 return CAMERA_ERROR_INVALID_PARAMETER;
4733 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4735 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4737 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4739 LOGD("ret : 0x%x", ret);
4745 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4747 int ret = CAMERA_ERROR_NONE;
4748 camera_cli_s *pc = (camera_cli_s *)camera;
4749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4750 camera_msg_param param;
4751 int set_mode = (int)mode;
4753 if (!pc || !pc->cb_info) {
4754 LOGE("NULL handle");
4755 return CAMERA_ERROR_INVALID_PARAMETER;
4758 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4760 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4768 int camera_attr_set_af_area(camera_h camera, int x, int y)
4770 int ret = CAMERA_ERROR_NONE;
4771 camera_cli_s *pc = (camera_cli_s *)camera;
4772 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4773 camera_msg_param param;
4776 if (!pc || !pc->cb_info) {
4777 LOGE("NULL handle");
4778 return CAMERA_ERROR_INVALID_PARAMETER;
4781 LOGD("Enter - %d,%d", x, y);
4783 value = (x << 16) | y;
4784 CAMERA_MSG_PARAM_SET(param, INT, value);
4786 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4788 LOGD("ret : 0x%x", ret);
4794 int camera_attr_clear_af_area(camera_h camera)
4796 int ret = CAMERA_ERROR_NONE;
4797 camera_cli_s *pc = (camera_cli_s *)camera;
4798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4800 if (!pc || !pc->cb_info) {
4801 LOGE("NULL handle");
4802 return CAMERA_ERROR_INVALID_PARAMETER;
4807 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4809 LOGD("ret : 0x%x", ret);
4815 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4817 int ret = CAMERA_ERROR_NONE;
4818 camera_cli_s *pc = (camera_cli_s *)camera;
4819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4820 camera_msg_param param;
4821 int set_mode = (int)mode;
4823 if (!pc || !pc->cb_info) {
4824 LOGE("NULL handle");
4825 return CAMERA_ERROR_INVALID_PARAMETER;
4830 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4834 LOGD("ret : 0x%x", ret);
4840 int camera_attr_set_exposure(camera_h camera, int value)
4842 int ret = CAMERA_ERROR_NONE;
4843 camera_cli_s *pc = (camera_cli_s *)camera;
4844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4845 camera_msg_param param;
4847 if (!pc || !pc->cb_info) {
4848 LOGE("NULL handle");
4849 return CAMERA_ERROR_INVALID_PARAMETER;
4854 CAMERA_MSG_PARAM_SET(param, INT, value);
4856 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4858 LOGD("ret : 0x%x", ret);
4864 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4866 int ret = CAMERA_ERROR_NONE;
4867 camera_cli_s *pc = (camera_cli_s *)camera;
4868 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4869 camera_msg_param param;
4870 int set_iso = (int)iso;
4872 if (!pc || !pc->cb_info) {
4873 LOGE("NULL handle");
4874 return CAMERA_ERROR_INVALID_PARAMETER;
4879 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4881 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4883 LOGD("ret : 0x%x", ret);
4889 int camera_attr_set_brightness(camera_h camera, int level)
4891 int ret = CAMERA_ERROR_NONE;
4892 camera_cli_s *pc = (camera_cli_s *)camera;
4893 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4894 camera_msg_param param;
4896 if (!pc || !pc->cb_info) {
4897 LOGE("NULL handle");
4898 return CAMERA_ERROR_INVALID_PARAMETER;
4903 CAMERA_MSG_PARAM_SET(param, INT, level);
4905 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4907 LOGD("ret : 0x%x", ret);
4913 int camera_attr_set_contrast(camera_h camera, int level)
4915 int ret = CAMERA_ERROR_NONE;
4916 camera_cli_s *pc = (camera_cli_s *)camera;
4917 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4918 camera_msg_param param;
4920 if (!pc || !pc->cb_info) {
4921 LOGE("NULL handle");
4922 return CAMERA_ERROR_INVALID_PARAMETER;
4927 CAMERA_MSG_PARAM_SET(param, INT, level);
4929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4931 LOGD("ret : 0x%x", ret);
4937 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4939 int ret = CAMERA_ERROR_NONE;
4940 camera_cli_s *pc = (camera_cli_s *)camera;
4941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4942 camera_msg_param param;
4943 int set_whitebalance = (int)wb;
4945 if (!pc || !pc->cb_info) {
4946 LOGE("NULL handle");
4947 return CAMERA_ERROR_INVALID_PARAMETER;
4952 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4954 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4956 LOGD("ret : 0x%x", ret);
4962 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4964 int ret = CAMERA_ERROR_NONE;
4965 camera_cli_s *pc = (camera_cli_s *)camera;
4966 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4967 camera_msg_param param;
4968 int set_effect = (int)effect;
4970 if (!pc || !pc->cb_info) {
4971 LOGE("NULL handle");
4972 return CAMERA_ERROR_INVALID_PARAMETER;
4977 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4979 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4981 LOGD("ret : 0x%x", ret);
4987 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4989 int ret = CAMERA_ERROR_NONE;
4990 camera_cli_s *pc = (camera_cli_s *)camera;
4991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4992 camera_msg_param param;
4993 int set_mode = (int)mode;
4995 if (!pc || !pc->cb_info) {
4996 LOGE("NULL handle");
4997 return CAMERA_ERROR_INVALID_PARAMETER;
5002 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5004 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5006 LOGD("ret : 0x%x", ret);
5012 int camera_attr_enable_tag(camera_h camera, bool enable)
5014 int ret = CAMERA_ERROR_NONE;
5015 camera_cli_s *pc = (camera_cli_s *)camera;
5016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
5017 camera_msg_param param;
5018 int set_enable = (int)enable;
5020 if (!pc || !pc->cb_info) {
5021 LOGE("NULL handle");
5022 return CAMERA_ERROR_INVALID_PARAMETER;
5027 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5029 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5031 LOGD("ret : 0x%x", ret);
5037 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
5039 int ret = CAMERA_ERROR_NONE;
5040 camera_cli_s *pc = (camera_cli_s *)camera;
5041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
5042 camera_msg_param param;
5044 if (!pc || !pc->cb_info || !description) {
5045 LOGE("NULL pointer %p %p", pc, description);
5046 return CAMERA_ERROR_INVALID_PARAMETER;
5051 CAMERA_MSG_PARAM_SET(param, STRING, description);
5053 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5055 LOGD("ret : 0x%x", ret);
5061 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
5063 int ret = CAMERA_ERROR_NONE;
5064 camera_cli_s *pc = (camera_cli_s *)camera;
5065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
5066 camera_msg_param param;
5067 int set_orientation = (int)orientation;
5069 if (!pc || !pc->cb_info) {
5070 LOGE("NULL handle");
5071 return CAMERA_ERROR_INVALID_PARAMETER;
5076 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
5078 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5080 LOGD("ret : 0x%x", ret);
5086 int camera_attr_set_tag_software(camera_h camera, const char *software)
5088 int ret = CAMERA_ERROR_NONE;
5089 camera_cli_s *pc = (camera_cli_s *)camera;
5090 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
5091 camera_msg_param param;
5093 if (!pc || !pc->cb_info || !software) {
5094 LOGE("NULL pointer %p %p", pc, software);
5095 return CAMERA_ERROR_INVALID_PARAMETER;
5098 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5100 CAMERA_MSG_PARAM_SET(param, STRING, software);
5102 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5104 LOGD("ret : 0x%x", ret);
5110 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5112 int ret = CAMERA_ERROR_NONE;
5113 camera_cli_s *pc = (camera_cli_s *)camera;
5114 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5115 double set_geotag[3] = {latitude, longitude, altitude};
5120 if (!pc || !pc->cb_info) {
5121 LOGE("NULL handle");
5122 return CAMERA_ERROR_INVALID_PARAMETER;
5127 length = sizeof(set_geotag) / sizeof(int) + \
5128 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5130 msg = muse_core_msg_new(api,
5131 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5134 LOGE("msg creation failed: api %d", api);
5135 return CAMERA_ERROR_OUT_OF_MEMORY;
5138 if (pc->cb_info->is_server_connected) {
5139 __camera_update_api_waiting(pc->cb_info, api, 1);
5141 g_mutex_lock(&pc->cb_info->fd_lock);
5142 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5143 g_mutex_unlock(&pc->cb_info->fd_lock);
5147 LOGE("message send failed");
5148 ret = CAMERA_ERROR_INVALID_OPERATION;
5150 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5153 __camera_update_api_waiting(pc->cb_info, api, -1);
5155 muse_core_msg_free(msg);
5157 LOGD("ret : 0x%x", ret);
5163 int camera_attr_remove_geotag(camera_h camera)
5165 int ret = CAMERA_ERROR_NONE;
5166 camera_cli_s *pc = (camera_cli_s *)camera;
5167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5169 if (!pc || !pc->cb_info) {
5170 LOGE("NULL handle");
5171 return CAMERA_ERROR_INVALID_PARAMETER;
5176 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5178 LOGD("ret : 0x%x", ret);
5184 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5186 int ret = CAMERA_ERROR_NONE;
5187 camera_cli_s *pc = (camera_cli_s *)camera;
5188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5189 camera_msg_param param;
5190 int set_mode = (int)mode;
5192 if (!pc || !pc->cb_info) {
5193 LOGE("NULL handle");
5194 return CAMERA_ERROR_INVALID_PARAMETER;
5199 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5201 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5203 LOGD("ret : 0x%x", ret);
5209 int camera_attr_get_zoom(camera_h camera, int *zoom)
5211 int ret = CAMERA_ERROR_NONE;
5212 camera_cli_s *pc = (camera_cli_s *)camera;
5213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5215 if (!pc || !pc->cb_info || !zoom) {
5216 LOGE("NULL pointer %p %p", pc, zoom);
5217 return CAMERA_ERROR_INVALID_PARAMETER;
5222 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5224 if (ret == CAMERA_ERROR_NONE)
5225 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5227 LOGD("ret : 0x%x", ret);
5233 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5239 if (!pc || !pc->cb_info || !min || !max) {
5240 LOGE("NULL pointer %p %p %p", pc, min, max);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5246 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE) {
5249 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5250 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5253 LOGD("ret : 0x%x", ret);
5259 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5261 int ret = CAMERA_ERROR_NONE;
5262 camera_cli_s *pc = (camera_cli_s *)camera;
5263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5265 if (!pc || !pc->cb_info || !mode) {
5266 LOGE("NULL pointer %p %p", pc, mode);
5267 return CAMERA_ERROR_INVALID_PARAMETER;
5272 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5274 if (ret == CAMERA_ERROR_NONE)
5275 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5277 LOGD("ret : 0x%x", ret);
5283 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5285 int ret = CAMERA_ERROR_NONE;
5286 camera_cli_s *pc = (camera_cli_s *)camera;
5287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5289 if (!pc || !pc->cb_info || !mode) {
5290 LOGE("NULL pointer %p %p", pc, mode);
5291 return CAMERA_ERROR_INVALID_PARAMETER;
5296 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5298 if (ret == CAMERA_ERROR_NONE)
5299 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5301 LOGD("ret : 0x%x", ret);
5307 int camera_attr_get_exposure(camera_h camera, int *value)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5313 if (!pc || !pc->cb_info || !value) {
5314 LOGE("NULL pointer %p %p", pc, value);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5320 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5325 LOGD("ret : 0x%x", ret);
5331 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5337 if (!pc || !pc->cb_info || !min || !max) {
5338 LOGE("NULL pointer %p %p %p", pc, min, max);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5344 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE) {
5347 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5348 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5351 LOGD("ret : 0x%x", ret);
5357 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5363 if (!pc || !pc->cb_info || !iso) {
5364 LOGE("NULL pointer %p %p", pc, iso);
5365 return CAMERA_ERROR_INVALID_PARAMETER;
5370 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 if (ret == CAMERA_ERROR_NONE)
5373 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5375 LOGD("ret : 0x%x", ret);
5381 int camera_attr_get_brightness(camera_h camera, int *level)
5383 int ret = CAMERA_ERROR_NONE;
5384 camera_cli_s *pc = (camera_cli_s *)camera;
5385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5387 if (!pc || !pc->cb_info || !level) {
5388 LOGE("NULL pointer %p %p", pc, level);
5389 return CAMERA_ERROR_INVALID_PARAMETER;
5394 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 if (ret == CAMERA_ERROR_NONE)
5397 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5399 LOGD("ret : 0x%x", ret);
5405 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5407 int ret = CAMERA_ERROR_NONE;
5408 camera_cli_s *pc = (camera_cli_s *)camera;
5409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5411 if (!pc || !pc->cb_info || !min || !max) {
5412 LOGE("NULL pointer %p %p %p", pc, min, max);
5413 return CAMERA_ERROR_INVALID_PARAMETER;
5418 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5420 if (ret == CAMERA_ERROR_NONE) {
5421 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5422 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5425 LOGD("ret : 0x%x", ret);
5431 int camera_attr_get_contrast(camera_h camera, int *level)
5433 int ret = CAMERA_ERROR_NONE;
5434 camera_cli_s *pc = (camera_cli_s *)camera;
5435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5437 if (!pc || !pc->cb_info || !level) {
5438 LOGE("NULL pointer %p %p", pc, level);
5439 return CAMERA_ERROR_INVALID_PARAMETER;
5444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5446 if (ret == CAMERA_ERROR_NONE)
5447 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5449 LOGD("ret : 0x%x", ret);
5455 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5457 int ret = CAMERA_ERROR_NONE;
5458 camera_cli_s *pc = (camera_cli_s *)camera;
5459 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5461 if (!pc || !pc->cb_info || !min || !max) {
5462 LOGE("NULL pointer %p %p %p", pc, min, max);
5463 return CAMERA_ERROR_INVALID_PARAMETER;
5468 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5470 if (ret == CAMERA_ERROR_NONE) {
5471 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5472 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5473 LOGD("min %d, max %d", *min, *max);
5476 LOGD("ret : 0x%x", ret);
5482 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5484 int ret = CAMERA_ERROR_NONE;
5485 camera_cli_s *pc = (camera_cli_s *)camera;
5486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5488 if (!pc || !pc->cb_info || !wb) {
5489 LOGE("NULL pointer %p %p", pc, wb);
5490 return CAMERA_ERROR_INVALID_PARAMETER;
5495 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5497 if (ret == CAMERA_ERROR_NONE)
5498 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5500 LOGD("ret : 0x%x", ret);
5506 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5508 int ret = CAMERA_ERROR_NONE;
5509 camera_cli_s *pc = (camera_cli_s *)camera;
5510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5512 if (!pc || !pc->cb_info || !effect) {
5513 LOGE("NULL pointer %p %p", pc, effect);
5514 return CAMERA_ERROR_INVALID_PARAMETER;
5519 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5521 if (ret == CAMERA_ERROR_NONE)
5522 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5524 LOGD("ret : 0x%x", ret);
5530 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5532 int ret = CAMERA_ERROR_NONE;
5533 camera_cli_s *pc = (camera_cli_s *)camera;
5534 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5536 if (!pc || !pc->cb_info || !mode) {
5537 LOGE("NULL pointer %p %p", pc, mode);
5538 return CAMERA_ERROR_INVALID_PARAMETER;
5543 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5545 if (ret == CAMERA_ERROR_NONE)
5546 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5548 LOGD("ret : 0x%x", ret);
5554 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5556 int ret = CAMERA_ERROR_NONE;
5557 camera_cli_s *pc = (camera_cli_s *)camera;
5558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5560 if (!pc || !pc->cb_info || !enable) {
5561 LOGE("NULL pointer %p %p", pc, enable);
5562 return CAMERA_ERROR_INVALID_PARAMETER;
5567 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5569 if (ret == CAMERA_ERROR_NONE)
5570 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5572 LOGD("ret : 0x%x", ret);
5578 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5580 int ret = CAMERA_ERROR_NONE;
5581 camera_cli_s *pc = (camera_cli_s *)camera;
5582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5584 if (!pc || !pc->cb_info || !description) {
5585 LOGE("NULL pointer %p %p", pc, description);
5586 return CAMERA_ERROR_INVALID_PARAMETER;
5591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5593 if (ret == CAMERA_ERROR_NONE)
5594 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5596 LOGD("ret : 0x%x", ret);
5602 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5604 int ret = CAMERA_ERROR_NONE;
5605 camera_cli_s *pc = (camera_cli_s *)camera;
5606 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5608 if (!pc || !pc->cb_info || !orientation) {
5609 LOGE("NULL pointer %p %p", pc, orientation);
5610 return CAMERA_ERROR_INVALID_PARAMETER;
5615 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5617 if (ret == CAMERA_ERROR_NONE)
5618 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5620 LOGD("ret : 0x%x", ret);
5626 int camera_attr_get_tag_software(camera_h camera, char **software)
5628 int ret = CAMERA_ERROR_NONE;
5629 camera_cli_s *pc = (camera_cli_s *)camera;
5630 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5632 if (!pc || !pc->cb_info || !software) {
5633 LOGE("NULL pointer %p %p", pc, software);
5634 return CAMERA_ERROR_INVALID_PARAMETER;
5639 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5641 if (ret == CAMERA_ERROR_NONE)
5642 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5644 LOGD("ret : 0x%x", ret);
5650 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5652 int ret = CAMERA_ERROR_NONE;
5653 camera_cli_s *pc = (camera_cli_s *)camera;
5654 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5656 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5657 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5658 return CAMERA_ERROR_INVALID_PARAMETER;
5663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5665 if (ret == CAMERA_ERROR_NONE) {
5666 *latitude = pc->cb_info->get_geotag[0];
5667 *longitude = pc->cb_info->get_geotag[1];
5668 *altitude = pc->cb_info->get_geotag[2];
5671 LOGD("ret : 0x%x", ret);
5677 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5679 int ret = CAMERA_ERROR_NONE;
5680 camera_cli_s *pc = (camera_cli_s *)camera;
5681 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5683 if (!pc || !pc->cb_info || !mode) {
5684 LOGE("NULL pointer %p %p", pc, mode);
5685 return CAMERA_ERROR_INVALID_PARAMETER;
5690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5692 if (ret == CAMERA_ERROR_NONE)
5693 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5695 LOGD("ret : 0x%x", ret);
5701 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5703 int ret = CAMERA_ERROR_NONE;
5704 int get_flash_state = 0;
5707 LOGE("NULL pointer");
5708 return CAMERA_ERROR_INVALID_PARAMETER;
5711 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5712 (int)device, "get_flash_state", &get_flash_state);
5714 if (ret == CAMERA_ERROR_NONE) {
5715 *state = (camera_flash_state_e)get_flash_state;
5716 LOGD("flash state %d", *state);
5718 LOGE("failed 0x%x", ret);
5725 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5727 int ret = CAMERA_ERROR_NONE;
5728 camera_cli_s *pc = (camera_cli_s *)camera;
5729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5731 if (!pc || !pc->cb_info || !foreach_cb) {
5732 LOGE("NULL pointer %p %p", pc, foreach_cb);
5733 return CAMERA_ERROR_INVALID_PARAMETER;
5738 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5739 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5741 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5743 LOGD("ret : 0x%x", ret);
5749 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5751 int ret = CAMERA_ERROR_NONE;
5752 camera_cli_s *pc = (camera_cli_s *)camera;
5753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5755 if (!pc || !pc->cb_info || !foreach_cb) {
5756 LOGE("NULL pointer %p %p", pc, foreach_cb);
5757 return CAMERA_ERROR_INVALID_PARAMETER;
5762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5765 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5767 LOGD("ret : 0x%x", ret);
5773 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5775 int ret = CAMERA_ERROR_NONE;
5776 camera_cli_s *pc = (camera_cli_s *)camera;
5777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5779 if (!pc || !pc->cb_info || !foreach_cb) {
5780 LOGE("NULL pointer %p %p", pc, foreach_cb);
5781 return CAMERA_ERROR_INVALID_PARAMETER;
5786 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5787 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5789 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5791 LOGD("ret : 0x%x", ret);
5797 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5799 int ret = CAMERA_ERROR_NONE;
5800 camera_cli_s *pc = (camera_cli_s *)camera;
5801 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5803 if (!pc || !pc->cb_info || !foreach_cb) {
5804 LOGE("NULL pointer %p %p", pc, foreach_cb);
5805 return CAMERA_ERROR_INVALID_PARAMETER;
5810 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5811 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5813 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5815 LOGD("ret : 0x%x", ret);
5821 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5823 int ret = CAMERA_ERROR_NONE;
5824 camera_cli_s *pc = (camera_cli_s *)camera;
5825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5827 if (!pc || !pc->cb_info || !foreach_cb) {
5828 LOGE("NULL pointer %p %p", pc, foreach_cb);
5829 return CAMERA_ERROR_INVALID_PARAMETER;
5834 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5835 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5837 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5839 LOGD("ret : 0x%x", ret);
5845 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5847 int ret = CAMERA_ERROR_NONE;
5848 camera_cli_s *pc = (camera_cli_s *)camera;
5849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5851 if (!pc || !pc->cb_info || !foreach_cb) {
5852 LOGE("NULL pointer %p %p", pc, foreach_cb);
5853 return CAMERA_ERROR_INVALID_PARAMETER;
5858 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5859 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5861 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5863 LOGD("ret : 0x%x", ret);
5869 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5871 int ret = CAMERA_ERROR_NONE;
5872 camera_cli_s *pc = (camera_cli_s *)camera;
5873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5875 if (!pc || !pc->cb_info || !foreach_cb) {
5876 LOGE("NULL pointer %p %p", pc, foreach_cb);
5877 return CAMERA_ERROR_INVALID_PARAMETER;
5882 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5883 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5887 LOGD("ret : 0x%x", ret);
5893 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5895 int ret = CAMERA_ERROR_NONE;
5896 camera_cli_s *pc = (camera_cli_s *)camera;
5897 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5899 if (!pc || !pc->cb_info || !foreach_cb) {
5900 LOGE("NULL pointer %p %p", pc, foreach_cb);
5901 return CAMERA_ERROR_INVALID_PARAMETER;
5906 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5907 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5911 LOGD("Enter, handle :%x", pc->remote_handle);
5917 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)
5919 int ret = CAMERA_ERROR_NONE;
5920 camera_cli_s *pc = (camera_cli_s *)camera;
5921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5922 camera_msg_param param;
5925 if (!pc || !pc->cb_info || !foreach_cb) {
5926 LOGE("NULL pointer %p %p", pc, foreach_cb);
5927 return CAMERA_ERROR_INVALID_PARAMETER;
5932 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5933 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5935 value = (width << 16) | height;
5936 CAMERA_MSG_PARAM_SET(param, INT, value);
5938 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5940 LOGD("ret : 0x%x", ret);
5946 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5948 int ret = CAMERA_ERROR_NONE;
5949 camera_cli_s *pc = (camera_cli_s *)camera;
5950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5952 if (!pc || !pc->cb_info || !foreach_cb) {
5953 LOGE("NULL pointer %p %p", pc, foreach_cb);
5954 return CAMERA_ERROR_INVALID_PARAMETER;
5959 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5960 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5962 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5964 LOGD("ret : 0x%x", ret);
5970 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5972 int ret = CAMERA_ERROR_NONE;
5973 camera_cli_s *pc = (camera_cli_s *)camera;
5974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5976 if (!pc || !pc->cb_info || !foreach_cb) {
5977 LOGE("NULL pointer %p %p", pc, foreach_cb);
5978 return CAMERA_ERROR_INVALID_PARAMETER;
5983 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5984 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5988 LOGD("ret : 0x%x", ret);
5994 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5996 int ret = CAMERA_ERROR_NONE;
5997 camera_cli_s *pc = (camera_cli_s *)camera;
5998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5999 camera_msg_param param;
6000 int set_rotation = (int)rotation;
6002 if (!pc || !pc->cb_info) {
6003 LOGE("NULL handle");
6004 return CAMERA_ERROR_INVALID_PARAMETER;
6009 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
6011 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6013 LOGD("ret : 0x%x", ret);
6019 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6021 int ret = CAMERA_ERROR_NONE;
6022 camera_cli_s *pc = (camera_cli_s *)camera;
6023 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6025 if (!pc || !pc->cb_info || !rotation) {
6026 LOGE("NULL pointer %p %p", pc, rotation);
6027 return CAMERA_ERROR_INVALID_PARAMETER;
6032 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6034 if (ret == CAMERA_ERROR_NONE)
6035 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6037 LOGD("ret : 0x%x", ret);
6043 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6045 int ret = CAMERA_ERROR_NONE;
6046 camera_cli_s *pc = (camera_cli_s *)camera;
6047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6048 camera_msg_param param;
6049 int set_flip = (int)flip;
6051 if (!pc || !pc->cb_info) {
6052 LOGE("NULL handle");
6053 return CAMERA_ERROR_INVALID_PARAMETER;
6058 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6060 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6062 LOGD("ret : 0x%x", ret);
6068 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6070 int ret = CAMERA_ERROR_NONE;
6071 camera_cli_s *pc = (camera_cli_s *)camera;
6072 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6074 if (!pc || !pc->cb_info || !flip) {
6075 LOGE("NULL pointer %p %p", pc, flip);
6076 return CAMERA_ERROR_INVALID_PARAMETER;
6081 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6083 if (ret == CAMERA_ERROR_NONE)
6084 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6086 LOGD("ret : 0x%x", ret);
6091 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6093 int ret = CAMERA_ERROR_NONE;
6094 camera_cli_s *pc = (camera_cli_s *)camera;
6095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6096 camera_msg_param param;
6097 int set_mode = (int)mode;
6099 if (!pc || !pc->cb_info) {
6100 LOGE("NULL handle");
6101 return CAMERA_ERROR_INVALID_PARAMETER;
6106 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6108 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6110 LOGD("ret : 0x%x", ret);
6116 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6118 int ret = CAMERA_ERROR_NONE;
6119 camera_cli_s *pc = (camera_cli_s *)camera;
6120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6122 if (!pc || !pc->cb_info || !mode) {
6123 LOGE("NULL pointer %p %p", pc, mode);
6124 return CAMERA_ERROR_INVALID_PARAMETER;
6129 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6131 if (ret == CAMERA_ERROR_NONE)
6132 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6134 LOGD("ret : 0x%x", ret);
6140 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6142 int ret = CAMERA_ERROR_NONE;
6143 camera_cli_s *pc = (camera_cli_s *)camera;
6144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6146 if (!pc || !pc->cb_info) {
6147 LOGE("NULL handle");
6148 return CAMERA_ERROR_INVALID_PARAMETER;
6153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6156 LOGE("error is occurred 0x%x", ret);
6160 LOGD("ret : %d", ret);
6166 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6168 int ret = CAMERA_ERROR_NONE;
6169 camera_cli_s *pc = (camera_cli_s *)camera;
6170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6172 if (!pc || !pc->cb_info) {
6173 LOGE("NULL handle");
6174 return CAMERA_ERROR_INVALID_PARAMETER;
6179 if (!camera_attr_is_supported_hdr_capture(camera)) {
6180 LOGE("HDR not supported");
6181 return CAMERA_ERROR_NOT_SUPPORTED;
6185 LOGE("NULL callback");
6186 return CAMERA_ERROR_INVALID_PARAMETER;
6189 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6191 if (ret == CAMERA_ERROR_NONE) {
6192 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6194 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6195 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6197 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6200 LOGD("ret : 0x%x", ret);
6206 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6208 int ret = CAMERA_ERROR_NONE;
6209 camera_cli_s *pc = (camera_cli_s *)camera;
6210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6212 if (!pc || !pc->cb_info) {
6213 LOGE("NULL handle");
6214 return CAMERA_ERROR_INVALID_PARAMETER;
6219 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6221 if (ret == CAMERA_ERROR_NONE) {
6222 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6224 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6225 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6227 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6230 LOGD("ret : 0x%x", ret);
6236 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6238 int ret = CAMERA_ERROR_NONE;
6239 camera_cli_s *pc = (camera_cli_s *)camera;
6240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6241 camera_msg_param param;
6242 int set_enable = (int)enable;
6244 if (!pc || !pc->cb_info) {
6245 LOGE("NULL handle");
6246 return CAMERA_ERROR_INVALID_PARAMETER;
6251 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6253 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6255 LOGD("ret : 0x%x", ret);
6261 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6263 int ret = CAMERA_ERROR_NONE;
6264 camera_cli_s *pc = (camera_cli_s *)camera;
6265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6267 if (!pc || !pc->cb_info || !enabled) {
6268 LOGE("NULL pointer %p %p", pc, enabled);
6269 return CAMERA_ERROR_INVALID_PARAMETER;
6274 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6276 if (ret == CAMERA_ERROR_NONE)
6277 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6279 LOGD("ret : 0x%x", ret);
6285 bool camera_attr_is_supported_anti_shake(camera_h camera)
6287 int ret = CAMERA_ERROR_NONE;
6288 camera_cli_s *pc = (camera_cli_s *)camera;
6289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6291 if (!pc || !pc->cb_info) {
6292 LOGE("NULL handle");
6293 return CAMERA_ERROR_INVALID_PARAMETER;
6298 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6301 LOGE("error is occurred 0x%x", ret);
6305 LOGD("ret : %d", ret);
6311 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6313 int ret = CAMERA_ERROR_NONE;
6314 camera_cli_s *pc = (camera_cli_s *)camera;
6315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6316 camera_msg_param param;
6317 int set_enable = (int)enable;
6319 if (!pc || !pc->cb_info) {
6320 LOGE("NULL handle");
6321 return CAMERA_ERROR_INVALID_PARAMETER;
6326 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6328 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6330 LOGD("ret : 0x%x", ret);
6336 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6338 int ret = CAMERA_ERROR_NONE;
6339 camera_cli_s *pc = (camera_cli_s *)camera;
6340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6342 if (!pc || !pc->cb_info || !enabled) {
6343 LOGE("NULL pointer %p %p", pc, enabled);
6344 return CAMERA_ERROR_INVALID_PARAMETER;
6349 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6351 if (ret == CAMERA_ERROR_NONE)
6352 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6354 LOGD("ret : 0x%x", ret);
6360 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6362 int ret = CAMERA_ERROR_NONE;
6363 camera_cli_s *pc = (camera_cli_s *)camera;
6364 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6366 if (!pc || !pc->cb_info) {
6367 LOGE("NULL handle");
6368 return CAMERA_ERROR_INVALID_PARAMETER;
6373 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6376 LOGE("error is occurred 0x%x", ret);
6380 LOGD("ret : %d", ret);
6386 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6388 int ret = CAMERA_ERROR_NONE;
6389 camera_cli_s *pc = (camera_cli_s *)camera;
6390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6391 camera_msg_param param;
6392 int set_enable = (int)enable;
6394 if (!pc || !pc->cb_info) {
6395 LOGE("NULL handle");
6396 return CAMERA_ERROR_INVALID_PARAMETER;
6401 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6403 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6405 LOGD("ret : 0x%x", ret);
6411 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6413 int ret = CAMERA_ERROR_NONE;
6414 camera_cli_s *pc = (camera_cli_s *)camera;
6415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6417 if (!pc || !pc->cb_info || !enabled) {
6418 LOGE("NULL pointer %p %p", pc, enabled);
6419 return CAMERA_ERROR_INVALID_PARAMETER;
6424 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6426 if (ret == CAMERA_ERROR_NONE)
6427 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6429 LOGD("ret : 0x%x", ret);
6435 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6437 int ret = CAMERA_ERROR_NONE;
6438 camera_cli_s *pc = (camera_cli_s *)camera;
6439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6441 if (!pc || !pc->cb_info) {
6442 LOGE("NULL handle");
6443 return CAMERA_ERROR_INVALID_PARAMETER;
6448 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6451 LOGE("error is occurred 0x%x", ret);
6455 LOGD("ret : %d", ret);
6461 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6463 int ret = CAMERA_ERROR_NONE;
6464 camera_cli_s *pc = (camera_cli_s *)camera;
6465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6466 camera_msg_param param;
6467 int set_disable = (int)disable;
6469 if (!pc || !pc->cb_info) {
6470 LOGE("NULL handle");
6471 return CAMERA_ERROR_INVALID_PARAMETER;
6476 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6478 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6480 LOGD("ret : 0x%x", ret);
6486 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6488 int ret = CAMERA_ERROR_NONE;
6489 camera_cli_s *pc = (camera_cli_s *)camera;
6490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6491 camera_msg_param param;
6492 int set_move_type = (int)move_type;
6495 if (!pc || !pc->cb_info) {
6496 LOGE("NULL handle");
6497 return CAMERA_ERROR_INVALID_PARAMETER;
6502 value = (set_move_type << 16) | pan_step;
6503 CAMERA_MSG_PARAM_SET(param, INT, value);
6505 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6507 LOGD("ret : 0x%x", ret);
6513 int camera_attr_get_pan(camera_h camera, int *pan_step)
6515 int ret = CAMERA_ERROR_NONE;
6516 camera_cli_s *pc = (camera_cli_s *)camera;
6517 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6519 if (!pc || !pc->cb_info || !pan_step) {
6520 LOGE("NULL pointer %p %p", pc, pan_step);
6521 return CAMERA_ERROR_INVALID_PARAMETER;
6526 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6528 if (ret == CAMERA_ERROR_NONE)
6529 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6531 LOGD("ret : 0x%x", ret);
6537 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6539 int ret = CAMERA_ERROR_NONE;
6540 camera_cli_s *pc = (camera_cli_s *)camera;
6541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6543 if (!pc || !pc->cb_info || !min || !max) {
6544 LOGE("NULL pointer %p %p %p", pc, min, max);
6545 return CAMERA_ERROR_INVALID_PARAMETER;
6550 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6552 if (ret == CAMERA_ERROR_NONE) {
6553 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6554 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6557 LOGD("ret : 0x%x", ret);
6563 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6565 int ret = CAMERA_ERROR_NONE;
6566 camera_cli_s *pc = (camera_cli_s *)camera;
6567 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6568 camera_msg_param param;
6569 int set_move_type = (int)move_type;
6572 if (!pc || !pc->cb_info) {
6573 LOGE("NULL handle");
6574 return CAMERA_ERROR_INVALID_PARAMETER;
6579 value = (set_move_type << 16) | tilt_step;
6580 CAMERA_MSG_PARAM_SET(param, INT, value);
6582 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6584 LOGD("ret : 0x%x", ret);
6590 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6592 int ret = CAMERA_ERROR_NONE;
6593 camera_cli_s *pc = (camera_cli_s *)camera;
6594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6596 if (!pc || !pc->cb_info || !tilt_step) {
6597 LOGE("NULL pointer %p %p", pc, tilt_step);
6598 return CAMERA_ERROR_INVALID_PARAMETER;
6603 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6605 if (ret == CAMERA_ERROR_NONE)
6606 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6608 LOGD("ret : 0x%x", ret);
6614 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6616 int ret = CAMERA_ERROR_NONE;
6617 camera_cli_s *pc = (camera_cli_s *)camera;
6618 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6620 if (!pc || !pc->cb_info || !min || !max) {
6621 LOGE("NULL pointer %p %p %p", pc, min, max);
6622 return CAMERA_ERROR_INVALID_PARAMETER;
6627 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6629 if (ret == CAMERA_ERROR_NONE) {
6630 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6631 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6634 LOGD("ret : 0x%x", ret);
6640 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6642 int ret = CAMERA_ERROR_NONE;
6643 camera_cli_s *pc = (camera_cli_s *)camera;
6644 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6645 camera_msg_param param;
6646 int set_ptz_type = (int)ptz_type;
6648 if (!pc || !pc->cb_info) {
6649 LOGE("NULL handle");
6650 return CAMERA_ERROR_INVALID_PARAMETER;
6655 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6659 LOGD("ret : 0x%x", ret);
6665 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6667 int ret = CAMERA_ERROR_NONE;
6668 camera_cli_s *pc = (camera_cli_s *)camera;
6669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6671 if (!pc || !pc->cb_info || !foreach_cb) {
6672 LOGE("NULL pointer %p %p", pc, foreach_cb);
6673 return CAMERA_ERROR_INVALID_PARAMETER;
6678 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6679 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6681 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6683 LOGD("ret : 0x%x", ret);
6689 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6691 int ret = CAMERA_ERROR_NONE;
6692 camera_cli_s *pc = (camera_cli_s *)camera;
6693 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6694 int set_display_roi_area[4] = {x, y, width, height};
6699 if (!pc || !pc->cb_info) {
6700 LOGE("NULL handle");
6701 return CAMERA_ERROR_INVALID_PARAMETER;
6706 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6707 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6708 g_mutex_lock(&pc->cb_info->evas_mutex);
6710 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6712 g_mutex_unlock(&pc->cb_info->evas_mutex);
6714 if (ret != MM_ERROR_NONE) {
6715 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6716 return CAMERA_ERROR_INVALID_OPERATION;
6719 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6721 length = sizeof(set_display_roi_area) / sizeof(int) + \
6722 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6724 msg = muse_core_msg_new(api,
6725 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6728 LOGE("msg creation failed: api %d", api);
6729 return CAMERA_ERROR_OUT_OF_MEMORY;
6732 if (pc->cb_info->is_server_connected) {
6733 __camera_update_api_waiting(pc->cb_info, api, 1);
6735 g_mutex_lock(&pc->cb_info->fd_lock);
6736 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6737 g_mutex_unlock(&pc->cb_info->fd_lock);
6741 LOGE("message send failed");
6742 ret = CAMERA_ERROR_INVALID_OPERATION;
6744 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6747 __camera_update_api_waiting(pc->cb_info, api, -1);
6749 muse_core_msg_free(msg);
6751 LOGD("ret : 0x%x", ret);
6757 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6759 camera_cli_s *pc = (camera_cli_s *)camera;
6760 int ret = CAMERA_ERROR_NONE;
6761 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6763 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6764 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6765 return CAMERA_ERROR_INVALID_PARAMETER;
6770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6772 if (ret == CAMERA_ERROR_NONE) {
6773 *x = pc->cb_info->get_display_roi_area[0];
6774 *y = pc->cb_info->get_display_roi_area[1];
6775 *width = pc->cb_info->get_display_roi_area[2];
6776 *height = pc->cb_info->get_display_roi_area[3];
6779 LOGD("ret : 0x%x", ret);
6785 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6787 int ret = CAMERA_ERROR_NONE;
6788 int get_device_state = 0;
6791 LOGE("NULL pointer");
6792 return CAMERA_ERROR_INVALID_PARAMETER;
6795 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6796 (int)device, "get_device_state", &get_device_state);
6798 if (ret == CAMERA_ERROR_NONE) {
6799 *state = (camera_device_state_e)get_device_state;
6800 LOGD("device state %d", *state);
6802 LOGE("failed 0x%x", ret);
6809 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6811 int ret = CAMERA_ERROR_NONE;
6812 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6813 camera_cb_info *info = NULL;
6815 if (!callback || !cb_id) {
6816 LOGE("invalid pointer %p %p", callback, cb_id);
6817 return CAMERA_ERROR_INVALID_PARAMETER;
6820 /* check camera support */
6821 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6822 if (ret != CAMERA_ERROR_NONE) {
6823 LOGE("get device state failed");
6827 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6829 info = g_new0(camera_cb_info, 1);
6831 LOGE("info failed");
6832 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6836 info->id = ++g_cam_dev_state_changed_cb_id;
6837 info->callback = (void *)callback;
6838 info->user_data = user_data;
6842 /* subscribe dbus signal for camera state change */
6843 if (!g_cam_dev_state_changed_cb_conn) {
6844 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6845 if (!g_cam_dev_state_changed_cb_conn) {
6846 LOGE("failed to get gdbus connection");
6847 ret = CAMERA_ERROR_INVALID_OPERATION;
6851 LOGD("subscribe signal %s - %s - %s",
6852 MM_CAMCORDER_DBUS_OBJECT,
6853 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6854 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6856 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6857 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6858 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6859 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6860 LOGE("failed to get gdbus connection");
6861 ret = CAMERA_ERROR_INVALID_OPERATION;
6865 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6868 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6870 LOGD("callback id %d", info->id);
6873 if (ret != CAMERA_ERROR_NONE) {
6879 if (g_cam_dev_state_changed_cb_conn) {
6880 g_object_unref(g_cam_dev_state_changed_cb_conn);
6881 g_cam_dev_state_changed_cb_conn = NULL;
6885 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6891 int camera_remove_device_state_changed_cb(int cb_id)
6893 int ret = CAMERA_ERROR_NONE;
6894 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6895 GList *tmp_list = NULL;
6896 camera_cb_info *info = NULL;
6898 /* check camera support */
6899 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6900 if (ret != CAMERA_ERROR_NONE) {
6901 LOGE("get device state failed");
6905 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6907 if (!g_cam_dev_state_changed_cb_list) {
6908 LOGE("there is no callback info");
6909 ret = CAMERA_ERROR_INVALID_OPERATION;
6913 tmp_list = g_cam_dev_state_changed_cb_list;
6916 info = tmp_list->data;
6917 tmp_list = tmp_list->next;
6924 if (info->id == cb_id) {
6925 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6930 if (!g_cam_dev_state_changed_cb_list) {
6931 /* no remained callback */
6932 if (g_cam_dev_state_changed_cb_conn) {
6933 /* unsubscribe signal */
6934 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6935 g_cam_dev_state_changed_cb_subscribe_id = 0;
6937 /* unref connection */
6938 g_object_unref(g_cam_dev_state_changed_cb_conn);
6939 g_cam_dev_state_changed_cb_conn = NULL;
6943 LOGD("id %d callback removed", cb_id);
6944 ret = CAMERA_ERROR_NONE;
6950 LOGE("id %d callback not found", cb_id);
6951 ret = CAMERA_ERROR_INVALID_PARAMETER;
6954 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);