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;
54 static void __global(void *data, struct wl_registry *registry,
55 uint32_t name, const char *interface, uint32_t version)
57 struct tizen_surface **tz_surface = NULL;
64 tz_surface = (struct tizen_surface **)data;
67 LOGW("NULL interface");
71 /*LOGI("interface %s", interface);*/
73 if (strcmp(interface, "tizen_surface") == 0) {
74 LOGD("binding tizen surface for wayland");
76 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
77 if (*tz_surface == NULL)
78 LOGE("failed to bind");
86 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
92 static const struct wl_registry_listener _camera_wl_registry_listener = {
97 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
104 *((unsigned int *)data) = id;
106 LOGD("[CLIENT] got parent_id [%u] from server", id);
111 static const struct tizen_resource_listener _camera_tz_resource_listener = {
115 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
117 int ret = CAMERA_ERROR_NONE;
118 Ecore_Wl_Window *window = NULL;
119 struct wl_display *display = NULL;
120 struct wl_display *display_wrapper = NULL;
121 struct wl_surface *surface = NULL;
122 struct wl_registry *registry = NULL;
123 struct wl_event_queue *queue = NULL;
124 struct tizen_surface *tz_surface = NULL;
125 struct tizen_resource *tz_resource = NULL;
127 if (!obj || !wl_info) {
128 LOGE("NULL parameter %p %p", obj, wl_info);
129 return CAMERA_ERROR_INVALID_OPERATION;
132 window = elm_win_wl_window_get(obj);
134 LOGE("failed to get wayland window");
135 ret = CAMERA_ERROR_INVALID_OPERATION;
139 ecore_wl_window_video_has(window, EINA_TRUE);
141 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
143 LOGE("failed to get wayland surface");
144 ret = CAMERA_ERROR_INVALID_OPERATION;
148 display = (struct wl_display *)ecore_wl_display_get();
150 LOGE("failed to get wayland display");
151 ret = CAMERA_ERROR_INVALID_OPERATION;
155 display_wrapper = wl_proxy_create_wrapper(display);
156 if (!display_wrapper) {
157 LOGE("failed to create wl display wrapper");
158 ret = CAMERA_ERROR_INVALID_OPERATION;
162 queue = wl_display_create_queue(display);
164 LOGE("failed to create wl display queue");
165 ret = CAMERA_ERROR_INVALID_OPERATION;
169 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
171 registry = wl_display_get_registry(display_wrapper);
173 LOGE("failed to get wayland registry");
174 ret = CAMERA_ERROR_INVALID_OPERATION;
178 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
180 wl_display_dispatch_queue(display, queue);
181 wl_display_roundtrip_queue(display, queue);
184 LOGE("failed to get tizen surface");
185 ret = CAMERA_ERROR_INVALID_OPERATION;
189 /* Get parent_id which is unique in a entire systemw. */
190 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
192 LOGE("failed to get tizen resurce");
193 ret = CAMERA_ERROR_INVALID_OPERATION;
197 wl_info->parent_id = 0;
199 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
201 wl_display_roundtrip_queue(display, queue);
203 if (wl_info->parent_id > 0) {
205 Ecore_Evas *ecore_evas = NULL;
206 ret = CAMERA_ERROR_NONE;
208 wl_info->evas_obj = obj;
210 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
211 &wl_info->window_width, &wl_info->window_height);
213 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
215 rotation = ecore_evas_rotation_get(ecore_evas);
216 if (rotation == 90 || rotation == 270) {
217 int temp = wl_info->window_width;
219 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
221 wl_info->window_width = wl_info->window_height;
222 wl_info->window_height = temp;
225 LOGW("failed to get ecore_evas.. skip rotation check");
228 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
229 wl_info->evas_obj, rotation, wl_info->parent_id,
230 wl_info->window_x, wl_info->window_y,
231 wl_info->window_width, wl_info->window_height);
233 ret = CAMERA_ERROR_INVALID_OPERATION;
234 LOGE("failed to get parent id");
239 tizen_surface_destroy(tz_surface);
244 tizen_resource_destroy(tz_resource);
249 wl_registry_destroy(registry);
254 wl_event_queue_destroy(queue);
258 if (display_wrapper) {
259 wl_proxy_wrapper_destroy(display_wrapper);
260 display_wrapper = NULL;
267 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
270 api < 0 || api >= MUSE_CAMERA_API_MAX) {
271 LOGE("invalid param %p %d", cb_info, api);
275 g_mutex_lock(&(cb_info->api_mutex[api]));
276 cb_info->api_waiting[api] += value;
277 g_mutex_unlock(&(cb_info->api_mutex[api]));
279 /*LOGD("api %d, value %d, waiting %d",
280 api, value, cb_info->api_waiting[api]);*/
286 static void __camera_device_state_changed_cb(GDBusConnection *connection,
287 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
288 const gchar *signal_name, GVariant *param, gpointer user_data)
291 camera_device_e device = CAMERA_DEVICE_CAMERA0;
292 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
293 GList *tmp_list = NULL;
294 camera_cb_info *info = NULL;
296 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
298 if (!g_cam_dev_state_changed_cb_list || !param) {
299 LOGW("no callback or NULL param %p", param);
303 /* get device and state */
304 g_variant_get(param, "(i)", &value);
306 device = value >> 16;
307 state = 0x0000ffff & value;
309 LOGD("device %d, state %d", device, state);
311 tmp_list = g_cam_dev_state_changed_cb_list;
314 info = (camera_cb_info *)tmp_list->data;
317 if (info->callback) {
318 LOGD("start id[%d] callback", info->id);
319 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
320 LOGD("returned id[%d] callback", info->id);
322 LOGW("NULL callback for id %d", info->id);
326 tmp_list = tmp_list->next;
330 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
336 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
338 tbm_bo tmp_bo = NULL;
339 tbm_bo_handle tmp_bo_handle = {NULL, };
341 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
342 LOGE("invalid parameter - %p %p %p, key %d",
343 bufmgr, bo, bo_handle, tbm_key);
347 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
348 if (tmp_bo == NULL) {
349 LOGE("import failed - key %d", tbm_key);
353 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
354 if (tmp_bo_handle.ptr == NULL) {
355 LOGE("map failed %p", tmp_bo);
356 tbm_bo_unref(tmp_bo);
361 tbm_bo_unmap(tmp_bo);
363 /* set bo and bo_handle */
365 *bo_handle = tmp_bo_handle;
370 static void _camera_release_imported_bo(tbm_bo *bo)
383 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
385 int ret = CAMERA_ERROR_NONE;
388 /*LOGD("Enter api : %d", api);*/
390 if (!cb_info->is_server_connected) {
391 LOGE("server is disconnected");
392 return CAMERA_ERROR_SERVICE_DISCONNECTED;
395 g_mutex_lock(&(cb_info->api_mutex[api]));
397 if (cb_info->api_activating[api] == 0) {
398 if (time_out == CAMERA_CB_NO_TIMEOUT) {
399 LOGW("wait for api %d", api);
400 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
401 ret = cb_info->api_ret[api];
402 cb_info->api_activating[api] = 0;
403 LOGW("api %d returned 0x%x", api, ret);
405 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
406 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
407 ret = cb_info->api_ret[api];
408 cb_info->api_activating[api] = 0;
409 /*LOGD("return value : 0x%x", ret);*/
411 ret = CAMERA_ERROR_INVALID_OPERATION;
412 LOGE("api %d was TIMED OUT!", api);
416 ret = cb_info->api_ret[api];
417 cb_info->api_activating[api] = 0;
419 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
422 g_mutex_unlock(&(cb_info->api_mutex[api]));
424 if (ret != CAMERA_ERROR_NONE) {
425 LOGE("api %d : error 0x%x", api, ret);
427 if (ret == CAMERA_ERROR_SOUND_POLICY)
428 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
429 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
430 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
431 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
432 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
439 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
440 int *ret, int timeout)
446 LOGE("NULL info - api %d", api);
449 *ret = CAMERA_ERROR_INVALID_PARAMETER;
454 msg = muse_core_msg_new(api, NULL);
456 LOGE("msg failed: api %d", api);
459 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
464 /*LOGD("send msg %s", msg);*/
466 if (cb_info->is_server_connected) {
467 __camera_update_api_waiting(cb_info, api, 1);
469 g_mutex_lock(&cb_info->fd_lock);
470 send_ret = muse_core_msg_send(cb_info->fd, msg);
471 g_mutex_unlock(&cb_info->fd_lock);
475 LOGE("msg send failed");
477 *ret = CAMERA_ERROR_INVALID_OPERATION;
480 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
483 __camera_update_api_waiting(cb_info, api, -1);
485 muse_core_msg_free(msg);
491 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
492 int *ret, camera_msg_param *param, int timeout)
497 if (!cb_info || !param) {
498 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
501 *ret = CAMERA_ERROR_INVALID_PARAMETER;
506 /*LOGD("type %d, name %s", param->type, param->name);*/
508 switch (param->type) {
510 msg = muse_core_msg_new(api,
511 param->type, param->name, param->value.value_INT,
514 case MUSE_TYPE_STRING:
515 msg = muse_core_msg_new(api,
516 param->type, param->name, param->value.value_STRING,
520 LOGE("unknown type %d", param->type);
525 LOGE("msg failed: api %d", api);
528 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
533 /*LOGD("send msg %s", msg);*/
535 if (cb_info->is_server_connected) {
536 __camera_update_api_waiting(cb_info, api, 1);
538 g_mutex_lock(&cb_info->fd_lock);
539 send_ret = muse_core_msg_send(cb_info->fd, msg);
540 g_mutex_unlock(&cb_info->fd_lock);
544 LOGE("msg send failed");
547 *ret = CAMERA_ERROR_INVALID_OPERATION;
550 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
553 __camera_update_api_waiting(cb_info, api, -1);
555 muse_core_msg_free(msg);
561 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
563 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
564 in_format >= MM_PIXEL_FORMAT_NUM ||
565 out_format == NULL) {
566 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
567 return CAMERA_ERROR_INVALID_PARAMETER;
571 case MM_PIXEL_FORMAT_NV12:
572 case MM_PIXEL_FORMAT_NV12T:
573 *out_format = TBM_FORMAT_NV12;
575 case MM_PIXEL_FORMAT_NV16:
576 *out_format = TBM_FORMAT_NV16;
578 case MM_PIXEL_FORMAT_NV21:
579 *out_format = TBM_FORMAT_NV21;
581 case MM_PIXEL_FORMAT_YUYV:
582 *out_format = TBM_FORMAT_YUYV;
584 case MM_PIXEL_FORMAT_UYVY:
585 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
586 *out_format = TBM_FORMAT_UYVY;
588 case MM_PIXEL_FORMAT_422P:
589 *out_format = TBM_FORMAT_YUV422;
591 case MM_PIXEL_FORMAT_I420:
592 *out_format = TBM_FORMAT_YUV420;
594 case MM_PIXEL_FORMAT_YV12:
595 *out_format = TBM_FORMAT_YVU420;
597 case MM_PIXEL_FORMAT_RGB565:
598 *out_format = TBM_FORMAT_RGB565;
600 case MM_PIXEL_FORMAT_RGB888:
601 *out_format = TBM_FORMAT_RGB888;
603 case MM_PIXEL_FORMAT_RGBA:
604 *out_format = TBM_FORMAT_RGBA8888;
606 case MM_PIXEL_FORMAT_ARGB:
607 *out_format = TBM_FORMAT_ARGB8888;
610 LOGE("invalid in_format %d", in_format);
611 return CAMERA_ERROR_INVALID_PARAMETER;
614 return CAMERA_ERROR_NONE;
618 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
620 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
621 in_format >= MM_PIXEL_FORMAT_NUM ||
623 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
624 return CAMERA_ERROR_INVALID_PARAMETER;
628 case MM_PIXEL_FORMAT_NV12:
629 case MM_PIXEL_FORMAT_NV12T:
630 *mimetype = MEDIA_FORMAT_NV12;
632 case MM_PIXEL_FORMAT_NV16:
633 *mimetype = MEDIA_FORMAT_NV16;
635 case MM_PIXEL_FORMAT_NV21:
636 *mimetype = MEDIA_FORMAT_NV21;
638 case MM_PIXEL_FORMAT_YUYV:
639 *mimetype = MEDIA_FORMAT_YUYV;
641 case MM_PIXEL_FORMAT_UYVY:
642 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
643 *mimetype = MEDIA_FORMAT_UYVY;
645 case MM_PIXEL_FORMAT_422P:
646 *mimetype = MEDIA_FORMAT_422P;
648 case MM_PIXEL_FORMAT_I420:
649 *mimetype = MEDIA_FORMAT_I420;
651 case MM_PIXEL_FORMAT_YV12:
652 *mimetype = MEDIA_FORMAT_YV12;
654 case MM_PIXEL_FORMAT_RGB565:
655 *mimetype = MEDIA_FORMAT_RGB565;
657 case MM_PIXEL_FORMAT_RGB888:
658 *mimetype = MEDIA_FORMAT_RGB888;
660 case MM_PIXEL_FORMAT_RGBA:
661 *mimetype = MEDIA_FORMAT_RGBA;
663 case MM_PIXEL_FORMAT_ARGB:
664 *mimetype = MEDIA_FORMAT_ARGB;
667 LOGE("invalid in_format %d", in_format);
668 return CAMERA_ERROR_INVALID_PARAMETER;
671 return CAMERA_ERROR_NONE;
674 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
675 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
678 unsigned char *buf_pos = NULL;
680 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
681 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
686 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
687 frame->format = MM_PIXEL_FORMAT_UYVY;
689 frame->format = stream->format;
691 frame->width = stream->width;
692 frame->height = stream->height;
693 frame->timestamp = stream->timestamp;
694 frame->num_of_planes = stream->num_planes;
696 if (num_buffer_key == 0) {
698 if (!data_bo_handle || !data_bo_handle->ptr) {
699 LOGE("NULL pointer");
703 buf_pos = data_bo_handle->ptr;
705 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
706 frame->data.encoded_plane.data = buf_pos;
707 frame->data.encoded_plane.size = stream->data.encoded.length_data;
708 total_size = stream->data.encoded.length_data;
710 switch (stream->num_planes) {
712 frame->data.single_plane.yuv = buf_pos;
713 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
714 total_size = stream->data.yuv420.length_yuv;
717 frame->data.double_plane.y = buf_pos;
718 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
719 buf_pos += stream->data.yuv420sp.length_y;
720 frame->data.double_plane.uv = buf_pos;
721 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
722 total_size = stream->data.yuv420sp.length_y + \
723 stream->data.yuv420sp.length_uv;
726 frame->data.triple_plane.y = buf_pos;
727 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
728 buf_pos += stream->data.yuv420p.length_y;
729 frame->data.triple_plane.u = buf_pos;
730 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
731 buf_pos += stream->data.yuv420p.length_u;
732 frame->data.triple_plane.v = buf_pos;
733 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
734 total_size = stream->data.yuv420p.length_y + \
735 stream->data.yuv420p.length_u + \
736 stream->data.yuv420p.length_v;
744 switch (stream->num_planes) {
746 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
747 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
748 total_size = stream->data.yuv420.length_yuv;
751 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
752 if (stream->num_planes == (unsigned int)num_buffer_key)
753 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
755 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
756 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
757 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
758 total_size = stream->data.yuv420sp.length_y + \
759 stream->data.yuv420sp.length_uv;
762 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
763 if (stream->num_planes == (unsigned int)num_buffer_key) {
764 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
765 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
767 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
768 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
770 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
771 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
772 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
773 total_size = stream->data.yuv420p.length_y + \
774 stream->data.yuv420p.length_u + \
775 stream->data.yuv420p.length_v;
783 LOGD("format %d, %dx%d, size %d plane num %d",
784 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
790 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
791 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
794 int ret = CAMERA_ERROR_NONE;
795 camera_media_packet_data *tmp_mp_data = NULL;
797 if (*mp_data == NULL) {
798 tmp_mp_data = g_new0(camera_media_packet_data, 1);
800 tmp_mp_data->tbm_key = tbm_key;
801 tmp_mp_data->num_buffer_key = num_buffer_key;
802 tmp_mp_data->bo = bo;
803 tmp_mp_data->data_bo = data_bo;
804 tmp_mp_data->ref_cnt++;
806 for (i = 0 ; i < num_buffer_key ; i++)
807 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
809 *mp_data = tmp_mp_data;
810 /*LOGD("mp_data %p", tmp_mp_data);*/
812 ret = CAMERA_ERROR_OUT_OF_MEMORY;
813 LOGE("failed to alloc media packet data");
816 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
822 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
826 camera_msg_param param;
828 if (!mp_data || !cb_info) {
829 LOGE("NULL pointer %p %p", mp_data, cb_info);
833 if (mp_data->ref_cnt > 1) {
835 LOGD("ref count %d", mp_data->ref_cnt);
837 /* release imported bo */
838 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
839 tbm_bo_unref(mp_data->buffer_bo[i]);
840 mp_data->buffer_bo[i] = NULL;
844 _camera_release_imported_bo(&mp_data->bo);
845 _camera_release_imported_bo(&mp_data->data_bo);
848 tbm_key = mp_data->tbm_key;
850 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
852 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
861 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
862 camera_media_packet_data *mp_data, media_packet_h *packet)
864 media_packet_h pkt = NULL;
865 bool make_pkt_fmt = false;
866 tbm_surface_h tsurf = NULL;
867 tbm_surface_info_s tsurf_info;
868 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
869 uint32_t bo_format = 0;
872 int num_buffer_key = 0;
873 tbm_bo *buffer_bo = NULL;
875 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
876 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
877 cb_info, stream, mp_data, packet);
878 return CAMERA_ERROR_INVALID_PARAMETER;
881 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
882 buffer_bo = mp_data->buffer_bo;
883 num_buffer_key = mp_data->num_buffer_key;
885 /* create tbm surface */
886 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
887 tsurf_info.planes[i].stride = stream->stride[i];
889 /* get tbm surface format */
890 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
891 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
893 if (ret == CAMERA_ERROR_NONE) {
894 tsurf_info.width = stream->width;
895 tsurf_info.height = stream->height;
896 tsurf_info.format = bo_format;
897 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
898 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
900 if (num_buffer_key > 0) {
902 case TBM_FORMAT_NV12:
903 case TBM_FORMAT_NV21:
904 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
905 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
906 tsurf_info.planes[0].offset = 0;
907 if (num_buffer_key == 1)
908 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
909 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
911 case TBM_FORMAT_YUV420:
912 case TBM_FORMAT_YVU420:
913 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
914 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
915 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
916 tsurf_info.planes[0].offset = 0;
917 if (num_buffer_key == 1) {
918 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
919 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
921 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
923 case TBM_FORMAT_UYVY:
924 case TBM_FORMAT_YUYV:
925 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
926 tsurf_info.planes[0].offset = 0;
927 tsurf_info.size = tsurf_info.planes[0].size;
933 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
934 } else if (mp_data->data_bo) {
936 case TBM_FORMAT_NV12:
937 case TBM_FORMAT_NV21:
938 tsurf_info.planes[0].size = stream->width * stream->height;
939 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
940 tsurf_info.planes[0].offset = 0;
941 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
942 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
944 case TBM_FORMAT_YUV420:
945 case TBM_FORMAT_YVU420:
946 tsurf_info.planes[0].size = stream->width * stream->height;
947 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
948 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
949 tsurf_info.planes[0].offset = 0;
950 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
951 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
952 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
954 case TBM_FORMAT_UYVY:
955 case TBM_FORMAT_YUYV:
956 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
957 tsurf_info.planes[0].offset = 0;
958 tsurf_info.size = tsurf_info.planes[0].size;
964 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
966 /*LOGD("tbm surface %p", tsurf);*/
970 /* check media packet format */
971 if (cb_info->pkt_fmt) {
972 int pkt_fmt_width = 0;
973 int pkt_fmt_height = 0;
974 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
976 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
977 if (pkt_fmt_mimetype != mimetype ||
978 pkt_fmt_width != stream->width ||
979 pkt_fmt_height != stream->height) {
980 LOGW("change fmt: current 0x%x, %dx%d",
981 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
982 media_format_unref(cb_info->pkt_fmt);
983 cb_info->pkt_fmt = NULL;
990 /* create packet format */
992 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
993 ret = media_format_create(&cb_info->pkt_fmt);
994 if (ret == MEDIA_FORMAT_ERROR_NONE) {
995 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
996 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
997 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
998 LOGW("media_format_set : 0x%x", ret);
1000 LOGW("media_format_create failed 0x%x", ret);
1004 /* create media packet */
1005 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1006 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1007 (void *)cb_info, &pkt);
1008 if (ret != MEDIA_PACKET_ERROR_NONE) {
1009 LOGE("media_packet_create failed 0x%x", ret);
1010 tbm_surface_destroy(tsurf);
1014 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1015 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1019 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1020 /* set media packet data */
1021 ret = media_packet_set_extra(pkt, (void *)mp_data);
1022 if (ret != MEDIA_PACKET_ERROR_NONE) {
1023 LOGE("media_packet_set_extra failed");
1025 _camera_media_packet_data_release(mp_data, cb_info);
1028 media_packet_destroy(pkt);
1031 /* set timestamp : msec -> nsec */
1032 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1033 LOGW("media_packet_set_pts failed");
1042 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1045 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1046 camera_media_packet_data *mp_data = NULL;
1047 tbm_surface_h tsurf = NULL;
1049 if (!pkt || !cb_info) {
1050 LOGE("NULL pointer %p %p", pkt, cb_info);
1051 return MEDIA_PACKET_FINALIZE;
1054 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1055 if (ret != MEDIA_PACKET_ERROR_NONE) {
1056 LOGE("media_packet_get_extra failed 0x%x", ret);
1057 return MEDIA_PACKET_FINALIZE;
1060 /*LOGD("mp_data %p", mp_data);*/
1062 g_mutex_lock(&cb_info->mp_data_mutex);
1064 _camera_media_packet_data_release(mp_data, cb_info);
1067 g_mutex_unlock(&cb_info->mp_data_mutex);
1069 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1070 if (ret != MEDIA_PACKET_ERROR_NONE)
1071 LOGE("get tbm_surface failed 0x%x", ret);
1074 tbm_surface_destroy(tsurf);
1078 return MEDIA_PACKET_FINALIZE;
1081 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1087 tbm_bo_handle bo_handle = {NULL, };
1088 camera_msg_param param;
1090 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1091 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1095 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1097 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1099 if (cb_info->user_cb[event] == NULL) {
1100 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1101 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1102 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1103 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1104 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1105 LOGW("NULL callback for event %d, return here", event);
1108 /* do not return in this case, because return buffer message should be sent. */
1109 LOGW("NULL callback for event %d, NOT return here", event);
1114 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1120 muse_camera_msg_get(previous, recv_msg);
1121 muse_camera_msg_get(current, recv_msg);
1122 muse_camera_msg_get(by_policy, recv_msg);
1124 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1125 previous, current, by_policy);
1127 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1128 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1131 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1135 muse_camera_msg_get(state, recv_msg);
1137 LOGD("FOCUS state - %d", state);
1139 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1142 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1143 LOGD("CAPTURE_COMPLETED");
1144 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1146 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1147 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1151 int num_buffer_key = 0;
1152 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1154 unsigned char *buf_pos = NULL;
1156 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1157 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1158 tbm_bo data_bo = NULL;
1159 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1161 camera_preview_data_s frame;
1162 camera_stream_data_s *stream = NULL;
1163 camera_media_packet_data *mp_data = NULL;
1164 media_packet_h pkt = NULL;
1165 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1166 media_packet_h pkt_evas = NULL;
1167 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1169 muse_camera_msg_get(tbm_key, recv_msg);
1170 muse_camera_msg_get(num_buffer_key, recv_msg);
1171 muse_camera_msg_get_array(buffer_key, recv_msg);
1172 muse_camera_msg_get(data_key, recv_msg);
1174 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1177 LOGE("invalid key %d", tbm_key);
1181 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1183 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1184 LOGE("invalid num buffer key %d", num_buffer_key);
1185 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1190 /* import tbm data_bo and get virtual address */
1191 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1192 LOGE("failed to import data key %d", data_key);
1193 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1198 /* import tbm bo and get virtual address */
1199 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1200 LOGE("failed to import key %d", tbm_key);
1201 _camera_release_imported_bo(&data_bo);
1202 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1206 buf_pos = (unsigned char *)bo_handle.ptr;
1208 /* get stream info */
1209 stream = (camera_stream_data_s *)buf_pos;
1211 for (i = 0 ; i < num_buffer_key ; i++) {
1212 /* import buffer bo and get virtual address */
1213 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1214 LOGE("failed to import buffer key %d", buffer_key[i]);
1216 /* release imported bo */
1217 _camera_release_imported_bo(&data_bo);
1218 _camera_release_imported_bo(&bo);
1220 for (i -= 1 ; i >= 0 ; i--)
1221 _camera_release_imported_bo(&buffer_bo[i]);
1223 /* send return buffer */
1224 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1230 /* call preview callback */
1231 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1232 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1234 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1235 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1238 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1239 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1240 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1242 if (ret == CAMERA_ERROR_NONE) {
1243 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1244 if (ret != CAMERA_ERROR_NONE) {
1245 LOGE("create pkt for evas failed");
1246 _camera_media_packet_data_release(mp_data, cb_info);
1250 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1251 LOGW("evas renderer is not supported");
1252 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1255 /* call media packet callback */
1256 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1257 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1259 if (ret == CAMERA_ERROR_NONE) {
1260 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1262 if (ret == CAMERA_ERROR_NONE) {
1263 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1264 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1266 _camera_media_packet_data_release(mp_data, cb_info);
1272 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1273 /* call evas renderer */
1275 g_mutex_lock(&cb_info->evas_mutex);
1276 if (cb_info->run_evas_render) {
1277 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1279 LOGW("evas renderer is stopped, skip this buffer...");
1280 media_packet_destroy(pkt_evas);
1283 g_mutex_unlock(&cb_info->evas_mutex);
1285 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1287 /* send message for preview callback return */
1288 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1289 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1291 if (mp_data == NULL) {
1292 /* release imported bo */
1293 for (i = 0 ; i < num_buffer_key ; i++)
1294 _camera_release_imported_bo(&buffer_bo[i]);
1296 /* unmap and unref tbm bo */
1297 _camera_release_imported_bo(&data_bo);
1298 _camera_release_imported_bo(&bo);
1301 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1303 /*LOGD("return buffer Done");*/
1307 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1311 muse_camera_msg_get(percent, recv_msg);
1313 LOGD("HDR progress - %d %%", percent);
1315 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1318 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1324 muse_camera_msg_get(policy, recv_msg);
1325 muse_camera_msg_get(previous, recv_msg);
1326 muse_camera_msg_get(current, recv_msg);
1328 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1329 policy, previous, current);
1331 if (policy == CAMERA_POLICY_SOUND)
1332 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1333 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1334 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1335 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1336 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1338 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1339 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1342 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1347 muse_camera_msg_get(policy, recv_msg);
1348 muse_camera_msg_get(state, recv_msg);
1350 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1352 if (policy == CAMERA_POLICY_SOUND)
1353 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1354 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1355 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1356 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1357 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1359 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1360 (camera_state_e)state, cb_info->user_data[event]);
1363 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1366 camera_detected_face_s *faces = NULL;
1368 muse_camera_msg_get(count, recv_msg);
1369 muse_camera_msg_get(tbm_key, recv_msg);
1371 if (count >= 0 && cb_info->user_cb[event]) {
1372 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1376 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1378 faces = bo_handle.ptr;
1382 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1385 _camera_release_imported_bo(&bo);
1387 LOGW("skip face detection message [count %d, key %d, cb %p",
1388 count, tbm_key, cb_info->user_cb[event]);
1393 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1394 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1395 /*LOGD("return buffer done");*/
1399 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1402 int current_state = 0;
1404 muse_camera_msg_get(error, recv_msg);
1405 muse_camera_msg_get(current_state, recv_msg);
1407 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1409 if (error == CAMERA_ERROR_SOUND_POLICY)
1410 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1411 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1412 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1413 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1414 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1416 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1417 (camera_state_e)current_state, cb_info->user_data[event]);
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1423 muse_camera_msg_get(param1, recv_msg);
1424 muse_camera_msg_get(param2, recv_msg);
1426 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1428 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1429 cb_info->user_cb[event] = NULL;
1430 cb_info->user_data[event] = NULL;
1431 LOGW("stop foreach callback for event %d", event);
1434 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1436 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1438 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1442 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1448 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1450 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1452 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1454 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1456 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1458 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1460 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1462 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1463 muse_camera_msg_get(param1, recv_msg);
1465 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1467 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1468 cb_info->user_cb[event] = NULL;
1469 cb_info->user_data[event] = NULL;
1470 LOGW("stop foreach callback for event %d", event);
1473 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1475 camera_image_data_s *rImage = NULL;
1476 camera_image_data_s *rPostview = NULL;
1477 camera_image_data_s *rThumbnail = NULL;
1478 unsigned char *buf_pos = NULL;
1479 int tbm_key_main = 0;
1480 int tbm_key_post = 0;
1481 int tbm_key_thumb = 0;
1482 tbm_bo bo_main = NULL;
1483 tbm_bo bo_post = NULL;
1484 tbm_bo bo_thumb = NULL;
1485 tbm_bo_handle bo_main_handle = {NULL, };
1486 tbm_bo_handle bo_post_handle = {NULL, };
1487 tbm_bo_handle bo_thumb_handle = {NULL, };
1489 muse_camera_msg_get(tbm_key_main, recv_msg);
1490 muse_camera_msg_get(tbm_key_post, recv_msg);
1491 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1494 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1495 tbm_key_main, tbm_key_post, tbm_key_thumb);
1498 if (tbm_key_main <= 0) {
1499 LOGE("invalid key %d", tbm_key_main);
1503 if (cb_info->user_cb[event] == NULL) {
1504 LOGW("NULL callback");
1505 goto _EVENT_CAPTURE_DONE;
1508 /* import tbm bo and get virtual address */
1509 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
1510 LOGE("failed to import key [%d] for main", tbm_key_main);
1511 goto _EVENT_CAPTURE_DONE;
1514 buf_pos = (unsigned char *)bo_main_handle.ptr;
1515 rImage = (camera_image_data_s *)buf_pos;
1516 rImage->data = buf_pos + sizeof(camera_image_data_s);
1517 if (rImage->exif && rImage->exif_size > 0) {
1518 rImage->exif = rImage->data + rImage->size;
1520 rImage->exif = NULL;
1521 rImage->exif_size = 0;
1524 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1525 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1527 if (tbm_key_post > 0) {
1528 /* import tbm bo and get virtual address */
1529 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
1530 buf_pos = (unsigned char *)bo_post_handle.ptr;
1531 rPostview = (camera_image_data_s *)buf_pos;
1532 LOGD("rPostview->size : %d", rPostview->size);
1533 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1535 LOGE("failed to import key [%d] for postview", tbm_key_post);
1539 if (tbm_key_thumb > 0) {
1540 /* import tbm bo and get virtual address */
1541 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
1542 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1543 rThumbnail = (camera_image_data_s *)buf_pos;
1544 LOGD("rThumbnail->size : %d", rThumbnail->size);
1545 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1547 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
1551 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1553 /* unmap and unref tbm bo */
1554 _camera_release_imported_bo(&bo_main);
1556 _EVENT_CAPTURE_DONE:
1558 tbm_key = tbm_key_main;
1560 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1562 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1564 if (tbm_key_post > 0) {
1565 /* unmap and unref tbm bo */
1566 _camera_release_imported_bo(&bo_post);
1569 param.value.value_INT = tbm_key_post;
1570 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1573 if (tbm_key_thumb > 0) {
1574 /* unmap and unref tbm bo */
1575 _camera_release_imported_bo(&bo_thumb);
1578 param.value.value_INT = tbm_key_thumb;
1579 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1582 LOGD("return buffer done");
1586 LOGW("unhandled event %d", event);
1590 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1595 static bool _camera_idle_event_callback(void *data)
1597 camera_cb_info_s *cb_info = NULL;
1598 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1600 if (cam_idle_event == NULL) {
1601 LOGE("cam_idle_event is NULL");
1606 g_mutex_lock(&cam_idle_event->event_mutex);
1608 cb_info = cam_idle_event->cb_info;
1609 if (cb_info == NULL) {
1610 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1611 goto IDLE_EVENT_CALLBACK_DONE;
1614 /* remove event from list */
1615 g_mutex_lock(&cb_info->idle_event_mutex);
1617 if (cb_info->idle_event_list)
1618 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1620 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1621 g_mutex_unlock(&cb_info->idle_event_mutex);
1624 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1626 /* send signal for waiting thread */
1627 g_cond_signal(&cb_info->idle_event_cond);
1629 IDLE_EVENT_CALLBACK_DONE:
1630 /* unlock and release event */
1631 g_mutex_unlock(&cam_idle_event->event_mutex);
1632 g_mutex_clear(&cam_idle_event->event_mutex);
1634 g_free(cam_idle_event);
1635 cam_idle_event = NULL;
1640 static void *_camera_msg_handler_func(gpointer data)
1644 camera_message_s *cam_msg = NULL;
1645 camera_idle_event_s *cam_idle_event = NULL;
1646 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1647 camera_cb_info_s *cb_info = NULL;
1649 if (!handler_info || !handler_info->cb_info) {
1650 LOGE("NULL handler %p", handler_info);
1654 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1655 type = handler_info->type;
1657 LOGD("t:%d start", type);
1659 g_mutex_lock(&handler_info->mutex);
1661 while (g_atomic_int_get(&handler_info->running)) {
1662 if (g_queue_is_empty(handler_info->queue)) {
1663 /*LOGD("t:%d signal wait...", type);*/
1664 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1665 /*LOGD("t:%d signal received", type);*/
1667 if (g_atomic_int_get(&handler_info->running) == 0) {
1668 LOGD("t:%d stop event thread", type);
1673 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1675 g_mutex_unlock(&handler_info->mutex);
1677 if (cam_msg == NULL) {
1678 LOGE("t:%d NULL message", type);
1679 g_mutex_lock(&handler_info->mutex);
1685 if (api < MUSE_CAMERA_API_MAX) {
1688 g_mutex_lock(&cb_info->api_mutex[api]);
1690 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1691 if (cb_info->api_waiting[api] > 0) {
1692 cb_info->api_ret[api] = ret;
1693 cb_info->api_activating[api] = 1;
1695 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1697 g_cond_signal(&cb_info->api_cond[api]);
1699 LOGW("no waiting for this api [%d]", api);
1702 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1705 g_mutex_unlock(&cb_info->api_mutex[api]);
1706 } else if (api == MUSE_CAMERA_CB_EVENT) {
1707 switch (cam_msg->event_class) {
1708 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1709 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1711 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1712 cam_idle_event = g_new0(camera_idle_event_s, 1);
1713 if (cam_idle_event == NULL) {
1714 LOGE("t:%d cam_idle_event alloc failed", type);
1718 cam_idle_event->event = cam_msg->event;
1719 cam_idle_event->cb_info = cb_info;
1720 g_mutex_init(&cam_idle_event->event_mutex);
1721 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1723 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1725 g_mutex_lock(&cb_info->idle_event_mutex);
1726 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1727 g_mutex_unlock(&cb_info->idle_event_mutex);
1729 g_idle_add_full(G_PRIORITY_DEFAULT,
1730 (GSourceFunc)_camera_idle_event_callback,
1731 (gpointer)cam_idle_event,
1735 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1739 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1745 g_mutex_lock(&handler_info->mutex);
1748 /* remove remained event */
1749 while (!g_queue_is_empty(handler_info->queue)) {
1750 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1752 LOGD("t:%d remove camera message %p", type, cam_msg);
1756 LOGW("t:%d NULL camera message", type);
1760 g_mutex_unlock(&handler_info->mutex);
1762 LOGD("t:%d return", type);
1768 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1770 camera_idle_event_s *cam_idle_event = NULL;
1772 gint64 end_time = 0;
1774 if (cb_info == NULL) {
1775 LOGE("cb_info is NULL");
1779 g_mutex_lock(&cb_info->idle_event_mutex);
1781 if (cb_info->idle_event_list == NULL) {
1782 LOGD("No remained idle event");
1783 g_mutex_unlock(&cb_info->idle_event_mutex);
1787 list = cb_info->idle_event_list;
1790 cam_idle_event = list->data;
1791 list = g_list_next(list);
1793 if (!cam_idle_event) {
1794 LOGW("Fail to remove idle event. The event is NULL");
1798 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1799 LOGW("lock failed, %p event is calling now", cam_idle_event);
1801 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1803 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1804 LOGW("signal received");
1811 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1812 cam_idle_event, cam_idle_event->event);
1814 cam_idle_event->cb_info = NULL;
1816 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1818 g_mutex_unlock(&cam_idle_event->event_mutex);
1821 g_list_free(cb_info->idle_event_list);
1822 cb_info->idle_event_list = NULL;
1824 g_mutex_unlock(&cb_info->idle_event_mutex);
1830 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1832 camera_message_s *cam_msg = NULL;
1834 if (!cb_info || !msg) {
1835 LOGE("NULL pointer %p %p", cb_info, msg);
1839 cam_msg = g_new0(camera_message_s, 1);
1841 LOGE("failed to alloc cam_msg for [%s]", msg);
1846 cam_msg->event = event;
1847 cam_msg->event_class = event_class;
1849 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1851 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1853 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1854 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1855 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1856 g_cond_signal(&cb_info->preview_cb_info.cond);
1857 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1858 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1859 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1860 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1861 g_cond_signal(&cb_info->capture_cb_info.cond);
1862 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1864 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1865 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1866 g_cond_signal(&cb_info->msg_handler_info.cond);
1867 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1876 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1878 int ret = CAMERA_ERROR_NONE;
1882 int event_class = -1;
1886 if (!cb_info || !msg) {
1887 LOGE("invalid ptr %p %p", cb_info, msg);
1891 /*LOGD("msg [%s]", msg);*/
1893 if (!muse_camera_msg_get(api, msg)) {
1894 LOGE("failed to get camera api");
1898 if (api == MUSE_CAMERA_CB_EVENT) {
1899 if (!muse_camera_msg_get(event, msg) ||
1900 !muse_camera_msg_get(event_class, msg)) {
1901 LOGE("failed to get camera event or event_class [%s]", msg);
1905 if (!muse_camera_msg_get(api_class, msg)) {
1906 LOGE("failed to get camera api_class [%s]", msg);
1911 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1912 if (api >= MUSE_CAMERA_API_MAX) {
1913 LOGE("invalid api %d", api);
1917 if (!muse_camera_msg_get(ret, msg)) {
1918 LOGE("failed to get camera ret");
1922 g_mutex_lock(&cb_info->api_mutex[api]);
1925 case MUSE_CAMERA_API_CREATE:
1926 if (ret != CAMERA_ERROR_NONE) {
1927 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1928 LOGE("camera create error 0x%x. close client cb handler", ret);
1931 case MUSE_CAMERA_API_DESTROY:
1932 if (ret == CAMERA_ERROR_NONE) {
1933 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1934 LOGD("camera destroy done. close client cb handler");
1938 muse_camera_msg_get(get_type, msg);
1939 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1940 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1941 muse_camera_msg_get(get_index, msg);
1944 case MUSE_CAMERA_GET_TYPE_INT:
1945 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1947 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1948 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1949 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1951 case MUSE_CAMERA_GET_TYPE_ARRAY:
1952 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1953 muse_core_msg_deserialize("get_value",
1954 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1955 LOGD("get display roi %d,%d,%dx%d",
1956 cb_info->get_display_roi_area[0],
1957 cb_info->get_display_roi_area[1],
1958 cb_info->get_display_roi_area[2],
1959 cb_info->get_display_roi_area[3]);
1961 muse_core_msg_deserialize("get_value",
1962 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1963 LOGD("get geotag %lf, %lf, %lf",
1964 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1967 case MUSE_CAMERA_GET_TYPE_STRING:
1968 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1971 LOGW("unknown type %d", get_type);
1978 if (cb_info->api_waiting[api] > 0) {
1979 cb_info->api_ret[api] = ret;
1980 cb_info->api_activating[api] = 1;
1982 g_cond_signal(&cb_info->api_cond[api]);
1984 LOGW("no waiting for this api [%d]", api);
1987 g_mutex_unlock(&cb_info->api_mutex[api]);
1988 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1989 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1991 LOGW("unknown camera api %d, class %d", api, api_class);
1998 static void *_camera_msg_recv_func(gpointer data)
2000 int recv_length = 0;
2001 int single_length = 0;
2002 int remained_length = 0;
2003 char *recv_msg = NULL;
2004 char *single_msg = NULL;
2005 char *remained_msg = NULL;
2009 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2012 LOGE("cb_info NULL");
2018 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2020 LOGE("single_msg malloc failed");
2024 recv_msg = cb_info->recv_msg;
2026 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2027 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2028 if (recv_length <= 0) {
2029 cb_info->is_server_connected = FALSE;
2030 LOGE("receive msg failed - server disconnected");
2038 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2040 /* Need to split the combined entering msgs */
2041 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2042 if (recv_msg[cur_pos] == '}') {
2043 single_length = cur_pos - prev_pos + 1;
2045 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2046 /* check remained msg */
2047 if (remained_length > 0) {
2049 strncpy(single_msg, remained_msg, remained_length);
2050 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2051 single_msg[remained_length + single_length] = '\0';
2054 remained_msg = NULL;
2056 strncpy(single_msg, recv_msg + prev_pos, single_length);
2057 single_msg[single_length] = '\0';
2058 LOGE("lost msg [%s], skip...", single_msg);
2061 remained_length = 0;
2063 strncpy(single_msg, recv_msg + prev_pos, single_length);
2064 single_msg[single_length] = '\0';
2067 if (single_msg[0] == '{') {
2069 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2070 /* process each message */
2071 __camera_process_msg(cb_info, single_msg);
2073 LOGE("invalid msg [%s]", single_msg);
2076 LOGE("too long message [len %d] skip...", single_length);
2079 prev_pos = cur_pos + 1;
2083 /* check incompleted message */
2084 if (recv_msg[recv_length - 1] != '}') {
2085 remained_length = recv_length - prev_pos;
2087 LOGW("incompleted message [len %d]", remained_length);
2091 remained_msg = NULL;
2094 remained_msg = (char *)malloc(remained_length + 1);
2096 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2097 remained_msg[remained_length] = '\0';
2099 LOGE("failed to alloc for remained msg");
2102 remained_length = 0;
2106 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2108 if (!cb_info->is_server_connected) {
2109 /* send error msg for server disconnection */
2110 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2111 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2112 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2116 LOGE("error_msg failed");
2117 goto CB_HANDLER_EXIT;
2120 __camera_add_msg_to_queue(cb_info,
2121 MUSE_CAMERA_CB_EVENT,
2122 MUSE_CAMERA_EVENT_TYPE_ERROR,
2123 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2126 muse_core_msg_free(error_msg);
2129 LOGE("add error msg for service disconnection done");
2140 remained_msg = NULL;
2147 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2148 int type, const char *thread_name, camera_cb_info_s *cb_info)
2150 if (!handler_info || !thread_name || !cb_info) {
2151 LOGE("t:%d NULL %p %p %p",
2152 type, handler_info, thread_name, cb_info);
2158 handler_info->type = type;
2159 handler_info->queue = g_queue_new();
2160 if (handler_info->queue == NULL) {
2161 LOGE("t:%d queue failed", type);
2165 g_mutex_init(&handler_info->mutex);
2166 g_cond_init(&handler_info->cond);
2168 handler_info->cb_info = (void *)cb_info;
2169 g_atomic_int_set(&handler_info->running, 1);
2171 handler_info->thread = g_thread_try_new(thread_name,
2172 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2173 if (handler_info->thread == NULL) {
2174 LOGE("t:%d thread failed", type);
2176 g_mutex_clear(&handler_info->mutex);
2177 g_cond_clear(&handler_info->cond);
2178 g_queue_free(handler_info->queue);
2179 handler_info->queue = NULL;
2184 LOGD("t:%d done", type);
2190 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2194 if (!handler_info) {
2195 LOGE("NULL handler");
2199 if (!handler_info->thread) {
2200 LOGW("thread is not created");
2204 type = handler_info->type;
2206 LOGD("t:%d thread %p", type, handler_info->thread);
2208 g_mutex_lock(&handler_info->mutex);
2209 g_atomic_int_set(&handler_info->running, 0);
2210 g_cond_signal(&handler_info->cond);
2211 g_mutex_unlock(&handler_info->mutex);
2213 g_thread_join(handler_info->thread);
2214 handler_info->thread = NULL;
2216 g_mutex_clear(&handler_info->mutex);
2217 g_cond_clear(&handler_info->cond);
2218 g_queue_free(handler_info->queue);
2219 handler_info->queue = NULL;
2221 LOGD("t:%d done", type);
2227 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2229 camera_cb_info_s *cb_info = NULL;
2232 g_return_val_if_fail(sockfd > 0, NULL);
2234 cb_info = g_new0(camera_cb_info_s, 1);
2235 if (cb_info == NULL) {
2236 LOGE("cb_info failed");
2240 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2242 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2243 g_mutex_init(&cb_info->api_mutex[i]);
2244 g_cond_init(&cb_info->api_cond[i]);
2247 g_mutex_init(&cb_info->fd_lock);
2248 g_mutex_init(&cb_info->idle_event_mutex);
2249 g_cond_init(&cb_info->idle_event_cond);
2250 g_mutex_init(&cb_info->mp_data_mutex);
2251 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2252 g_mutex_init(&cb_info->evas_mutex);
2253 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2255 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2256 g_mutex_init(&cb_info->user_cb_mutex[i]);
2258 /* message handler thread */
2259 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2260 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2261 LOGE("msg_handler_info failed");
2265 /* message handler thread for preview callback */
2266 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2267 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2268 LOGE("preview_cb_info failed");
2272 /* message handler thread for capture callback */
2273 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2274 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2275 LOGE("capture_cb_info failed");
2279 cb_info->fd = sockfd;
2280 cb_info->preview_cb_flag = 0;
2281 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2282 cb_info->evas_info = NULL;
2283 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2285 /* message receive thread */
2286 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2287 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2288 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2289 if (cb_info->msg_recv_thread == NULL) {
2290 LOGE("message receive thread creation failed");
2294 cb_info->is_server_connected = TRUE;
2300 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2301 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2302 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2304 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2305 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2307 g_mutex_clear(&cb_info->fd_lock);
2308 g_mutex_clear(&cb_info->idle_event_mutex);
2309 g_cond_clear(&cb_info->idle_event_cond);
2310 g_mutex_clear(&cb_info->mp_data_mutex);
2311 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2312 g_mutex_clear(&cb_info->evas_mutex);
2313 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2315 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2316 g_mutex_clear(&cb_info->api_mutex[i]);
2317 g_cond_clear(&cb_info->api_cond[i]);
2327 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2331 g_return_if_fail(cb_info != NULL);
2333 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2335 g_thread_join(cb_info->msg_recv_thread);
2336 cb_info->msg_recv_thread = NULL;
2338 LOGD("msg_recv thread removed");
2340 /* destroy msg handler threads */
2341 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2342 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2343 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2345 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2346 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2348 g_mutex_clear(&cb_info->fd_lock);
2349 g_mutex_clear(&cb_info->idle_event_mutex);
2350 g_cond_clear(&cb_info->idle_event_cond);
2351 g_mutex_clear(&cb_info->mp_data_mutex);
2352 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2353 g_mutex_clear(&cb_info->evas_mutex);
2354 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2356 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2357 g_mutex_clear(&cb_info->api_mutex[i]);
2358 g_cond_clear(&cb_info->api_cond[i]);
2361 if (cb_info->fd > -1) {
2362 muse_client_close(cb_info->fd);
2366 if (cb_info->bufmgr) {
2367 tbm_bufmgr_deinit(cb_info->bufmgr);
2368 cb_info->bufmgr = NULL;
2370 if (cb_info->pkt_fmt) {
2371 media_format_unref(cb_info->pkt_fmt);
2372 cb_info->pkt_fmt = NULL;
2375 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2376 if (cb_info->evas_info)
2377 mm_evas_renderer_destroy(&cb_info->evas_info);
2378 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2380 cb_info->preview_cb_flag = 0;
2389 int _camera_start_evas_rendering(camera_h camera)
2391 int ret = CAMERA_ERROR_NONE;
2392 camera_cli_s *pc = (camera_cli_s *)camera;
2394 if (!pc || !pc->cb_info) {
2395 LOGE("NULL handle");
2396 return CAMERA_ERROR_INVALID_PARAMETER;
2401 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2402 LOGE("EVAS surface is not set");
2403 return CAMERA_ERROR_NONE;
2406 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2407 g_mutex_lock(&pc->cb_info->evas_mutex);
2409 /* set evas render flag as RUN */
2410 pc->cb_info->run_evas_render = true;
2411 ret = CAMERA_ERROR_NONE;
2413 g_mutex_unlock(&pc->cb_info->evas_mutex);
2414 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2415 LOGW("evas renderer is not supported");
2416 ret = CAMERA_ERROR_NOT_SUPPORTED;
2417 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2423 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2425 int ret = CAMERA_ERROR_NONE;
2426 camera_cli_s *pc = (camera_cli_s *)camera;
2428 if (!pc || !pc->cb_info) {
2429 LOGE("NULL handle");
2430 return CAMERA_ERROR_INVALID_PARAMETER;
2433 LOGD("stop - keep screen %d", keep_screen);
2435 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2436 LOGE("EVAS surface is not set");
2437 return CAMERA_ERROR_NONE;
2440 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2441 g_mutex_lock(&pc->cb_info->evas_mutex);
2443 /* set evas render flag as STOP and release buffers */
2444 pc->cb_info->run_evas_render = false;
2446 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2447 if (ret != MM_ERROR_NONE) {
2448 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2449 ret = CAMERA_ERROR_INVALID_OPERATION;
2452 g_mutex_unlock(&pc->cb_info->evas_mutex);
2453 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2454 LOGW("evas renderer is not supported");
2455 ret = CAMERA_ERROR_NOT_SUPPORTED;
2456 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2462 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2464 int ret = CAMERA_ERROR_NONE;
2467 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2469 /* create muse connection */
2470 if (!key || !value) {
2471 LOGE("NULL pointer");
2472 return CAMERA_ERROR_INVALID_PARAMETER;
2475 sock_fd = muse_client_new();
2477 LOGE("muse_client_new failed");
2478 return CAMERA_ERROR_INVALID_OPERATION;
2481 msg = muse_core_msg_new(api,
2482 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2483 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2487 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2491 ret = muse_core_msg_send(sock_fd, msg);
2493 muse_core_msg_free(msg);
2497 LOGE("send msg failed");
2498 ret = CAMERA_ERROR_INVALID_OPERATION;
2502 ret = muse_core_msg_recv(sock_fd, recv_msg);
2504 LOGE("recv msg failed %d", errno);
2505 ret = CAMERA_ERROR_INVALID_OPERATION;
2509 if (!muse_camera_msg_get(ret, recv_msg)) {
2510 LOGE("failed to get return value from msg [%s]", recv_msg);
2511 ret = CAMERA_ERROR_INVALID_OPERATION;
2515 if (ret == CAMERA_ERROR_NONE)
2516 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2518 LOGD("api %d - value %d", api, *value);
2522 muse_client_close(sock_fd);
2530 int camera_create(camera_device_e device, camera_h *camera)
2533 char *send_msg = NULL;
2535 int ret = CAMERA_ERROR_NONE;
2537 camera_cli_s *pc = NULL;
2538 tbm_bufmgr bufmgr = NULL;
2540 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2541 muse_core_api_module_e muse_module = MUSE_CAMERA;
2542 int device_type = (int)device;
2545 LOGE("NULL pointer");
2546 return CAMERA_ERROR_INVALID_PARAMETER;
2549 sock_fd = muse_client_new();
2551 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2552 ret = CAMERA_ERROR_INVALID_OPERATION;
2558 send_msg = muse_core_msg_new(api,
2559 MUSE_TYPE_INT, "module", muse_module,
2560 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2561 MUSE_TYPE_INT, "pid", pid,
2566 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2570 send_ret = muse_core_msg_send(sock_fd, send_msg);
2572 muse_core_msg_free(send_msg);
2576 LOGE("send msg failed %d", errno);
2577 ret = CAMERA_ERROR_INVALID_OPERATION;
2581 pc = g_new0(camera_cli_s, 1);
2583 LOGE("camera_cli_s alloc failed");
2584 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2588 bufmgr = tbm_bufmgr_init(-1);
2589 if (bufmgr == NULL) {
2590 LOGE("get tbm bufmgr failed");
2591 ret = CAMERA_ERROR_INVALID_OPERATION;
2595 pc->cb_info = _camera_client_callback_new(sock_fd);
2596 if (pc->cb_info == NULL) {
2597 LOGE("cb_info alloc failed");
2598 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2604 LOGD("cb info : %d", pc->cb_info->fd);
2606 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2608 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2610 if (ret == CAMERA_ERROR_NONE) {
2611 intptr_t handle = 0;
2612 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2614 LOGE("Receiving Handle Failed!!");
2615 ret = CAMERA_ERROR_INVALID_OPERATION;
2619 pc->remote_handle = handle;
2620 pc->cb_info->bufmgr = bufmgr;
2622 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2623 if (ret != CAMERA_ERROR_NONE) {
2624 LOGE("init display failed 0x%x", ret);
2628 LOGD("camera create 0x%x", pc->remote_handle);
2629 *camera = (camera_h)pc;
2638 tbm_bufmgr_deinit(bufmgr);
2643 muse_client_close(sock_fd);
2649 _camera_client_callback_destroy(pc->cb_info);
2656 LOGE("camera create error : 0x%x", ret);
2662 int camera_change_device(camera_h camera, camera_device_e device)
2665 int ret = CAMERA_ERROR_NONE;
2666 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2667 camera_cli_s *pc = (camera_cli_s *)camera;
2668 camera_msg_param param;
2670 if (!pc || !pc->cb_info) {
2671 LOGE("NULL handle");
2672 return CAMERA_ERROR_INVALID_PARAMETER;
2675 CAMERA_MSG_PARAM_SET(param, INT, device);
2677 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2679 if (ret == CAMERA_ERROR_NONE) {
2680 /* reset callback and user data */
2681 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2682 pc->cb_info->user_cb[i] = NULL;
2683 pc->cb_info->user_data[i] = NULL;
2685 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2692 int camera_destroy(camera_h camera)
2694 int ret = CAMERA_ERROR_NONE;
2695 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2696 camera_cli_s *pc = (camera_cli_s *)camera;
2698 if (!pc || !pc->cb_info) {
2699 LOGE("NULL handle");
2700 return CAMERA_ERROR_INVALID_PARAMETER;
2705 if (pc->cb_info->is_server_connected)
2706 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2708 LOGW("server disconnected. release resource without send message.");
2710 if (ret == CAMERA_ERROR_NONE) {
2711 _camera_deactivate_idle_event_all(pc->cb_info);
2712 _camera_client_callback_destroy(pc->cb_info);
2722 int camera_start_preview(camera_h camera)
2724 int ret = CAMERA_ERROR_NONE;
2725 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2726 camera_cli_s *pc = (camera_cli_s *)camera;
2728 if (!pc || !pc->cb_info) {
2729 LOGE("NULL handle");
2730 return CAMERA_ERROR_INVALID_PARAMETER;
2735 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2736 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2737 ret = _camera_start_evas_rendering(camera);
2738 if (ret != CAMERA_ERROR_NONE) {
2739 LOGE("stop preview because of error");
2740 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2744 LOGD("ret : 0x%x", ret);
2750 int camera_stop_preview(camera_h camera)
2752 int ret = CAMERA_ERROR_NONE;
2753 camera_cli_s *pc = (camera_cli_s *)camera;
2754 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2755 camera_state_e current_state = CAMERA_STATE_NONE;
2757 if (!pc || !pc->cb_info) {
2758 LOGE("NULL handle");
2759 return CAMERA_ERROR_INVALID_PARAMETER;
2764 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2765 ret = camera_get_state(camera, ¤t_state);
2766 if (ret != CAMERA_ERROR_NONE) {
2767 LOGE("failed to get current state 0x%x", ret);
2771 if (current_state == CAMERA_STATE_PREVIEW) {
2772 ret = _camera_stop_evas_rendering(camera, false);
2773 if (ret != CAMERA_ERROR_NONE)
2778 /* send stop preview message */
2779 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2781 if (ret != CAMERA_ERROR_NONE &&
2782 current_state == CAMERA_STATE_PREVIEW) {
2783 LOGW("restart evas rendering");
2784 _camera_start_evas_rendering(camera);
2787 LOGD("ret : 0x%x", ret);
2793 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2795 int ret = CAMERA_ERROR_NONE;
2796 camera_cli_s *pc = (camera_cli_s *)camera;
2797 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2799 if (!pc || !pc->cb_info) {
2800 LOGE("NULL handle");
2801 return CAMERA_ERROR_INVALID_PARAMETER;
2806 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2807 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2812 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2814 LOGD("ret : 0x%x", ret);
2820 bool camera_is_supported_continuous_capture(camera_h camera)
2822 int ret = CAMERA_ERROR_NONE;
2823 camera_cli_s *pc = (camera_cli_s *)camera;
2824 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2826 if (!pc || !pc->cb_info) {
2827 LOGE("NULL handle");
2828 return CAMERA_ERROR_INVALID_PARAMETER;
2833 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2836 LOGE("error is occurred 0x%x", ret);
2840 LOGD("ret : %d", ret);
2846 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)
2848 int ret = CAMERA_ERROR_NONE;
2849 camera_cli_s *pc = (camera_cli_s *)camera;
2850 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2851 camera_msg_param param;
2854 if (!pc || !pc->cb_info) {
2855 LOGE("NULL handle");
2856 return CAMERA_ERROR_INVALID_PARAMETER;
2861 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2862 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2864 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2865 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2867 value = (count << 16) | interval;
2868 CAMERA_MSG_PARAM_SET(param, INT, value);
2870 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2872 LOGD("ret : 0x%x", ret);
2878 int camera_stop_continuous_capture(camera_h camera)
2880 int ret = CAMERA_ERROR_NONE;
2881 camera_cli_s *pc = (camera_cli_s *)camera;
2882 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2884 if (!pc || !pc->cb_info) {
2885 LOGE("NULL handle");
2886 return CAMERA_ERROR_INVALID_PARAMETER;
2891 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2893 LOGD("ret : 0x%x", ret);
2899 bool camera_is_supported_face_detection(camera_h camera)
2901 int ret = CAMERA_ERROR_NONE;
2902 camera_cli_s *pc = (camera_cli_s *)camera;
2903 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2905 if (!pc || !pc->cb_info) {
2906 LOGE("NULL handle");
2907 return CAMERA_ERROR_INVALID_PARAMETER;
2912 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2915 LOGE("error is occurred 0x%x", ret);
2919 LOGD("ret : %d", ret);
2925 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2927 int ret = CAMERA_ERROR_NONE;
2928 camera_cli_s *pc = (camera_cli_s *)camera;
2929 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2931 if (!pc || !pc->cb_info) {
2932 LOGE("NULL handle");
2933 return CAMERA_ERROR_INVALID_PARAMETER;
2938 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2941 LOGE("error is occurred 0x%x", ret);
2945 LOGD("ret : %d", ret);
2951 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2953 int ret = CAMERA_ERROR_NONE;
2954 camera_cli_s *pc = (camera_cli_s *)camera;
2955 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2957 if (!pc || !pc->cb_info) {
2958 LOGE("NULL handle");
2959 return CAMERA_ERROR_INVALID_PARAMETER;
2964 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2967 LOGE("error is occurred 0x%x", ret);
2971 LOGD("ret : %d", ret);
2976 int camera_get_device_count(camera_h camera, int *device_count)
2978 int ret = CAMERA_ERROR_NONE;
2979 camera_cli_s *pc = (camera_cli_s *)camera;
2980 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2982 if (!pc || !pc->cb_info) {
2983 LOGE("NULL handle");
2984 return CAMERA_ERROR_INVALID_PARAMETER;
2989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2991 if (ret == CAMERA_ERROR_NONE)
2992 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2994 LOGD("ret : 0x%x", ret);
2999 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3001 int ret = CAMERA_ERROR_NONE;
3002 camera_cli_s *pc = (camera_cli_s *)camera;
3003 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3005 if (!pc || !pc->cb_info) {
3006 LOGE("NULL handle");
3007 return CAMERA_ERROR_INVALID_PARAMETER;
3012 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3014 if (ret == CAMERA_ERROR_NONE) {
3015 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3017 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3018 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3020 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3023 LOGD("ret : 0x%x", ret);
3028 int camera_stop_face_detection(camera_h camera)
3030 int ret = CAMERA_ERROR_NONE;
3031 camera_cli_s *pc = (camera_cli_s *)camera;
3032 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3034 if (!pc || !pc->cb_info) {
3035 LOGE("NULL handle");
3036 return CAMERA_ERROR_INVALID_PARAMETER;
3041 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3043 if (ret == CAMERA_ERROR_NONE) {
3044 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
3049 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
3052 LOGD("ret : 0x%x", ret);
3057 int camera_get_state(camera_h camera, camera_state_e *state)
3059 int ret = CAMERA_ERROR_NONE;
3060 camera_cli_s *pc = (camera_cli_s *)camera;
3061 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3063 if (!pc || !pc->cb_info || !state) {
3064 LOGE("NULL pointer %p %p", pc, state);
3065 return CAMERA_ERROR_INVALID_PARAMETER;
3070 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3072 if (ret == CAMERA_ERROR_NONE)
3073 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3075 LOGD("ret : 0x%x", ret);
3080 int camera_start_focusing(camera_h camera, bool continuous)
3082 int ret = CAMERA_ERROR_NONE;
3083 camera_cli_s *pc = (camera_cli_s *)camera;
3084 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3085 camera_msg_param param;
3086 int is_continuous = (int)continuous;
3088 if (!pc || !pc->cb_info) {
3089 LOGE("NULL handle");
3090 return CAMERA_ERROR_INVALID_PARAMETER;
3095 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3097 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3099 LOGD("ret : 0x%x", ret);
3104 int camera_cancel_focusing(camera_h camera)
3106 int ret = CAMERA_ERROR_NONE;
3107 camera_cli_s *pc = (camera_cli_s *)camera;
3108 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3110 if (!pc || !pc->cb_info) {
3111 LOGE("NULL handle");
3112 return CAMERA_ERROR_INVALID_PARAMETER;
3115 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3117 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3119 LOGD("ret : 0x%x", ret);
3124 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3126 int ret = CAMERA_ERROR_NONE;
3127 void *set_display_handle = NULL;
3128 Evas_Object *obj = NULL;
3129 const char *object_type = NULL;
3130 camera_cli_s *pc = (camera_cli_s *)camera;
3131 camera_cb_info_s *cb_info = NULL;
3132 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3133 camera_state_e current_state = CAMERA_STATE_NONE;
3134 camera_msg_param param;
3138 if (!pc || !pc->cb_info) {
3139 LOGE("NULL handle");
3140 return CAMERA_ERROR_INVALID_PARAMETER;
3143 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3144 LOGE("invalid type %d", type);
3145 return CAMERA_ERROR_INVALID_PARAMETER;
3148 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3149 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3150 return CAMERA_ERROR_INVALID_PARAMETER;
3153 cb_info = (camera_cb_info_s *)pc->cb_info;
3155 ret = camera_get_state(camera, ¤t_state);
3156 if (ret != CAMERA_ERROR_NONE) {
3157 LOGE("failed to get current state 0x%x", ret);
3161 if (current_state != CAMERA_STATE_CREATED) {
3162 LOGE("INVALID_STATE : current %d", current_state);
3163 return CAMERA_ERROR_INVALID_STATE;
3166 LOGD("Enter - display : %p", display);
3168 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3169 set_display_handle = 0;
3170 LOGD("display type NONE");
3172 obj = (Evas_Object *)display;
3173 object_type = evas_object_type_get(obj);
3175 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3176 /* get wayland parent id */
3177 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3178 LOGE("failed to get wayland info");
3179 return CAMERA_ERROR_INVALID_OPERATION;
3182 set_display_handle = (void *)&pc->wl_info;
3183 LOGD("display type OVERLAY : handle %p", set_display_handle);
3184 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3185 /* evas object surface */
3186 set_display_handle = (void *)display;
3187 LOGD("display type EVAS : handle %p", set_display_handle);
3189 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3190 g_mutex_lock(&cb_info->evas_mutex);
3192 if (cb_info->evas_info) {
3193 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3194 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3195 if (ret != MM_ERROR_NONE) {
3196 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3197 g_mutex_unlock(&cb_info->evas_mutex);
3198 return CAMERA_ERROR_INVALID_OPERATION;
3202 /* create evas renderer */
3203 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3204 if (ret == MM_ERROR_NONE) {
3205 camera_flip_e flip = CAMERA_FLIP_NONE;
3206 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3207 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3214 camera_get_display_flip(camera, &flip);
3215 camera_get_display_mode(camera, &mode);
3216 camera_get_display_rotation(camera, &rotation);
3217 camera_is_display_visible(camera, &visible);
3218 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3220 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3221 flip, mode, rotation, visible, x, y, width, height);
3223 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3224 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3225 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3226 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3228 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3229 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3232 g_mutex_unlock(&cb_info->evas_mutex);
3234 if (ret != MM_ERROR_NONE) {
3235 LOGE("mm_evas_renderer error 0x%x", ret);
3236 return CAMERA_ERROR_INVALID_OPERATION;
3238 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3239 LOGE("EVAS surface is not supported");
3240 return CAMERA_ERROR_NOT_SUPPORTED;
3241 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3243 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3244 return CAMERA_ERROR_INVALID_PARAMETER;
3247 LOGE("failed to get evas object type from %p", obj);
3248 return CAMERA_ERROR_INVALID_PARAMETER;
3252 pc->display_handle = (intptr_t)set_display_handle;
3254 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3257 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3258 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3260 msg = muse_core_msg_new(api,
3261 MUSE_TYPE_INT, "type", type,
3262 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3265 LOGE("msg creation failed: api %d", api);
3266 return CAMERA_ERROR_OUT_OF_MEMORY;
3269 if (pc->cb_info->is_server_connected) {
3270 __camera_update_api_waiting(pc->cb_info, api, 1);
3272 g_mutex_lock(&pc->cb_info->fd_lock);
3273 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3274 g_mutex_unlock(&pc->cb_info->fd_lock);
3278 LOGE("message send failed");
3279 ret = CAMERA_ERROR_INVALID_OPERATION;
3281 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3284 __camera_update_api_waiting(pc->cb_info, api, -1);
3286 muse_core_msg_free(msg);
3288 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3289 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3290 pc->wl_info.window_width, pc->wl_info.window_height);
3292 CAMERA_MSG_PARAM_SET(param, INT, type);
3294 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3297 if (ret != CAMERA_ERROR_NONE)
3298 LOGE("set display error 0x%x", ret);
3299 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3300 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3306 int camera_set_preview_resolution(camera_h camera, int width, int height)
3308 int ret = CAMERA_ERROR_NONE;
3309 camera_state_e current_state = CAMERA_STATE_NONE;
3310 camera_cli_s *pc = (camera_cli_s *)camera;
3311 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3312 camera_msg_param param;
3315 if (!pc || !pc->cb_info) {
3316 LOGE("NULL handle");
3317 return CAMERA_ERROR_INVALID_PARAMETER;
3320 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3321 ret = camera_get_state(camera, ¤t_state);
3322 if (ret != CAMERA_ERROR_NONE) {
3323 LOGE("failed to get current state 0x%x", ret);
3327 if (current_state == CAMERA_STATE_PREVIEW) {
3328 ret = _camera_stop_evas_rendering(camera, true);
3329 if (ret != CAMERA_ERROR_NONE)
3334 value = (width << 16) | height;
3335 CAMERA_MSG_PARAM_SET(param, INT, value);
3337 LOGD("%dx%d -> 0x%x", width, height, value);
3339 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3341 LOGD("ret : 0x%x", ret);
3343 if (current_state == CAMERA_STATE_PREVIEW) {
3344 LOGW("restart evas rendering");
3345 _camera_start_evas_rendering(camera);
3352 int camera_set_capture_resolution(camera_h camera, int width, int height)
3354 int ret = CAMERA_ERROR_NONE;
3355 camera_cli_s *pc = (camera_cli_s *)camera;
3356 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3357 camera_msg_param param;
3360 if (!pc || !pc->cb_info) {
3361 LOGE("NULL handle");
3362 return CAMERA_ERROR_INVALID_PARAMETER;
3367 value = (width << 16) | height;
3368 CAMERA_MSG_PARAM_SET(param, INT, value);
3370 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3372 LOGD("ret : 0x%x", ret);
3378 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3380 int ret = CAMERA_ERROR_NONE;
3381 int set_format = (int)format;
3382 camera_cli_s *pc = (camera_cli_s *)camera;
3383 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3384 camera_msg_param param;
3386 if (!pc || !pc->cb_info) {
3387 LOGE("NULL handle");
3388 return CAMERA_ERROR_INVALID_PARAMETER;
3391 LOGD("Enter - format %d", set_format);
3393 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3395 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3397 LOGD("ret : 0x%x", ret);
3403 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3405 int ret = CAMERA_ERROR_NONE;
3406 int set_format = (int)format;
3407 camera_msg_param param;
3408 camera_cli_s *pc = (camera_cli_s *)camera;
3409 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3411 if (!pc || !pc->cb_info) {
3412 LOGE("NULL handle");
3413 return CAMERA_ERROR_INVALID_PARAMETER;
3416 LOGD("Enter - capture_format %d", set_format);
3418 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3420 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3422 LOGD("ret : 0x%x", ret);
3428 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3430 int ret = CAMERA_ERROR_NONE;
3431 camera_cli_s *pc = (camera_cli_s *)camera;
3432 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3434 if (!pc || !pc->cb_info || !width || !height) {
3435 LOGE("NULL pointer %p %p %p", pc, width, height);
3436 return CAMERA_ERROR_INVALID_PARAMETER;
3441 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3443 if (ret == CAMERA_ERROR_NONE) {
3444 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3445 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3448 LOGD("ret : 0x%x", ret);
3454 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3456 int ret = CAMERA_ERROR_NONE;
3457 int set_rotation = (int)rotation;
3458 camera_cli_s *pc = (camera_cli_s *)camera;
3459 camera_msg_param param;
3461 if (!pc || !pc->cb_info) {
3462 LOGE("NULL handle");
3463 return CAMERA_ERROR_INVALID_PARAMETER;
3466 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3467 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3468 g_mutex_lock(&pc->cb_info->evas_mutex);
3470 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3472 g_mutex_unlock(&pc->cb_info->evas_mutex);
3474 if (ret != MM_ERROR_NONE) {
3475 LOGE("failed to set rotation for evas surface 0x%x", ret);
3476 return CAMERA_ERROR_INVALID_OPERATION;
3479 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3481 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3483 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3489 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3491 int ret = CAMERA_ERROR_NONE;
3492 camera_cli_s *pc = (camera_cli_s *)camera;
3494 if (!pc || !pc->cb_info || !rotation) {
3495 LOGE("NULL pointer %p %p", pc, rotation);
3496 return CAMERA_ERROR_INVALID_PARAMETER;
3499 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3501 if (ret == CAMERA_ERROR_NONE)
3502 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3508 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3510 int ret = CAMERA_ERROR_NONE;
3511 int set_flip = (int)flip;
3512 camera_cli_s *pc = (camera_cli_s *)camera;
3513 camera_msg_param param;
3515 if (!pc || !pc->cb_info) {
3516 LOGE("NULL handle");
3517 return CAMERA_ERROR_INVALID_PARAMETER;
3520 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3521 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3522 g_mutex_lock(&pc->cb_info->evas_mutex);
3524 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3526 g_mutex_unlock(&pc->cb_info->evas_mutex);
3528 if (ret != MM_ERROR_NONE) {
3529 LOGE("failed to set flip for evas surface 0x%x", ret);
3530 return CAMERA_ERROR_INVALID_OPERATION;
3533 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3535 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3537 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3543 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3545 int ret = CAMERA_ERROR_NONE;
3546 camera_cli_s *pc = (camera_cli_s *)camera;
3548 if (!pc || !pc->cb_info || !flip) {
3549 LOGE("NULL pointer %p %p", pc, flip);
3550 return CAMERA_ERROR_INVALID_PARAMETER;
3553 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3555 if (ret == CAMERA_ERROR_NONE)
3556 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3562 int camera_set_display_visible(camera_h camera, bool visible)
3564 int ret = CAMERA_ERROR_NONE;
3565 int set_visible = (int)visible;
3566 camera_cli_s *pc = (camera_cli_s *)camera;
3567 camera_msg_param param;
3569 if (!pc || !pc->cb_info) {
3570 LOGE("NULL handle");
3571 return CAMERA_ERROR_INVALID_PARAMETER;
3574 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3575 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3576 g_mutex_lock(&pc->cb_info->evas_mutex);
3578 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3580 g_mutex_unlock(&pc->cb_info->evas_mutex);
3582 if (ret != MM_ERROR_NONE) {
3583 LOGE("failed to set visible for evas surface 0x%x", ret);
3584 return CAMERA_ERROR_INVALID_OPERATION;
3587 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3589 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3591 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3597 int camera_is_display_visible(camera_h camera, bool *visible)
3599 int ret = CAMERA_ERROR_NONE;
3600 camera_cli_s *pc = (camera_cli_s *)camera;
3602 if (!pc || !pc->cb_info || !visible) {
3603 LOGE("NULL pointer %p %p", pc, visible);
3604 return CAMERA_ERROR_INVALID_PARAMETER;
3607 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3609 if (ret == CAMERA_ERROR_NONE)
3610 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3616 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3618 int ret = CAMERA_ERROR_NONE;
3619 int set_mode = (int)mode;
3620 camera_cli_s *pc = (camera_cli_s *)camera;
3621 camera_msg_param param;
3623 if (!pc || !pc->cb_info) {
3624 LOGE("NULL handle");
3625 return CAMERA_ERROR_INVALID_PARAMETER;
3628 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3629 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3630 g_mutex_lock(&pc->cb_info->evas_mutex);
3632 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3634 g_mutex_unlock(&pc->cb_info->evas_mutex);
3636 if (ret != MM_ERROR_NONE) {
3637 LOGE("failed to set geometry for evas surface 0x%x", ret);
3638 return CAMERA_ERROR_INVALID_OPERATION;
3641 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3643 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3645 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3651 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3653 int ret = CAMERA_ERROR_NONE;
3654 camera_cli_s *pc = (camera_cli_s *)camera;
3656 if (!pc || !pc->cb_info || !mode) {
3657 LOGE("NULL pointer %p %p", pc, mode);
3658 return CAMERA_ERROR_INVALID_PARAMETER;
3661 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3663 if (ret == CAMERA_ERROR_NONE)
3664 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3670 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3672 int ret = CAMERA_ERROR_NONE;
3673 int set_hint = (int)hint;
3674 camera_cli_s *pc = (camera_cli_s *)camera;
3675 camera_msg_param param;
3677 if (!pc || !pc->cb_info) {
3678 LOGE("NULL handle");
3679 return CAMERA_ERROR_INVALID_PARAMETER;
3682 LOGD("Enter - hint %d", set_hint);
3684 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3686 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3692 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3694 int ret = CAMERA_ERROR_NONE;
3695 camera_cli_s *pc = (camera_cli_s *)camera;
3696 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3698 if (!pc || !pc->cb_info || !hint) {
3699 LOGE("NULL pointer %p %p", pc, hint);
3700 return CAMERA_ERROR_INVALID_PARAMETER;
3703 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3705 if (ret == CAMERA_ERROR_NONE) {
3706 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3707 LOGD("display reuse hint %d", *hint);
3714 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3716 int ret = CAMERA_ERROR_NONE;
3717 camera_cli_s *pc = (camera_cli_s *)camera;
3718 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3720 if (!pc || !pc->cb_info || !width || !height) {
3721 LOGE("NULL pointer %p %p %p", pc, width, height);
3722 return CAMERA_ERROR_INVALID_PARAMETER;
3727 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3729 if (ret == CAMERA_ERROR_NONE) {
3730 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3731 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3734 LOGD("ret : 0x%x", ret);
3740 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3742 int ret = CAMERA_ERROR_NONE;
3743 camera_cli_s *pc = (camera_cli_s *)camera;
3744 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3746 if (!pc || !pc->cb_info || !format) {
3747 LOGE("NULL pointer %p %p", pc, format);
3748 return CAMERA_ERROR_INVALID_PARAMETER;
3753 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3755 if (ret == CAMERA_ERROR_NONE)
3756 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3758 LOGD("ret : 0x%x", ret);
3764 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3766 int ret = CAMERA_ERROR_NONE;
3767 camera_cli_s *pc = (camera_cli_s *)camera;
3768 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3770 if (!pc || !pc->cb_info || !format) {
3771 LOGE("NULL pointer %p %p", pc, format);
3772 return CAMERA_ERROR_INVALID_PARAMETER;
3777 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3779 if (ret == CAMERA_ERROR_NONE)
3780 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3782 LOGD("ret : 0x%x", ret);
3788 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3790 int ret = CAMERA_ERROR_NONE;
3791 camera_cli_s *pc = (camera_cli_s *)camera;
3792 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3794 if (!pc || !pc->cb_info || !facing_direction) {
3795 LOGE("NULL pointer %p %p", pc, facing_direction);
3796 return CAMERA_ERROR_INVALID_PARAMETER;
3801 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3803 if (ret == CAMERA_ERROR_NONE)
3804 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3806 LOGD("ret : 0x%x", ret);
3812 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3814 int ret = CAMERA_ERROR_NONE;
3815 camera_cli_s *pc = (camera_cli_s *)camera;
3816 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3818 if (!pc || !pc->cb_info || !callback) {
3819 LOGE("NULL pointer %p %p", pc, callback);
3820 return CAMERA_ERROR_INVALID_PARAMETER;
3825 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3827 if (ret == CAMERA_ERROR_NONE) {
3828 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3830 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3831 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3833 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3835 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3838 LOGD("ret : 0x%x", ret);
3844 int camera_unset_preview_cb(camera_h camera)
3846 int ret = CAMERA_ERROR_NONE;
3847 camera_cli_s *pc = (camera_cli_s *)camera;
3848 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3850 if (!pc || !pc->cb_info) {
3851 LOGE("NULL handle");
3852 return CAMERA_ERROR_INVALID_PARAMETER;
3857 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3859 if (ret == CAMERA_ERROR_NONE) {
3860 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3862 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3863 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3865 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3867 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3870 LOGD("ret : 0x%x", ret);
3876 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3878 int ret = CAMERA_ERROR_NONE;
3879 camera_cli_s *pc = (camera_cli_s *)camera;
3880 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3882 if (!pc || !pc->cb_info) {
3883 LOGE("NULL handle");
3884 return CAMERA_ERROR_INVALID_PARAMETER;
3887 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3888 LOGE("NOT SUPPORTED");
3889 return CAMERA_ERROR_NOT_SUPPORTED;
3892 if (callback == NULL) {
3893 LOGE("NULL callback");
3894 return CAMERA_ERROR_INVALID_PARAMETER;
3899 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3901 if (ret == CAMERA_ERROR_NONE) {
3902 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3904 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3905 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3907 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3910 LOGD("ret : 0x%x", ret);
3916 int camera_unset_media_packet_preview_cb(camera_h camera)
3918 int ret = CAMERA_ERROR_NONE;
3919 camera_cli_s *pc = (camera_cli_s *)camera;
3920 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3922 if (!pc || !pc->cb_info) {
3923 LOGE("NULL handle");
3924 return CAMERA_ERROR_INVALID_PARAMETER;
3929 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3931 if (ret == CAMERA_ERROR_NONE) {
3932 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3934 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3935 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3937 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3940 LOGD("ret : 0x%x", ret);
3946 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3948 int ret = CAMERA_ERROR_NONE;
3949 camera_cli_s *pc = (camera_cli_s *)camera;
3950 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3952 if (!pc || !pc->cb_info || !callback) {
3953 LOGE("NULL pointer %p %p", pc, callback);
3954 return CAMERA_ERROR_INVALID_PARAMETER;
3959 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3961 if (ret == CAMERA_ERROR_NONE) {
3962 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3964 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3965 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3967 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3970 LOGD("ret : 0x%x", ret);
3976 int camera_unset_state_changed_cb(camera_h camera)
3978 int ret = CAMERA_ERROR_NONE;
3979 camera_cli_s *pc = (camera_cli_s *)camera;
3980 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3982 if (!pc || !pc->cb_info) {
3983 LOGE("NULL handle");
3984 return CAMERA_ERROR_INVALID_PARAMETER;
3989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3991 if (ret == CAMERA_ERROR_NONE) {
3992 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3994 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3995 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3997 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
4000 LOGD("ret : 0x%x", ret);
4006 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
4008 int ret = CAMERA_ERROR_NONE;
4009 camera_cli_s *pc = (camera_cli_s *)camera;
4010 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
4012 if (!pc || !pc->cb_info || !callback) {
4013 LOGE("NULL pointer %p %p", pc, callback);
4014 return CAMERA_ERROR_INVALID_PARAMETER;
4019 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4021 if (ret == CAMERA_ERROR_NONE) {
4022 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4027 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4030 LOGD("ret : 0x%x", ret);
4036 int camera_unset_interrupted_cb(camera_h camera)
4038 int ret = CAMERA_ERROR_NONE;
4039 camera_cli_s *pc = (camera_cli_s *)camera;
4040 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4042 if (!pc || !pc->cb_info) {
4043 LOGE("NULL handle");
4044 return CAMERA_ERROR_INVALID_PARAMETER;
4049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4051 if (ret == CAMERA_ERROR_NONE) {
4052 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4054 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4055 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4057 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
4060 LOGD("ret : 0x%x", ret);
4066 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4068 int ret = CAMERA_ERROR_NONE;
4069 camera_cli_s *pc = (camera_cli_s *)camera;
4070 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4072 if (!pc || !pc->cb_info || !callback) {
4073 LOGE("NULL pointer %p %p", pc, callback);
4074 return CAMERA_ERROR_INVALID_PARAMETER;
4079 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4081 if (ret == CAMERA_ERROR_NONE) {
4082 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4084 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4085 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4087 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4090 LOGD("ret : 0x%x", ret);
4096 int camera_unset_interrupt_started_cb(camera_h camera)
4098 int ret = CAMERA_ERROR_NONE;
4099 camera_cli_s *pc = (camera_cli_s *)camera;
4100 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4102 if (!pc || !pc->cb_info) {
4103 LOGE("NULL handle");
4104 return CAMERA_ERROR_INVALID_PARAMETER;
4109 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4111 if (ret == CAMERA_ERROR_NONE) {
4112 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4114 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4115 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4117 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
4120 LOGD("ret : 0x%x", ret);
4126 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4128 int ret = CAMERA_ERROR_NONE;
4129 camera_cli_s *pc = (camera_cli_s *)camera;
4130 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4132 if (!pc || !pc->cb_info || !callback) {
4133 LOGE("NULL pointer %p %p", pc, callback);
4134 return CAMERA_ERROR_INVALID_PARAMETER;
4139 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4141 if (ret == CAMERA_ERROR_NONE) {
4142 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4144 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4145 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4147 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4150 LOGD("ret : 0x%x", ret);
4156 int camera_unset_focus_changed_cb(camera_h camera)
4158 int ret = CAMERA_ERROR_NONE;
4159 camera_cli_s *pc = (camera_cli_s *)camera;
4160 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4162 if (!pc || !pc->cb_info) {
4163 LOGE("NULL handle");
4164 return CAMERA_ERROR_INVALID_PARAMETER;
4169 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4171 if (ret == CAMERA_ERROR_NONE) {
4172 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4174 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4175 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4177 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
4180 LOGD("ret : 0x%x", ret);
4186 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4188 int ret = CAMERA_ERROR_NONE;
4189 camera_cli_s *pc = (camera_cli_s *)camera;
4190 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4192 if (!pc || !pc->cb_info || !callback) {
4193 LOGE("NULL pointer %p %p", pc, callback);
4194 return CAMERA_ERROR_INVALID_PARAMETER;
4199 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4201 if (ret == CAMERA_ERROR_NONE) {
4202 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4204 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4205 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4207 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4210 LOGD("ret : 0x%x", ret);
4216 int camera_unset_error_cb(camera_h camera)
4218 int ret = CAMERA_ERROR_NONE;
4219 camera_cli_s *pc = (camera_cli_s *)camera;
4220 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4222 if (!pc || !pc->cb_info) {
4223 LOGE("NULL handle");
4224 return CAMERA_ERROR_INVALID_PARAMETER;
4229 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4231 if (ret == CAMERA_ERROR_NONE) {
4232 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4234 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4235 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4237 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4240 LOGD("ret : 0x%x", ret);
4246 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4248 int ret = CAMERA_ERROR_NONE;
4249 camera_cli_s *pc = (camera_cli_s *)camera;
4250 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4252 if (!pc || !pc->cb_info || !foreach_cb) {
4253 LOGE("NULL pointer %p %p", pc, foreach_cb);
4254 return CAMERA_ERROR_INVALID_PARAMETER;
4259 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4260 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4262 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4264 LOGD("ret : 0x%x", ret);
4270 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4272 int ret = CAMERA_ERROR_NONE;
4273 camera_cli_s *pc = (camera_cli_s *)camera;
4274 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4276 if (!pc || !pc->cb_info || !foreach_cb) {
4277 LOGE("NULL pointer %p %p", pc, foreach_cb);
4278 return CAMERA_ERROR_INVALID_PARAMETER;
4283 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4284 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4286 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4288 LOGD("ret : 0x%x", ret);
4294 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4296 int ret = CAMERA_ERROR_NONE;
4297 camera_cli_s *pc = (camera_cli_s *)camera;
4298 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4300 if (!pc || !pc->cb_info || !foreach_cb) {
4301 LOGE("NULL pointer %p %p", pc, foreach_cb);
4302 return CAMERA_ERROR_INVALID_PARAMETER;
4307 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4308 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4310 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4312 LOGD("ret : 0x%x", ret);
4318 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4320 int ret = CAMERA_ERROR_NONE;
4321 camera_cli_s *pc = (camera_cli_s *)camera;
4322 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4324 if (!pc || !pc->cb_info || !foreach_cb) {
4325 LOGE("NULL pointer %p %p", pc, foreach_cb);
4326 return CAMERA_ERROR_INVALID_PARAMETER;
4331 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4332 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4334 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4336 LOGD("ret : 0x%x", ret);
4342 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4344 int ret = CAMERA_ERROR_NONE;
4345 camera_cli_s *pc = (camera_cli_s *)camera;
4346 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4348 if (!pc || !pc->cb_info || !width || !height) {
4349 LOGE("NULL pointer %p %p %p", pc, width, height);
4350 return CAMERA_ERROR_INVALID_PARAMETER;
4354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4356 if (ret == CAMERA_ERROR_NONE) {
4357 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4358 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4361 LOGD("ret : 0x%x", ret);
4367 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4369 int ret = CAMERA_ERROR_NONE;
4370 camera_cli_s *pc = (camera_cli_s *)camera;
4371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4373 if (!pc || !pc->cb_info || !angle) {
4374 LOGE("NULL pointer %p %p", pc, angle);
4375 return CAMERA_ERROR_INVALID_PARAMETER;
4380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4382 if (ret == CAMERA_ERROR_NONE)
4383 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4385 LOGD("ret : 0x%x", ret);
4391 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4393 int ret = CAMERA_ERROR_NONE;
4394 camera_cli_s *pc = (camera_cli_s *)camera;
4395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4396 camera_msg_param param;
4397 int set_mode = (int)mode;
4399 if (!pc || !pc->cb_info) {
4400 LOGE("NULL handle");
4401 return CAMERA_ERROR_INVALID_PARAMETER;
4406 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4408 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4410 LOGD("ret : 0x%x", ret);
4416 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4418 int ret = CAMERA_ERROR_NONE;
4419 camera_cli_s *pc = (camera_cli_s *)camera;
4420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4422 if (!pc || !pc->cb_info || !mode) {
4423 LOGE("NULL pointer %p %p", pc, mode);
4424 return CAMERA_ERROR_INVALID_PARAMETER;
4429 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4431 if (ret == CAMERA_ERROR_NONE)
4432 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4434 LOGD("ret : 0x%x", ret);
4440 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4442 int ret = CAMERA_ERROR_NONE;
4443 camera_cli_s *pc = (camera_cli_s *)camera;
4444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4446 if (!pc || !pc->cb_info || !foreach_cb) {
4447 LOGE("NULL pointer %p %p", pc, foreach_cb);
4448 return CAMERA_ERROR_INVALID_PARAMETER;
4453 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4454 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4456 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4458 LOGD("Finish, return :%x", ret);
4464 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4466 int ret = CAMERA_ERROR_NONE;
4467 camera_cli_s *pc = (camera_cli_s *)camera;
4468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4469 camera_msg_param param;
4470 int set_fps = (int)fps;
4472 if (!pc || !pc->cb_info) {
4473 LOGE("NULL handle");
4474 return CAMERA_ERROR_INVALID_PARAMETER;
4479 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4481 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4483 LOGD("ret : 0x%x", ret);
4489 int camera_attr_set_image_quality(camera_h camera, int quality)
4491 int ret = CAMERA_ERROR_NONE;
4492 camera_cli_s *pc = (camera_cli_s *)camera;
4493 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4494 camera_msg_param param;
4496 if (!pc || !pc->cb_info) {
4497 LOGE("NULL handle");
4498 return CAMERA_ERROR_INVALID_PARAMETER;
4503 CAMERA_MSG_PARAM_SET(param, INT, quality);
4505 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4507 LOGD("ret : 0x%x", ret);
4513 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4515 int ret = CAMERA_ERROR_NONE;
4516 camera_cli_s *pc = (camera_cli_s *)camera;
4517 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4519 if (!pc || !pc->cb_info || !fps) {
4520 LOGE("NULL pointer %p %p", pc, fps);
4521 return CAMERA_ERROR_INVALID_PARAMETER;
4526 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4528 if (ret == CAMERA_ERROR_NONE)
4529 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4531 LOGD("ret : 0x%x", ret);
4537 int camera_attr_get_image_quality(camera_h camera, int *quality)
4539 int ret = CAMERA_ERROR_NONE;
4540 camera_cli_s *pc = (camera_cli_s *)camera;
4541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4543 if (!pc || !pc->cb_info || !quality) {
4544 LOGE("NULL pointer %p %p", pc, quality);
4545 return CAMERA_ERROR_INVALID_PARAMETER;
4550 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4552 if (ret == CAMERA_ERROR_NONE)
4553 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4555 LOGD("ret : 0x%x", ret);
4561 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4563 int ret = CAMERA_ERROR_NONE;
4564 camera_cli_s *pc = (camera_cli_s *)camera;
4565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4567 if (!pc || !pc->cb_info || !bitrate) {
4568 LOGE("NULL pointer %p %p", pc, bitrate);
4569 return CAMERA_ERROR_INVALID_PARAMETER;
4574 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4576 if (ret == CAMERA_ERROR_NONE)
4577 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4579 LOGD("ret : 0x%x", ret);
4585 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4587 int ret = CAMERA_ERROR_NONE;
4588 camera_cli_s *pc = (camera_cli_s *)camera;
4589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4590 camera_msg_param param;
4591 int set_bitrate = bitrate;
4593 if (!pc || !pc->cb_info) {
4594 LOGE("NULL handle");
4595 return CAMERA_ERROR_INVALID_PARAMETER;
4600 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4602 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4604 LOGD("ret : 0x%x", ret);
4610 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4612 int ret = CAMERA_ERROR_NONE;
4613 camera_cli_s *pc = (camera_cli_s *)camera;
4614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4616 if (!pc || !pc->cb_info || !interval) {
4617 LOGE("NULL pointer %p %p", pc, interval);
4618 return CAMERA_ERROR_INVALID_PARAMETER;
4623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4625 if (ret == CAMERA_ERROR_NONE)
4626 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4628 LOGD("ret : 0x%x", ret);
4634 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4636 int ret = CAMERA_ERROR_NONE;
4637 camera_cli_s *pc = (camera_cli_s *)camera;
4638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4639 camera_msg_param param;
4640 int set_gop_interval = interval;
4642 if (!pc || !pc->cb_info) {
4643 LOGE("NULL handle");
4644 return CAMERA_ERROR_INVALID_PARAMETER;
4649 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4651 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4653 LOGD("ret : 0x%x", ret);
4659 int camera_attr_set_zoom(camera_h camera, int zoom)
4661 int ret = CAMERA_ERROR_NONE;
4662 camera_cli_s *pc = (camera_cli_s *)camera;
4663 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4664 camera_msg_param param;
4666 if (!pc || !pc->cb_info) {
4667 LOGE("NULL handle");
4668 return CAMERA_ERROR_INVALID_PARAMETER;
4671 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4673 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4675 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4677 LOGD("ret : 0x%x", ret);
4683 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4685 int ret = CAMERA_ERROR_NONE;
4686 camera_cli_s *pc = (camera_cli_s *)camera;
4687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4688 camera_msg_param param;
4689 int set_mode = (int)mode;
4691 if (!pc || !pc->cb_info) {
4692 LOGE("NULL handle");
4693 return CAMERA_ERROR_INVALID_PARAMETER;
4696 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4698 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4700 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4706 int camera_attr_set_af_area(camera_h camera, int x, int y)
4708 int ret = CAMERA_ERROR_NONE;
4709 camera_cli_s *pc = (camera_cli_s *)camera;
4710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4711 camera_msg_param param;
4714 if (!pc || !pc->cb_info) {
4715 LOGE("NULL handle");
4716 return CAMERA_ERROR_INVALID_PARAMETER;
4719 LOGD("Enter - %d,%d", x, y);
4721 value = (x << 16) | y;
4722 CAMERA_MSG_PARAM_SET(param, INT, value);
4724 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4726 LOGD("ret : 0x%x", ret);
4732 int camera_attr_clear_af_area(camera_h camera)
4734 int ret = CAMERA_ERROR_NONE;
4735 camera_cli_s *pc = (camera_cli_s *)camera;
4736 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4738 if (!pc || !pc->cb_info) {
4739 LOGE("NULL handle");
4740 return CAMERA_ERROR_INVALID_PARAMETER;
4745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4747 LOGD("ret : 0x%x", ret);
4753 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4755 int ret = CAMERA_ERROR_NONE;
4756 camera_cli_s *pc = (camera_cli_s *)camera;
4757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4758 camera_msg_param param;
4759 int set_mode = (int)mode;
4761 if (!pc || !pc->cb_info) {
4762 LOGE("NULL handle");
4763 return CAMERA_ERROR_INVALID_PARAMETER;
4768 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4770 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4772 LOGD("ret : 0x%x", ret);
4778 int camera_attr_set_exposure(camera_h camera, int value)
4780 int ret = CAMERA_ERROR_NONE;
4781 camera_cli_s *pc = (camera_cli_s *)camera;
4782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4783 camera_msg_param param;
4785 if (!pc || !pc->cb_info) {
4786 LOGE("NULL handle");
4787 return CAMERA_ERROR_INVALID_PARAMETER;
4792 CAMERA_MSG_PARAM_SET(param, INT, value);
4794 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4796 LOGD("ret : 0x%x", ret);
4802 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4804 int ret = CAMERA_ERROR_NONE;
4805 camera_cli_s *pc = (camera_cli_s *)camera;
4806 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4807 camera_msg_param param;
4808 int set_iso = (int)iso;
4810 if (!pc || !pc->cb_info) {
4811 LOGE("NULL handle");
4812 return CAMERA_ERROR_INVALID_PARAMETER;
4817 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4821 LOGD("ret : 0x%x", ret);
4827 int camera_attr_set_brightness(camera_h camera, int level)
4829 int ret = CAMERA_ERROR_NONE;
4830 camera_cli_s *pc = (camera_cli_s *)camera;
4831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4832 camera_msg_param param;
4834 if (!pc || !pc->cb_info) {
4835 LOGE("NULL handle");
4836 return CAMERA_ERROR_INVALID_PARAMETER;
4841 CAMERA_MSG_PARAM_SET(param, INT, level);
4843 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4845 LOGD("ret : 0x%x", ret);
4851 int camera_attr_set_contrast(camera_h camera, int level)
4853 int ret = CAMERA_ERROR_NONE;
4854 camera_cli_s *pc = (camera_cli_s *)camera;
4855 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4856 camera_msg_param param;
4858 if (!pc || !pc->cb_info) {
4859 LOGE("NULL handle");
4860 return CAMERA_ERROR_INVALID_PARAMETER;
4865 CAMERA_MSG_PARAM_SET(param, INT, level);
4867 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4869 LOGD("ret : 0x%x", ret);
4875 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4877 int ret = CAMERA_ERROR_NONE;
4878 camera_cli_s *pc = (camera_cli_s *)camera;
4879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4880 camera_msg_param param;
4881 int set_whitebalance = (int)wb;
4883 if (!pc || !pc->cb_info) {
4884 LOGE("NULL handle");
4885 return CAMERA_ERROR_INVALID_PARAMETER;
4890 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4892 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4894 LOGD("ret : 0x%x", ret);
4900 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4902 int ret = CAMERA_ERROR_NONE;
4903 camera_cli_s *pc = (camera_cli_s *)camera;
4904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4905 camera_msg_param param;
4906 int set_effect = (int)effect;
4908 if (!pc || !pc->cb_info) {
4909 LOGE("NULL handle");
4910 return CAMERA_ERROR_INVALID_PARAMETER;
4915 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4917 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4919 LOGD("ret : 0x%x", ret);
4925 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4927 int ret = CAMERA_ERROR_NONE;
4928 camera_cli_s *pc = (camera_cli_s *)camera;
4929 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4930 camera_msg_param param;
4931 int set_mode = (int)mode;
4933 if (!pc || !pc->cb_info) {
4934 LOGE("NULL handle");
4935 return CAMERA_ERROR_INVALID_PARAMETER;
4940 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4942 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4944 LOGD("ret : 0x%x", ret);
4950 int camera_attr_enable_tag(camera_h camera, bool enable)
4952 int ret = CAMERA_ERROR_NONE;
4953 camera_cli_s *pc = (camera_cli_s *)camera;
4954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4955 camera_msg_param param;
4956 int set_enable = (int)enable;
4958 if (!pc || !pc->cb_info) {
4959 LOGE("NULL handle");
4960 return CAMERA_ERROR_INVALID_PARAMETER;
4965 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4967 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4969 LOGD("ret : 0x%x", ret);
4975 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4977 int ret = CAMERA_ERROR_NONE;
4978 camera_cli_s *pc = (camera_cli_s *)camera;
4979 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4980 camera_msg_param param;
4982 if (!pc || !pc->cb_info || !description) {
4983 LOGE("NULL pointer %p %p", pc, description);
4984 return CAMERA_ERROR_INVALID_PARAMETER;
4989 CAMERA_MSG_PARAM_SET(param, STRING, description);
4991 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4993 LOGD("ret : 0x%x", ret);
4999 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
5001 int ret = CAMERA_ERROR_NONE;
5002 camera_cli_s *pc = (camera_cli_s *)camera;
5003 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
5004 camera_msg_param param;
5005 int set_orientation = (int)orientation;
5007 if (!pc || !pc->cb_info) {
5008 LOGE("NULL handle");
5009 return CAMERA_ERROR_INVALID_PARAMETER;
5014 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
5016 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5018 LOGD("ret : 0x%x", ret);
5024 int camera_attr_set_tag_software(camera_h camera, const char *software)
5026 int ret = CAMERA_ERROR_NONE;
5027 camera_cli_s *pc = (camera_cli_s *)camera;
5028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
5029 camera_msg_param param;
5031 if (!pc || !pc->cb_info || !software) {
5032 LOGE("NULL pointer %p %p", pc, software);
5033 return CAMERA_ERROR_INVALID_PARAMETER;
5036 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5038 CAMERA_MSG_PARAM_SET(param, STRING, software);
5040 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5042 LOGD("ret : 0x%x", ret);
5048 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
5050 int ret = CAMERA_ERROR_NONE;
5051 camera_cli_s *pc = (camera_cli_s *)camera;
5052 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5053 double set_geotag[3] = {latitude, longitude, altitude};
5058 if (!pc || !pc->cb_info) {
5059 LOGE("NULL handle");
5060 return CAMERA_ERROR_INVALID_PARAMETER;
5065 length = sizeof(set_geotag) / sizeof(int) + \
5066 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5068 msg = muse_core_msg_new(api,
5069 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5072 LOGE("msg creation failed: api %d", api);
5073 return CAMERA_ERROR_OUT_OF_MEMORY;
5076 if (pc->cb_info->is_server_connected) {
5077 __camera_update_api_waiting(pc->cb_info, api, 1);
5079 g_mutex_lock(&pc->cb_info->fd_lock);
5080 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5081 g_mutex_unlock(&pc->cb_info->fd_lock);
5085 LOGE("message send failed");
5086 ret = CAMERA_ERROR_INVALID_OPERATION;
5088 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5091 __camera_update_api_waiting(pc->cb_info, api, -1);
5093 muse_core_msg_free(msg);
5095 LOGD("ret : 0x%x", ret);
5101 int camera_attr_remove_geotag(camera_h camera)
5103 int ret = CAMERA_ERROR_NONE;
5104 camera_cli_s *pc = (camera_cli_s *)camera;
5105 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5107 if (!pc || !pc->cb_info) {
5108 LOGE("NULL handle");
5109 return CAMERA_ERROR_INVALID_PARAMETER;
5114 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5116 LOGD("ret : 0x%x", ret);
5122 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5124 int ret = CAMERA_ERROR_NONE;
5125 camera_cli_s *pc = (camera_cli_s *)camera;
5126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5127 camera_msg_param param;
5128 int set_mode = (int)mode;
5130 if (!pc || !pc->cb_info) {
5131 LOGE("NULL handle");
5132 return CAMERA_ERROR_INVALID_PARAMETER;
5137 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5139 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5141 LOGD("ret : 0x%x", ret);
5147 int camera_attr_get_zoom(camera_h camera, int *zoom)
5149 int ret = CAMERA_ERROR_NONE;
5150 camera_cli_s *pc = (camera_cli_s *)camera;
5151 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5153 if (!pc || !pc->cb_info || !zoom) {
5154 LOGE("NULL pointer %p %p", pc, zoom);
5155 return CAMERA_ERROR_INVALID_PARAMETER;
5160 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5162 if (ret == CAMERA_ERROR_NONE)
5163 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5165 LOGD("ret : 0x%x", ret);
5171 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5173 int ret = CAMERA_ERROR_NONE;
5174 camera_cli_s *pc = (camera_cli_s *)camera;
5175 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5177 if (!pc || !pc->cb_info || !min || !max) {
5178 LOGE("NULL pointer %p %p %p", pc, min, max);
5179 return CAMERA_ERROR_INVALID_PARAMETER;
5184 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5186 if (ret == CAMERA_ERROR_NONE) {
5187 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5188 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5191 LOGD("ret : 0x%x", ret);
5197 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5199 int ret = CAMERA_ERROR_NONE;
5200 camera_cli_s *pc = (camera_cli_s *)camera;
5201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5203 if (!pc || !pc->cb_info || !mode) {
5204 LOGE("NULL pointer %p %p", pc, mode);
5205 return CAMERA_ERROR_INVALID_PARAMETER;
5210 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5212 if (ret == CAMERA_ERROR_NONE)
5213 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5215 LOGD("ret : 0x%x", ret);
5221 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5223 int ret = CAMERA_ERROR_NONE;
5224 camera_cli_s *pc = (camera_cli_s *)camera;
5225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5227 if (!pc || !pc->cb_info || !mode) {
5228 LOGE("NULL pointer %p %p", pc, mode);
5229 return CAMERA_ERROR_INVALID_PARAMETER;
5234 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5236 if (ret == CAMERA_ERROR_NONE)
5237 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5239 LOGD("ret : 0x%x", ret);
5245 int camera_attr_get_exposure(camera_h camera, int *value)
5247 int ret = CAMERA_ERROR_NONE;
5248 camera_cli_s *pc = (camera_cli_s *)camera;
5249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5251 if (!pc || !pc->cb_info || !value) {
5252 LOGE("NULL pointer %p %p", pc, value);
5253 return CAMERA_ERROR_INVALID_PARAMETER;
5258 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5260 if (ret == CAMERA_ERROR_NONE)
5261 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5263 LOGD("ret : 0x%x", ret);
5269 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5271 int ret = CAMERA_ERROR_NONE;
5272 camera_cli_s *pc = (camera_cli_s *)camera;
5273 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5275 if (!pc || !pc->cb_info || !min || !max) {
5276 LOGE("NULL pointer %p %p %p", pc, min, max);
5277 return CAMERA_ERROR_INVALID_PARAMETER;
5282 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5284 if (ret == CAMERA_ERROR_NONE) {
5285 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5286 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5289 LOGD("ret : 0x%x", ret);
5295 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5297 int ret = CAMERA_ERROR_NONE;
5298 camera_cli_s *pc = (camera_cli_s *)camera;
5299 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5301 if (!pc || !pc->cb_info || !iso) {
5302 LOGE("NULL pointer %p %p", pc, iso);
5303 return CAMERA_ERROR_INVALID_PARAMETER;
5308 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5310 if (ret == CAMERA_ERROR_NONE)
5311 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5313 LOGD("ret : 0x%x", ret);
5319 int camera_attr_get_brightness(camera_h camera, int *level)
5321 int ret = CAMERA_ERROR_NONE;
5322 camera_cli_s *pc = (camera_cli_s *)camera;
5323 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5325 if (!pc || !pc->cb_info || !level) {
5326 LOGE("NULL pointer %p %p", pc, level);
5327 return CAMERA_ERROR_INVALID_PARAMETER;
5332 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5334 if (ret == CAMERA_ERROR_NONE)
5335 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5337 LOGD("ret : 0x%x", ret);
5343 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5345 int ret = CAMERA_ERROR_NONE;
5346 camera_cli_s *pc = (camera_cli_s *)camera;
5347 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5349 if (!pc || !pc->cb_info || !min || !max) {
5350 LOGE("NULL pointer %p %p %p", pc, min, max);
5351 return CAMERA_ERROR_INVALID_PARAMETER;
5356 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5358 if (ret == CAMERA_ERROR_NONE) {
5359 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5360 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5363 LOGD("ret : 0x%x", ret);
5369 int camera_attr_get_contrast(camera_h camera, int *level)
5371 int ret = CAMERA_ERROR_NONE;
5372 camera_cli_s *pc = (camera_cli_s *)camera;
5373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5375 if (!pc || !pc->cb_info || !level) {
5376 LOGE("NULL pointer %p %p", pc, level);
5377 return CAMERA_ERROR_INVALID_PARAMETER;
5382 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5384 if (ret == CAMERA_ERROR_NONE)
5385 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5387 LOGD("ret : 0x%x", ret);
5393 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5395 int ret = CAMERA_ERROR_NONE;
5396 camera_cli_s *pc = (camera_cli_s *)camera;
5397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5399 if (!pc || !pc->cb_info || !min || !max) {
5400 LOGE("NULL pointer %p %p %p", pc, min, max);
5401 return CAMERA_ERROR_INVALID_PARAMETER;
5406 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5408 if (ret == CAMERA_ERROR_NONE) {
5409 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5410 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5411 LOGD("min %d, max %d", *min, *max);
5414 LOGD("ret : 0x%x", ret);
5420 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5422 int ret = CAMERA_ERROR_NONE;
5423 camera_cli_s *pc = (camera_cli_s *)camera;
5424 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5426 if (!pc || !pc->cb_info || !wb) {
5427 LOGE("NULL pointer %p %p", pc, wb);
5428 return CAMERA_ERROR_INVALID_PARAMETER;
5433 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5435 if (ret == CAMERA_ERROR_NONE)
5436 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5438 LOGD("ret : 0x%x", ret);
5444 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5446 int ret = CAMERA_ERROR_NONE;
5447 camera_cli_s *pc = (camera_cli_s *)camera;
5448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5450 if (!pc || !pc->cb_info || !effect) {
5451 LOGE("NULL pointer %p %p", pc, effect);
5452 return CAMERA_ERROR_INVALID_PARAMETER;
5457 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5459 if (ret == CAMERA_ERROR_NONE)
5460 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5462 LOGD("ret : 0x%x", ret);
5468 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5470 int ret = CAMERA_ERROR_NONE;
5471 camera_cli_s *pc = (camera_cli_s *)camera;
5472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5474 if (!pc || !pc->cb_info || !mode) {
5475 LOGE("NULL pointer %p %p", pc, mode);
5476 return CAMERA_ERROR_INVALID_PARAMETER;
5481 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5483 if (ret == CAMERA_ERROR_NONE)
5484 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5486 LOGD("ret : 0x%x", ret);
5492 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5494 int ret = CAMERA_ERROR_NONE;
5495 camera_cli_s *pc = (camera_cli_s *)camera;
5496 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5498 if (!pc || !pc->cb_info || !enable) {
5499 LOGE("NULL pointer %p %p", pc, enable);
5500 return CAMERA_ERROR_INVALID_PARAMETER;
5505 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5507 if (ret == CAMERA_ERROR_NONE)
5508 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5510 LOGD("ret : 0x%x", ret);
5516 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5518 int ret = CAMERA_ERROR_NONE;
5519 camera_cli_s *pc = (camera_cli_s *)camera;
5520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5522 if (!pc || !pc->cb_info || !description) {
5523 LOGE("NULL pointer %p %p", pc, description);
5524 return CAMERA_ERROR_INVALID_PARAMETER;
5529 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5531 if (ret == CAMERA_ERROR_NONE)
5532 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5534 LOGD("ret : 0x%x", ret);
5540 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5542 int ret = CAMERA_ERROR_NONE;
5543 camera_cli_s *pc = (camera_cli_s *)camera;
5544 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5546 if (!pc || !pc->cb_info || !orientation) {
5547 LOGE("NULL pointer %p %p", pc, orientation);
5548 return CAMERA_ERROR_INVALID_PARAMETER;
5553 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5555 if (ret == CAMERA_ERROR_NONE)
5556 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5558 LOGD("ret : 0x%x", ret);
5564 int camera_attr_get_tag_software(camera_h camera, char **software)
5566 int ret = CAMERA_ERROR_NONE;
5567 camera_cli_s *pc = (camera_cli_s *)camera;
5568 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5570 if (!pc || !pc->cb_info || !software) {
5571 LOGE("NULL pointer %p %p", pc, software);
5572 return CAMERA_ERROR_INVALID_PARAMETER;
5577 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5579 if (ret == CAMERA_ERROR_NONE)
5580 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5582 LOGD("ret : 0x%x", ret);
5588 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5590 int ret = CAMERA_ERROR_NONE;
5591 camera_cli_s *pc = (camera_cli_s *)camera;
5592 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5594 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5595 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5596 return CAMERA_ERROR_INVALID_PARAMETER;
5601 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5603 if (ret == CAMERA_ERROR_NONE) {
5604 *latitude = pc->cb_info->get_geotag[0];
5605 *longitude = pc->cb_info->get_geotag[1];
5606 *altitude = pc->cb_info->get_geotag[2];
5609 LOGD("ret : 0x%x", ret);
5615 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5617 int ret = CAMERA_ERROR_NONE;
5618 camera_cli_s *pc = (camera_cli_s *)camera;
5619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5621 if (!pc || !pc->cb_info || !mode) {
5622 LOGE("NULL pointer %p %p", pc, mode);
5623 return CAMERA_ERROR_INVALID_PARAMETER;
5628 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5630 if (ret == CAMERA_ERROR_NONE)
5631 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5633 LOGD("ret : 0x%x", ret);
5639 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5641 int ret = CAMERA_ERROR_NONE;
5642 int get_flash_state = 0;
5645 LOGE("NULL pointer");
5646 return CAMERA_ERROR_INVALID_PARAMETER;
5649 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5650 (int)device, "get_flash_state", &get_flash_state);
5652 if (ret == CAMERA_ERROR_NONE) {
5653 *state = (camera_flash_state_e)get_flash_state;
5654 LOGD("flash state %d", *state);
5656 LOGE("failed 0x%x", ret);
5663 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5665 int ret = CAMERA_ERROR_NONE;
5666 camera_cli_s *pc = (camera_cli_s *)camera;
5667 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5669 if (!pc || !pc->cb_info || !foreach_cb) {
5670 LOGE("NULL pointer %p %p", pc, foreach_cb);
5671 return CAMERA_ERROR_INVALID_PARAMETER;
5676 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5677 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5679 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5681 LOGD("ret : 0x%x", ret);
5687 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5689 int ret = CAMERA_ERROR_NONE;
5690 camera_cli_s *pc = (camera_cli_s *)camera;
5691 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5693 if (!pc || !pc->cb_info || !foreach_cb) {
5694 LOGE("NULL pointer %p %p", pc, foreach_cb);
5695 return CAMERA_ERROR_INVALID_PARAMETER;
5700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5703 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5705 LOGD("ret : 0x%x", ret);
5711 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5713 int ret = CAMERA_ERROR_NONE;
5714 camera_cli_s *pc = (camera_cli_s *)camera;
5715 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5717 if (!pc || !pc->cb_info || !foreach_cb) {
5718 LOGE("NULL pointer %p %p", pc, foreach_cb);
5719 return CAMERA_ERROR_INVALID_PARAMETER;
5724 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5725 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5727 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5729 LOGD("ret : 0x%x", ret);
5735 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5737 int ret = CAMERA_ERROR_NONE;
5738 camera_cli_s *pc = (camera_cli_s *)camera;
5739 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5741 if (!pc || !pc->cb_info || !foreach_cb) {
5742 LOGE("NULL pointer %p %p", pc, foreach_cb);
5743 return CAMERA_ERROR_INVALID_PARAMETER;
5748 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5749 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5751 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5753 LOGD("ret : 0x%x", ret);
5759 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5761 int ret = CAMERA_ERROR_NONE;
5762 camera_cli_s *pc = (camera_cli_s *)camera;
5763 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5765 if (!pc || !pc->cb_info || !foreach_cb) {
5766 LOGE("NULL pointer %p %p", pc, foreach_cb);
5767 return CAMERA_ERROR_INVALID_PARAMETER;
5772 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5773 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5775 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5777 LOGD("ret : 0x%x", ret);
5783 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5785 int ret = CAMERA_ERROR_NONE;
5786 camera_cli_s *pc = (camera_cli_s *)camera;
5787 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5789 if (!pc || !pc->cb_info || !foreach_cb) {
5790 LOGE("NULL pointer %p %p", pc, foreach_cb);
5791 return CAMERA_ERROR_INVALID_PARAMETER;
5796 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5797 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5799 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5801 LOGD("ret : 0x%x", ret);
5807 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5809 int ret = CAMERA_ERROR_NONE;
5810 camera_cli_s *pc = (camera_cli_s *)camera;
5811 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5813 if (!pc || !pc->cb_info || !foreach_cb) {
5814 LOGE("NULL pointer %p %p", pc, foreach_cb);
5815 return CAMERA_ERROR_INVALID_PARAMETER;
5820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5823 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5825 LOGD("ret : 0x%x", ret);
5831 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5833 int ret = CAMERA_ERROR_NONE;
5834 camera_cli_s *pc = (camera_cli_s *)camera;
5835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5837 if (!pc || !pc->cb_info || !foreach_cb) {
5838 LOGE("NULL pointer %p %p", pc, foreach_cb);
5839 return CAMERA_ERROR_INVALID_PARAMETER;
5844 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5849 LOGD("Enter, handle :%x", pc->remote_handle);
5855 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)
5857 int ret = CAMERA_ERROR_NONE;
5858 camera_cli_s *pc = (camera_cli_s *)camera;
5859 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5860 camera_msg_param param;
5863 if (!pc || !pc->cb_info || !foreach_cb) {
5864 LOGE("NULL pointer %p %p", pc, foreach_cb);
5865 return CAMERA_ERROR_INVALID_PARAMETER;
5870 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5871 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5873 value = (width << 16) | height;
5874 CAMERA_MSG_PARAM_SET(param, INT, value);
5876 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5878 LOGD("ret : 0x%x", ret);
5884 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5886 int ret = CAMERA_ERROR_NONE;
5887 camera_cli_s *pc = (camera_cli_s *)camera;
5888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5890 if (!pc || !pc->cb_info || !foreach_cb) {
5891 LOGE("NULL pointer %p %p", pc, foreach_cb);
5892 return CAMERA_ERROR_INVALID_PARAMETER;
5897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5900 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5902 LOGD("ret : 0x%x", ret);
5908 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5910 int ret = CAMERA_ERROR_NONE;
5911 camera_cli_s *pc = (camera_cli_s *)camera;
5912 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5914 if (!pc || !pc->cb_info || !foreach_cb) {
5915 LOGE("NULL pointer %p %p", pc, foreach_cb);
5916 return CAMERA_ERROR_INVALID_PARAMETER;
5921 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5922 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5924 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5926 LOGD("ret : 0x%x", ret);
5932 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5934 int ret = CAMERA_ERROR_NONE;
5935 camera_cli_s *pc = (camera_cli_s *)camera;
5936 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5937 camera_msg_param param;
5938 int set_rotation = (int)rotation;
5940 if (!pc || !pc->cb_info) {
5941 LOGE("NULL handle");
5942 return CAMERA_ERROR_INVALID_PARAMETER;
5947 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5949 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5951 LOGD("ret : 0x%x", ret);
5957 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5959 int ret = CAMERA_ERROR_NONE;
5960 camera_cli_s *pc = (camera_cli_s *)camera;
5961 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5963 if (!pc || !pc->cb_info || !rotation) {
5964 LOGE("NULL pointer %p %p", pc, rotation);
5965 return CAMERA_ERROR_INVALID_PARAMETER;
5970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5972 if (ret == CAMERA_ERROR_NONE)
5973 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5975 LOGD("ret : 0x%x", ret);
5981 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5983 int ret = CAMERA_ERROR_NONE;
5984 camera_cli_s *pc = (camera_cli_s *)camera;
5985 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5986 camera_msg_param param;
5987 int set_flip = (int)flip;
5989 if (!pc || !pc->cb_info) {
5990 LOGE("NULL handle");
5991 return CAMERA_ERROR_INVALID_PARAMETER;
5996 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5998 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6000 LOGD("ret : 0x%x", ret);
6006 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
6008 int ret = CAMERA_ERROR_NONE;
6009 camera_cli_s *pc = (camera_cli_s *)camera;
6010 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
6012 if (!pc || !pc->cb_info || !flip) {
6013 LOGE("NULL pointer %p %p", pc, flip);
6014 return CAMERA_ERROR_INVALID_PARAMETER;
6019 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6021 if (ret == CAMERA_ERROR_NONE)
6022 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
6024 LOGD("ret : 0x%x", ret);
6029 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
6031 int ret = CAMERA_ERROR_NONE;
6032 camera_cli_s *pc = (camera_cli_s *)camera;
6033 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
6034 camera_msg_param param;
6035 int set_mode = (int)mode;
6037 if (!pc || !pc->cb_info) {
6038 LOGE("NULL handle");
6039 return CAMERA_ERROR_INVALID_PARAMETER;
6044 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
6046 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6048 LOGD("ret : 0x%x", ret);
6054 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6056 int ret = CAMERA_ERROR_NONE;
6057 camera_cli_s *pc = (camera_cli_s *)camera;
6058 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6060 if (!pc || !pc->cb_info || !mode) {
6061 LOGE("NULL pointer %p %p", pc, mode);
6062 return CAMERA_ERROR_INVALID_PARAMETER;
6067 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6069 if (ret == CAMERA_ERROR_NONE)
6070 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6072 LOGD("ret : 0x%x", ret);
6078 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6080 int ret = CAMERA_ERROR_NONE;
6081 camera_cli_s *pc = (camera_cli_s *)camera;
6082 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6084 if (!pc || !pc->cb_info) {
6085 LOGE("NULL handle");
6086 return CAMERA_ERROR_INVALID_PARAMETER;
6091 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6094 LOGE("error is occurred 0x%x", ret);
6098 LOGD("ret : %d", ret);
6104 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6106 int ret = CAMERA_ERROR_NONE;
6107 camera_cli_s *pc = (camera_cli_s *)camera;
6108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6110 if (!pc || !pc->cb_info) {
6111 LOGE("NULL handle");
6112 return CAMERA_ERROR_INVALID_PARAMETER;
6117 if (!camera_attr_is_supported_hdr_capture(camera)) {
6118 LOGE("HDR not supported");
6119 return CAMERA_ERROR_NOT_SUPPORTED;
6123 LOGE("NULL callback");
6124 return CAMERA_ERROR_INVALID_PARAMETER;
6127 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6129 if (ret == CAMERA_ERROR_NONE) {
6130 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6132 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6133 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6135 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6138 LOGD("ret : 0x%x", ret);
6144 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6146 int ret = CAMERA_ERROR_NONE;
6147 camera_cli_s *pc = (camera_cli_s *)camera;
6148 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6150 if (!pc || !pc->cb_info) {
6151 LOGE("NULL handle");
6152 return CAMERA_ERROR_INVALID_PARAMETER;
6157 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6159 if (ret == CAMERA_ERROR_NONE) {
6160 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6162 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6163 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6165 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6168 LOGD("ret : 0x%x", ret);
6174 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6176 int ret = CAMERA_ERROR_NONE;
6177 camera_cli_s *pc = (camera_cli_s *)camera;
6178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6179 camera_msg_param param;
6180 int set_enable = (int)enable;
6182 if (!pc || !pc->cb_info) {
6183 LOGE("NULL handle");
6184 return CAMERA_ERROR_INVALID_PARAMETER;
6189 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6191 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6193 LOGD("ret : 0x%x", ret);
6199 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6201 int ret = CAMERA_ERROR_NONE;
6202 camera_cli_s *pc = (camera_cli_s *)camera;
6203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6205 if (!pc || !pc->cb_info || !enabled) {
6206 LOGE("NULL pointer %p %p", pc, enabled);
6207 return CAMERA_ERROR_INVALID_PARAMETER;
6212 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6214 if (ret == CAMERA_ERROR_NONE)
6215 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6217 LOGD("ret : 0x%x", ret);
6223 bool camera_attr_is_supported_anti_shake(camera_h camera)
6225 int ret = CAMERA_ERROR_NONE;
6226 camera_cli_s *pc = (camera_cli_s *)camera;
6227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6229 if (!pc || !pc->cb_info) {
6230 LOGE("NULL handle");
6231 return CAMERA_ERROR_INVALID_PARAMETER;
6236 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6239 LOGE("error is occurred 0x%x", ret);
6243 LOGD("ret : %d", ret);
6249 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6251 int ret = CAMERA_ERROR_NONE;
6252 camera_cli_s *pc = (camera_cli_s *)camera;
6253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6254 camera_msg_param param;
6255 int set_enable = (int)enable;
6257 if (!pc || !pc->cb_info) {
6258 LOGE("NULL handle");
6259 return CAMERA_ERROR_INVALID_PARAMETER;
6264 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6266 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6268 LOGD("ret : 0x%x", ret);
6274 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6276 int ret = CAMERA_ERROR_NONE;
6277 camera_cli_s *pc = (camera_cli_s *)camera;
6278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6280 if (!pc || !pc->cb_info || !enabled) {
6281 LOGE("NULL pointer %p %p", pc, enabled);
6282 return CAMERA_ERROR_INVALID_PARAMETER;
6287 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6289 if (ret == CAMERA_ERROR_NONE)
6290 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6292 LOGD("ret : 0x%x", ret);
6298 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6300 int ret = CAMERA_ERROR_NONE;
6301 camera_cli_s *pc = (camera_cli_s *)camera;
6302 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6304 if (!pc || !pc->cb_info) {
6305 LOGE("NULL handle");
6306 return CAMERA_ERROR_INVALID_PARAMETER;
6311 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6314 LOGE("error is occurred 0x%x", ret);
6318 LOGD("ret : %d", ret);
6324 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6326 int ret = CAMERA_ERROR_NONE;
6327 camera_cli_s *pc = (camera_cli_s *)camera;
6328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6329 camera_msg_param param;
6330 int set_enable = (int)enable;
6332 if (!pc || !pc->cb_info) {
6333 LOGE("NULL handle");
6334 return CAMERA_ERROR_INVALID_PARAMETER;
6339 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6341 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6343 LOGD("ret : 0x%x", ret);
6349 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6351 int ret = CAMERA_ERROR_NONE;
6352 camera_cli_s *pc = (camera_cli_s *)camera;
6353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6355 if (!pc || !pc->cb_info || !enabled) {
6356 LOGE("NULL pointer %p %p", pc, enabled);
6357 return CAMERA_ERROR_INVALID_PARAMETER;
6362 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6364 if (ret == CAMERA_ERROR_NONE)
6365 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6367 LOGD("ret : 0x%x", ret);
6373 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6375 int ret = CAMERA_ERROR_NONE;
6376 camera_cli_s *pc = (camera_cli_s *)camera;
6377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6379 if (!pc || !pc->cb_info) {
6380 LOGE("NULL handle");
6381 return CAMERA_ERROR_INVALID_PARAMETER;
6386 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6389 LOGE("error is occurred 0x%x", ret);
6393 LOGD("ret : %d", ret);
6399 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6401 int ret = CAMERA_ERROR_NONE;
6402 camera_cli_s *pc = (camera_cli_s *)camera;
6403 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6404 camera_msg_param param;
6405 int set_disable = (int)disable;
6407 if (!pc || !pc->cb_info) {
6408 LOGE("NULL handle");
6409 return CAMERA_ERROR_INVALID_PARAMETER;
6414 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6416 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6418 LOGD("ret : 0x%x", ret);
6424 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6426 int ret = CAMERA_ERROR_NONE;
6427 camera_cli_s *pc = (camera_cli_s *)camera;
6428 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6429 camera_msg_param param;
6430 int set_move_type = (int)move_type;
6433 if (!pc || !pc->cb_info) {
6434 LOGE("NULL handle");
6435 return CAMERA_ERROR_INVALID_PARAMETER;
6440 value = (set_move_type << 16) | pan_step;
6441 CAMERA_MSG_PARAM_SET(param, INT, value);
6443 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6445 LOGD("ret : 0x%x", ret);
6451 int camera_attr_get_pan(camera_h camera, int *pan_step)
6453 int ret = CAMERA_ERROR_NONE;
6454 camera_cli_s *pc = (camera_cli_s *)camera;
6455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6457 if (!pc || !pc->cb_info || !pan_step) {
6458 LOGE("NULL pointer %p %p", pc, pan_step);
6459 return CAMERA_ERROR_INVALID_PARAMETER;
6464 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6466 if (ret == CAMERA_ERROR_NONE)
6467 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6469 LOGD("ret : 0x%x", ret);
6475 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6477 int ret = CAMERA_ERROR_NONE;
6478 camera_cli_s *pc = (camera_cli_s *)camera;
6479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6481 if (!pc || !pc->cb_info || !min || !max) {
6482 LOGE("NULL pointer %p %p %p", pc, min, max);
6483 return CAMERA_ERROR_INVALID_PARAMETER;
6488 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6490 if (ret == CAMERA_ERROR_NONE) {
6491 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6492 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6495 LOGD("ret : 0x%x", ret);
6501 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6503 int ret = CAMERA_ERROR_NONE;
6504 camera_cli_s *pc = (camera_cli_s *)camera;
6505 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6506 camera_msg_param param;
6507 int set_move_type = (int)move_type;
6510 if (!pc || !pc->cb_info) {
6511 LOGE("NULL handle");
6512 return CAMERA_ERROR_INVALID_PARAMETER;
6517 value = (set_move_type << 16) | tilt_step;
6518 CAMERA_MSG_PARAM_SET(param, INT, value);
6520 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6522 LOGD("ret : 0x%x", ret);
6528 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6530 int ret = CAMERA_ERROR_NONE;
6531 camera_cli_s *pc = (camera_cli_s *)camera;
6532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6534 if (!pc || !pc->cb_info || !tilt_step) {
6535 LOGE("NULL pointer %p %p", pc, tilt_step);
6536 return CAMERA_ERROR_INVALID_PARAMETER;
6541 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6543 if (ret == CAMERA_ERROR_NONE)
6544 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6546 LOGD("ret : 0x%x", ret);
6552 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6554 int ret = CAMERA_ERROR_NONE;
6555 camera_cli_s *pc = (camera_cli_s *)camera;
6556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6558 if (!pc || !pc->cb_info || !min || !max) {
6559 LOGE("NULL pointer %p %p %p", pc, min, max);
6560 return CAMERA_ERROR_INVALID_PARAMETER;
6565 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6567 if (ret == CAMERA_ERROR_NONE) {
6568 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6569 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6572 LOGD("ret : 0x%x", ret);
6578 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6580 int ret = CAMERA_ERROR_NONE;
6581 camera_cli_s *pc = (camera_cli_s *)camera;
6582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6583 camera_msg_param param;
6584 int set_ptz_type = (int)ptz_type;
6586 if (!pc || !pc->cb_info) {
6587 LOGE("NULL handle");
6588 return CAMERA_ERROR_INVALID_PARAMETER;
6593 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6597 LOGD("ret : 0x%x", ret);
6603 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6605 int ret = CAMERA_ERROR_NONE;
6606 camera_cli_s *pc = (camera_cli_s *)camera;
6607 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6609 if (!pc || !pc->cb_info || !foreach_cb) {
6610 LOGE("NULL pointer %p %p", pc, foreach_cb);
6611 return CAMERA_ERROR_INVALID_PARAMETER;
6616 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6617 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6619 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6621 LOGD("ret : 0x%x", ret);
6627 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6629 int ret = CAMERA_ERROR_NONE;
6630 camera_cli_s *pc = (camera_cli_s *)camera;
6631 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6632 int set_display_roi_area[4] = {x, y, width, height};
6637 if (!pc || !pc->cb_info) {
6638 LOGE("NULL handle");
6639 return CAMERA_ERROR_INVALID_PARAMETER;
6644 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6645 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6646 g_mutex_lock(&pc->cb_info->evas_mutex);
6648 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6650 g_mutex_unlock(&pc->cb_info->evas_mutex);
6652 if (ret != MM_ERROR_NONE) {
6653 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6654 return CAMERA_ERROR_INVALID_OPERATION;
6657 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6659 length = sizeof(set_display_roi_area) / sizeof(int) + \
6660 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6662 msg = muse_core_msg_new(api,
6663 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6666 LOGE("msg creation failed: api %d", api);
6667 return CAMERA_ERROR_OUT_OF_MEMORY;
6670 if (pc->cb_info->is_server_connected) {
6671 __camera_update_api_waiting(pc->cb_info, api, 1);
6673 g_mutex_lock(&pc->cb_info->fd_lock);
6674 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6675 g_mutex_unlock(&pc->cb_info->fd_lock);
6679 LOGE("message send failed");
6680 ret = CAMERA_ERROR_INVALID_OPERATION;
6682 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6685 __camera_update_api_waiting(pc->cb_info, api, -1);
6687 muse_core_msg_free(msg);
6689 LOGD("ret : 0x%x", ret);
6695 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6697 camera_cli_s *pc = (camera_cli_s *)camera;
6698 int ret = CAMERA_ERROR_NONE;
6699 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6701 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6702 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6703 return CAMERA_ERROR_INVALID_PARAMETER;
6708 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6710 if (ret == CAMERA_ERROR_NONE) {
6711 *x = pc->cb_info->get_display_roi_area[0];
6712 *y = pc->cb_info->get_display_roi_area[1];
6713 *width = pc->cb_info->get_display_roi_area[2];
6714 *height = pc->cb_info->get_display_roi_area[3];
6717 LOGD("ret : 0x%x", ret);
6723 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6725 int ret = CAMERA_ERROR_NONE;
6726 int get_device_state = 0;
6729 LOGE("NULL pointer");
6730 return CAMERA_ERROR_INVALID_PARAMETER;
6733 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6734 (int)device, "get_device_state", &get_device_state);
6736 if (ret == CAMERA_ERROR_NONE) {
6737 *state = (camera_device_state_e)get_device_state;
6738 LOGD("device state %d", *state);
6740 LOGE("failed 0x%x", ret);
6747 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6749 int ret = CAMERA_ERROR_NONE;
6750 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6751 camera_cb_info *info = NULL;
6753 if (!callback || !cb_id) {
6754 LOGE("invalid pointer %p %p", callback, cb_id);
6755 return CAMERA_ERROR_INVALID_PARAMETER;
6758 /* check camera support */
6759 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6760 if (ret != CAMERA_ERROR_NONE) {
6761 LOGE("get device state failed");
6765 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6767 info = g_new0(camera_cb_info, 1);
6769 LOGE("info failed");
6770 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6774 info->id = ++g_cam_dev_state_changed_cb_id;
6775 info->callback = (void *)callback;
6776 info->user_data = user_data;
6780 /* subscribe dbus signal for camera state change */
6781 if (!g_cam_dev_state_changed_cb_conn) {
6782 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6783 if (!g_cam_dev_state_changed_cb_conn) {
6784 LOGE("failed to get gdbus connection");
6785 ret = CAMERA_ERROR_INVALID_OPERATION;
6789 LOGD("subscribe signal %s - %s - %s",
6790 MM_CAMCORDER_DBUS_OBJECT,
6791 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6792 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6794 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6795 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6796 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6797 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6798 LOGE("failed to get gdbus connection");
6799 ret = CAMERA_ERROR_INVALID_OPERATION;
6803 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6806 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6808 LOGD("callback id %d", info->id);
6811 if (ret != CAMERA_ERROR_NONE) {
6817 if (g_cam_dev_state_changed_cb_conn) {
6818 g_object_unref(g_cam_dev_state_changed_cb_conn);
6819 g_cam_dev_state_changed_cb_conn = NULL;
6823 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6829 int camera_remove_device_state_changed_cb(int cb_id)
6831 int ret = CAMERA_ERROR_NONE;
6832 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6833 GList *tmp_list = NULL;
6834 camera_cb_info *info = NULL;
6836 /* check camera support */
6837 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6838 if (ret != CAMERA_ERROR_NONE) {
6839 LOGE("get device state failed");
6843 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6845 if (!g_cam_dev_state_changed_cb_list) {
6846 LOGE("there is no callback info");
6847 ret = CAMERA_ERROR_INVALID_OPERATION;
6851 tmp_list = g_cam_dev_state_changed_cb_list;
6854 info = tmp_list->data;
6855 tmp_list = tmp_list->next;
6862 if (info->id == cb_id) {
6863 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6868 if (!g_cam_dev_state_changed_cb_list) {
6869 /* no remained callback */
6870 if (g_cam_dev_state_changed_cb_conn) {
6871 /* unsubscribe signal */
6872 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6873 g_cam_dev_state_changed_cb_subscribe_id = 0;
6875 /* unref connection */
6876 g_object_unref(g_cam_dev_state_changed_cb_conn);
6877 g_cam_dev_state_changed_cb_conn = NULL;
6881 LOGD("id %d callback removed", cb_id);
6882 ret = CAMERA_ERROR_NONE;
6888 LOGE("id %d callback not found", cb_id);
6889 ret = CAMERA_ERROR_INVALID_PARAMETER;
6892 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);