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 wl_info->evas_obj = obj;
224 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
225 &wl_info->window_width, &wl_info->window_height);
227 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
229 rotation = ecore_evas_rotation_get(ecore_evas);
230 if (rotation == 90 || rotation == 270) {
231 int temp = wl_info->window_width;
233 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
235 wl_info->window_width = wl_info->window_height;
236 wl_info->window_height = temp;
239 LOGW("failed to get ecore_evas.. skip rotation check");
242 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
243 wl_info->evas_obj, rotation, wl_info->parent_id,
244 wl_info->window_x, wl_info->window_y,
245 wl_info->window_width, wl_info->window_height);
247 ret = CAMERA_ERROR_INVALID_OPERATION;
248 LOGE("failed to get parent id");
253 tizen_surface_destroy(tz_surface);
258 tizen_resource_destroy(tz_resource);
263 wl_registry_destroy(registry);
268 wl_event_queue_destroy(queue);
272 if (display_wrapper) {
273 wl_proxy_wrapper_destroy(display_wrapper);
274 display_wrapper = NULL;
281 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
284 api < 0 || api >= MUSE_CAMERA_API_MAX) {
285 LOGE("invalid param %p %d", cb_info, api);
289 g_mutex_lock(&(cb_info->api_mutex[api]));
290 cb_info->api_waiting[api] += value;
291 g_mutex_unlock(&(cb_info->api_mutex[api]));
293 /*LOGD("api %d, value %d, waiting %d",
294 api, value, cb_info->api_waiting[api]);*/
300 static void __camera_device_state_changed_cb(GDBusConnection *connection,
301 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
302 const gchar *signal_name, GVariant *param, gpointer user_data)
305 camera_device_e device = CAMERA_DEVICE_CAMERA0;
306 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
307 GList *tmp_list = NULL;
308 camera_cb_info *info = NULL;
310 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
312 if (!g_cam_dev_state_changed_cb_list || !param) {
313 LOGW("no callback or NULL param %p", param);
317 /* get device and state */
318 g_variant_get(param, "(i)", &value);
320 device = value >> 16;
321 state = 0x0000ffff & value;
323 LOGD("device %d, state %d", device, state);
325 tmp_list = g_cam_dev_state_changed_cb_list;
328 info = (camera_cb_info *)tmp_list->data;
331 if (info->callback) {
332 LOGD("start id[%d] callback", info->id);
333 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
334 LOGD("returned id[%d] callback", info->id);
336 LOGW("NULL callback for id %d", info->id);
340 tmp_list = tmp_list->next;
344 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
350 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
354 int num_buffer_key = 0;
355 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
358 unsigned char *buf_pos = NULL;
359 camera_msg_param param;
362 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
363 tbm_bo_handle bo_handle = {.ptr = NULL};
364 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
365 tbm_bo data_bo = NULL;
366 tbm_bo_handle data_bo_handle = {.ptr = NULL};
368 camera_preview_data_s frame;
369 camera_stream_data_s *stream = NULL;
370 camera_media_packet_data *mp_data = NULL;
371 media_packet_h pkt = NULL;
372 #ifdef TIZEN_FEATURE_EVAS_RENDERER
373 media_packet_h pkt_evas = NULL;
374 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
376 if (!cb_info || !recv_msg) {
377 LOGE("invalid param %p %p", cb_info, recv_msg);
381 muse_camera_msg_get(tbm_key, recv_msg);
382 muse_camera_msg_get(num_buffer_key, recv_msg);
383 muse_camera_msg_get_array(buffer_key, recv_msg);
384 muse_camera_msg_get(data_key, recv_msg);
386 memset(&frame, 0x0, sizeof(camera_preview_data_s));
389 LOGE("invalid key %d", tbm_key);
393 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
395 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
396 LOGE("invalid num buffer key %d", num_buffer_key);
397 goto _PREVIEW_CB_HANDLER_DONE;
401 /* import tbm data_bo and get virtual address */
402 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
403 LOGE("failed to import data key %d", data_key);
404 goto _PREVIEW_CB_HANDLER_DONE;
408 /* import tbm bo and get virtual address */
409 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
410 LOGE("failed to import key %d", tbm_key);
411 goto _PREVIEW_CB_HANDLER_DONE;
414 buf_pos = (unsigned char *)bo_handle.ptr;
416 /* get stream info */
417 stream = (camera_stream_data_s *)buf_pos;
419 for (i = 0 ; i < num_buffer_key ; i++) {
420 /* import buffer bo and get virtual address */
421 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
422 LOGE("failed to import buffer key %d", buffer_key[i]);
423 goto _PREVIEW_CB_HANDLER_DONE;
427 /* call preview callback */
428 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
429 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
431 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
432 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
435 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
436 #ifdef TIZEN_FEATURE_EVAS_RENDERER
437 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
439 if (ret == CAMERA_ERROR_NONE) {
440 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
441 if (ret != CAMERA_ERROR_NONE) {
442 LOGE("create pkt for evas failed");
443 _camera_media_packet_data_release(mp_data, cb_info);
447 #else /* TIZEN_FEATURE_EVAS_RENDERER */
448 LOGW("evas renderer is not supported");
449 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
452 /* call media packet callback */
453 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
454 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
456 if (ret == CAMERA_ERROR_NONE) {
457 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
459 if (ret == CAMERA_ERROR_NONE) {
460 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
461 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
463 _camera_media_packet_data_release(mp_data, cb_info);
469 #ifdef TIZEN_FEATURE_EVAS_RENDERER
470 /* call evas renderer */
472 g_mutex_lock(&cb_info->evas_mutex);
473 if (cb_info->run_evas_render) {
474 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
476 LOGW("evas renderer is stopped, skip this buffer...");
477 media_packet_destroy(pkt_evas);
480 g_mutex_unlock(&cb_info->evas_mutex);
482 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
484 /* send message for preview callback return */
485 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
486 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
488 _PREVIEW_CB_HANDLER_DONE:
489 if (mp_data == NULL) {
490 /* release imported bo */
491 for (i = 0 ; i < num_buffer_key ; i++)
492 _camera_release_imported_bo(&buffer_bo[i]);
494 /* unmap and unref tbm bo */
495 _camera_release_imported_bo(&data_bo);
496 _camera_release_imported_bo(&bo);
499 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
501 /*LOGD("return buffer Done");*/
508 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
511 int tbm_key_main = 0;
512 int tbm_key_post = 0;
513 int tbm_key_thumb = 0;
514 unsigned char *buf_pos = NULL;
516 camera_msg_param param;
517 camera_image_data_s *rImage = NULL;
518 camera_image_data_s *rPostview = NULL;
519 camera_image_data_s *rThumbnail = NULL;
521 tbm_bo bo_main = NULL;
522 tbm_bo bo_post = NULL;
523 tbm_bo bo_thumb = NULL;
524 tbm_bo_handle bo_main_handle = {.ptr = NULL};
525 tbm_bo_handle bo_post_handle = {.ptr = NULL};
526 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
528 if (!cb_info || !recv_msg) {
529 LOGE("invalid param %p %p", cb_info, recv_msg);
533 muse_camera_msg_get(tbm_key_main, recv_msg);
534 muse_camera_msg_get(tbm_key_post, recv_msg);
535 muse_camera_msg_get(tbm_key_thumb, recv_msg);
538 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
539 tbm_key_main, tbm_key_post, tbm_key_thumb);
542 if (tbm_key_main <= 0) {
543 LOGE("invalid key %d", tbm_key_main);
544 goto _CAPTURE_CB_HANDLER_DONE;
547 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
548 LOGW("NULL callback");
549 goto _CAPTURE_CB_HANDLER_DONE;
552 /* import tbm bo and get virtual address */
553 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
554 LOGE("failed to import key [%d] for main", tbm_key_main);
555 goto _CAPTURE_CB_HANDLER_DONE;
558 buf_pos = (unsigned char *)bo_main_handle.ptr;
559 rImage = (camera_image_data_s *)buf_pos;
560 rImage->data = buf_pos + sizeof(camera_image_data_s);
561 if (rImage->exif && rImage->exif_size > 0) {
562 rImage->exif = rImage->data + rImage->size;
565 rImage->exif_size = 0;
568 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
569 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
571 if (tbm_key_post > 0) {
572 /* import tbm bo and get virtual address */
573 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
574 buf_pos = (unsigned char *)bo_post_handle.ptr;
575 rPostview = (camera_image_data_s *)buf_pos;
576 LOGD("rPostview->size : %d", rPostview->size);
577 rPostview->data = buf_pos + sizeof(camera_image_data_s);
579 LOGE("failed to import key [%d] for postview", tbm_key_post);
583 if (tbm_key_thumb > 0) {
584 /* import tbm bo and get virtual address */
585 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
586 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
587 rThumbnail = (camera_image_data_s *)buf_pos;
588 LOGD("rThumbnail->size : %d", rThumbnail->size);
589 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
591 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
595 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
596 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
598 _CAPTURE_CB_HANDLER_DONE:
600 if (tbm_key_main > 0) {
601 _camera_release_imported_bo(&bo_main);
603 tbm_key = tbm_key_main;
604 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
606 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
609 if (tbm_key_post > 0) {
610 _camera_release_imported_bo(&bo_post);
612 tbm_key = tbm_key_post;
613 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
615 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
618 if (tbm_key_thumb > 0) {
619 _camera_release_imported_bo(&bo_thumb);
621 tbm_key = tbm_key_thumb;
622 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
624 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
627 LOGD("return buffer done");
633 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
637 camera_detected_face_s *faces = NULL;
638 camera_msg_param param;
641 tbm_bo_handle bo_handle = {.ptr = NULL};
643 if (!cb_info || !recv_msg) {
644 LOGE("invalid param %p %p", cb_info, recv_msg);
648 muse_camera_msg_get(count, recv_msg);
649 muse_camera_msg_get(tbm_key, recv_msg);
651 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
652 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
656 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
658 faces = bo_handle.ptr;
662 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
663 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
666 _camera_release_imported_bo(&bo);
668 LOGW("skip face detection message [count %d, key %d, cb %p",
669 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
674 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
675 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
676 /*LOGD("return buffer done");*/
683 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
685 tbm_bo tmp_bo = NULL;
686 tbm_bo_handle tmp_bo_handle = {NULL, };
688 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
689 LOGE("invalid parameter - %p %p %p, key %d",
690 bufmgr, bo, bo_handle, tbm_key);
694 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
695 if (tmp_bo == NULL) {
696 LOGE("import failed - key %d", tbm_key);
700 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
701 if (tmp_bo_handle.ptr == NULL) {
702 LOGE("map failed %p", tmp_bo);
703 tbm_bo_unref(tmp_bo);
708 tbm_bo_unmap(tmp_bo);
710 /* set bo and bo_handle */
712 *bo_handle = tmp_bo_handle;
717 static void _camera_release_imported_bo(tbm_bo *bo)
730 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
732 int ret = CAMERA_ERROR_NONE;
735 /*LOGD("Enter api : %d", api);*/
737 if (!cb_info->is_server_connected) {
738 LOGE("server is disconnected");
739 return CAMERA_ERROR_SERVICE_DISCONNECTED;
742 g_mutex_lock(&(cb_info->api_mutex[api]));
744 if (cb_info->api_activating[api] == 0) {
745 if (time_out == CAMERA_CB_NO_TIMEOUT) {
746 LOGW("wait for api %d", api);
747 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
748 ret = cb_info->api_ret[api];
749 cb_info->api_activating[api] = 0;
750 LOGW("api %d returned 0x%x", api, ret);
752 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
753 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
754 ret = cb_info->api_ret[api];
755 cb_info->api_activating[api] = 0;
756 /*LOGD("return value : 0x%x", ret);*/
758 ret = CAMERA_ERROR_INVALID_OPERATION;
759 LOGE("api %d was TIMED OUT!", api);
763 ret = cb_info->api_ret[api];
764 cb_info->api_activating[api] = 0;
766 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
769 g_mutex_unlock(&(cb_info->api_mutex[api]));
771 if (ret != CAMERA_ERROR_NONE) {
772 LOGE("api %d : error 0x%x", api, ret);
774 if (ret == CAMERA_ERROR_SOUND_POLICY)
775 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
776 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
777 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
778 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
779 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
786 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
787 int *ret, int timeout)
793 LOGE("NULL info - api %d", api);
796 *ret = CAMERA_ERROR_INVALID_PARAMETER;
801 msg = muse_core_msg_new(api, NULL);
803 LOGE("msg failed: api %d", api);
806 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
811 /*LOGD("send msg %s", msg);*/
813 if (cb_info->is_server_connected) {
814 __camera_update_api_waiting(cb_info, api, 1);
816 g_mutex_lock(&cb_info->fd_lock);
817 send_ret = muse_core_msg_send(cb_info->fd, msg);
818 g_mutex_unlock(&cb_info->fd_lock);
822 LOGE("msg send failed");
824 *ret = CAMERA_ERROR_INVALID_OPERATION;
827 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
830 __camera_update_api_waiting(cb_info, api, -1);
832 muse_core_msg_free(msg);
838 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
839 int *ret, camera_msg_param *param, int timeout)
844 if (!cb_info || !param) {
845 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
848 *ret = CAMERA_ERROR_INVALID_PARAMETER;
853 /*LOGD("type %d, name %s", param->type, param->name);*/
855 switch (param->type) {
857 msg = muse_core_msg_new(api,
858 param->type, param->name, param->value.value_INT,
861 case MUSE_TYPE_STRING:
862 msg = muse_core_msg_new(api,
863 param->type, param->name, param->value.value_STRING,
867 LOGE("unknown type %d", param->type);
872 LOGE("msg failed: api %d", api);
875 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
880 /*LOGD("send msg %s", msg);*/
882 if (cb_info->is_server_connected) {
883 __camera_update_api_waiting(cb_info, api, 1);
885 g_mutex_lock(&cb_info->fd_lock);
886 send_ret = muse_core_msg_send(cb_info->fd, msg);
887 g_mutex_unlock(&cb_info->fd_lock);
891 LOGE("msg send failed");
894 *ret = CAMERA_ERROR_INVALID_OPERATION;
897 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
900 __camera_update_api_waiting(cb_info, api, -1);
902 muse_core_msg_free(msg);
908 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
910 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
911 in_format >= MM_PIXEL_FORMAT_NUM ||
912 out_format == NULL) {
913 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
914 return CAMERA_ERROR_INVALID_PARAMETER;
918 case MM_PIXEL_FORMAT_NV12:
919 case MM_PIXEL_FORMAT_NV12T:
920 *out_format = TBM_FORMAT_NV12;
922 case MM_PIXEL_FORMAT_NV16:
923 *out_format = TBM_FORMAT_NV16;
925 case MM_PIXEL_FORMAT_NV21:
926 *out_format = TBM_FORMAT_NV21;
928 case MM_PIXEL_FORMAT_YUYV:
929 *out_format = TBM_FORMAT_YUYV;
931 case MM_PIXEL_FORMAT_UYVY:
932 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
933 *out_format = TBM_FORMAT_UYVY;
935 case MM_PIXEL_FORMAT_422P:
936 *out_format = TBM_FORMAT_YUV422;
938 case MM_PIXEL_FORMAT_I420:
939 *out_format = TBM_FORMAT_YUV420;
941 case MM_PIXEL_FORMAT_YV12:
942 *out_format = TBM_FORMAT_YVU420;
944 case MM_PIXEL_FORMAT_RGB565:
945 *out_format = TBM_FORMAT_RGB565;
947 case MM_PIXEL_FORMAT_RGB888:
948 *out_format = TBM_FORMAT_RGB888;
950 case MM_PIXEL_FORMAT_RGBA:
951 *out_format = TBM_FORMAT_RGBA8888;
953 case MM_PIXEL_FORMAT_ARGB:
954 *out_format = TBM_FORMAT_ARGB8888;
957 LOGE("invalid in_format %d", in_format);
958 return CAMERA_ERROR_INVALID_PARAMETER;
961 return CAMERA_ERROR_NONE;
965 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
967 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
968 in_format >= MM_PIXEL_FORMAT_NUM ||
970 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
971 return CAMERA_ERROR_INVALID_PARAMETER;
975 case MM_PIXEL_FORMAT_NV12:
976 case MM_PIXEL_FORMAT_NV12T:
977 *mimetype = MEDIA_FORMAT_NV12;
979 case MM_PIXEL_FORMAT_NV16:
980 *mimetype = MEDIA_FORMAT_NV16;
982 case MM_PIXEL_FORMAT_NV21:
983 *mimetype = MEDIA_FORMAT_NV21;
985 case MM_PIXEL_FORMAT_YUYV:
986 *mimetype = MEDIA_FORMAT_YUYV;
988 case MM_PIXEL_FORMAT_UYVY:
989 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
990 *mimetype = MEDIA_FORMAT_UYVY;
992 case MM_PIXEL_FORMAT_422P:
993 *mimetype = MEDIA_FORMAT_422P;
995 case MM_PIXEL_FORMAT_I420:
996 *mimetype = MEDIA_FORMAT_I420;
998 case MM_PIXEL_FORMAT_YV12:
999 *mimetype = MEDIA_FORMAT_YV12;
1001 case MM_PIXEL_FORMAT_RGB565:
1002 *mimetype = MEDIA_FORMAT_RGB565;
1004 case MM_PIXEL_FORMAT_RGB888:
1005 *mimetype = MEDIA_FORMAT_RGB888;
1007 case MM_PIXEL_FORMAT_RGBA:
1008 *mimetype = MEDIA_FORMAT_RGBA;
1010 case MM_PIXEL_FORMAT_ARGB:
1011 *mimetype = MEDIA_FORMAT_ARGB;
1014 LOGE("invalid in_format %d", in_format);
1015 return CAMERA_ERROR_INVALID_PARAMETER;
1018 return CAMERA_ERROR_NONE;
1021 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
1022 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
1025 unsigned char *buf_pos = NULL;
1027 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
1028 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
1032 /* set frame info */
1033 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
1034 frame->format = MM_PIXEL_FORMAT_UYVY;
1036 frame->format = stream->format;
1038 frame->width = stream->width;
1039 frame->height = stream->height;
1040 frame->timestamp = stream->timestamp;
1041 frame->num_of_planes = stream->num_planes;
1043 if (num_buffer_key == 0) {
1045 if (!data_bo_handle || !data_bo_handle->ptr) {
1046 LOGE("NULL pointer");
1050 buf_pos = data_bo_handle->ptr;
1052 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
1053 frame->data.encoded_plane.data = buf_pos;
1054 frame->data.encoded_plane.size = stream->data.encoded.length_data;
1055 total_size = stream->data.encoded.length_data;
1057 switch (stream->num_planes) {
1059 frame->data.single_plane.yuv = buf_pos;
1060 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1061 total_size = stream->data.yuv420.length_yuv;
1064 frame->data.double_plane.y = buf_pos;
1065 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1066 buf_pos += stream->data.yuv420sp.length_y;
1067 frame->data.double_plane.uv = buf_pos;
1068 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1069 total_size = stream->data.yuv420sp.length_y + \
1070 stream->data.yuv420sp.length_uv;
1073 frame->data.triple_plane.y = buf_pos;
1074 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1075 buf_pos += stream->data.yuv420p.length_y;
1076 frame->data.triple_plane.u = buf_pos;
1077 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1078 buf_pos += stream->data.yuv420p.length_u;
1079 frame->data.triple_plane.v = buf_pos;
1080 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1081 total_size = stream->data.yuv420p.length_y + \
1082 stream->data.yuv420p.length_u + \
1083 stream->data.yuv420p.length_v;
1091 switch (stream->num_planes) {
1093 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
1094 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
1095 total_size = stream->data.yuv420.length_yuv;
1098 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
1099 if (stream->num_planes == (unsigned int)num_buffer_key)
1100 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
1102 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
1103 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
1104 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
1105 total_size = stream->data.yuv420sp.length_y + \
1106 stream->data.yuv420sp.length_uv;
1109 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
1110 if (stream->num_planes == (unsigned int)num_buffer_key) {
1111 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
1112 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
1114 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
1115 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
1117 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
1118 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
1119 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
1120 total_size = stream->data.yuv420p.length_y + \
1121 stream->data.yuv420p.length_u + \
1122 stream->data.yuv420p.length_v;
1130 LOGD("format %d, %dx%d, size %d plane num %d",
1131 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
1137 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
1138 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
1141 int ret = CAMERA_ERROR_NONE;
1142 camera_media_packet_data *tmp_mp_data = NULL;
1144 if (*mp_data == NULL) {
1145 tmp_mp_data = g_new0(camera_media_packet_data, 1);
1147 tmp_mp_data->tbm_key = tbm_key;
1148 tmp_mp_data->num_buffer_key = num_buffer_key;
1149 tmp_mp_data->bo = bo;
1150 tmp_mp_data->data_bo = data_bo;
1151 tmp_mp_data->ref_cnt++;
1153 for (i = 0 ; i < num_buffer_key ; i++)
1154 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
1156 *mp_data = tmp_mp_data;
1157 /*LOGD("mp_data %p", tmp_mp_data);*/
1159 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1160 LOGE("failed to alloc media packet data");
1163 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1169 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1173 camera_msg_param param;
1175 if (!mp_data || !cb_info) {
1176 LOGE("NULL pointer %p %p", mp_data, cb_info);
1180 if (mp_data->ref_cnt > 1) {
1182 LOGD("ref count %d", mp_data->ref_cnt);
1184 /* release imported bo */
1185 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1186 tbm_bo_unref(mp_data->buffer_bo[i]);
1187 mp_data->buffer_bo[i] = NULL;
1191 _camera_release_imported_bo(&mp_data->bo);
1192 _camera_release_imported_bo(&mp_data->data_bo);
1195 tbm_key = mp_data->tbm_key;
1197 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1199 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1208 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1209 camera_media_packet_data *mp_data, media_packet_h *packet)
1211 media_packet_h pkt = NULL;
1212 bool make_pkt_fmt = false;
1213 tbm_surface_h tsurf = NULL;
1214 tbm_surface_info_s tsurf_info;
1215 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1216 uint32_t bo_format = 0;
1219 int num_buffer_key = 0;
1220 tbm_bo *buffer_bo = NULL;
1222 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1223 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1224 cb_info, stream, mp_data, packet);
1225 return CAMERA_ERROR_INVALID_PARAMETER;
1228 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1229 buffer_bo = mp_data->buffer_bo;
1230 num_buffer_key = mp_data->num_buffer_key;
1232 /* create tbm surface */
1233 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1234 tsurf_info.planes[i].stride = stream->stride[i];
1236 /* get tbm surface format */
1237 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1238 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1240 if (ret == CAMERA_ERROR_NONE) {
1241 tsurf_info.width = stream->width;
1242 tsurf_info.height = stream->height;
1243 tsurf_info.format = bo_format;
1244 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1245 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1247 if (num_buffer_key > 0) {
1248 switch (bo_format) {
1249 case TBM_FORMAT_NV12:
1250 case TBM_FORMAT_NV21:
1251 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1252 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1253 tsurf_info.planes[0].offset = 0;
1254 if (num_buffer_key == 1)
1255 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1256 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1258 case TBM_FORMAT_YUV420:
1259 case TBM_FORMAT_YVU420:
1260 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1261 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1262 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1263 tsurf_info.planes[0].offset = 0;
1264 if (num_buffer_key == 1) {
1265 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1266 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1268 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1270 case TBM_FORMAT_UYVY:
1271 case TBM_FORMAT_YUYV:
1272 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1273 tsurf_info.planes[0].offset = 0;
1274 tsurf_info.size = tsurf_info.planes[0].size;
1280 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1281 } else if (mp_data->data_bo) {
1282 switch (bo_format) {
1283 case TBM_FORMAT_NV12:
1284 case TBM_FORMAT_NV21:
1285 tsurf_info.planes[0].size = stream->width * stream->height;
1286 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1287 tsurf_info.planes[0].offset = 0;
1288 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1289 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1291 case TBM_FORMAT_YUV420:
1292 case TBM_FORMAT_YVU420:
1293 tsurf_info.planes[0].size = stream->width * stream->height;
1294 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1295 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1296 tsurf_info.planes[0].offset = 0;
1297 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1298 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1299 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1301 case TBM_FORMAT_UYVY:
1302 case TBM_FORMAT_YUYV:
1303 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1304 tsurf_info.planes[0].offset = 0;
1305 tsurf_info.size = tsurf_info.planes[0].size;
1311 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1313 /*LOGD("tbm surface %p", tsurf);*/
1317 /* check media packet format */
1318 if (cb_info->pkt_fmt) {
1319 int pkt_fmt_width = 0;
1320 int pkt_fmt_height = 0;
1321 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1323 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1324 if (pkt_fmt_mimetype != mimetype ||
1325 pkt_fmt_width != stream->width ||
1326 pkt_fmt_height != stream->height) {
1327 LOGW("change fmt: current 0x%x, %dx%d",
1328 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1329 media_format_unref(cb_info->pkt_fmt);
1330 cb_info->pkt_fmt = NULL;
1331 make_pkt_fmt = true;
1334 make_pkt_fmt = true;
1337 /* create packet format */
1339 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1340 ret = media_format_create(&cb_info->pkt_fmt);
1341 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1342 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1343 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1344 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1345 LOGW("media_format_set : 0x%x", ret);
1347 LOGW("media_format_create failed 0x%x", ret);
1351 /* create media packet */
1352 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1353 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1354 (void *)cb_info, &pkt);
1355 if (ret != MEDIA_PACKET_ERROR_NONE) {
1356 LOGE("media_packet_create failed 0x%x", ret);
1357 tbm_surface_destroy(tsurf);
1361 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1362 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1366 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1367 /* set media packet data */
1368 ret = media_packet_set_extra(pkt, (void *)mp_data);
1369 if (ret != MEDIA_PACKET_ERROR_NONE) {
1370 LOGE("media_packet_set_extra failed");
1372 _camera_media_packet_data_release(mp_data, cb_info);
1375 media_packet_destroy(pkt);
1378 /* set timestamp : msec -> nsec */
1379 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1380 LOGW("media_packet_set_pts failed");
1389 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1392 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1393 camera_media_packet_data *mp_data = NULL;
1394 tbm_surface_h tsurf = NULL;
1396 if (!pkt || !cb_info) {
1397 LOGE("NULL pointer %p %p", pkt, cb_info);
1398 return MEDIA_PACKET_FINALIZE;
1401 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1402 if (ret != MEDIA_PACKET_ERROR_NONE) {
1403 LOGE("media_packet_get_extra failed 0x%x", ret);
1404 return MEDIA_PACKET_FINALIZE;
1407 /*LOGD("mp_data %p", mp_data);*/
1409 g_mutex_lock(&cb_info->mp_data_mutex);
1411 _camera_media_packet_data_release(mp_data, cb_info);
1414 g_mutex_unlock(&cb_info->mp_data_mutex);
1416 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1417 if (ret != MEDIA_PACKET_ERROR_NONE)
1418 LOGE("get tbm_surface failed 0x%x", ret);
1421 tbm_surface_destroy(tsurf);
1425 return MEDIA_PACKET_FINALIZE;
1428 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1433 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1434 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1438 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1440 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1442 if (cb_info->user_cb[event] == NULL) {
1443 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1444 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1445 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1446 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1447 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1448 LOGW("NULL callback for event %d, return here", event);
1451 /* do not return in this case, because return buffer message should be sent. */
1452 LOGW("NULL callback for event %d, NOT return here", event);
1457 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1463 muse_camera_msg_get(previous, recv_msg);
1464 muse_camera_msg_get(current, recv_msg);
1465 muse_camera_msg_get(by_policy, recv_msg);
1467 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1468 previous, current, by_policy);
1470 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1471 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1474 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1478 muse_camera_msg_get(state, recv_msg);
1480 LOGD("FOCUS state - %d", state);
1482 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1485 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1486 LOGD("CAPTURE_COMPLETED");
1487 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1489 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1490 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1491 __camera_event_handler_preview(cb_info, recv_msg);
1493 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1497 muse_camera_msg_get(percent, recv_msg);
1499 LOGD("HDR progress - %d %%", percent);
1501 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1504 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1510 muse_camera_msg_get(policy, recv_msg);
1511 muse_camera_msg_get(previous, recv_msg);
1512 muse_camera_msg_get(current, recv_msg);
1514 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1515 policy, previous, current);
1517 if (policy == CAMERA_POLICY_SOUND)
1518 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1519 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1520 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1521 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1522 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1524 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1525 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1528 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1533 muse_camera_msg_get(policy, recv_msg);
1534 muse_camera_msg_get(state, recv_msg);
1536 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1538 if (policy == CAMERA_POLICY_SOUND)
1539 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1540 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1541 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1542 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1543 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1545 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1546 (camera_state_e)state, cb_info->user_data[event]);
1549 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1550 __camera_event_handler_face_detection(cb_info, recv_msg);
1552 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1555 int current_state = 0;
1557 muse_camera_msg_get(error, recv_msg);
1558 muse_camera_msg_get(current_state, recv_msg);
1560 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1562 if (error == CAMERA_ERROR_SOUND_POLICY)
1563 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1564 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1565 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1566 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1567 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1569 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1570 (camera_state_e)current_state, cb_info->user_data[event]);
1573 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1575 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1576 muse_camera_msg_get(param1, recv_msg);
1577 muse_camera_msg_get(param2, recv_msg);
1579 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1581 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1582 cb_info->user_cb[event] = NULL;
1583 cb_info->user_data[event] = NULL;
1584 LOGW("stop foreach callback for event %d", event);
1587 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1589 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1591 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1593 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1595 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1597 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1599 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1601 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1603 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1605 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1607 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1609 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1611 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1613 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1615 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1616 muse_camera_msg_get(param1, recv_msg);
1618 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1620 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1621 cb_info->user_cb[event] = NULL;
1622 cb_info->user_data[event] = NULL;
1623 LOGW("stop foreach callback for event %d", event);
1626 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1627 __camera_event_handler_capture(cb_info, recv_msg);
1630 LOGW("unhandled event %d", event);
1634 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1639 static bool _camera_idle_event_callback(void *data)
1641 camera_cb_info_s *cb_info = NULL;
1642 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1644 if (cam_idle_event == NULL) {
1645 LOGE("cam_idle_event is NULL");
1650 g_mutex_lock(&cam_idle_event->event_mutex);
1652 cb_info = cam_idle_event->cb_info;
1653 if (cb_info == NULL) {
1654 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1655 goto IDLE_EVENT_CALLBACK_DONE;
1658 /* remove event from list */
1659 g_mutex_lock(&cb_info->idle_event_mutex);
1661 if (cb_info->idle_event_list)
1662 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1664 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1665 g_mutex_unlock(&cb_info->idle_event_mutex);
1668 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1670 /* send signal for waiting thread */
1671 g_cond_signal(&cb_info->idle_event_cond);
1673 IDLE_EVENT_CALLBACK_DONE:
1674 /* unlock and release event */
1675 g_mutex_unlock(&cam_idle_event->event_mutex);
1676 g_mutex_clear(&cam_idle_event->event_mutex);
1678 g_free(cam_idle_event);
1679 cam_idle_event = NULL;
1684 static void *_camera_msg_handler_func(gpointer data)
1688 camera_message_s *cam_msg = NULL;
1689 camera_idle_event_s *cam_idle_event = NULL;
1690 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1691 camera_cb_info_s *cb_info = NULL;
1693 if (!handler_info || !handler_info->cb_info) {
1694 LOGE("NULL handler %p", handler_info);
1698 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1699 type = handler_info->type;
1701 LOGD("t:%d start", type);
1703 g_mutex_lock(&handler_info->mutex);
1705 while (g_atomic_int_get(&handler_info->running)) {
1706 if (g_queue_is_empty(handler_info->queue)) {
1707 /*LOGD("t:%d signal wait...", type);*/
1708 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1709 /*LOGD("t:%d signal received", type);*/
1711 if (g_atomic_int_get(&handler_info->running) == 0) {
1712 LOGD("t:%d stop event thread", type);
1717 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1719 g_mutex_unlock(&handler_info->mutex);
1721 if (cam_msg == NULL) {
1722 LOGE("t:%d NULL message", type);
1723 g_mutex_lock(&handler_info->mutex);
1729 if (api < MUSE_CAMERA_API_MAX) {
1732 g_mutex_lock(&cb_info->api_mutex[api]);
1734 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1735 if (cb_info->api_waiting[api] > 0) {
1736 cb_info->api_ret[api] = ret;
1737 cb_info->api_activating[api] = 1;
1739 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1741 g_cond_signal(&cb_info->api_cond[api]);
1743 LOGW("no waiting for this api [%d]", api);
1746 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1749 g_mutex_unlock(&cb_info->api_mutex[api]);
1750 } else if (api == MUSE_CAMERA_CB_EVENT) {
1751 switch (cam_msg->event_class) {
1752 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1753 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1755 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1756 cam_idle_event = g_new0(camera_idle_event_s, 1);
1757 if (cam_idle_event == NULL) {
1758 LOGE("t:%d cam_idle_event alloc failed", type);
1762 cam_idle_event->event = cam_msg->event;
1763 cam_idle_event->cb_info = cb_info;
1764 g_mutex_init(&cam_idle_event->event_mutex);
1765 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1767 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1769 g_mutex_lock(&cb_info->idle_event_mutex);
1770 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1771 g_mutex_unlock(&cb_info->idle_event_mutex);
1773 g_idle_add_full(G_PRIORITY_DEFAULT,
1774 (GSourceFunc)_camera_idle_event_callback,
1775 (gpointer)cam_idle_event,
1779 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1783 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1789 g_mutex_lock(&handler_info->mutex);
1792 /* remove remained event */
1793 while (!g_queue_is_empty(handler_info->queue)) {
1794 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1796 LOGD("t:%d remove camera message %p", type, cam_msg);
1800 LOGW("t:%d NULL camera message", type);
1804 g_mutex_unlock(&handler_info->mutex);
1806 LOGD("t:%d return", type);
1812 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1814 camera_idle_event_s *cam_idle_event = NULL;
1816 gint64 end_time = 0;
1818 if (cb_info == NULL) {
1819 LOGE("cb_info is NULL");
1823 g_mutex_lock(&cb_info->idle_event_mutex);
1825 if (cb_info->idle_event_list == NULL) {
1826 LOGD("No remained idle event");
1827 g_mutex_unlock(&cb_info->idle_event_mutex);
1831 list = cb_info->idle_event_list;
1834 cam_idle_event = list->data;
1835 list = g_list_next(list);
1837 if (!cam_idle_event) {
1838 LOGW("Fail to remove idle event. The event is NULL");
1842 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1843 LOGW("lock failed, %p event is calling now", cam_idle_event);
1845 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1847 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1848 LOGW("signal received");
1855 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1856 cam_idle_event, cam_idle_event->event);
1858 cam_idle_event->cb_info = NULL;
1860 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1862 g_mutex_unlock(&cam_idle_event->event_mutex);
1865 g_list_free(cb_info->idle_event_list);
1866 cb_info->idle_event_list = NULL;
1868 g_mutex_unlock(&cb_info->idle_event_mutex);
1874 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1876 camera_message_s *cam_msg = NULL;
1878 if (!cb_info || !msg) {
1879 LOGE("NULL pointer %p %p", cb_info, msg);
1883 cam_msg = g_new0(camera_message_s, 1);
1885 LOGE("failed to alloc cam_msg for [%s]", msg);
1890 cam_msg->event = event;
1891 cam_msg->event_class = event_class;
1893 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1895 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1897 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1898 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1899 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1900 g_cond_signal(&cb_info->preview_cb_info.cond);
1901 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1902 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1903 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1904 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1905 g_cond_signal(&cb_info->capture_cb_info.cond);
1906 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1908 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1909 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1910 g_cond_signal(&cb_info->msg_handler_info.cond);
1911 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1920 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1922 int ret = CAMERA_ERROR_NONE;
1926 int event_class = -1;
1930 if (!cb_info || !msg) {
1931 LOGE("invalid ptr %p %p", cb_info, msg);
1935 /*LOGD("msg [%s]", msg);*/
1937 if (!muse_camera_msg_get(api, msg)) {
1938 LOGE("failed to get camera api");
1942 if (api == MUSE_CAMERA_CB_EVENT) {
1943 if (!muse_camera_msg_get(event, msg) ||
1944 !muse_camera_msg_get(event_class, msg)) {
1945 LOGE("failed to get camera event or event_class [%s]", msg);
1949 if (!muse_camera_msg_get(api_class, msg)) {
1950 LOGE("failed to get camera api_class [%s]", msg);
1955 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1956 if (api >= MUSE_CAMERA_API_MAX) {
1957 LOGE("invalid api %d", api);
1961 if (!muse_camera_msg_get(ret, msg)) {
1962 LOGE("failed to get camera ret");
1966 g_mutex_lock(&cb_info->api_mutex[api]);
1969 case MUSE_CAMERA_API_CREATE:
1970 if (ret != CAMERA_ERROR_NONE) {
1971 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1972 LOGE("camera create error 0x%x. close client cb handler", ret);
1975 case MUSE_CAMERA_API_DESTROY:
1976 if (ret == CAMERA_ERROR_NONE) {
1977 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1978 LOGD("camera destroy done. close client cb handler");
1982 muse_camera_msg_get(get_type, msg);
1983 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1984 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1985 muse_camera_msg_get(get_index, msg);
1988 case MUSE_CAMERA_GET_TYPE_INT:
1989 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1991 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1992 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1993 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1995 case MUSE_CAMERA_GET_TYPE_ARRAY:
1996 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1997 muse_core_msg_deserialize("get_value",
1998 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1999 LOGD("get display roi %d,%d,%dx%d",
2000 cb_info->get_display_roi_area[0],
2001 cb_info->get_display_roi_area[1],
2002 cb_info->get_display_roi_area[2],
2003 cb_info->get_display_roi_area[3]);
2005 muse_core_msg_deserialize("get_value",
2006 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
2007 LOGD("get geotag %lf, %lf, %lf",
2008 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
2011 case MUSE_CAMERA_GET_TYPE_STRING:
2012 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
2015 LOGW("unknown type %d", get_type);
2022 if (cb_info->api_waiting[api] > 0) {
2023 cb_info->api_ret[api] = ret;
2024 cb_info->api_activating[api] = 1;
2026 g_cond_signal(&cb_info->api_cond[api]);
2028 LOGW("no waiting for this api [%d]", api);
2031 g_mutex_unlock(&cb_info->api_mutex[api]);
2032 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2033 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
2035 LOGW("unknown camera api %d, class %d", api, api_class);
2042 static void *_camera_msg_recv_func(gpointer data)
2044 int recv_length = 0;
2045 int single_length = 0;
2046 int remained_length = 0;
2047 char *recv_msg = NULL;
2048 char *single_msg = NULL;
2049 char *remained_msg = NULL;
2053 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2056 LOGE("cb_info NULL");
2062 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2064 LOGE("single_msg malloc failed");
2068 recv_msg = cb_info->recv_msg;
2070 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2071 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2072 if (recv_length <= 0) {
2073 cb_info->is_server_connected = FALSE;
2074 LOGE("receive msg failed - server disconnected");
2082 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2084 /* Need to split the combined entering msgs */
2085 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2086 if (recv_msg[cur_pos] == '}') {
2087 single_length = cur_pos - prev_pos + 1;
2089 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2090 /* check remained msg */
2091 if (remained_length > 0) {
2093 strncpy(single_msg, remained_msg, remained_length);
2094 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2095 single_msg[remained_length + single_length] = '\0';
2098 remained_msg = NULL;
2100 strncpy(single_msg, recv_msg + prev_pos, single_length);
2101 single_msg[single_length] = '\0';
2102 LOGE("lost msg [%s], skip...", single_msg);
2105 remained_length = 0;
2107 strncpy(single_msg, recv_msg + prev_pos, single_length);
2108 single_msg[single_length] = '\0';
2111 if (single_msg[0] == '{') {
2113 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2114 /* process each message */
2115 __camera_process_msg(cb_info, single_msg);
2117 LOGE("invalid msg [%s]", single_msg);
2120 LOGE("too long message [len %d] skip...", single_length);
2123 prev_pos = cur_pos + 1;
2127 /* check incompleted message */
2128 if (recv_msg[recv_length - 1] != '}') {
2129 remained_length = recv_length - prev_pos;
2131 LOGW("incompleted message [len %d]", remained_length);
2135 remained_msg = NULL;
2138 remained_msg = (char *)malloc(remained_length + 1);
2140 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2141 remained_msg[remained_length] = '\0';
2143 LOGE("failed to alloc for remained msg");
2146 remained_length = 0;
2150 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2152 if (!cb_info->is_server_connected) {
2153 /* send error msg for server disconnection */
2154 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2155 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2156 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2160 LOGE("error_msg failed");
2161 goto CB_HANDLER_EXIT;
2164 __camera_add_msg_to_queue(cb_info,
2165 MUSE_CAMERA_CB_EVENT,
2166 MUSE_CAMERA_EVENT_TYPE_ERROR,
2167 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2170 muse_core_msg_free(error_msg);
2173 LOGE("add error msg for service disconnection done");
2184 remained_msg = NULL;
2191 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2192 int type, const char *thread_name, camera_cb_info_s *cb_info)
2194 if (!handler_info || !thread_name || !cb_info) {
2195 LOGE("t:%d NULL %p %p %p",
2196 type, handler_info, thread_name, cb_info);
2202 handler_info->type = type;
2203 handler_info->queue = g_queue_new();
2204 if (handler_info->queue == NULL) {
2205 LOGE("t:%d queue failed", type);
2209 g_mutex_init(&handler_info->mutex);
2210 g_cond_init(&handler_info->cond);
2212 handler_info->cb_info = (void *)cb_info;
2213 g_atomic_int_set(&handler_info->running, 1);
2215 handler_info->thread = g_thread_try_new(thread_name,
2216 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2217 if (handler_info->thread == NULL) {
2218 LOGE("t:%d thread failed", type);
2220 g_mutex_clear(&handler_info->mutex);
2221 g_cond_clear(&handler_info->cond);
2222 g_queue_free(handler_info->queue);
2223 handler_info->queue = NULL;
2228 LOGD("t:%d done", type);
2234 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2238 if (!handler_info) {
2239 LOGE("NULL handler");
2243 if (!handler_info->thread) {
2244 LOGW("thread is not created");
2248 type = handler_info->type;
2250 LOGD("t:%d thread %p", type, handler_info->thread);
2252 g_mutex_lock(&handler_info->mutex);
2253 g_atomic_int_set(&handler_info->running, 0);
2254 g_cond_signal(&handler_info->cond);
2255 g_mutex_unlock(&handler_info->mutex);
2257 g_thread_join(handler_info->thread);
2258 handler_info->thread = NULL;
2260 g_mutex_clear(&handler_info->mutex);
2261 g_cond_clear(&handler_info->cond);
2262 g_queue_free(handler_info->queue);
2263 handler_info->queue = NULL;
2265 LOGD("t:%d done", type);
2271 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2273 camera_cb_info_s *cb_info = NULL;
2276 g_return_val_if_fail(sockfd > 0, NULL);
2278 cb_info = g_new0(camera_cb_info_s, 1);
2279 if (cb_info == NULL) {
2280 LOGE("cb_info failed");
2284 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2286 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2287 g_mutex_init(&cb_info->api_mutex[i]);
2288 g_cond_init(&cb_info->api_cond[i]);
2291 g_mutex_init(&cb_info->fd_lock);
2292 g_mutex_init(&cb_info->idle_event_mutex);
2293 g_cond_init(&cb_info->idle_event_cond);
2294 g_mutex_init(&cb_info->mp_data_mutex);
2295 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2296 g_mutex_init(&cb_info->evas_mutex);
2297 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2299 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2300 g_mutex_init(&cb_info->user_cb_mutex[i]);
2302 /* message handler thread */
2303 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2304 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2305 LOGE("msg_handler_info failed");
2309 /* message handler thread for preview callback */
2310 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2311 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2312 LOGE("preview_cb_info failed");
2316 /* message handler thread for capture callback */
2317 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2318 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2319 LOGE("capture_cb_info failed");
2323 cb_info->fd = sockfd;
2324 cb_info->preview_cb_flag = 0;
2325 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2326 cb_info->evas_info = NULL;
2327 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2329 /* message receive thread */
2330 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2331 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2332 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2333 if (cb_info->msg_recv_thread == NULL) {
2334 LOGE("message receive thread creation failed");
2338 cb_info->is_server_connected = TRUE;
2344 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2345 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2346 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2348 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2349 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2351 g_mutex_clear(&cb_info->fd_lock);
2352 g_mutex_clear(&cb_info->idle_event_mutex);
2353 g_cond_clear(&cb_info->idle_event_cond);
2354 g_mutex_clear(&cb_info->mp_data_mutex);
2355 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2356 g_mutex_clear(&cb_info->evas_mutex);
2357 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2359 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2360 g_mutex_clear(&cb_info->api_mutex[i]);
2361 g_cond_clear(&cb_info->api_cond[i]);
2371 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2375 g_return_if_fail(cb_info != NULL);
2377 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2379 g_thread_join(cb_info->msg_recv_thread);
2380 cb_info->msg_recv_thread = NULL;
2382 LOGD("msg_recv thread removed");
2384 /* destroy msg handler threads */
2385 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2386 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2387 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2389 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2390 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2392 g_mutex_clear(&cb_info->fd_lock);
2393 g_mutex_clear(&cb_info->idle_event_mutex);
2394 g_cond_clear(&cb_info->idle_event_cond);
2395 g_mutex_clear(&cb_info->mp_data_mutex);
2396 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2397 g_mutex_clear(&cb_info->evas_mutex);
2398 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2400 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2401 g_mutex_clear(&cb_info->api_mutex[i]);
2402 g_cond_clear(&cb_info->api_cond[i]);
2405 if (cb_info->fd > -1) {
2406 muse_client_close(cb_info->fd);
2410 if (cb_info->bufmgr) {
2411 tbm_bufmgr_deinit(cb_info->bufmgr);
2412 cb_info->bufmgr = NULL;
2414 if (cb_info->pkt_fmt) {
2415 media_format_unref(cb_info->pkt_fmt);
2416 cb_info->pkt_fmt = NULL;
2419 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2420 if (cb_info->evas_info)
2421 mm_evas_renderer_destroy(&cb_info->evas_info);
2422 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2424 cb_info->preview_cb_flag = 0;
2433 int _camera_start_evas_rendering(camera_h camera)
2435 int ret = CAMERA_ERROR_NONE;
2436 camera_cli_s *pc = (camera_cli_s *)camera;
2438 if (!pc || !pc->cb_info) {
2439 LOGE("NULL handle");
2440 return CAMERA_ERROR_INVALID_PARAMETER;
2445 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2446 LOGE("EVAS surface is not set");
2447 return CAMERA_ERROR_NONE;
2450 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2451 g_mutex_lock(&pc->cb_info->evas_mutex);
2453 /* set evas render flag as RUN */
2454 pc->cb_info->run_evas_render = true;
2455 ret = CAMERA_ERROR_NONE;
2457 g_mutex_unlock(&pc->cb_info->evas_mutex);
2458 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2459 LOGW("evas renderer is not supported");
2460 ret = CAMERA_ERROR_NOT_SUPPORTED;
2461 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2467 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2469 int ret = CAMERA_ERROR_NONE;
2470 camera_cli_s *pc = (camera_cli_s *)camera;
2472 if (!pc || !pc->cb_info) {
2473 LOGE("NULL handle");
2474 return CAMERA_ERROR_INVALID_PARAMETER;
2477 LOGD("stop - keep screen %d", keep_screen);
2479 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2480 LOGE("EVAS surface is not set");
2481 return CAMERA_ERROR_NONE;
2484 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2485 g_mutex_lock(&pc->cb_info->evas_mutex);
2487 /* set evas render flag as STOP and release buffers */
2488 pc->cb_info->run_evas_render = false;
2490 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2491 if (ret != MM_ERROR_NONE) {
2492 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2493 ret = CAMERA_ERROR_INVALID_OPERATION;
2496 g_mutex_unlock(&pc->cb_info->evas_mutex);
2497 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2498 LOGW("evas renderer is not supported");
2499 ret = CAMERA_ERROR_NOT_SUPPORTED;
2500 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2506 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2508 int ret = CAMERA_ERROR_NONE;
2511 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2513 /* create muse connection */
2514 if (!key || !value) {
2515 LOGE("NULL pointer");
2516 return CAMERA_ERROR_INVALID_PARAMETER;
2519 sock_fd = muse_client_new();
2521 LOGE("muse_client_new failed");
2522 return CAMERA_ERROR_INVALID_OPERATION;
2525 msg = muse_core_msg_new(api,
2526 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2527 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2531 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2535 ret = muse_core_msg_send(sock_fd, msg);
2537 muse_core_msg_free(msg);
2541 LOGE("send msg failed");
2542 ret = CAMERA_ERROR_INVALID_OPERATION;
2546 ret = muse_core_msg_recv(sock_fd, recv_msg);
2548 LOGE("recv msg failed %d", errno);
2549 ret = CAMERA_ERROR_INVALID_OPERATION;
2553 if (!muse_camera_msg_get(ret, recv_msg)) {
2554 LOGE("failed to get return value from msg [%s]", recv_msg);
2555 ret = CAMERA_ERROR_INVALID_OPERATION;
2559 if (ret == CAMERA_ERROR_NONE)
2560 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2562 LOGD("api %d - value %d", api, *value);
2566 muse_client_close(sock_fd);
2574 int camera_create(camera_device_e device, camera_h *camera)
2577 char *send_msg = NULL;
2579 int ret = CAMERA_ERROR_NONE;
2581 camera_cli_s *pc = NULL;
2582 tbm_bufmgr bufmgr = NULL;
2584 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2585 muse_core_api_module_e muse_module = MUSE_CAMERA;
2586 int device_type = (int)device;
2589 LOGE("NULL pointer");
2590 return CAMERA_ERROR_INVALID_PARAMETER;
2593 sock_fd = muse_client_new();
2595 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2596 ret = CAMERA_ERROR_INVALID_OPERATION;
2602 send_msg = muse_core_msg_new(api,
2603 MUSE_TYPE_INT, "module", muse_module,
2604 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2605 MUSE_TYPE_INT, "pid", pid,
2610 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2614 send_ret = muse_core_msg_send(sock_fd, send_msg);
2616 muse_core_msg_free(send_msg);
2620 LOGE("send msg failed %d", errno);
2621 ret = CAMERA_ERROR_INVALID_OPERATION;
2625 pc = g_new0(camera_cli_s, 1);
2627 LOGE("camera_cli_s alloc failed");
2628 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2632 bufmgr = tbm_bufmgr_init(-1);
2633 if (bufmgr == NULL) {
2634 LOGE("get tbm bufmgr failed");
2635 ret = CAMERA_ERROR_INVALID_OPERATION;
2639 pc->cb_info = _camera_client_callback_new(sock_fd);
2640 if (pc->cb_info == NULL) {
2641 LOGE("cb_info alloc failed");
2642 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2648 LOGD("cb info : %d", pc->cb_info->fd);
2650 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2652 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2654 if (ret == CAMERA_ERROR_NONE) {
2655 intptr_t handle = 0;
2656 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2658 LOGE("Receiving Handle Failed!!");
2659 ret = CAMERA_ERROR_INVALID_OPERATION;
2663 pc->remote_handle = handle;
2664 pc->cb_info->bufmgr = bufmgr;
2666 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2667 if (ret != CAMERA_ERROR_NONE) {
2668 LOGE("init display failed 0x%x", ret);
2672 LOGD("camera create 0x%x", pc->remote_handle);
2673 *camera = (camera_h)pc;
2682 tbm_bufmgr_deinit(bufmgr);
2687 muse_client_close(sock_fd);
2693 _camera_client_callback_destroy(pc->cb_info);
2700 LOGE("camera create error : 0x%x", ret);
2706 int camera_change_device(camera_h camera, camera_device_e device)
2709 int ret = CAMERA_ERROR_NONE;
2710 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2711 camera_cli_s *pc = (camera_cli_s *)camera;
2712 camera_msg_param param;
2714 if (!pc || !pc->cb_info) {
2715 LOGE("NULL handle");
2716 return CAMERA_ERROR_INVALID_PARAMETER;
2719 CAMERA_MSG_PARAM_SET(param, INT, device);
2721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2723 if (ret == CAMERA_ERROR_NONE) {
2724 /* reset callback and user data */
2725 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2726 pc->cb_info->user_cb[i] = NULL;
2727 pc->cb_info->user_data[i] = NULL;
2729 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2736 int camera_destroy(camera_h camera)
2738 int ret = CAMERA_ERROR_NONE;
2739 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2740 camera_cli_s *pc = (camera_cli_s *)camera;
2742 if (!pc || !pc->cb_info) {
2743 LOGE("NULL handle");
2744 return CAMERA_ERROR_INVALID_PARAMETER;
2749 if (pc->cb_info->is_server_connected)
2750 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2752 LOGW("server disconnected. release resource without send message.");
2754 if (ret == CAMERA_ERROR_NONE) {
2755 _camera_deactivate_idle_event_all(pc->cb_info);
2756 _camera_client_callback_destroy(pc->cb_info);
2766 int camera_start_preview(camera_h camera)
2768 int ret = CAMERA_ERROR_NONE;
2769 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2770 camera_cli_s *pc = (camera_cli_s *)camera;
2772 if (!pc || !pc->cb_info) {
2773 LOGE("NULL handle");
2774 return CAMERA_ERROR_INVALID_PARAMETER;
2779 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2780 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2781 ret = _camera_start_evas_rendering(camera);
2782 if (ret != CAMERA_ERROR_NONE) {
2783 LOGE("stop preview because of error");
2784 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2788 LOGD("ret : 0x%x", ret);
2794 int camera_stop_preview(camera_h camera)
2796 int ret = CAMERA_ERROR_NONE;
2797 camera_cli_s *pc = (camera_cli_s *)camera;
2798 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2799 camera_state_e current_state = CAMERA_STATE_NONE;
2801 if (!pc || !pc->cb_info) {
2802 LOGE("NULL handle");
2803 return CAMERA_ERROR_INVALID_PARAMETER;
2808 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2809 ret = camera_get_state(camera, ¤t_state);
2810 if (ret != CAMERA_ERROR_NONE) {
2811 LOGE("failed to get current state 0x%x", ret);
2815 if (current_state == CAMERA_STATE_PREVIEW) {
2816 ret = _camera_stop_evas_rendering(camera, false);
2817 if (ret != CAMERA_ERROR_NONE)
2822 /* send stop preview message */
2823 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2825 if (ret != CAMERA_ERROR_NONE &&
2826 current_state == CAMERA_STATE_PREVIEW) {
2827 LOGW("restart evas rendering");
2828 _camera_start_evas_rendering(camera);
2831 LOGD("ret : 0x%x", ret);
2837 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2839 int ret = CAMERA_ERROR_NONE;
2840 camera_cli_s *pc = (camera_cli_s *)camera;
2841 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2843 if (!pc || !pc->cb_info) {
2844 LOGE("NULL handle");
2845 return CAMERA_ERROR_INVALID_PARAMETER;
2850 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2851 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2853 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2854 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2856 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2858 LOGD("ret : 0x%x", ret);
2864 bool camera_is_supported_continuous_capture(camera_h camera)
2866 int ret = CAMERA_ERROR_NONE;
2867 camera_cli_s *pc = (camera_cli_s *)camera;
2868 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2870 if (!pc || !pc->cb_info) {
2871 LOGE("NULL handle");
2872 return CAMERA_ERROR_INVALID_PARAMETER;
2877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2880 LOGE("error is occurred 0x%x", ret);
2884 LOGD("ret : %d", ret);
2890 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)
2892 int ret = CAMERA_ERROR_NONE;
2893 camera_cli_s *pc = (camera_cli_s *)camera;
2894 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2895 camera_msg_param param;
2898 if (!pc || !pc->cb_info) {
2899 LOGE("NULL handle");
2900 return CAMERA_ERROR_INVALID_PARAMETER;
2905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2911 value = (count << 16) | interval;
2912 CAMERA_MSG_PARAM_SET(param, INT, value);
2914 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2916 LOGD("ret : 0x%x", ret);
2922 int camera_stop_continuous_capture(camera_h camera)
2924 int ret = CAMERA_ERROR_NONE;
2925 camera_cli_s *pc = (camera_cli_s *)camera;
2926 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2928 if (!pc || !pc->cb_info) {
2929 LOGE("NULL handle");
2930 return CAMERA_ERROR_INVALID_PARAMETER;
2935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2937 LOGD("ret : 0x%x", ret);
2943 bool camera_is_supported_face_detection(camera_h camera)
2945 int ret = CAMERA_ERROR_NONE;
2946 camera_cli_s *pc = (camera_cli_s *)camera;
2947 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2949 if (!pc || !pc->cb_info) {
2950 LOGE("NULL handle");
2951 return CAMERA_ERROR_INVALID_PARAMETER;
2956 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2959 LOGE("error is occurred 0x%x", ret);
2963 LOGD("ret : %d", ret);
2969 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2971 int ret = CAMERA_ERROR_NONE;
2972 camera_cli_s *pc = (camera_cli_s *)camera;
2973 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2975 if (!pc || !pc->cb_info) {
2976 LOGE("NULL handle");
2977 return CAMERA_ERROR_INVALID_PARAMETER;
2982 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2985 LOGE("error is occurred 0x%x", ret);
2989 LOGD("ret : %d", ret);
2995 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2997 int ret = CAMERA_ERROR_NONE;
2998 camera_cli_s *pc = (camera_cli_s *)camera;
2999 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
3001 if (!pc || !pc->cb_info) {
3002 LOGE("NULL handle");
3003 return CAMERA_ERROR_INVALID_PARAMETER;
3008 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3011 LOGE("error is occurred 0x%x", ret);
3015 LOGD("ret : %d", ret);
3020 int camera_get_device_count(camera_h camera, int *device_count)
3022 int ret = CAMERA_ERROR_NONE;
3023 camera_cli_s *pc = (camera_cli_s *)camera;
3024 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
3026 if (!pc || !pc->cb_info) {
3027 LOGE("NULL handle");
3028 return CAMERA_ERROR_INVALID_PARAMETER;
3033 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3035 if (ret == CAMERA_ERROR_NONE)
3036 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3038 LOGD("ret : 0x%x", ret);
3043 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3045 int ret = CAMERA_ERROR_NONE;
3046 camera_cli_s *pc = (camera_cli_s *)camera;
3047 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3049 if (!pc || !pc->cb_info) {
3050 LOGE("NULL handle");
3051 return CAMERA_ERROR_INVALID_PARAMETER;
3056 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3058 if (ret == CAMERA_ERROR_NONE) {
3059 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3061 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3062 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3064 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3067 LOGD("ret : 0x%x", ret);
3072 int camera_stop_face_detection(camera_h camera)
3074 int ret = CAMERA_ERROR_NONE;
3075 camera_cli_s *pc = (camera_cli_s *)camera;
3076 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3078 if (!pc || !pc->cb_info) {
3079 LOGE("NULL handle");
3080 return CAMERA_ERROR_INVALID_PARAMETER;
3085 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3087 if (ret == CAMERA_ERROR_NONE) {
3088 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3090 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3091 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3093 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3096 LOGD("ret : 0x%x", ret);
3101 int camera_get_state(camera_h camera, camera_state_e *state)
3103 int ret = CAMERA_ERROR_NONE;
3104 camera_cli_s *pc = (camera_cli_s *)camera;
3105 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3107 if (!pc || !pc->cb_info || !state) {
3108 LOGE("NULL pointer %p %p", pc, state);
3109 return CAMERA_ERROR_INVALID_PARAMETER;
3114 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3116 if (ret == CAMERA_ERROR_NONE)
3117 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3119 LOGD("ret : 0x%x", ret);
3124 int camera_start_focusing(camera_h camera, bool continuous)
3126 int ret = CAMERA_ERROR_NONE;
3127 camera_cli_s *pc = (camera_cli_s *)camera;
3128 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3129 camera_msg_param param;
3130 int is_continuous = (int)continuous;
3132 if (!pc || !pc->cb_info) {
3133 LOGE("NULL handle");
3134 return CAMERA_ERROR_INVALID_PARAMETER;
3139 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3141 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3143 LOGD("ret : 0x%x", ret);
3148 int camera_cancel_focusing(camera_h camera)
3150 int ret = CAMERA_ERROR_NONE;
3151 camera_cli_s *pc = (camera_cli_s *)camera;
3152 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3154 if (!pc || !pc->cb_info) {
3155 LOGE("NULL handle");
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3159 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3161 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3163 LOGD("ret : 0x%x", ret);
3168 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3170 int ret = CAMERA_ERROR_NONE;
3171 void *set_display_handle = NULL;
3172 Evas_Object *obj = NULL;
3173 const char *object_type = NULL;
3174 camera_cli_s *pc = (camera_cli_s *)camera;
3175 camera_cb_info_s *cb_info = NULL;
3176 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3177 camera_state_e current_state = CAMERA_STATE_NONE;
3178 camera_msg_param param;
3182 if (!pc || !pc->cb_info) {
3183 LOGE("NULL handle");
3184 return CAMERA_ERROR_INVALID_PARAMETER;
3187 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3188 LOGE("invalid type %d", type);
3189 return CAMERA_ERROR_INVALID_PARAMETER;
3192 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3193 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3194 return CAMERA_ERROR_INVALID_PARAMETER;
3197 cb_info = (camera_cb_info_s *)pc->cb_info;
3199 ret = camera_get_state(camera, ¤t_state);
3200 if (ret != CAMERA_ERROR_NONE) {
3201 LOGE("failed to get current state 0x%x", ret);
3205 if (current_state != CAMERA_STATE_CREATED) {
3206 LOGE("INVALID_STATE : current %d", current_state);
3207 return CAMERA_ERROR_INVALID_STATE;
3210 LOGD("Enter - display : %p", display);
3212 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3213 set_display_handle = 0;
3214 LOGD("display type NONE");
3216 obj = (Evas_Object *)display;
3217 object_type = evas_object_type_get(obj);
3219 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3220 /* get wayland parent id */
3221 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3222 LOGE("failed to get wayland info");
3223 return CAMERA_ERROR_INVALID_OPERATION;
3226 set_display_handle = (void *)&pc->wl_info;
3227 LOGD("display type OVERLAY : handle %p", set_display_handle);
3228 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3229 /* evas object surface */
3230 set_display_handle = (void *)display;
3231 LOGD("display type EVAS : handle %p", set_display_handle);
3233 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3234 g_mutex_lock(&cb_info->evas_mutex);
3236 if (cb_info->evas_info) {
3237 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3238 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3239 if (ret != MM_ERROR_NONE) {
3240 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3241 g_mutex_unlock(&cb_info->evas_mutex);
3242 return CAMERA_ERROR_INVALID_OPERATION;
3246 /* create evas renderer */
3247 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3248 if (ret == MM_ERROR_NONE) {
3249 camera_flip_e flip = CAMERA_FLIP_NONE;
3250 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3251 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3258 camera_get_display_flip(camera, &flip);
3259 camera_get_display_mode(camera, &mode);
3260 camera_get_display_rotation(camera, &rotation);
3261 camera_is_display_visible(camera, &visible);
3262 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3264 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3265 flip, mode, rotation, visible, x, y, width, height);
3267 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3268 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3269 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3270 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3272 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3273 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3276 g_mutex_unlock(&cb_info->evas_mutex);
3278 if (ret != MM_ERROR_NONE) {
3279 LOGE("mm_evas_renderer error 0x%x", ret);
3280 return CAMERA_ERROR_INVALID_OPERATION;
3282 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3283 LOGE("EVAS surface is not supported");
3284 return CAMERA_ERROR_NOT_SUPPORTED;
3285 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3287 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3288 return CAMERA_ERROR_INVALID_PARAMETER;
3291 LOGE("failed to get evas object type from %p", obj);
3292 return CAMERA_ERROR_INVALID_PARAMETER;
3296 pc->display_handle = (intptr_t)set_display_handle;
3298 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3301 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3302 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3304 msg = muse_core_msg_new(api,
3305 MUSE_TYPE_INT, "type", type,
3306 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3309 LOGE("msg creation failed: api %d", api);
3310 return CAMERA_ERROR_OUT_OF_MEMORY;
3313 if (pc->cb_info->is_server_connected) {
3314 __camera_update_api_waiting(pc->cb_info, api, 1);
3316 g_mutex_lock(&pc->cb_info->fd_lock);
3317 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3318 g_mutex_unlock(&pc->cb_info->fd_lock);
3322 LOGE("message send failed");
3323 ret = CAMERA_ERROR_INVALID_OPERATION;
3325 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3328 __camera_update_api_waiting(pc->cb_info, api, -1);
3330 muse_core_msg_free(msg);
3332 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3333 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3334 pc->wl_info.window_width, pc->wl_info.window_height);
3336 CAMERA_MSG_PARAM_SET(param, INT, type);
3338 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3341 if (ret != CAMERA_ERROR_NONE)
3342 LOGE("set display error 0x%x", ret);
3343 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3344 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3350 int camera_set_preview_resolution(camera_h camera, int width, int height)
3352 int ret = CAMERA_ERROR_NONE;
3353 camera_state_e current_state = CAMERA_STATE_NONE;
3354 camera_cli_s *pc = (camera_cli_s *)camera;
3355 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3356 camera_msg_param param;
3359 if (!pc || !pc->cb_info) {
3360 LOGE("NULL handle");
3361 return CAMERA_ERROR_INVALID_PARAMETER;
3364 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3365 ret = camera_get_state(camera, ¤t_state);
3366 if (ret != CAMERA_ERROR_NONE) {
3367 LOGE("failed to get current state 0x%x", ret);
3371 if (current_state == CAMERA_STATE_PREVIEW) {
3372 ret = _camera_stop_evas_rendering(camera, true);
3373 if (ret != CAMERA_ERROR_NONE)
3378 value = (width << 16) | height;
3379 CAMERA_MSG_PARAM_SET(param, INT, value);
3381 LOGD("%dx%d -> 0x%x", width, height, value);
3383 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3385 LOGD("ret : 0x%x", ret);
3387 if (current_state == CAMERA_STATE_PREVIEW) {
3388 LOGW("restart evas rendering");
3389 _camera_start_evas_rendering(camera);
3396 int camera_set_capture_resolution(camera_h camera, int width, int height)
3398 int ret = CAMERA_ERROR_NONE;
3399 camera_cli_s *pc = (camera_cli_s *)camera;
3400 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3401 camera_msg_param param;
3404 if (!pc || !pc->cb_info) {
3405 LOGE("NULL handle");
3406 return CAMERA_ERROR_INVALID_PARAMETER;
3411 value = (width << 16) | height;
3412 CAMERA_MSG_PARAM_SET(param, INT, value);
3414 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3416 LOGD("ret : 0x%x", ret);
3422 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3424 int ret = CAMERA_ERROR_NONE;
3425 int set_format = (int)format;
3426 camera_cli_s *pc = (camera_cli_s *)camera;
3427 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3428 camera_msg_param param;
3430 if (!pc || !pc->cb_info) {
3431 LOGE("NULL handle");
3432 return CAMERA_ERROR_INVALID_PARAMETER;
3435 LOGD("Enter - format %d", set_format);
3437 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3439 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3441 LOGD("ret : 0x%x", ret);
3447 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3449 int ret = CAMERA_ERROR_NONE;
3450 int set_format = (int)format;
3451 camera_msg_param param;
3452 camera_cli_s *pc = (camera_cli_s *)camera;
3453 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3455 if (!pc || !pc->cb_info) {
3456 LOGE("NULL handle");
3457 return CAMERA_ERROR_INVALID_PARAMETER;
3460 LOGD("Enter - capture_format %d", set_format);
3462 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3464 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3466 LOGD("ret : 0x%x", ret);
3472 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3474 int ret = CAMERA_ERROR_NONE;
3475 camera_cli_s *pc = (camera_cli_s *)camera;
3476 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3478 if (!pc || !pc->cb_info || !width || !height) {
3479 LOGE("NULL pointer %p %p %p", pc, width, height);
3480 return CAMERA_ERROR_INVALID_PARAMETER;
3485 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3487 if (ret == CAMERA_ERROR_NONE) {
3488 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3489 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3492 LOGD("ret : 0x%x", ret);
3498 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3500 int ret = CAMERA_ERROR_NONE;
3501 int set_rotation = (int)rotation;
3502 camera_cli_s *pc = (camera_cli_s *)camera;
3503 camera_msg_param param;
3505 if (!pc || !pc->cb_info) {
3506 LOGE("NULL handle");
3507 return CAMERA_ERROR_INVALID_PARAMETER;
3510 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3511 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3512 g_mutex_lock(&pc->cb_info->evas_mutex);
3514 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3516 g_mutex_unlock(&pc->cb_info->evas_mutex);
3518 if (ret != MM_ERROR_NONE) {
3519 LOGE("failed to set rotation for evas surface 0x%x", ret);
3520 return CAMERA_ERROR_INVALID_OPERATION;
3523 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3525 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3527 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3533 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3535 int ret = CAMERA_ERROR_NONE;
3536 camera_cli_s *pc = (camera_cli_s *)camera;
3538 if (!pc || !pc->cb_info || !rotation) {
3539 LOGE("NULL pointer %p %p", pc, rotation);
3540 return CAMERA_ERROR_INVALID_PARAMETER;
3543 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3545 if (ret == CAMERA_ERROR_NONE)
3546 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3552 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3554 int ret = CAMERA_ERROR_NONE;
3555 int set_flip = (int)flip;
3556 camera_cli_s *pc = (camera_cli_s *)camera;
3557 camera_msg_param param;
3559 if (!pc || !pc->cb_info) {
3560 LOGE("NULL handle");
3561 return CAMERA_ERROR_INVALID_PARAMETER;
3564 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3565 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3566 g_mutex_lock(&pc->cb_info->evas_mutex);
3568 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3570 g_mutex_unlock(&pc->cb_info->evas_mutex);
3572 if (ret != MM_ERROR_NONE) {
3573 LOGE("failed to set flip for evas surface 0x%x", ret);
3574 return CAMERA_ERROR_INVALID_OPERATION;
3577 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3579 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3581 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3587 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3589 int ret = CAMERA_ERROR_NONE;
3590 camera_cli_s *pc = (camera_cli_s *)camera;
3592 if (!pc || !pc->cb_info || !flip) {
3593 LOGE("NULL pointer %p %p", pc, flip);
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3597 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3599 if (ret == CAMERA_ERROR_NONE)
3600 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3606 int camera_set_display_visible(camera_h camera, bool visible)
3608 int ret = CAMERA_ERROR_NONE;
3609 int set_visible = (int)visible;
3610 camera_cli_s *pc = (camera_cli_s *)camera;
3611 camera_msg_param param;
3613 if (!pc || !pc->cb_info) {
3614 LOGE("NULL handle");
3615 return CAMERA_ERROR_INVALID_PARAMETER;
3618 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3619 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3620 g_mutex_lock(&pc->cb_info->evas_mutex);
3622 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3624 g_mutex_unlock(&pc->cb_info->evas_mutex);
3626 if (ret != MM_ERROR_NONE) {
3627 LOGE("failed to set visible for evas surface 0x%x", ret);
3628 return CAMERA_ERROR_INVALID_OPERATION;
3631 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3633 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3635 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3641 int camera_is_display_visible(camera_h camera, bool *visible)
3643 int ret = CAMERA_ERROR_NONE;
3644 camera_cli_s *pc = (camera_cli_s *)camera;
3646 if (!pc || !pc->cb_info || !visible) {
3647 LOGE("NULL pointer %p %p", pc, visible);
3648 return CAMERA_ERROR_INVALID_PARAMETER;
3651 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3653 if (ret == CAMERA_ERROR_NONE)
3654 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3660 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3662 int ret = CAMERA_ERROR_NONE;
3663 int set_mode = (int)mode;
3664 camera_cli_s *pc = (camera_cli_s *)camera;
3665 camera_msg_param param;
3667 if (!pc || !pc->cb_info) {
3668 LOGE("NULL handle");
3669 return CAMERA_ERROR_INVALID_PARAMETER;
3672 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3673 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3674 g_mutex_lock(&pc->cb_info->evas_mutex);
3676 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3678 g_mutex_unlock(&pc->cb_info->evas_mutex);
3680 if (ret != MM_ERROR_NONE) {
3681 LOGE("failed to set geometry for evas surface 0x%x", ret);
3682 return CAMERA_ERROR_INVALID_OPERATION;
3685 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3687 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3689 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3695 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3697 int ret = CAMERA_ERROR_NONE;
3698 camera_cli_s *pc = (camera_cli_s *)camera;
3700 if (!pc || !pc->cb_info || !mode) {
3701 LOGE("NULL pointer %p %p", pc, mode);
3702 return CAMERA_ERROR_INVALID_PARAMETER;
3705 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3707 if (ret == CAMERA_ERROR_NONE)
3708 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3714 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3716 int ret = CAMERA_ERROR_NONE;
3717 int set_hint = (int)hint;
3718 camera_cli_s *pc = (camera_cli_s *)camera;
3719 camera_msg_param param;
3721 if (!pc || !pc->cb_info) {
3722 LOGE("NULL handle");
3723 return CAMERA_ERROR_INVALID_PARAMETER;
3726 LOGD("Enter - hint %d", set_hint);
3728 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3730 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3736 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3738 int ret = CAMERA_ERROR_NONE;
3739 camera_cli_s *pc = (camera_cli_s *)camera;
3740 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3742 if (!pc || !pc->cb_info || !hint) {
3743 LOGE("NULL pointer %p %p", pc, hint);
3744 return CAMERA_ERROR_INVALID_PARAMETER;
3747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3749 if (ret == CAMERA_ERROR_NONE) {
3750 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3751 LOGD("display reuse hint %d", *hint);
3758 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3760 int ret = CAMERA_ERROR_NONE;
3761 camera_cli_s *pc = (camera_cli_s *)camera;
3762 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3764 if (!pc || !pc->cb_info || !width || !height) {
3765 LOGE("NULL pointer %p %p %p", pc, width, height);
3766 return CAMERA_ERROR_INVALID_PARAMETER;
3771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3773 if (ret == CAMERA_ERROR_NONE) {
3774 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3775 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3778 LOGD("ret : 0x%x", ret);
3784 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3786 int ret = CAMERA_ERROR_NONE;
3787 camera_cli_s *pc = (camera_cli_s *)camera;
3788 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3790 if (!pc || !pc->cb_info || !format) {
3791 LOGE("NULL pointer %p %p", pc, format);
3792 return CAMERA_ERROR_INVALID_PARAMETER;
3797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3799 if (ret == CAMERA_ERROR_NONE)
3800 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3802 LOGD("ret : 0x%x", ret);
3808 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3810 int ret = CAMERA_ERROR_NONE;
3811 camera_cli_s *pc = (camera_cli_s *)camera;
3812 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3814 if (!pc || !pc->cb_info || !format) {
3815 LOGE("NULL pointer %p %p", pc, format);
3816 return CAMERA_ERROR_INVALID_PARAMETER;
3821 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3823 if (ret == CAMERA_ERROR_NONE)
3824 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3826 LOGD("ret : 0x%x", ret);
3832 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3838 if (!pc || !pc->cb_info || !facing_direction) {
3839 LOGE("NULL pointer %p %p", pc, facing_direction);
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3847 if (ret == CAMERA_ERROR_NONE)
3848 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3850 LOGD("ret : 0x%x", ret);
3856 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3858 int ret = CAMERA_ERROR_NONE;
3859 camera_cli_s *pc = (camera_cli_s *)camera;
3860 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3862 if (!pc || !pc->cb_info || !callback) {
3863 LOGE("NULL pointer %p %p", pc, callback);
3864 return CAMERA_ERROR_INVALID_PARAMETER;
3869 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3871 if (ret == CAMERA_ERROR_NONE) {
3872 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3874 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3875 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3877 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3879 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3882 LOGD("ret : 0x%x", ret);
3888 int camera_unset_preview_cb(camera_h camera)
3890 int ret = CAMERA_ERROR_NONE;
3891 camera_cli_s *pc = (camera_cli_s *)camera;
3892 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3894 if (!pc || !pc->cb_info) {
3895 LOGE("NULL handle");
3896 return CAMERA_ERROR_INVALID_PARAMETER;
3901 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3903 if (ret == CAMERA_ERROR_NONE) {
3904 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3906 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3907 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3909 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3911 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3914 LOGD("ret : 0x%x", ret);
3920 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3922 int ret = CAMERA_ERROR_NONE;
3923 camera_cli_s *pc = (camera_cli_s *)camera;
3924 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3926 if (!pc || !pc->cb_info) {
3927 LOGE("NULL handle");
3928 return CAMERA_ERROR_INVALID_PARAMETER;
3931 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3932 LOGE("NOT SUPPORTED");
3933 return CAMERA_ERROR_NOT_SUPPORTED;
3936 if (callback == NULL) {
3937 LOGE("NULL callback");
3938 return CAMERA_ERROR_INVALID_PARAMETER;
3943 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3945 if (ret == CAMERA_ERROR_NONE) {
3946 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3951 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3954 LOGD("ret : 0x%x", ret);
3960 int camera_unset_media_packet_preview_cb(camera_h camera)
3962 int ret = CAMERA_ERROR_NONE;
3963 camera_cli_s *pc = (camera_cli_s *)camera;
3964 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3966 if (!pc || !pc->cb_info) {
3967 LOGE("NULL handle");
3968 return CAMERA_ERROR_INVALID_PARAMETER;
3973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3975 if (ret == CAMERA_ERROR_NONE) {
3976 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3978 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3979 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3981 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3984 LOGD("ret : 0x%x", ret);
3990 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3992 int ret = CAMERA_ERROR_NONE;
3993 camera_cli_s *pc = (camera_cli_s *)camera;
3994 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3996 if (!pc || !pc->cb_info || !callback) {
3997 LOGE("NULL pointer %p %p", pc, callback);
3998 return CAMERA_ERROR_INVALID_PARAMETER;
4003 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4005 if (ret == CAMERA_ERROR_NONE) {
4006 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4008 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
4009 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
4011 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4014 LOGD("ret : 0x%x", ret);
4020 int camera_unset_state_changed_cb(camera_h camera)
4022 int ret = CAMERA_ERROR_NONE;
4023 camera_cli_s *pc = (camera_cli_s *)camera;
4024 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
4026 if (!pc || !pc->cb_info) {
4027 LOGE("NULL handle");
4028 return CAMERA_ERROR_INVALID_PARAMETER;
4033 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4035 if (ret == CAMERA_ERROR_NONE) {
4036 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
4041 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4044 LOGD("ret : 0x%x", ret);
4050 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4052 int ret = CAMERA_ERROR_NONE;
4053 camera_cli_s *pc = (camera_cli_s *)camera;
4054 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4056 if (!pc || !pc->cb_info || !callback) {
4057 LOGE("NULL pointer %p %p", pc, callback);
4058 return CAMERA_ERROR_INVALID_PARAMETER;
4063 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4065 if (ret == CAMERA_ERROR_NONE) {
4066 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4068 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4069 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4071 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4074 LOGD("ret : 0x%x", ret);
4080 int camera_unset_interrupted_cb(camera_h camera)
4082 int ret = CAMERA_ERROR_NONE;
4083 camera_cli_s *pc = (camera_cli_s *)camera;
4084 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4086 if (!pc || !pc->cb_info) {
4087 LOGE("NULL handle");
4088 return CAMERA_ERROR_INVALID_PARAMETER;
4093 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4095 if (ret == CAMERA_ERROR_NONE) {
4096 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4098 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4099 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4101 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4104 LOGD("ret : 0x%x", ret);
4110 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4112 int ret = CAMERA_ERROR_NONE;
4113 camera_cli_s *pc = (camera_cli_s *)camera;
4114 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4116 if (!pc || !pc->cb_info || !callback) {
4117 LOGE("NULL pointer %p %p", pc, callback);
4118 return CAMERA_ERROR_INVALID_PARAMETER;
4123 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4125 if (ret == CAMERA_ERROR_NONE) {
4126 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4128 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4129 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4131 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4134 LOGD("ret : 0x%x", ret);
4140 int camera_unset_interrupt_started_cb(camera_h camera)
4142 int ret = CAMERA_ERROR_NONE;
4143 camera_cli_s *pc = (camera_cli_s *)camera;
4144 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4146 if (!pc || !pc->cb_info) {
4147 LOGE("NULL handle");
4148 return CAMERA_ERROR_INVALID_PARAMETER;
4153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4155 if (ret == CAMERA_ERROR_NONE) {
4156 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4158 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4159 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4161 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4164 LOGD("ret : 0x%x", ret);
4170 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4172 int ret = CAMERA_ERROR_NONE;
4173 camera_cli_s *pc = (camera_cli_s *)camera;
4174 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4176 if (!pc || !pc->cb_info || !callback) {
4177 LOGE("NULL pointer %p %p", pc, callback);
4178 return CAMERA_ERROR_INVALID_PARAMETER;
4183 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4185 if (ret == CAMERA_ERROR_NONE) {
4186 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4188 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4189 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4191 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4194 LOGD("ret : 0x%x", ret);
4200 int camera_unset_focus_changed_cb(camera_h camera)
4202 int ret = CAMERA_ERROR_NONE;
4203 camera_cli_s *pc = (camera_cli_s *)camera;
4204 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4206 if (!pc || !pc->cb_info) {
4207 LOGE("NULL handle");
4208 return CAMERA_ERROR_INVALID_PARAMETER;
4213 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4215 if (ret == CAMERA_ERROR_NONE) {
4216 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4218 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4219 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4221 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4224 LOGD("ret : 0x%x", ret);
4230 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4232 int ret = CAMERA_ERROR_NONE;
4233 camera_cli_s *pc = (camera_cli_s *)camera;
4234 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4236 if (!pc || !pc->cb_info || !callback) {
4237 LOGE("NULL pointer %p %p", pc, callback);
4238 return CAMERA_ERROR_INVALID_PARAMETER;
4243 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4245 if (ret == CAMERA_ERROR_NONE) {
4246 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4248 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4249 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4251 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4254 LOGD("ret : 0x%x", ret);
4260 int camera_unset_error_cb(camera_h camera)
4262 int ret = CAMERA_ERROR_NONE;
4263 camera_cli_s *pc = (camera_cli_s *)camera;
4264 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4266 if (!pc || !pc->cb_info) {
4267 LOGE("NULL handle");
4268 return CAMERA_ERROR_INVALID_PARAMETER;
4273 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4275 if (ret == CAMERA_ERROR_NONE) {
4276 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4278 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4279 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4281 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4284 LOGD("ret : 0x%x", ret);
4290 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4292 int ret = CAMERA_ERROR_NONE;
4293 camera_cli_s *pc = (camera_cli_s *)camera;
4294 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4296 if (!pc || !pc->cb_info || !foreach_cb) {
4297 LOGE("NULL pointer %p %p", pc, foreach_cb);
4298 return CAMERA_ERROR_INVALID_PARAMETER;
4303 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4304 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4306 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4308 LOGD("ret : 0x%x", ret);
4314 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4316 int ret = CAMERA_ERROR_NONE;
4317 camera_cli_s *pc = (camera_cli_s *)camera;
4318 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4320 if (!pc || !pc->cb_info || !foreach_cb) {
4321 LOGE("NULL pointer %p %p", pc, foreach_cb);
4322 return CAMERA_ERROR_INVALID_PARAMETER;
4327 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4328 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4330 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4332 LOGD("ret : 0x%x", ret);
4338 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4344 if (!pc || !pc->cb_info || !foreach_cb) {
4345 LOGE("NULL pointer %p %p", pc, foreach_cb);
4346 return CAMERA_ERROR_INVALID_PARAMETER;
4351 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4352 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4356 LOGD("ret : 0x%x", ret);
4362 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4364 int ret = CAMERA_ERROR_NONE;
4365 camera_cli_s *pc = (camera_cli_s *)camera;
4366 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4368 if (!pc || !pc->cb_info || !foreach_cb) {
4369 LOGE("NULL pointer %p %p", pc, foreach_cb);
4370 return CAMERA_ERROR_INVALID_PARAMETER;
4375 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4376 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4380 LOGD("ret : 0x%x", ret);
4386 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4388 int ret = CAMERA_ERROR_NONE;
4389 camera_cli_s *pc = (camera_cli_s *)camera;
4390 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4392 if (!pc || !pc->cb_info || !width || !height) {
4393 LOGE("NULL pointer %p %p %p", pc, width, height);
4394 return CAMERA_ERROR_INVALID_PARAMETER;
4398 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4400 if (ret == CAMERA_ERROR_NONE) {
4401 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4402 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4405 LOGD("ret : 0x%x", ret);
4411 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4417 if (!pc || !pc->cb_info || !angle) {
4418 LOGE("NULL pointer %p %p", pc, angle);
4419 return CAMERA_ERROR_INVALID_PARAMETER;
4424 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4426 if (ret == CAMERA_ERROR_NONE)
4427 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4429 LOGD("ret : 0x%x", ret);
4435 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4437 int ret = CAMERA_ERROR_NONE;
4438 camera_cli_s *pc = (camera_cli_s *)camera;
4439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4440 camera_msg_param param;
4441 int set_mode = (int)mode;
4443 if (!pc || !pc->cb_info) {
4444 LOGE("NULL handle");
4445 return CAMERA_ERROR_INVALID_PARAMETER;
4450 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4454 LOGD("ret : 0x%x", ret);
4460 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4466 if (!pc || !pc->cb_info || !mode) {
4467 LOGE("NULL pointer %p %p", pc, mode);
4468 return CAMERA_ERROR_INVALID_PARAMETER;
4473 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4475 if (ret == CAMERA_ERROR_NONE)
4476 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4478 LOGD("ret : 0x%x", ret);
4484 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4486 int ret = CAMERA_ERROR_NONE;
4487 camera_cli_s *pc = (camera_cli_s *)camera;
4488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4490 if (!pc || !pc->cb_info || !foreach_cb) {
4491 LOGE("NULL pointer %p %p", pc, foreach_cb);
4492 return CAMERA_ERROR_INVALID_PARAMETER;
4497 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4498 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4500 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4502 LOGD("Finish, return :%x", ret);
4508 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4510 int ret = CAMERA_ERROR_NONE;
4511 camera_cli_s *pc = (camera_cli_s *)camera;
4512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4513 camera_msg_param param;
4514 int set_fps = (int)fps;
4516 if (!pc || !pc->cb_info) {
4517 LOGE("NULL handle");
4518 return CAMERA_ERROR_INVALID_PARAMETER;
4523 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4525 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4527 LOGD("ret : 0x%x", ret);
4533 int camera_attr_set_image_quality(camera_h camera, int quality)
4535 int ret = CAMERA_ERROR_NONE;
4536 camera_cli_s *pc = (camera_cli_s *)camera;
4537 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4538 camera_msg_param param;
4540 if (!pc || !pc->cb_info) {
4541 LOGE("NULL handle");
4542 return CAMERA_ERROR_INVALID_PARAMETER;
4547 CAMERA_MSG_PARAM_SET(param, INT, quality);
4549 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4551 LOGD("ret : 0x%x", ret);
4557 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4559 int ret = CAMERA_ERROR_NONE;
4560 camera_cli_s *pc = (camera_cli_s *)camera;
4561 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4563 if (!pc || !pc->cb_info || !fps) {
4564 LOGE("NULL pointer %p %p", pc, fps);
4565 return CAMERA_ERROR_INVALID_PARAMETER;
4570 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4572 if (ret == CAMERA_ERROR_NONE)
4573 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4575 LOGD("ret : 0x%x", ret);
4581 int camera_attr_get_image_quality(camera_h camera, int *quality)
4583 int ret = CAMERA_ERROR_NONE;
4584 camera_cli_s *pc = (camera_cli_s *)camera;
4585 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4587 if (!pc || !pc->cb_info || !quality) {
4588 LOGE("NULL pointer %p %p", pc, quality);
4589 return CAMERA_ERROR_INVALID_PARAMETER;
4594 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4596 if (ret == CAMERA_ERROR_NONE)
4597 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4599 LOGD("ret : 0x%x", ret);
4605 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4607 int ret = CAMERA_ERROR_NONE;
4608 camera_cli_s *pc = (camera_cli_s *)camera;
4609 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4611 if (!pc || !pc->cb_info || !bitrate) {
4612 LOGE("NULL pointer %p %p", pc, bitrate);
4613 return CAMERA_ERROR_INVALID_PARAMETER;
4618 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4620 if (ret == CAMERA_ERROR_NONE)
4621 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4623 LOGD("ret : 0x%x", ret);
4629 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4631 int ret = CAMERA_ERROR_NONE;
4632 camera_cli_s *pc = (camera_cli_s *)camera;
4633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4634 camera_msg_param param;
4635 int set_bitrate = bitrate;
4637 if (!pc || !pc->cb_info) {
4638 LOGE("NULL handle");
4639 return CAMERA_ERROR_INVALID_PARAMETER;
4644 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4646 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4648 LOGD("ret : 0x%x", ret);
4654 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4656 int ret = CAMERA_ERROR_NONE;
4657 camera_cli_s *pc = (camera_cli_s *)camera;
4658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4660 if (!pc || !pc->cb_info || !interval) {
4661 LOGE("NULL pointer %p %p", pc, interval);
4662 return CAMERA_ERROR_INVALID_PARAMETER;
4667 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4669 if (ret == CAMERA_ERROR_NONE)
4670 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4672 LOGD("ret : 0x%x", ret);
4678 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4680 int ret = CAMERA_ERROR_NONE;
4681 camera_cli_s *pc = (camera_cli_s *)camera;
4682 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4683 camera_msg_param param;
4684 int set_gop_interval = interval;
4686 if (!pc || !pc->cb_info) {
4687 LOGE("NULL handle");
4688 return CAMERA_ERROR_INVALID_PARAMETER;
4693 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4695 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4697 LOGD("ret : 0x%x", ret);
4703 int camera_attr_set_zoom(camera_h camera, int zoom)
4705 int ret = CAMERA_ERROR_NONE;
4706 camera_cli_s *pc = (camera_cli_s *)camera;
4707 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4708 camera_msg_param param;
4710 if (!pc || !pc->cb_info) {
4711 LOGE("NULL handle");
4712 return CAMERA_ERROR_INVALID_PARAMETER;
4715 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4717 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4719 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4721 LOGD("ret : 0x%x", ret);
4727 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4729 int ret = CAMERA_ERROR_NONE;
4730 camera_cli_s *pc = (camera_cli_s *)camera;
4731 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4732 camera_msg_param param;
4733 int set_mode = (int)mode;
4735 if (!pc || !pc->cb_info) {
4736 LOGE("NULL handle");
4737 return CAMERA_ERROR_INVALID_PARAMETER;
4740 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4742 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4744 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4750 int camera_attr_set_af_area(camera_h camera, int x, int y)
4752 int ret = CAMERA_ERROR_NONE;
4753 camera_cli_s *pc = (camera_cli_s *)camera;
4754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4755 camera_msg_param param;
4758 if (!pc || !pc->cb_info) {
4759 LOGE("NULL handle");
4760 return CAMERA_ERROR_INVALID_PARAMETER;
4763 LOGD("Enter - %d,%d", x, y);
4765 value = (x << 16) | y;
4766 CAMERA_MSG_PARAM_SET(param, INT, value);
4768 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4770 LOGD("ret : 0x%x", ret);
4776 int camera_attr_clear_af_area(camera_h camera)
4778 int ret = CAMERA_ERROR_NONE;
4779 camera_cli_s *pc = (camera_cli_s *)camera;
4780 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4782 if (!pc || !pc->cb_info) {
4783 LOGE("NULL handle");
4784 return CAMERA_ERROR_INVALID_PARAMETER;
4789 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4791 LOGD("ret : 0x%x", ret);
4797 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4799 int ret = CAMERA_ERROR_NONE;
4800 camera_cli_s *pc = (camera_cli_s *)camera;
4801 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4802 camera_msg_param param;
4803 int set_mode = (int)mode;
4805 if (!pc || !pc->cb_info) {
4806 LOGE("NULL handle");
4807 return CAMERA_ERROR_INVALID_PARAMETER;
4812 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4816 LOGD("ret : 0x%x", ret);
4822 int camera_attr_set_exposure(camera_h camera, int value)
4824 int ret = CAMERA_ERROR_NONE;
4825 camera_cli_s *pc = (camera_cli_s *)camera;
4826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4827 camera_msg_param param;
4829 if (!pc || !pc->cb_info) {
4830 LOGE("NULL handle");
4831 return CAMERA_ERROR_INVALID_PARAMETER;
4836 CAMERA_MSG_PARAM_SET(param, INT, value);
4838 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4840 LOGD("ret : 0x%x", ret);
4846 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4848 int ret = CAMERA_ERROR_NONE;
4849 camera_cli_s *pc = (camera_cli_s *)camera;
4850 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4851 camera_msg_param param;
4852 int set_iso = (int)iso;
4854 if (!pc || !pc->cb_info) {
4855 LOGE("NULL handle");
4856 return CAMERA_ERROR_INVALID_PARAMETER;
4861 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4863 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_set_brightness(camera_h camera, int level)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4876 camera_msg_param param;
4878 if (!pc || !pc->cb_info) {
4879 LOGE("NULL handle");
4880 return CAMERA_ERROR_INVALID_PARAMETER;
4885 CAMERA_MSG_PARAM_SET(param, INT, level);
4887 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4889 LOGD("ret : 0x%x", ret);
4895 int camera_attr_set_contrast(camera_h camera, int level)
4897 int ret = CAMERA_ERROR_NONE;
4898 camera_cli_s *pc = (camera_cli_s *)camera;
4899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4900 camera_msg_param param;
4902 if (!pc || !pc->cb_info) {
4903 LOGE("NULL handle");
4904 return CAMERA_ERROR_INVALID_PARAMETER;
4909 CAMERA_MSG_PARAM_SET(param, INT, level);
4911 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4913 LOGD("ret : 0x%x", ret);
4919 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4921 int ret = CAMERA_ERROR_NONE;
4922 camera_cli_s *pc = (camera_cli_s *)camera;
4923 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4924 camera_msg_param param;
4925 int set_whitebalance = (int)wb;
4927 if (!pc || !pc->cb_info) {
4928 LOGE("NULL handle");
4929 return CAMERA_ERROR_INVALID_PARAMETER;
4934 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4936 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4938 LOGD("ret : 0x%x", ret);
4944 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4946 int ret = CAMERA_ERROR_NONE;
4947 camera_cli_s *pc = (camera_cli_s *)camera;
4948 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4949 camera_msg_param param;
4950 int set_effect = (int)effect;
4952 if (!pc || !pc->cb_info) {
4953 LOGE("NULL handle");
4954 return CAMERA_ERROR_INVALID_PARAMETER;
4959 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4961 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4963 LOGD("ret : 0x%x", ret);
4969 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4971 int ret = CAMERA_ERROR_NONE;
4972 camera_cli_s *pc = (camera_cli_s *)camera;
4973 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4974 camera_msg_param param;
4975 int set_mode = (int)mode;
4977 if (!pc || !pc->cb_info) {
4978 LOGE("NULL handle");
4979 return CAMERA_ERROR_INVALID_PARAMETER;
4984 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4986 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4988 LOGD("ret : 0x%x", ret);
4994 int camera_attr_enable_tag(camera_h camera, bool enable)
4996 int ret = CAMERA_ERROR_NONE;
4997 camera_cli_s *pc = (camera_cli_s *)camera;
4998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4999 camera_msg_param param;
5000 int set_enable = (int)enable;
5002 if (!pc || !pc->cb_info) {
5003 LOGE("NULL handle");
5004 return CAMERA_ERROR_INVALID_PARAMETER;
5009 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5011 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5013 LOGD("ret : 0x%x", ret);
5019 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
5021 int ret = CAMERA_ERROR_NONE;
5022 camera_cli_s *pc = (camera_cli_s *)camera;
5023 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
5024 camera_msg_param param;
5026 if (!pc || !pc->cb_info || !description) {
5027 LOGE("NULL pointer %p %p", pc, description);
5028 return CAMERA_ERROR_INVALID_PARAMETER;
5033 CAMERA_MSG_PARAM_SET(param, STRING, description);
5035 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5037 LOGD("ret : 0x%x", ret);
5043 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
5048 camera_msg_param param;
5049 int set_orientation = (int)orientation;
5051 if (!pc || !pc->cb_info) {
5052 LOGE("NULL handle");
5053 return CAMERA_ERROR_INVALID_PARAMETER;
5058 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
5060 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5062 LOGD("ret : 0x%x", ret);
5068 int camera_attr_set_tag_software(camera_h camera, const char *software)
5070 int ret = CAMERA_ERROR_NONE;
5071 camera_cli_s *pc = (camera_cli_s *)camera;
5072 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
5073 camera_msg_param param;
5075 if (!pc || !pc->cb_info || !software) {
5076 LOGE("NULL pointer %p %p", pc, software);
5077 return CAMERA_ERROR_INVALID_PARAMETER;
5080 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5082 CAMERA_MSG_PARAM_SET(param, STRING, software);
5084 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5086 LOGD("ret : 0x%x", ret);
5092 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5094 int ret = CAMERA_ERROR_NONE;
5095 camera_cli_s *pc = (camera_cli_s *)camera;
5096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5097 double set_geotag[3] = {latitude, longitude, altitude};
5102 if (!pc || !pc->cb_info) {
5103 LOGE("NULL handle");
5104 return CAMERA_ERROR_INVALID_PARAMETER;
5109 length = sizeof(set_geotag) / sizeof(int) + \
5110 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5112 msg = muse_core_msg_new(api,
5113 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5116 LOGE("msg creation failed: api %d", api);
5117 return CAMERA_ERROR_OUT_OF_MEMORY;
5120 if (pc->cb_info->is_server_connected) {
5121 __camera_update_api_waiting(pc->cb_info, api, 1);
5123 g_mutex_lock(&pc->cb_info->fd_lock);
5124 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5125 g_mutex_unlock(&pc->cb_info->fd_lock);
5129 LOGE("message send failed");
5130 ret = CAMERA_ERROR_INVALID_OPERATION;
5132 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5135 __camera_update_api_waiting(pc->cb_info, api, -1);
5137 muse_core_msg_free(msg);
5139 LOGD("ret : 0x%x", ret);
5145 int camera_attr_remove_geotag(camera_h camera)
5147 int ret = CAMERA_ERROR_NONE;
5148 camera_cli_s *pc = (camera_cli_s *)camera;
5149 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5151 if (!pc || !pc->cb_info) {
5152 LOGE("NULL handle");
5153 return CAMERA_ERROR_INVALID_PARAMETER;
5158 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5160 LOGD("ret : 0x%x", ret);
5166 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5168 int ret = CAMERA_ERROR_NONE;
5169 camera_cli_s *pc = (camera_cli_s *)camera;
5170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5171 camera_msg_param param;
5172 int set_mode = (int)mode;
5174 if (!pc || !pc->cb_info) {
5175 LOGE("NULL handle");
5176 return CAMERA_ERROR_INVALID_PARAMETER;
5181 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5183 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5185 LOGD("ret : 0x%x", ret);
5191 int camera_attr_get_zoom(camera_h camera, int *zoom)
5193 int ret = CAMERA_ERROR_NONE;
5194 camera_cli_s *pc = (camera_cli_s *)camera;
5195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5197 if (!pc || !pc->cb_info || !zoom) {
5198 LOGE("NULL pointer %p %p", pc, zoom);
5199 return CAMERA_ERROR_INVALID_PARAMETER;
5204 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5206 if (ret == CAMERA_ERROR_NONE)
5207 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5209 LOGD("ret : 0x%x", ret);
5215 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5217 int ret = CAMERA_ERROR_NONE;
5218 camera_cli_s *pc = (camera_cli_s *)camera;
5219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5221 if (!pc || !pc->cb_info || !min || !max) {
5222 LOGE("NULL pointer %p %p %p", pc, min, max);
5223 return CAMERA_ERROR_INVALID_PARAMETER;
5228 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5230 if (ret == CAMERA_ERROR_NONE) {
5231 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5232 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5235 LOGD("ret : 0x%x", ret);
5241 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5243 int ret = CAMERA_ERROR_NONE;
5244 camera_cli_s *pc = (camera_cli_s *)camera;
5245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5247 if (!pc || !pc->cb_info || !mode) {
5248 LOGE("NULL pointer %p %p", pc, mode);
5249 return CAMERA_ERROR_INVALID_PARAMETER;
5254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5256 if (ret == CAMERA_ERROR_NONE)
5257 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5259 LOGD("ret : 0x%x", ret);
5265 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5267 int ret = CAMERA_ERROR_NONE;
5268 camera_cli_s *pc = (camera_cli_s *)camera;
5269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5271 if (!pc || !pc->cb_info || !mode) {
5272 LOGE("NULL pointer %p %p", pc, mode);
5273 return CAMERA_ERROR_INVALID_PARAMETER;
5278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 if (ret == CAMERA_ERROR_NONE)
5281 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5283 LOGD("ret : 0x%x", ret);
5289 int camera_attr_get_exposure(camera_h camera, int *value)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5295 if (!pc || !pc->cb_info || !value) {
5296 LOGE("NULL pointer %p %p", pc, value);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE)
5305 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5307 LOGD("ret : 0x%x", ret);
5313 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5315 int ret = CAMERA_ERROR_NONE;
5316 camera_cli_s *pc = (camera_cli_s *)camera;
5317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5319 if (!pc || !pc->cb_info || !min || !max) {
5320 LOGE("NULL pointer %p %p %p", pc, min, max);
5321 return CAMERA_ERROR_INVALID_PARAMETER;
5326 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5328 if (ret == CAMERA_ERROR_NONE) {
5329 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5330 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5333 LOGD("ret : 0x%x", ret);
5339 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5345 if (!pc || !pc->cb_info || !iso) {
5346 LOGE("NULL pointer %p %p", pc, iso);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE)
5355 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5357 LOGD("ret : 0x%x", ret);
5363 int camera_attr_get_brightness(camera_h camera, int *level)
5365 int ret = CAMERA_ERROR_NONE;
5366 camera_cli_s *pc = (camera_cli_s *)camera;
5367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5369 if (!pc || !pc->cb_info || !level) {
5370 LOGE("NULL pointer %p %p", pc, level);
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5378 if (ret == CAMERA_ERROR_NONE)
5379 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5381 LOGD("ret : 0x%x", ret);
5387 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5389 int ret = CAMERA_ERROR_NONE;
5390 camera_cli_s *pc = (camera_cli_s *)camera;
5391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5393 if (!pc || !pc->cb_info || !min || !max) {
5394 LOGE("NULL pointer %p %p %p", pc, min, max);
5395 return CAMERA_ERROR_INVALID_PARAMETER;
5400 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5402 if (ret == CAMERA_ERROR_NONE) {
5403 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5404 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5407 LOGD("ret : 0x%x", ret);
5413 int camera_attr_get_contrast(camera_h camera, int *level)
5415 int ret = CAMERA_ERROR_NONE;
5416 camera_cli_s *pc = (camera_cli_s *)camera;
5417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5419 if (!pc || !pc->cb_info || !level) {
5420 LOGE("NULL pointer %p %p", pc, level);
5421 return CAMERA_ERROR_INVALID_PARAMETER;
5426 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5428 if (ret == CAMERA_ERROR_NONE)
5429 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5431 LOGD("ret : 0x%x", ret);
5437 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5439 int ret = CAMERA_ERROR_NONE;
5440 camera_cli_s *pc = (camera_cli_s *)camera;
5441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5443 if (!pc || !pc->cb_info || !min || !max) {
5444 LOGE("NULL pointer %p %p %p", pc, min, max);
5445 return CAMERA_ERROR_INVALID_PARAMETER;
5450 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5452 if (ret == CAMERA_ERROR_NONE) {
5453 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5454 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5455 LOGD("min %d, max %d", *min, *max);
5458 LOGD("ret : 0x%x", ret);
5464 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5466 int ret = CAMERA_ERROR_NONE;
5467 camera_cli_s *pc = (camera_cli_s *)camera;
5468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5470 if (!pc || !pc->cb_info || !wb) {
5471 LOGE("NULL pointer %p %p", pc, wb);
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5477 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5479 if (ret == CAMERA_ERROR_NONE)
5480 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5482 LOGD("ret : 0x%x", ret);
5488 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5490 int ret = CAMERA_ERROR_NONE;
5491 camera_cli_s *pc = (camera_cli_s *)camera;
5492 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5494 if (!pc || !pc->cb_info || !effect) {
5495 LOGE("NULL pointer %p %p", pc, effect);
5496 return CAMERA_ERROR_INVALID_PARAMETER;
5501 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5503 if (ret == CAMERA_ERROR_NONE)
5504 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5506 LOGD("ret : 0x%x", ret);
5512 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5514 int ret = CAMERA_ERROR_NONE;
5515 camera_cli_s *pc = (camera_cli_s *)camera;
5516 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5518 if (!pc || !pc->cb_info || !mode) {
5519 LOGE("NULL pointer %p %p", pc, mode);
5520 return CAMERA_ERROR_INVALID_PARAMETER;
5525 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5527 if (ret == CAMERA_ERROR_NONE)
5528 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5530 LOGD("ret : 0x%x", ret);
5536 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5538 int ret = CAMERA_ERROR_NONE;
5539 camera_cli_s *pc = (camera_cli_s *)camera;
5540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5542 if (!pc || !pc->cb_info || !enable) {
5543 LOGE("NULL pointer %p %p", pc, enable);
5544 return CAMERA_ERROR_INVALID_PARAMETER;
5549 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5551 if (ret == CAMERA_ERROR_NONE)
5552 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5554 LOGD("ret : 0x%x", ret);
5560 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5562 int ret = CAMERA_ERROR_NONE;
5563 camera_cli_s *pc = (camera_cli_s *)camera;
5564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5566 if (!pc || !pc->cb_info || !description) {
5567 LOGE("NULL pointer %p %p", pc, description);
5568 return CAMERA_ERROR_INVALID_PARAMETER;
5573 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5575 if (ret == CAMERA_ERROR_NONE)
5576 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5578 LOGD("ret : 0x%x", ret);
5584 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5586 int ret = CAMERA_ERROR_NONE;
5587 camera_cli_s *pc = (camera_cli_s *)camera;
5588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5590 if (!pc || !pc->cb_info || !orientation) {
5591 LOGE("NULL pointer %p %p", pc, orientation);
5592 return CAMERA_ERROR_INVALID_PARAMETER;
5597 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5599 if (ret == CAMERA_ERROR_NONE)
5600 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5602 LOGD("ret : 0x%x", ret);
5608 int camera_attr_get_tag_software(camera_h camera, char **software)
5610 int ret = CAMERA_ERROR_NONE;
5611 camera_cli_s *pc = (camera_cli_s *)camera;
5612 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5614 if (!pc || !pc->cb_info || !software) {
5615 LOGE("NULL pointer %p %p", pc, software);
5616 return CAMERA_ERROR_INVALID_PARAMETER;
5621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5623 if (ret == CAMERA_ERROR_NONE)
5624 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5626 LOGD("ret : 0x%x", ret);
5632 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5634 int ret = CAMERA_ERROR_NONE;
5635 camera_cli_s *pc = (camera_cli_s *)camera;
5636 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5638 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5639 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5640 return CAMERA_ERROR_INVALID_PARAMETER;
5645 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5647 if (ret == CAMERA_ERROR_NONE) {
5648 *latitude = pc->cb_info->get_geotag[0];
5649 *longitude = pc->cb_info->get_geotag[1];
5650 *altitude = pc->cb_info->get_geotag[2];
5653 LOGD("ret : 0x%x", ret);
5659 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5661 int ret = CAMERA_ERROR_NONE;
5662 camera_cli_s *pc = (camera_cli_s *)camera;
5663 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5665 if (!pc || !pc->cb_info || !mode) {
5666 LOGE("NULL pointer %p %p", pc, mode);
5667 return CAMERA_ERROR_INVALID_PARAMETER;
5672 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5674 if (ret == CAMERA_ERROR_NONE)
5675 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5677 LOGD("ret : 0x%x", ret);
5683 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5685 int ret = CAMERA_ERROR_NONE;
5686 int get_flash_state = 0;
5689 LOGE("NULL pointer");
5690 return CAMERA_ERROR_INVALID_PARAMETER;
5693 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5694 (int)device, "get_flash_state", &get_flash_state);
5696 if (ret == CAMERA_ERROR_NONE) {
5697 *state = (camera_flash_state_e)get_flash_state;
5698 LOGD("flash state %d", *state);
5700 LOGE("failed 0x%x", ret);
5707 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5709 int ret = CAMERA_ERROR_NONE;
5710 camera_cli_s *pc = (camera_cli_s *)camera;
5711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5713 if (!pc || !pc->cb_info || !foreach_cb) {
5714 LOGE("NULL pointer %p %p", pc, foreach_cb);
5715 return CAMERA_ERROR_INVALID_PARAMETER;
5720 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5721 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5723 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5725 LOGD("ret : 0x%x", ret);
5731 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5733 int ret = CAMERA_ERROR_NONE;
5734 camera_cli_s *pc = (camera_cli_s *)camera;
5735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5737 if (!pc || !pc->cb_info || !foreach_cb) {
5738 LOGE("NULL pointer %p %p", pc, foreach_cb);
5739 return CAMERA_ERROR_INVALID_PARAMETER;
5744 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5745 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5749 LOGD("ret : 0x%x", ret);
5755 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5757 int ret = CAMERA_ERROR_NONE;
5758 camera_cli_s *pc = (camera_cli_s *)camera;
5759 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5761 if (!pc || !pc->cb_info || !foreach_cb) {
5762 LOGE("NULL pointer %p %p", pc, foreach_cb);
5763 return CAMERA_ERROR_INVALID_PARAMETER;
5768 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5769 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5773 LOGD("ret : 0x%x", ret);
5779 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5781 int ret = CAMERA_ERROR_NONE;
5782 camera_cli_s *pc = (camera_cli_s *)camera;
5783 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5785 if (!pc || !pc->cb_info || !foreach_cb) {
5786 LOGE("NULL pointer %p %p", pc, foreach_cb);
5787 return CAMERA_ERROR_INVALID_PARAMETER;
5792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5795 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5797 LOGD("ret : 0x%x", ret);
5803 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5805 int ret = CAMERA_ERROR_NONE;
5806 camera_cli_s *pc = (camera_cli_s *)camera;
5807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5809 if (!pc || !pc->cb_info || !foreach_cb) {
5810 LOGE("NULL pointer %p %p", pc, foreach_cb);
5811 return CAMERA_ERROR_INVALID_PARAMETER;
5816 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5817 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5821 LOGD("ret : 0x%x", ret);
5827 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5829 int ret = CAMERA_ERROR_NONE;
5830 camera_cli_s *pc = (camera_cli_s *)camera;
5831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5833 if (!pc || !pc->cb_info || !foreach_cb) {
5834 LOGE("NULL pointer %p %p", pc, foreach_cb);
5835 return CAMERA_ERROR_INVALID_PARAMETER;
5840 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5841 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5843 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5845 LOGD("ret : 0x%x", ret);
5851 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5853 int ret = CAMERA_ERROR_NONE;
5854 camera_cli_s *pc = (camera_cli_s *)camera;
5855 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5857 if (!pc || !pc->cb_info || !foreach_cb) {
5858 LOGE("NULL pointer %p %p", pc, foreach_cb);
5859 return CAMERA_ERROR_INVALID_PARAMETER;
5864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5867 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5869 LOGD("ret : 0x%x", ret);
5875 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5877 int ret = CAMERA_ERROR_NONE;
5878 camera_cli_s *pc = (camera_cli_s *)camera;
5879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5881 if (!pc || !pc->cb_info || !foreach_cb) {
5882 LOGE("NULL pointer %p %p", pc, foreach_cb);
5883 return CAMERA_ERROR_INVALID_PARAMETER;
5888 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5889 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5891 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5893 LOGD("Enter, handle :%x", pc->remote_handle);
5899 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)
5901 int ret = CAMERA_ERROR_NONE;
5902 camera_cli_s *pc = (camera_cli_s *)camera;
5903 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5904 camera_msg_param param;
5907 if (!pc || !pc->cb_info || !foreach_cb) {
5908 LOGE("NULL pointer %p %p", pc, foreach_cb);
5909 return CAMERA_ERROR_INVALID_PARAMETER;
5914 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5915 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5917 value = (width << 16) | height;
5918 CAMERA_MSG_PARAM_SET(param, INT, value);
5920 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5922 LOGD("ret : 0x%x", ret);
5928 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5930 int ret = CAMERA_ERROR_NONE;
5931 camera_cli_s *pc = (camera_cli_s *)camera;
5932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5934 if (!pc || !pc->cb_info || !foreach_cb) {
5935 LOGE("NULL pointer %p %p", pc, foreach_cb);
5936 return CAMERA_ERROR_INVALID_PARAMETER;
5941 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5942 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5944 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5946 LOGD("ret : 0x%x", ret);
5952 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5954 int ret = CAMERA_ERROR_NONE;
5955 camera_cli_s *pc = (camera_cli_s *)camera;
5956 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5958 if (!pc || !pc->cb_info || !foreach_cb) {
5959 LOGE("NULL pointer %p %p", pc, foreach_cb);
5960 return CAMERA_ERROR_INVALID_PARAMETER;
5965 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5966 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5968 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5970 LOGD("ret : 0x%x", ret);
5976 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5981 camera_msg_param param;
5982 int set_rotation = (int)rotation;
5984 if (!pc || !pc->cb_info) {
5985 LOGE("NULL handle");
5986 return CAMERA_ERROR_INVALID_PARAMETER;
5991 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5993 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5995 LOGD("ret : 0x%x", ret);
6001 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
6003 int ret = CAMERA_ERROR_NONE;
6004 camera_cli_s *pc = (camera_cli_s *)camera;
6005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
6007 if (!pc || !pc->cb_info || !rotation) {
6008 LOGE("NULL pointer %p %p", pc, rotation);
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6014 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6016 if (ret == CAMERA_ERROR_NONE)
6017 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
6019 LOGD("ret : 0x%x", ret);
6025 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
6027 int ret = CAMERA_ERROR_NONE;
6028 camera_cli_s *pc = (camera_cli_s *)camera;
6029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
6030 camera_msg_param param;
6031 int set_flip = (int)flip;
6033 if (!pc || !pc->cb_info) {
6034 LOGE("NULL handle");
6035 return CAMERA_ERROR_INVALID_PARAMETER;
6040 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
6042 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6044 LOGD("ret : 0x%x", ret);
6050 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6052 int ret = CAMERA_ERROR_NONE;
6053 camera_cli_s *pc = (camera_cli_s *)camera;
6054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6056 if (!pc || !pc->cb_info || !flip) {
6057 LOGE("NULL pointer %p %p", pc, flip);
6058 return CAMERA_ERROR_INVALID_PARAMETER;
6063 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6065 if (ret == CAMERA_ERROR_NONE)
6066 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6068 LOGD("ret : 0x%x", ret);
6073 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6075 int ret = CAMERA_ERROR_NONE;
6076 camera_cli_s *pc = (camera_cli_s *)camera;
6077 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6078 camera_msg_param param;
6079 int set_mode = (int)mode;
6081 if (!pc || !pc->cb_info) {
6082 LOGE("NULL handle");
6083 return CAMERA_ERROR_INVALID_PARAMETER;
6088 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6090 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6092 LOGD("ret : 0x%x", ret);
6098 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6100 int ret = CAMERA_ERROR_NONE;
6101 camera_cli_s *pc = (camera_cli_s *)camera;
6102 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6104 if (!pc || !pc->cb_info || !mode) {
6105 LOGE("NULL pointer %p %p", pc, mode);
6106 return CAMERA_ERROR_INVALID_PARAMETER;
6111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6113 if (ret == CAMERA_ERROR_NONE)
6114 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6116 LOGD("ret : 0x%x", ret);
6122 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6124 int ret = CAMERA_ERROR_NONE;
6125 camera_cli_s *pc = (camera_cli_s *)camera;
6126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6128 if (!pc || !pc->cb_info) {
6129 LOGE("NULL handle");
6130 return CAMERA_ERROR_INVALID_PARAMETER;
6135 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6138 LOGE("error is occurred 0x%x", ret);
6142 LOGD("ret : %d", ret);
6148 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6150 int ret = CAMERA_ERROR_NONE;
6151 camera_cli_s *pc = (camera_cli_s *)camera;
6152 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6154 if (!pc || !pc->cb_info) {
6155 LOGE("NULL handle");
6156 return CAMERA_ERROR_INVALID_PARAMETER;
6161 if (!camera_attr_is_supported_hdr_capture(camera)) {
6162 LOGE("HDR not supported");
6163 return CAMERA_ERROR_NOT_SUPPORTED;
6167 LOGE("NULL callback");
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6173 if (ret == CAMERA_ERROR_NONE) {
6174 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6176 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6177 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6179 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6182 LOGD("ret : 0x%x", ret);
6188 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6194 if (!pc || !pc->cb_info) {
6195 LOGE("NULL handle");
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6203 if (ret == CAMERA_ERROR_NONE) {
6204 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6206 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6207 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6209 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6212 LOGD("ret : 0x%x", ret);
6218 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6220 int ret = CAMERA_ERROR_NONE;
6221 camera_cli_s *pc = (camera_cli_s *)camera;
6222 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6223 camera_msg_param param;
6224 int set_enable = (int)enable;
6226 if (!pc || !pc->cb_info) {
6227 LOGE("NULL handle");
6228 return CAMERA_ERROR_INVALID_PARAMETER;
6233 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6235 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6237 LOGD("ret : 0x%x", ret);
6243 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6245 int ret = CAMERA_ERROR_NONE;
6246 camera_cli_s *pc = (camera_cli_s *)camera;
6247 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6249 if (!pc || !pc->cb_info || !enabled) {
6250 LOGE("NULL pointer %p %p", pc, enabled);
6251 return CAMERA_ERROR_INVALID_PARAMETER;
6256 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6258 if (ret == CAMERA_ERROR_NONE)
6259 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6261 LOGD("ret : 0x%x", ret);
6267 bool camera_attr_is_supported_anti_shake(camera_h camera)
6269 int ret = CAMERA_ERROR_NONE;
6270 camera_cli_s *pc = (camera_cli_s *)camera;
6271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6273 if (!pc || !pc->cb_info) {
6274 LOGE("NULL handle");
6275 return CAMERA_ERROR_INVALID_PARAMETER;
6280 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6283 LOGE("error is occurred 0x%x", ret);
6287 LOGD("ret : %d", ret);
6293 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6295 int ret = CAMERA_ERROR_NONE;
6296 camera_cli_s *pc = (camera_cli_s *)camera;
6297 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6298 camera_msg_param param;
6299 int set_enable = (int)enable;
6301 if (!pc || !pc->cb_info) {
6302 LOGE("NULL handle");
6303 return CAMERA_ERROR_INVALID_PARAMETER;
6308 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6310 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6312 LOGD("ret : 0x%x", ret);
6318 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6320 int ret = CAMERA_ERROR_NONE;
6321 camera_cli_s *pc = (camera_cli_s *)camera;
6322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6324 if (!pc || !pc->cb_info || !enabled) {
6325 LOGE("NULL pointer %p %p", pc, enabled);
6326 return CAMERA_ERROR_INVALID_PARAMETER;
6331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6333 if (ret == CAMERA_ERROR_NONE)
6334 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6336 LOGD("ret : 0x%x", ret);
6342 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6348 if (!pc || !pc->cb_info) {
6349 LOGE("NULL handle");
6350 return CAMERA_ERROR_INVALID_PARAMETER;
6355 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6358 LOGE("error is occurred 0x%x", ret);
6362 LOGD("ret : %d", ret);
6368 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6370 int ret = CAMERA_ERROR_NONE;
6371 camera_cli_s *pc = (camera_cli_s *)camera;
6372 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6373 camera_msg_param param;
6374 int set_enable = (int)enable;
6376 if (!pc || !pc->cb_info) {
6377 LOGE("NULL handle");
6378 return CAMERA_ERROR_INVALID_PARAMETER;
6383 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6385 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6387 LOGD("ret : 0x%x", ret);
6393 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6395 int ret = CAMERA_ERROR_NONE;
6396 camera_cli_s *pc = (camera_cli_s *)camera;
6397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6399 if (!pc || !pc->cb_info || !enabled) {
6400 LOGE("NULL pointer %p %p", pc, enabled);
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6406 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6408 if (ret == CAMERA_ERROR_NONE)
6409 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6411 LOGD("ret : 0x%x", ret);
6417 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6419 int ret = CAMERA_ERROR_NONE;
6420 camera_cli_s *pc = (camera_cli_s *)camera;
6421 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6423 if (!pc || !pc->cb_info) {
6424 LOGE("NULL handle");
6425 return CAMERA_ERROR_INVALID_PARAMETER;
6430 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6433 LOGE("error is occurred 0x%x", ret);
6437 LOGD("ret : %d", ret);
6443 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6445 int ret = CAMERA_ERROR_NONE;
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6448 camera_msg_param param;
6449 int set_disable = (int)disable;
6451 if (!pc || !pc->cb_info) {
6452 LOGE("NULL handle");
6453 return CAMERA_ERROR_INVALID_PARAMETER;
6458 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6460 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6462 LOGD("ret : 0x%x", ret);
6468 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6470 int ret = CAMERA_ERROR_NONE;
6471 camera_cli_s *pc = (camera_cli_s *)camera;
6472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6473 camera_msg_param param;
6474 int set_move_type = (int)move_type;
6477 if (!pc || !pc->cb_info) {
6478 LOGE("NULL handle");
6479 return CAMERA_ERROR_INVALID_PARAMETER;
6484 value = (set_move_type << 16) | pan_step;
6485 CAMERA_MSG_PARAM_SET(param, INT, value);
6487 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6489 LOGD("ret : 0x%x", ret);
6495 int camera_attr_get_pan(camera_h camera, int *pan_step)
6497 int ret = CAMERA_ERROR_NONE;
6498 camera_cli_s *pc = (camera_cli_s *)camera;
6499 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6501 if (!pc || !pc->cb_info || !pan_step) {
6502 LOGE("NULL pointer %p %p", pc, pan_step);
6503 return CAMERA_ERROR_INVALID_PARAMETER;
6508 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6510 if (ret == CAMERA_ERROR_NONE)
6511 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6513 LOGD("ret : 0x%x", ret);
6519 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6521 int ret = CAMERA_ERROR_NONE;
6522 camera_cli_s *pc = (camera_cli_s *)camera;
6523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6525 if (!pc || !pc->cb_info || !min || !max) {
6526 LOGE("NULL pointer %p %p %p", pc, min, max);
6527 return CAMERA_ERROR_INVALID_PARAMETER;
6532 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6534 if (ret == CAMERA_ERROR_NONE) {
6535 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6536 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6539 LOGD("ret : 0x%x", ret);
6545 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6547 int ret = CAMERA_ERROR_NONE;
6548 camera_cli_s *pc = (camera_cli_s *)camera;
6549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6550 camera_msg_param param;
6551 int set_move_type = (int)move_type;
6554 if (!pc || !pc->cb_info) {
6555 LOGE("NULL handle");
6556 return CAMERA_ERROR_INVALID_PARAMETER;
6561 value = (set_move_type << 16) | tilt_step;
6562 CAMERA_MSG_PARAM_SET(param, INT, value);
6564 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6566 LOGD("ret : 0x%x", ret);
6572 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6574 int ret = CAMERA_ERROR_NONE;
6575 camera_cli_s *pc = (camera_cli_s *)camera;
6576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6578 if (!pc || !pc->cb_info || !tilt_step) {
6579 LOGE("NULL pointer %p %p", pc, tilt_step);
6580 return CAMERA_ERROR_INVALID_PARAMETER;
6585 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6587 if (ret == CAMERA_ERROR_NONE)
6588 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6590 LOGD("ret : 0x%x", ret);
6596 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6598 int ret = CAMERA_ERROR_NONE;
6599 camera_cli_s *pc = (camera_cli_s *)camera;
6600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6602 if (!pc || !pc->cb_info || !min || !max) {
6603 LOGE("NULL pointer %p %p %p", pc, min, max);
6604 return CAMERA_ERROR_INVALID_PARAMETER;
6609 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6611 if (ret == CAMERA_ERROR_NONE) {
6612 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6613 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6616 LOGD("ret : 0x%x", ret);
6622 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6624 int ret = CAMERA_ERROR_NONE;
6625 camera_cli_s *pc = (camera_cli_s *)camera;
6626 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6627 camera_msg_param param;
6628 int set_ptz_type = (int)ptz_type;
6630 if (!pc || !pc->cb_info) {
6631 LOGE("NULL handle");
6632 return CAMERA_ERROR_INVALID_PARAMETER;
6637 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6639 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6641 LOGD("ret : 0x%x", ret);
6647 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6649 int ret = CAMERA_ERROR_NONE;
6650 camera_cli_s *pc = (camera_cli_s *)camera;
6651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6653 if (!pc || !pc->cb_info || !foreach_cb) {
6654 LOGE("NULL pointer %p %p", pc, foreach_cb);
6655 return CAMERA_ERROR_INVALID_PARAMETER;
6660 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6661 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6665 LOGD("ret : 0x%x", ret);
6671 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6673 int ret = CAMERA_ERROR_NONE;
6674 camera_cli_s *pc = (camera_cli_s *)camera;
6675 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6676 int set_display_roi_area[4] = {x, y, width, height};
6681 if (!pc || !pc->cb_info) {
6682 LOGE("NULL handle");
6683 return CAMERA_ERROR_INVALID_PARAMETER;
6688 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6689 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6690 g_mutex_lock(&pc->cb_info->evas_mutex);
6692 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6694 g_mutex_unlock(&pc->cb_info->evas_mutex);
6696 if (ret != MM_ERROR_NONE) {
6697 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6698 return CAMERA_ERROR_INVALID_OPERATION;
6701 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6703 length = sizeof(set_display_roi_area) / sizeof(int) + \
6704 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6706 msg = muse_core_msg_new(api,
6707 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6710 LOGE("msg creation failed: api %d", api);
6711 return CAMERA_ERROR_OUT_OF_MEMORY;
6714 if (pc->cb_info->is_server_connected) {
6715 __camera_update_api_waiting(pc->cb_info, api, 1);
6717 g_mutex_lock(&pc->cb_info->fd_lock);
6718 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6719 g_mutex_unlock(&pc->cb_info->fd_lock);
6723 LOGE("message send failed");
6724 ret = CAMERA_ERROR_INVALID_OPERATION;
6726 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6729 __camera_update_api_waiting(pc->cb_info, api, -1);
6731 muse_core_msg_free(msg);
6733 LOGD("ret : 0x%x", ret);
6739 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6741 camera_cli_s *pc = (camera_cli_s *)camera;
6742 int ret = CAMERA_ERROR_NONE;
6743 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6745 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6746 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6747 return CAMERA_ERROR_INVALID_PARAMETER;
6752 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6754 if (ret == CAMERA_ERROR_NONE) {
6755 *x = pc->cb_info->get_display_roi_area[0];
6756 *y = pc->cb_info->get_display_roi_area[1];
6757 *width = pc->cb_info->get_display_roi_area[2];
6758 *height = pc->cb_info->get_display_roi_area[3];
6761 LOGD("ret : 0x%x", ret);
6767 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6769 int ret = CAMERA_ERROR_NONE;
6770 int get_device_state = 0;
6773 LOGE("NULL pointer");
6774 return CAMERA_ERROR_INVALID_PARAMETER;
6777 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6778 (int)device, "get_device_state", &get_device_state);
6780 if (ret == CAMERA_ERROR_NONE) {
6781 *state = (camera_device_state_e)get_device_state;
6782 LOGD("device state %d", *state);
6784 LOGE("failed 0x%x", ret);
6791 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6793 int ret = CAMERA_ERROR_NONE;
6794 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6795 camera_cb_info *info = NULL;
6797 if (!callback || !cb_id) {
6798 LOGE("invalid pointer %p %p", callback, cb_id);
6799 return CAMERA_ERROR_INVALID_PARAMETER;
6802 /* check camera support */
6803 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6804 if (ret != CAMERA_ERROR_NONE) {
6805 LOGE("get device state failed");
6809 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6811 info = g_new0(camera_cb_info, 1);
6813 LOGE("info failed");
6814 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6818 info->id = ++g_cam_dev_state_changed_cb_id;
6819 info->callback = (void *)callback;
6820 info->user_data = user_data;
6824 /* subscribe dbus signal for camera state change */
6825 if (!g_cam_dev_state_changed_cb_conn) {
6826 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6827 if (!g_cam_dev_state_changed_cb_conn) {
6828 LOGE("failed to get gdbus connection");
6829 ret = CAMERA_ERROR_INVALID_OPERATION;
6833 LOGD("subscribe signal %s - %s - %s",
6834 MM_CAMCORDER_DBUS_OBJECT,
6835 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6836 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6838 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6839 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6840 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6841 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6842 LOGE("failed to get gdbus connection");
6843 ret = CAMERA_ERROR_INVALID_OPERATION;
6847 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6850 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6852 LOGD("callback id %d", info->id);
6855 if (ret != CAMERA_ERROR_NONE) {
6861 if (g_cam_dev_state_changed_cb_conn) {
6862 g_object_unref(g_cam_dev_state_changed_cb_conn);
6863 g_cam_dev_state_changed_cb_conn = NULL;
6867 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6873 int camera_remove_device_state_changed_cb(int cb_id)
6875 int ret = CAMERA_ERROR_NONE;
6876 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6877 GList *tmp_list = NULL;
6878 camera_cb_info *info = NULL;
6880 /* check camera support */
6881 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6882 if (ret != CAMERA_ERROR_NONE) {
6883 LOGE("get device state failed");
6887 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6889 if (!g_cam_dev_state_changed_cb_list) {
6890 LOGE("there is no callback info");
6891 ret = CAMERA_ERROR_INVALID_OPERATION;
6895 tmp_list = g_cam_dev_state_changed_cb_list;
6898 info = tmp_list->data;
6899 tmp_list = tmp_list->next;
6906 if (info->id == cb_id) {
6907 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6912 if (!g_cam_dev_state_changed_cb_list) {
6913 /* no remained callback */
6914 if (g_cam_dev_state_changed_cb_conn) {
6915 /* unsubscribe signal */
6916 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6917 g_cam_dev_state_changed_cb_subscribe_id = 0;
6919 /* unref connection */
6920 g_object_unref(g_cam_dev_state_changed_cb_conn);
6921 g_cam_dev_state_changed_cb_conn = NULL;
6925 LOGD("id %d callback removed", cb_id);
6926 ret = CAMERA_ERROR_NONE;
6932 LOGE("id %d callback not found", cb_id);
6933 ret = CAMERA_ERROR_INVALID_PARAMETER;
6936 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);