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 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1098 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1099 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1100 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1101 /* return preview callback */
1102 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1105 muse_camera_msg_get(tbm_key, recv_msg);
1106 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1108 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1109 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1113 } else if (cb_info->user_cb[event] == NULL) {
1114 LOGW("user callback for event %d is not set", event);
1119 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1125 muse_camera_msg_get(previous, recv_msg);
1126 muse_camera_msg_get(current, recv_msg);
1127 muse_camera_msg_get(by_policy, recv_msg);
1129 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1130 previous, current, by_policy);
1132 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1133 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1136 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1140 muse_camera_msg_get(state, recv_msg);
1142 LOGD("FOCUS state - %d", state);
1144 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1147 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1148 LOGD("CAPTURE_COMPLETED");
1149 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1151 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1152 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1156 int num_buffer_key = 0;
1157 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1159 unsigned char *buf_pos = NULL;
1161 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1162 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1163 tbm_bo data_bo = NULL;
1164 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1166 camera_preview_data_s frame;
1167 camera_stream_data_s *stream = NULL;
1168 camera_media_packet_data *mp_data = NULL;
1169 media_packet_h pkt = NULL;
1170 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1171 media_packet_h pkt_evas = NULL;
1172 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1174 muse_camera_msg_get(tbm_key, recv_msg);
1175 muse_camera_msg_get(num_buffer_key, recv_msg);
1176 muse_camera_msg_get_array(buffer_key, recv_msg);
1177 muse_camera_msg_get(data_key, recv_msg);
1179 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1182 LOGE("invalid key %d", tbm_key);
1186 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1188 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1189 LOGE("invalid num buffer key %d", num_buffer_key);
1190 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1195 /* import tbm data_bo and get virtual address */
1196 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1197 LOGE("failed to import data key %d", data_key);
1198 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1203 /* import tbm bo and get virtual address */
1204 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1205 LOGE("failed to import key %d", tbm_key);
1206 _camera_release_imported_bo(&data_bo);
1207 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1211 buf_pos = (unsigned char *)bo_handle.ptr;
1213 /* get stream info */
1214 stream = (camera_stream_data_s *)buf_pos;
1216 for (i = 0 ; i < num_buffer_key ; i++) {
1217 /* import buffer bo and get virtual address */
1218 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1219 LOGE("failed to import buffer key %d", buffer_key[i]);
1221 /* release imported bo */
1222 _camera_release_imported_bo(&data_bo);
1223 _camera_release_imported_bo(&bo);
1225 for (i -= 1 ; i >= 0 ; i--)
1226 _camera_release_imported_bo(&buffer_bo[i]);
1228 /* send return buffer */
1229 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1235 /* call preview callback */
1236 g_mutex_lock(&cb_info->preview_cb_mutex);
1238 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1239 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1241 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1242 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1245 g_mutex_unlock(&cb_info->preview_cb_mutex);
1247 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1248 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1249 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1251 if (ret == CAMERA_ERROR_NONE) {
1252 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1253 if (ret != CAMERA_ERROR_NONE) {
1254 LOGE("create pkt for evas failed");
1255 _camera_media_packet_data_release(mp_data, cb_info);
1259 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1260 LOGW("evas renderer is not supported");
1261 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1264 /* call media packet callback */
1265 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1266 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1268 if (ret == CAMERA_ERROR_NONE) {
1269 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1271 if (ret == CAMERA_ERROR_NONE) {
1272 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1273 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1275 _camera_media_packet_data_release(mp_data, cb_info);
1281 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1282 /* call evas renderer */
1284 g_mutex_lock(&cb_info->evas_mutex);
1285 if (cb_info->run_evas_render) {
1286 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1288 LOGW("evas renderer is stopped, skip this buffer...");
1289 media_packet_destroy(pkt_evas);
1292 g_mutex_unlock(&cb_info->evas_mutex);
1294 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1296 /* send message for preview callback return */
1297 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1298 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1300 if (mp_data == NULL) {
1301 /* release imported bo */
1302 for (i = 0 ; i < num_buffer_key ; i++)
1303 _camera_release_imported_bo(&buffer_bo[i]);
1305 /* unmap and unref tbm bo */
1306 _camera_release_imported_bo(&data_bo);
1307 _camera_release_imported_bo(&bo);
1310 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1312 /*LOGD("return buffer Done");*/
1316 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1320 muse_camera_msg_get(percent, recv_msg);
1322 LOGD("HDR progress - %d %%", percent);
1324 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1327 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1333 muse_camera_msg_get(policy, recv_msg);
1334 muse_camera_msg_get(previous, recv_msg);
1335 muse_camera_msg_get(current, recv_msg);
1337 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1338 policy, previous, current);
1340 if (policy == CAMERA_POLICY_SOUND)
1341 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1342 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1343 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1344 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1345 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1347 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1348 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1351 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1356 muse_camera_msg_get(policy, recv_msg);
1357 muse_camera_msg_get(state, recv_msg);
1359 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1361 if (policy == CAMERA_POLICY_SOUND)
1362 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1363 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1364 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1365 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1366 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1368 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1369 (camera_state_e)state, cb_info->user_data[event]);
1372 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1375 camera_detected_face_s *faces = NULL;
1377 muse_camera_msg_get(count, recv_msg);
1378 muse_camera_msg_get(tbm_key, recv_msg);
1381 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1385 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1387 faces = bo_handle.ptr;
1391 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1394 _camera_release_imported_bo(&bo);
1398 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1399 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1400 /*LOGD("return buffer done");*/
1403 LOGE("invalid message - count %d, key %d", count, tbm_key);
1407 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1410 int current_state = 0;
1412 muse_camera_msg_get(error, recv_msg);
1413 muse_camera_msg_get(current_state, recv_msg);
1415 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1417 if (error == CAMERA_ERROR_SOUND_POLICY)
1418 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1419 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1420 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1421 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1422 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1424 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1425 (camera_state_e)current_state, cb_info->user_data[event]);
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1431 muse_camera_msg_get(param1, recv_msg);
1432 muse_camera_msg_get(param2, recv_msg);
1434 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1436 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1437 cb_info->user_cb[event] = NULL;
1438 cb_info->user_data[event] = NULL;
1439 LOGW("stop foreach callback for event %d", event);
1442 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1448 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1450 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1452 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1454 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1456 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1458 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1460 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1462 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1464 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1466 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1468 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1470 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1471 muse_camera_msg_get(param1, recv_msg);
1473 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1475 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1476 cb_info->user_cb[event] = NULL;
1477 cb_info->user_data[event] = NULL;
1478 LOGW("stop foreach callback for event %d", event);
1481 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1483 camera_image_data_s *rImage = NULL;
1484 camera_image_data_s *rPostview = NULL;
1485 camera_image_data_s *rThumbnail = NULL;
1486 unsigned char *buf_pos = NULL;
1487 int tbm_key_main = 0;
1488 int tbm_key_post = 0;
1489 int tbm_key_thumb = 0;
1490 tbm_bo bo_main = NULL;
1491 tbm_bo bo_post = NULL;
1492 tbm_bo bo_thumb = NULL;
1493 tbm_bo_handle bo_main_handle = {NULL, };
1494 tbm_bo_handle bo_post_handle = {NULL, };
1495 tbm_bo_handle bo_thumb_handle = {NULL, };
1497 muse_camera_msg_get(tbm_key_main, recv_msg);
1498 muse_camera_msg_get(tbm_key_post, recv_msg);
1499 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1502 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1503 tbm_key_main, tbm_key_post, tbm_key_thumb);
1506 if (tbm_key_main <= 0) {
1507 LOGE("invalid key %d", tbm_key_main);
1511 /* import tbm bo and get virtual address */
1512 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1515 buf_pos = (unsigned char *)bo_main_handle.ptr;
1516 rImage = (camera_image_data_s *)buf_pos;
1517 rImage->data = buf_pos + sizeof(camera_image_data_s);
1518 if (rImage->exif && rImage->exif_size > 0) {
1519 rImage->exif = rImage->data + rImage->size;
1521 rImage->exif = NULL;
1522 rImage->exif_size = 0;
1525 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1526 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1528 if (tbm_key_post > 0) {
1529 /* import tbm bo and get virtual address */
1530 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1533 buf_pos = (unsigned char *)bo_post_handle.ptr;
1534 rPostview = (camera_image_data_s *)buf_pos;
1535 LOGD("rPostview->size : %d", rPostview->size);
1536 rPostview->data = buf_pos + sizeof(camera_image_data_s);
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))
1544 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1546 rThumbnail = (camera_image_data_s *)buf_pos;
1547 LOGD("rThumbnail->size : %d", rThumbnail->size);
1548 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
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);
1557 tbm_key = tbm_key_main;
1559 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1561 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1563 if (tbm_key_post > 0) {
1564 /* unmap and unref tbm bo */
1565 _camera_release_imported_bo(&bo_post);
1568 param.value.value_INT = tbm_key_post;
1569 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1572 if (tbm_key_thumb > 0) {
1573 /* unmap and unref tbm bo */
1574 _camera_release_imported_bo(&bo_thumb);
1577 param.value.value_INT = tbm_key_thumb;
1578 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1581 LOGD("return buffer done");
1585 LOGW("unhandled event %d", event);
1592 static bool _camera_idle_event_callback(void *data)
1594 camera_cb_info_s *cb_info = NULL;
1595 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1597 if (cam_idle_event == NULL) {
1598 LOGE("cam_idle_event is NULL");
1603 g_mutex_lock(&cam_idle_event->event_mutex);
1605 cb_info = cam_idle_event->cb_info;
1606 if (cb_info == NULL) {
1607 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1608 goto IDLE_EVENT_CALLBACK_DONE;
1611 /* remove event from list */
1612 g_mutex_lock(&cb_info->idle_event_mutex);
1614 if (cb_info->idle_event_list)
1615 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1617 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1618 g_mutex_unlock(&cb_info->idle_event_mutex);
1621 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1623 /* send signal for waiting thread */
1624 g_cond_signal(&cb_info->idle_event_cond);
1626 IDLE_EVENT_CALLBACK_DONE:
1627 /* unlock and release event */
1628 g_mutex_unlock(&cam_idle_event->event_mutex);
1629 g_mutex_clear(&cam_idle_event->event_mutex);
1631 g_free(cam_idle_event);
1632 cam_idle_event = NULL;
1637 static void *_camera_msg_handler_func(gpointer data)
1641 camera_message_s *cam_msg = NULL;
1642 camera_idle_event_s *cam_idle_event = NULL;
1643 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1644 camera_cb_info_s *cb_info = NULL;
1646 if (!handler_info || !handler_info->cb_info) {
1647 LOGE("NULL handler %p", handler_info);
1651 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1652 type = handler_info->type;
1654 LOGD("t:%d start", type);
1656 g_mutex_lock(&handler_info->mutex);
1658 while (g_atomic_int_get(&handler_info->running)) {
1659 if (g_queue_is_empty(handler_info->queue)) {
1660 /*LOGD("t:%d signal wait...", type);*/
1661 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1662 /*LOGD("t:%d signal received", type);*/
1664 if (g_atomic_int_get(&handler_info->running) == 0) {
1665 LOGD("t:%d stop event thread", type);
1670 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1672 g_mutex_unlock(&handler_info->mutex);
1674 if (cam_msg == NULL) {
1675 LOGE("t:%d NULL message", type);
1676 g_mutex_lock(&handler_info->mutex);
1682 if (api < MUSE_CAMERA_API_MAX) {
1685 g_mutex_lock(&cb_info->api_mutex[api]);
1687 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1688 if (cb_info->api_waiting[api] > 0) {
1689 cb_info->api_ret[api] = ret;
1690 cb_info->api_activating[api] = 1;
1692 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1694 g_cond_signal(&cb_info->api_cond[api]);
1696 LOGW("no waiting for this api [%d]", api);
1699 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1702 g_mutex_unlock(&cb_info->api_mutex[api]);
1703 } else if (api == MUSE_CAMERA_CB_EVENT) {
1704 switch (cam_msg->event_class) {
1705 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1706 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1708 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1709 cam_idle_event = g_new0(camera_idle_event_s, 1);
1710 if (cam_idle_event == NULL) {
1711 LOGE("t:%d cam_idle_event alloc failed", type);
1715 cam_idle_event->event = cam_msg->event;
1716 cam_idle_event->cb_info = cb_info;
1717 g_mutex_init(&cam_idle_event->event_mutex);
1718 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1720 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1722 g_mutex_lock(&cb_info->idle_event_mutex);
1723 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1724 g_mutex_unlock(&cb_info->idle_event_mutex);
1726 g_idle_add_full(G_PRIORITY_DEFAULT,
1727 (GSourceFunc)_camera_idle_event_callback,
1728 (gpointer)cam_idle_event,
1732 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1736 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1742 g_mutex_lock(&handler_info->mutex);
1745 /* remove remained event */
1746 while (!g_queue_is_empty(handler_info->queue)) {
1747 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1749 LOGD("t:%d remove camera message %p", type, cam_msg);
1753 LOGW("t:%d NULL camera message", type);
1757 g_mutex_unlock(&handler_info->mutex);
1759 LOGD("t:%d return", type);
1765 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1767 camera_idle_event_s *cam_idle_event = NULL;
1769 gint64 end_time = 0;
1771 if (cb_info == NULL) {
1772 LOGE("cb_info is NULL");
1776 g_mutex_lock(&cb_info->idle_event_mutex);
1778 if (cb_info->idle_event_list == NULL) {
1779 LOGD("No remained idle event");
1780 g_mutex_unlock(&cb_info->idle_event_mutex);
1784 list = cb_info->idle_event_list;
1787 cam_idle_event = list->data;
1788 list = g_list_next(list);
1790 if (!cam_idle_event) {
1791 LOGW("Fail to remove idle event. The event is NULL");
1795 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1796 LOGW("lock failed, %p event is calling now", cam_idle_event);
1798 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1800 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1801 LOGW("signal received");
1808 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1809 cam_idle_event, cam_idle_event->event);
1811 cam_idle_event->cb_info = NULL;
1813 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1815 g_mutex_unlock(&cam_idle_event->event_mutex);
1818 g_list_free(cb_info->idle_event_list);
1819 cb_info->idle_event_list = NULL;
1821 g_mutex_unlock(&cb_info->idle_event_mutex);
1827 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1829 camera_message_s *cam_msg = NULL;
1831 if (!cb_info || !msg) {
1832 LOGE("NULL pointer %p %p", cb_info, msg);
1836 cam_msg = g_new0(camera_message_s, 1);
1838 LOGE("failed to alloc cam_msg for [%s]", msg);
1843 cam_msg->event = event;
1844 cam_msg->event_class = event_class;
1846 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1848 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1850 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1851 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1852 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1853 g_cond_signal(&cb_info->preview_cb_info.cond);
1854 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1855 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1856 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1857 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1858 g_cond_signal(&cb_info->capture_cb_info.cond);
1859 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1861 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1862 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1863 g_cond_signal(&cb_info->msg_handler_info.cond);
1864 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1873 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1875 int ret = CAMERA_ERROR_NONE;
1879 int event_class = -1;
1883 if (!cb_info || !msg) {
1884 LOGE("invalid ptr %p %p", cb_info, msg);
1888 /*LOGD("msg [%s]", msg);*/
1890 if (!muse_camera_msg_get(api, msg)) {
1891 LOGE("failed to get camera api");
1895 if (api == MUSE_CAMERA_CB_EVENT) {
1896 if (!muse_camera_msg_get(event, msg) ||
1897 !muse_camera_msg_get(event_class, msg)) {
1898 LOGE("failed to get camera event or event_class [%s]", msg);
1902 if (!muse_camera_msg_get(api_class, msg)) {
1903 LOGE("failed to get camera api_class [%s]", msg);
1908 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1909 if (api >= MUSE_CAMERA_API_MAX) {
1910 LOGE("invalid api %d", api);
1914 if (!muse_camera_msg_get(ret, msg)) {
1915 LOGE("failed to get camera ret");
1919 g_mutex_lock(&cb_info->api_mutex[api]);
1922 case MUSE_CAMERA_API_CREATE:
1923 if (ret != CAMERA_ERROR_NONE) {
1924 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1925 LOGE("camera create error 0x%x. close client cb handler", ret);
1928 case MUSE_CAMERA_API_DESTROY:
1929 if (ret == CAMERA_ERROR_NONE) {
1930 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1931 LOGD("camera destroy done. close client cb handler");
1935 muse_camera_msg_get(get_type, msg);
1936 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1937 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1938 muse_camera_msg_get(get_index, msg);
1941 case MUSE_CAMERA_GET_TYPE_INT:
1942 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1944 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1945 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1946 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1948 case MUSE_CAMERA_GET_TYPE_ARRAY:
1949 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1950 muse_core_msg_deserialize("get_value",
1951 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1952 LOGD("get display roi %d,%d,%dx%d",
1953 cb_info->get_display_roi_area[0],
1954 cb_info->get_display_roi_area[1],
1955 cb_info->get_display_roi_area[2],
1956 cb_info->get_display_roi_area[3]);
1958 muse_core_msg_deserialize("get_value",
1959 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1960 LOGD("get geotag %lf, %lf, %lf",
1961 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1964 case MUSE_CAMERA_GET_TYPE_STRING:
1965 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1968 LOGW("unknown type %d", get_type);
1975 if (cb_info->api_waiting[api] > 0) {
1976 cb_info->api_ret[api] = ret;
1977 cb_info->api_activating[api] = 1;
1979 g_cond_signal(&cb_info->api_cond[api]);
1981 LOGW("no waiting for this api [%d]", api);
1984 g_mutex_unlock(&cb_info->api_mutex[api]);
1985 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1986 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1988 LOGW("unknown camera api %d, class %d", api, api_class);
1995 static void *_camera_msg_recv_func(gpointer data)
1997 int recv_length = 0;
1998 int single_length = 0;
1999 int remained_length = 0;
2000 char *recv_msg = NULL;
2001 char *single_msg = NULL;
2002 char *remained_msg = NULL;
2006 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2009 LOGE("cb_info NULL");
2015 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2017 LOGE("single_msg malloc failed");
2021 recv_msg = cb_info->recv_msg;
2023 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2024 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2025 if (recv_length <= 0) {
2026 cb_info->is_server_connected = FALSE;
2027 LOGE("receive msg failed - server disconnected");
2035 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2037 /* Need to split the combined entering msgs */
2038 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2039 if (recv_msg[cur_pos] == '}') {
2040 single_length = cur_pos - prev_pos + 1;
2042 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2043 /* check remained msg */
2044 if (remained_length > 0) {
2046 strncpy(single_msg, remained_msg, remained_length);
2047 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2048 single_msg[remained_length + single_length] = '\0';
2051 remained_msg = NULL;
2053 strncpy(single_msg, recv_msg + prev_pos, single_length);
2054 single_msg[single_length] = '\0';
2055 LOGE("lost msg [%s], skip...", single_msg);
2058 remained_length = 0;
2060 strncpy(single_msg, recv_msg + prev_pos, single_length);
2061 single_msg[single_length] = '\0';
2064 if (single_msg[0] == '{') {
2066 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2067 /* process each message */
2068 __camera_process_msg(cb_info, single_msg);
2070 LOGE("invalid msg [%s]", single_msg);
2073 LOGE("too long message [len %d] skip...", single_length);
2076 prev_pos = cur_pos + 1;
2080 /* check incompleted message */
2081 if (recv_msg[recv_length - 1] != '}') {
2082 remained_length = recv_length - prev_pos;
2084 LOGW("incompleted message [len %d]", remained_length);
2086 remained_msg = (char *)malloc(remained_length + 1);
2088 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2089 remained_msg[remained_length] = '\0';
2091 LOGE("failed to alloc for remained msg");
2094 remained_length = 0;
2098 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2100 if (!cb_info->is_server_connected) {
2101 /* send error msg for server disconnection */
2102 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2103 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2104 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2108 LOGE("error_msg failed");
2109 goto CB_HANDLER_EXIT;
2112 __camera_add_msg_to_queue(cb_info,
2113 MUSE_CAMERA_CB_EVENT,
2114 MUSE_CAMERA_EVENT_TYPE_ERROR,
2115 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2118 muse_core_msg_free(error_msg);
2121 LOGE("add error msg for service disconnection done");
2132 remained_msg = NULL;
2139 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2140 int type, const char *thread_name, camera_cb_info_s *cb_info)
2142 if (!handler_info || !thread_name || !cb_info) {
2143 LOGE("t:%d NULL %p %p %p",
2144 type, handler_info, thread_name, cb_info);
2150 handler_info->type = type;
2151 handler_info->queue = g_queue_new();
2152 if (handler_info->queue == NULL) {
2153 LOGE("t:%d queue failed", type);
2157 g_mutex_init(&handler_info->mutex);
2158 g_cond_init(&handler_info->cond);
2160 handler_info->cb_info = (void *)cb_info;
2161 g_atomic_int_set(&handler_info->running, 1);
2163 handler_info->thread = g_thread_try_new(thread_name,
2164 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2165 if (handler_info->thread == NULL) {
2166 LOGE("t:%d thread failed", type);
2168 g_mutex_clear(&handler_info->mutex);
2169 g_cond_clear(&handler_info->cond);
2170 g_queue_free(handler_info->queue);
2171 handler_info->queue = NULL;
2176 LOGD("t:%d done", type);
2182 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2186 if (!handler_info) {
2187 LOGE("NULL handler");
2191 if (!handler_info->thread) {
2192 LOGW("thread is not created");
2196 type = handler_info->type;
2198 LOGD("t:%d thread %p", type, handler_info->thread);
2200 g_mutex_lock(&handler_info->mutex);
2201 g_atomic_int_set(&handler_info->running, 0);
2202 g_cond_signal(&handler_info->cond);
2203 g_mutex_unlock(&handler_info->mutex);
2205 g_thread_join(handler_info->thread);
2206 handler_info->thread = NULL;
2208 g_mutex_clear(&handler_info->mutex);
2209 g_cond_clear(&handler_info->cond);
2210 g_queue_free(handler_info->queue);
2211 handler_info->queue = NULL;
2213 LOGD("t:%d done", type);
2219 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2221 camera_cb_info_s *cb_info = NULL;
2224 g_return_val_if_fail(sockfd > 0, NULL);
2226 cb_info = g_new0(camera_cb_info_s, 1);
2227 if (cb_info == NULL) {
2228 LOGE("cb_info failed");
2232 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2234 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2235 g_mutex_init(&cb_info->api_mutex[i]);
2236 g_cond_init(&cb_info->api_cond[i]);
2239 g_mutex_init(&cb_info->fd_lock);
2240 g_mutex_init(&cb_info->idle_event_mutex);
2241 g_cond_init(&cb_info->idle_event_cond);
2242 g_mutex_init(&cb_info->mp_data_mutex);
2243 g_mutex_init(&cb_info->preview_cb_mutex);
2244 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2245 g_mutex_init(&cb_info->evas_mutex);
2246 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2248 /* message handler thread */
2249 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2250 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2251 LOGE("msg_handler_info failed");
2255 /* message handler thread for preview callback */
2256 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2257 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2258 LOGE("preview_cb_info failed");
2262 /* message handler thread for capture callback */
2263 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2264 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2265 LOGE("capture_cb_info failed");
2269 cb_info->fd = sockfd;
2270 cb_info->preview_cb_flag = 0;
2271 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2272 cb_info->evas_info = NULL;
2273 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2275 /* message receive thread */
2276 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2277 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2278 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2279 if (cb_info->msg_recv_thread == NULL) {
2280 LOGE("message receive thread creation failed");
2284 cb_info->is_server_connected = TRUE;
2290 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2291 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2292 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2294 g_mutex_clear(&cb_info->fd_lock);
2295 g_mutex_clear(&cb_info->idle_event_mutex);
2296 g_cond_clear(&cb_info->idle_event_cond);
2297 g_mutex_clear(&cb_info->mp_data_mutex);
2298 g_mutex_clear(&cb_info->preview_cb_mutex);
2299 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2300 g_mutex_clear(&cb_info->evas_mutex);
2301 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2303 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2304 g_mutex_clear(&cb_info->api_mutex[i]);
2305 g_cond_clear(&cb_info->api_cond[i]);
2315 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2319 g_return_if_fail(cb_info != NULL);
2321 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2323 g_thread_join(cb_info->msg_recv_thread);
2324 cb_info->msg_recv_thread = NULL;
2326 LOGD("msg_recv thread removed");
2328 /* destroy msg handler threads */
2329 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2330 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2331 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2333 g_mutex_clear(&cb_info->fd_lock);
2334 g_mutex_clear(&cb_info->idle_event_mutex);
2335 g_cond_clear(&cb_info->idle_event_cond);
2336 g_mutex_clear(&cb_info->mp_data_mutex);
2337 g_mutex_clear(&cb_info->preview_cb_mutex);
2338 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2339 g_mutex_clear(&cb_info->evas_mutex);
2340 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2342 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2343 g_mutex_clear(&cb_info->api_mutex[i]);
2344 g_cond_clear(&cb_info->api_cond[i]);
2347 if (cb_info->fd > -1) {
2348 muse_client_close(cb_info->fd);
2352 if (cb_info->bufmgr) {
2353 tbm_bufmgr_deinit(cb_info->bufmgr);
2354 cb_info->bufmgr = NULL;
2356 if (cb_info->pkt_fmt) {
2357 media_format_unref(cb_info->pkt_fmt);
2358 cb_info->pkt_fmt = NULL;
2361 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2362 if (cb_info->evas_info)
2363 mm_evas_renderer_destroy(&cb_info->evas_info);
2364 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2366 cb_info->preview_cb_flag = 0;
2375 int _camera_start_evas_rendering(camera_h camera)
2377 int ret = CAMERA_ERROR_NONE;
2378 camera_cli_s *pc = (camera_cli_s *)camera;
2380 if (!pc || !pc->cb_info) {
2381 LOGE("NULL handle");
2382 return CAMERA_ERROR_INVALID_PARAMETER;
2387 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2388 LOGE("EVAS surface is not set");
2389 return CAMERA_ERROR_NONE;
2392 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2393 g_mutex_lock(&pc->cb_info->evas_mutex);
2395 /* set evas render flag as RUN */
2396 pc->cb_info->run_evas_render = true;
2397 ret = CAMERA_ERROR_NONE;
2399 g_mutex_unlock(&pc->cb_info->evas_mutex);
2400 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2401 LOGW("evas renderer is not supported");
2402 ret = CAMERA_ERROR_NOT_SUPPORTED;
2403 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2409 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2411 int ret = CAMERA_ERROR_NONE;
2412 camera_cli_s *pc = (camera_cli_s *)camera;
2414 if (!pc || !pc->cb_info) {
2415 LOGE("NULL handle");
2416 return CAMERA_ERROR_INVALID_PARAMETER;
2419 LOGD("stop - keep screen %d", keep_screen);
2421 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2422 LOGE("EVAS surface is not set");
2423 return CAMERA_ERROR_NONE;
2426 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2427 g_mutex_lock(&pc->cb_info->evas_mutex);
2429 /* set evas render flag as STOP and release buffers */
2430 pc->cb_info->run_evas_render = false;
2432 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2433 if (ret != MM_ERROR_NONE) {
2434 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2435 ret = CAMERA_ERROR_INVALID_OPERATION;
2438 g_mutex_unlock(&pc->cb_info->evas_mutex);
2439 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2440 LOGW("evas renderer is not supported");
2441 ret = CAMERA_ERROR_NOT_SUPPORTED;
2442 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2448 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2450 int ret = CAMERA_ERROR_NONE;
2453 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2455 /* create muse connection */
2456 if (!key || !value) {
2457 LOGE("NULL pointer");
2458 return CAMERA_ERROR_INVALID_PARAMETER;
2461 sock_fd = muse_client_new();
2463 LOGE("muse_client_new failed");
2464 return CAMERA_ERROR_INVALID_OPERATION;
2467 msg = muse_core_msg_new(api,
2468 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2469 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2473 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2477 ret = muse_core_msg_send(sock_fd, msg);
2479 muse_core_msg_free(msg);
2483 LOGE("send msg failed");
2484 ret = CAMERA_ERROR_INVALID_OPERATION;
2488 ret = muse_core_msg_recv(sock_fd, recv_msg);
2490 LOGE("recv msg failed %d", errno);
2491 ret = CAMERA_ERROR_INVALID_OPERATION;
2495 if (!muse_camera_msg_get(ret, recv_msg)) {
2496 LOGE("failed to get return value from msg [%s]", recv_msg);
2497 ret = CAMERA_ERROR_INVALID_OPERATION;
2501 if (ret == CAMERA_ERROR_NONE)
2502 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2504 LOGD("api %d - value %d", api, *value);
2508 muse_client_close(sock_fd);
2516 int camera_create(camera_device_e device, camera_h *camera)
2519 char *send_msg = NULL;
2521 int ret = CAMERA_ERROR_NONE;
2523 camera_cli_s *pc = NULL;
2524 tbm_bufmgr bufmgr = NULL;
2526 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2527 muse_core_api_module_e muse_module = MUSE_CAMERA;
2528 int device_type = (int)device;
2531 LOGE("NULL pointer");
2532 return CAMERA_ERROR_INVALID_PARAMETER;
2535 sock_fd = muse_client_new();
2537 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2538 ret = CAMERA_ERROR_INVALID_OPERATION;
2544 send_msg = muse_core_msg_new(api,
2545 MUSE_TYPE_INT, "module", muse_module,
2546 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2547 MUSE_TYPE_INT, "pid", pid,
2552 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2556 send_ret = muse_core_msg_send(sock_fd, send_msg);
2558 muse_core_msg_free(send_msg);
2562 LOGE("send msg failed %d", errno);
2563 ret = CAMERA_ERROR_INVALID_OPERATION;
2567 pc = g_new0(camera_cli_s, 1);
2569 LOGE("camera_cli_s alloc failed");
2570 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2574 bufmgr = tbm_bufmgr_init(-1);
2575 if (bufmgr == NULL) {
2576 LOGE("get tbm bufmgr failed");
2577 ret = CAMERA_ERROR_INVALID_OPERATION;
2581 pc->cb_info = _camera_client_callback_new(sock_fd);
2582 if (pc->cb_info == NULL) {
2583 LOGE("cb_info alloc failed");
2584 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2590 LOGD("cb info : %d", pc->cb_info->fd);
2592 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2594 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2596 if (ret == CAMERA_ERROR_NONE) {
2597 intptr_t handle = 0;
2598 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2600 LOGE("Receiving Handle Failed!!");
2601 ret = CAMERA_ERROR_INVALID_OPERATION;
2605 pc->remote_handle = handle;
2606 pc->cb_info->bufmgr = bufmgr;
2608 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2609 if (ret != CAMERA_ERROR_NONE) {
2610 LOGE("init display failed 0x%x", ret);
2614 LOGD("camera create 0x%x", pc->remote_handle);
2615 *camera = (camera_h)pc;
2624 tbm_bufmgr_deinit(bufmgr);
2629 muse_client_close(sock_fd);
2635 _camera_client_callback_destroy(pc->cb_info);
2642 LOGE("camera create error : 0x%x", ret);
2648 int camera_change_device(camera_h camera, camera_device_e device)
2651 int ret = CAMERA_ERROR_NONE;
2652 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2653 camera_cli_s *pc = (camera_cli_s *)camera;
2654 camera_msg_param param;
2656 if (!pc || !pc->cb_info) {
2657 LOGE("NULL handle");
2658 return CAMERA_ERROR_INVALID_PARAMETER;
2661 CAMERA_MSG_PARAM_SET(param, INT, device);
2663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2665 if (ret == CAMERA_ERROR_NONE) {
2666 /* reset callback and user data */
2667 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2668 pc->cb_info->user_cb[i] = NULL;
2669 pc->cb_info->user_data[i] = NULL;
2671 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2678 int camera_destroy(camera_h camera)
2680 int ret = CAMERA_ERROR_NONE;
2681 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2682 camera_cli_s *pc = (camera_cli_s *)camera;
2684 if (!pc || !pc->cb_info) {
2685 LOGE("NULL handle");
2686 return CAMERA_ERROR_INVALID_PARAMETER;
2691 if (pc->cb_info->is_server_connected)
2692 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2694 LOGW("server disconnected. release resource without send message.");
2696 if (ret == CAMERA_ERROR_NONE) {
2697 _camera_deactivate_idle_event_all(pc->cb_info);
2698 _camera_client_callback_destroy(pc->cb_info);
2708 int camera_start_preview(camera_h camera)
2710 int ret = CAMERA_ERROR_NONE;
2711 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2712 camera_cli_s *pc = (camera_cli_s *)camera;
2714 if (!pc || !pc->cb_info) {
2715 LOGE("NULL handle");
2716 return CAMERA_ERROR_INVALID_PARAMETER;
2721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2722 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2723 ret = _camera_start_evas_rendering(camera);
2724 if (ret != CAMERA_ERROR_NONE) {
2725 LOGE("stop preview because of error");
2726 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2730 LOGD("ret : 0x%x", ret);
2736 int camera_stop_preview(camera_h camera)
2738 int ret = CAMERA_ERROR_NONE;
2739 camera_cli_s *pc = (camera_cli_s *)camera;
2740 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2741 camera_state_e current_state = CAMERA_STATE_NONE;
2743 if (!pc || !pc->cb_info) {
2744 LOGE("NULL handle");
2745 return CAMERA_ERROR_INVALID_PARAMETER;
2750 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2751 ret = camera_get_state(camera, ¤t_state);
2752 if (ret != CAMERA_ERROR_NONE) {
2753 LOGE("failed to get current state 0x%x", ret);
2757 if (current_state == CAMERA_STATE_PREVIEW) {
2758 ret = _camera_stop_evas_rendering(camera, false);
2759 if (ret != CAMERA_ERROR_NONE)
2764 /* send stop preview message */
2765 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2767 if (ret != CAMERA_ERROR_NONE &&
2768 current_state == CAMERA_STATE_PREVIEW) {
2769 LOGW("restart evas rendering");
2770 _camera_start_evas_rendering(camera);
2773 LOGD("ret : 0x%x", ret);
2779 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2781 int ret = CAMERA_ERROR_NONE;
2782 camera_cli_s *pc = (camera_cli_s *)camera;
2783 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2785 if (!pc || !pc->cb_info) {
2786 LOGE("NULL handle");
2787 return CAMERA_ERROR_INVALID_PARAMETER;
2792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2795 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2796 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2798 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2800 LOGD("ret : 0x%x", ret);
2806 bool camera_is_supported_continuous_capture(camera_h camera)
2808 int ret = CAMERA_ERROR_NONE;
2809 camera_cli_s *pc = (camera_cli_s *)camera;
2810 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2812 if (!pc || !pc->cb_info) {
2813 LOGE("NULL handle");
2814 return CAMERA_ERROR_INVALID_PARAMETER;
2819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2822 LOGE("error is occurred 0x%x", ret);
2826 LOGD("ret : %d", ret);
2832 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)
2834 int ret = CAMERA_ERROR_NONE;
2835 camera_cli_s *pc = (camera_cli_s *)camera;
2836 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2837 camera_msg_param param;
2840 if (!pc || !pc->cb_info) {
2841 LOGE("NULL handle");
2842 return CAMERA_ERROR_INVALID_PARAMETER;
2847 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2848 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2850 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2851 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2853 value = (count << 16) | interval;
2854 CAMERA_MSG_PARAM_SET(param, INT, value);
2856 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2858 LOGD("ret : 0x%x", ret);
2864 int camera_stop_continuous_capture(camera_h camera)
2866 int ret = CAMERA_ERROR_NONE;
2867 camera_cli_s *pc = (camera_cli_s *)camera;
2868 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2870 if (!pc || !pc->cb_info) {
2871 LOGE("NULL handle");
2872 return CAMERA_ERROR_INVALID_PARAMETER;
2877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2879 LOGD("ret : 0x%x", ret);
2885 bool camera_is_supported_face_detection(camera_h camera)
2887 int ret = CAMERA_ERROR_NONE;
2888 camera_cli_s *pc = (camera_cli_s *)camera;
2889 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2891 if (!pc || !pc->cb_info) {
2892 LOGE("NULL handle");
2893 return CAMERA_ERROR_INVALID_PARAMETER;
2898 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2901 LOGE("error is occurred 0x%x", ret);
2905 LOGD("ret : %d", ret);
2911 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2913 int ret = CAMERA_ERROR_NONE;
2914 camera_cli_s *pc = (camera_cli_s *)camera;
2915 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2917 if (!pc || !pc->cb_info) {
2918 LOGE("NULL handle");
2919 return CAMERA_ERROR_INVALID_PARAMETER;
2924 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2927 LOGE("error is occurred 0x%x", ret);
2931 LOGD("ret : %d", ret);
2937 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2939 int ret = CAMERA_ERROR_NONE;
2940 camera_cli_s *pc = (camera_cli_s *)camera;
2941 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2943 if (!pc || !pc->cb_info) {
2944 LOGE("NULL handle");
2945 return CAMERA_ERROR_INVALID_PARAMETER;
2950 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2953 LOGE("error is occurred 0x%x", ret);
2957 LOGD("ret : %d", ret);
2962 int camera_get_device_count(camera_h camera, int *device_count)
2964 int ret = CAMERA_ERROR_NONE;
2965 camera_cli_s *pc = (camera_cli_s *)camera;
2966 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2968 if (!pc || !pc->cb_info) {
2969 LOGE("NULL handle");
2970 return CAMERA_ERROR_INVALID_PARAMETER;
2975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2977 if (ret == CAMERA_ERROR_NONE)
2978 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2980 LOGD("ret : 0x%x", ret);
2985 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2987 int ret = CAMERA_ERROR_NONE;
2988 camera_cli_s *pc = (camera_cli_s *)camera;
2989 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2991 if (!pc || !pc->cb_info) {
2992 LOGE("NULL handle");
2993 return CAMERA_ERROR_INVALID_PARAMETER;
2998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3001 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3003 LOGD("ret : 0x%x", ret);
3008 int camera_stop_face_detection(camera_h camera)
3010 int ret = CAMERA_ERROR_NONE;
3011 camera_cli_s *pc = (camera_cli_s *)camera;
3012 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3014 if (!pc || !pc->cb_info) {
3015 LOGE("NULL handle");
3016 return CAMERA_ERROR_INVALID_PARAMETER;
3021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3023 LOGD("ret : 0x%x", ret);
3028 int camera_get_state(camera_h camera, camera_state_e *state)
3030 int ret = CAMERA_ERROR_NONE;
3031 camera_cli_s *pc = (camera_cli_s *)camera;
3032 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3034 if (!pc || !pc->cb_info || !state) {
3035 LOGE("NULL pointer %p %p", pc, state);
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 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3046 LOGD("ret : 0x%x", ret);
3051 int camera_start_focusing(camera_h camera, bool continuous)
3053 int ret = CAMERA_ERROR_NONE;
3054 camera_cli_s *pc = (camera_cli_s *)camera;
3055 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3056 camera_msg_param param;
3057 int is_continuous = (int)continuous;
3059 if (!pc || !pc->cb_info) {
3060 LOGE("NULL handle");
3061 return CAMERA_ERROR_INVALID_PARAMETER;
3066 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3068 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3070 LOGD("ret : 0x%x", ret);
3075 int camera_cancel_focusing(camera_h camera)
3077 int ret = CAMERA_ERROR_NONE;
3078 camera_cli_s *pc = (camera_cli_s *)camera;
3079 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3081 if (!pc || !pc->cb_info) {
3082 LOGE("NULL handle");
3083 return CAMERA_ERROR_INVALID_PARAMETER;
3086 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3088 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3090 LOGD("ret : 0x%x", ret);
3095 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3097 int ret = CAMERA_ERROR_NONE;
3098 void *set_display_handle = NULL;
3099 Evas_Object *obj = NULL;
3100 const char *object_type = NULL;
3101 camera_cli_s *pc = (camera_cli_s *)camera;
3102 camera_cb_info_s *cb_info = NULL;
3103 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3104 camera_state_e current_state = CAMERA_STATE_NONE;
3105 camera_msg_param param;
3109 if (!pc || !pc->cb_info) {
3110 LOGE("NULL handle");
3111 return CAMERA_ERROR_INVALID_PARAMETER;
3114 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3115 LOGE("invalid type %d", type);
3116 return CAMERA_ERROR_INVALID_PARAMETER;
3119 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3120 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3121 return CAMERA_ERROR_INVALID_PARAMETER;
3124 cb_info = (camera_cb_info_s *)pc->cb_info;
3126 ret = camera_get_state(camera, ¤t_state);
3127 if (ret != CAMERA_ERROR_NONE) {
3128 LOGE("failed to get current state 0x%x", ret);
3132 if (current_state != CAMERA_STATE_CREATED) {
3133 LOGE("INVALID_STATE : current %d", current_state);
3134 return CAMERA_ERROR_INVALID_STATE;
3137 LOGD("Enter - display : %p", display);
3139 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3140 set_display_handle = 0;
3141 LOGD("display type NONE");
3143 obj = (Evas_Object *)display;
3144 object_type = evas_object_type_get(obj);
3146 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3147 /* get wayland parent id */
3148 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3149 LOGE("failed to get wayland info");
3150 return CAMERA_ERROR_INVALID_OPERATION;
3153 set_display_handle = (void *)&pc->wl_info;
3154 LOGD("display type OVERLAY : handle %p", set_display_handle);
3155 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3156 /* evas object surface */
3157 set_display_handle = (void *)display;
3158 LOGD("display type EVAS : handle %p", set_display_handle);
3160 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3161 g_mutex_lock(&cb_info->evas_mutex);
3163 if (cb_info->evas_info) {
3164 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3165 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3166 if (ret != MM_ERROR_NONE) {
3167 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3168 g_mutex_unlock(&cb_info->evas_mutex);
3169 return CAMERA_ERROR_INVALID_OPERATION;
3173 /* create evas renderer */
3174 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3175 if (ret == MM_ERROR_NONE) {
3176 camera_flip_e flip = CAMERA_FLIP_NONE;
3177 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3178 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3185 camera_get_display_flip(camera, &flip);
3186 camera_get_display_mode(camera, &mode);
3187 camera_get_display_rotation(camera, &rotation);
3188 camera_is_display_visible(camera, &visible);
3189 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3191 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3192 flip, mode, rotation, visible, x, y, width, height);
3194 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3195 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3196 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3197 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3199 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3200 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3203 g_mutex_unlock(&cb_info->evas_mutex);
3205 if (ret != MM_ERROR_NONE) {
3206 LOGE("mm_evas_renderer error 0x%x", ret);
3207 return CAMERA_ERROR_INVALID_OPERATION;
3209 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3210 LOGE("EVAS surface is not supported");
3211 return CAMERA_ERROR_NOT_SUPPORTED;
3212 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3214 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3215 return CAMERA_ERROR_INVALID_PARAMETER;
3218 LOGE("failed to get evas object type from %p", obj);
3219 return CAMERA_ERROR_INVALID_PARAMETER;
3223 pc->display_handle = (intptr_t)set_display_handle;
3225 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3228 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3229 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3231 msg = muse_core_msg_new(api,
3232 MUSE_TYPE_INT, "type", type,
3233 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3236 LOGE("msg creation failed: api %d", api);
3237 return CAMERA_ERROR_OUT_OF_MEMORY;
3240 if (pc->cb_info->is_server_connected) {
3241 __camera_update_api_waiting(pc->cb_info, api, 1);
3243 g_mutex_lock(&pc->cb_info->fd_lock);
3244 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3245 g_mutex_unlock(&pc->cb_info->fd_lock);
3249 LOGE("message send failed");
3250 ret = CAMERA_ERROR_INVALID_OPERATION;
3252 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3255 __camera_update_api_waiting(pc->cb_info, api, -1);
3257 muse_core_msg_free(msg);
3259 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3260 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3261 pc->wl_info.window_width, pc->wl_info.window_height);
3263 CAMERA_MSG_PARAM_SET(param, INT, type);
3265 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3268 if (ret != CAMERA_ERROR_NONE)
3269 LOGE("set display error 0x%x", ret);
3270 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3271 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3277 int camera_set_preview_resolution(camera_h camera, int width, int height)
3279 int ret = CAMERA_ERROR_NONE;
3280 camera_state_e current_state = CAMERA_STATE_NONE;
3281 camera_cli_s *pc = (camera_cli_s *)camera;
3282 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3283 camera_msg_param param;
3286 if (!pc || !pc->cb_info) {
3287 LOGE("NULL handle");
3288 return CAMERA_ERROR_INVALID_PARAMETER;
3291 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3292 ret = camera_get_state(camera, ¤t_state);
3293 if (ret != CAMERA_ERROR_NONE) {
3294 LOGE("failed to get current state 0x%x", ret);
3298 if (current_state == CAMERA_STATE_PREVIEW) {
3299 ret = _camera_stop_evas_rendering(camera, true);
3300 if (ret != CAMERA_ERROR_NONE)
3305 value = (width << 16) | height;
3306 CAMERA_MSG_PARAM_SET(param, INT, value);
3308 LOGD("%dx%d -> 0x%x", width, height, value);
3310 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3312 LOGD("ret : 0x%x", ret);
3314 if (current_state == CAMERA_STATE_PREVIEW) {
3315 LOGW("restart evas rendering");
3316 _camera_start_evas_rendering(camera);
3323 int camera_set_capture_resolution(camera_h camera, int width, int height)
3325 int ret = CAMERA_ERROR_NONE;
3326 camera_cli_s *pc = (camera_cli_s *)camera;
3327 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3328 camera_msg_param param;
3331 if (!pc || !pc->cb_info) {
3332 LOGE("NULL handle");
3333 return CAMERA_ERROR_INVALID_PARAMETER;
3338 value = (width << 16) | height;
3339 CAMERA_MSG_PARAM_SET(param, INT, value);
3341 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3343 LOGD("ret : 0x%x", ret);
3349 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3351 int ret = CAMERA_ERROR_NONE;
3352 int set_format = (int)format;
3353 camera_cli_s *pc = (camera_cli_s *)camera;
3354 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3355 camera_msg_param param;
3357 if (!pc || !pc->cb_info) {
3358 LOGE("NULL handle");
3359 return CAMERA_ERROR_INVALID_PARAMETER;
3362 LOGD("Enter - format %d", set_format);
3364 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3366 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3368 LOGD("ret : 0x%x", ret);
3374 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3376 int ret = CAMERA_ERROR_NONE;
3377 int set_format = (int)format;
3378 camera_msg_param param;
3379 camera_cli_s *pc = (camera_cli_s *)camera;
3380 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3382 if (!pc || !pc->cb_info) {
3383 LOGE("NULL handle");
3384 return CAMERA_ERROR_INVALID_PARAMETER;
3387 LOGD("Enter - capture_format %d", set_format);
3389 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3391 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3393 LOGD("ret : 0x%x", ret);
3399 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3401 int ret = CAMERA_ERROR_NONE;
3402 camera_cli_s *pc = (camera_cli_s *)camera;
3403 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3405 if (!pc || !pc->cb_info || !width || !height) {
3406 LOGE("NULL pointer %p %p %p", pc, width, height);
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3412 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3414 if (ret == CAMERA_ERROR_NONE) {
3415 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3416 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3419 LOGD("ret : 0x%x", ret);
3425 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3427 int ret = CAMERA_ERROR_NONE;
3428 int set_rotation = (int)rotation;
3429 camera_cli_s *pc = (camera_cli_s *)camera;
3430 camera_msg_param param;
3432 if (!pc || !pc->cb_info) {
3433 LOGE("NULL handle");
3434 return CAMERA_ERROR_INVALID_PARAMETER;
3437 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3438 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3439 g_mutex_lock(&pc->cb_info->evas_mutex);
3441 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3443 g_mutex_unlock(&pc->cb_info->evas_mutex);
3445 if (ret != MM_ERROR_NONE) {
3446 LOGE("failed to set rotation for evas surface 0x%x", ret);
3447 return CAMERA_ERROR_INVALID_OPERATION;
3450 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3452 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3454 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3460 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3462 int ret = CAMERA_ERROR_NONE;
3463 camera_cli_s *pc = (camera_cli_s *)camera;
3465 if (!pc || !pc->cb_info || !rotation) {
3466 LOGE("NULL pointer %p %p", pc, rotation);
3467 return CAMERA_ERROR_INVALID_PARAMETER;
3470 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3472 if (ret == CAMERA_ERROR_NONE)
3473 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3479 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3481 int ret = CAMERA_ERROR_NONE;
3482 int set_flip = (int)flip;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3484 camera_msg_param param;
3486 if (!pc || !pc->cb_info) {
3487 LOGE("NULL handle");
3488 return CAMERA_ERROR_INVALID_PARAMETER;
3491 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3492 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3493 g_mutex_lock(&pc->cb_info->evas_mutex);
3495 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3497 g_mutex_unlock(&pc->cb_info->evas_mutex);
3499 if (ret != MM_ERROR_NONE) {
3500 LOGE("failed to set flip for evas surface 0x%x", ret);
3501 return CAMERA_ERROR_INVALID_OPERATION;
3504 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3506 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3508 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3514 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3516 int ret = CAMERA_ERROR_NONE;
3517 camera_cli_s *pc = (camera_cli_s *)camera;
3519 if (!pc || !pc->cb_info || !flip) {
3520 LOGE("NULL pointer %p %p", pc, flip);
3521 return CAMERA_ERROR_INVALID_PARAMETER;
3524 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3526 if (ret == CAMERA_ERROR_NONE)
3527 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3533 int camera_set_display_visible(camera_h camera, bool visible)
3535 int ret = CAMERA_ERROR_NONE;
3536 int set_visible = (int)visible;
3537 camera_cli_s *pc = (camera_cli_s *)camera;
3538 camera_msg_param param;
3540 if (!pc || !pc->cb_info) {
3541 LOGE("NULL handle");
3542 return CAMERA_ERROR_INVALID_PARAMETER;
3545 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3546 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3547 g_mutex_lock(&pc->cb_info->evas_mutex);
3549 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3551 g_mutex_unlock(&pc->cb_info->evas_mutex);
3553 if (ret != MM_ERROR_NONE) {
3554 LOGE("failed to set visible for evas surface 0x%x", ret);
3555 return CAMERA_ERROR_INVALID_OPERATION;
3558 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3560 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3562 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3568 int camera_is_display_visible(camera_h camera, bool *visible)
3570 int ret = CAMERA_ERROR_NONE;
3571 camera_cli_s *pc = (camera_cli_s *)camera;
3573 if (!pc || !pc->cb_info || !visible) {
3574 LOGE("NULL pointer %p %p", pc, visible);
3575 return CAMERA_ERROR_INVALID_PARAMETER;
3578 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3580 if (ret == CAMERA_ERROR_NONE)
3581 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3587 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3589 int ret = CAMERA_ERROR_NONE;
3590 int set_mode = (int)mode;
3591 camera_cli_s *pc = (camera_cli_s *)camera;
3592 camera_msg_param param;
3594 if (!pc || !pc->cb_info) {
3595 LOGE("NULL handle");
3596 return CAMERA_ERROR_INVALID_PARAMETER;
3599 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3600 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3601 g_mutex_lock(&pc->cb_info->evas_mutex);
3603 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3605 g_mutex_unlock(&pc->cb_info->evas_mutex);
3607 if (ret != MM_ERROR_NONE) {
3608 LOGE("failed to set geometry for evas surface 0x%x", ret);
3609 return CAMERA_ERROR_INVALID_OPERATION;
3612 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3614 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3616 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3622 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3624 int ret = CAMERA_ERROR_NONE;
3625 camera_cli_s *pc = (camera_cli_s *)camera;
3627 if (!pc || !pc->cb_info || !mode) {
3628 LOGE("NULL pointer %p %p", pc, mode);
3629 return CAMERA_ERROR_INVALID_PARAMETER;
3632 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3634 if (ret == CAMERA_ERROR_NONE)
3635 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3641 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3643 int ret = CAMERA_ERROR_NONE;
3644 int set_hint = (int)hint;
3645 camera_cli_s *pc = (camera_cli_s *)camera;
3646 camera_msg_param param;
3648 if (!pc || !pc->cb_info) {
3649 LOGE("NULL handle");
3650 return CAMERA_ERROR_INVALID_PARAMETER;
3653 LOGD("Enter - hint %d", set_hint);
3655 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3657 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3663 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3665 int ret = CAMERA_ERROR_NONE;
3666 camera_cli_s *pc = (camera_cli_s *)camera;
3667 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3669 if (!pc || !pc->cb_info || !hint) {
3670 LOGE("NULL pointer %p %p", pc, hint);
3671 return CAMERA_ERROR_INVALID_PARAMETER;
3674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3676 if (ret == CAMERA_ERROR_NONE) {
3677 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3678 LOGD("display reuse hint %d", *hint);
3685 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3687 int ret = CAMERA_ERROR_NONE;
3688 camera_cli_s *pc = (camera_cli_s *)camera;
3689 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3691 if (!pc || !pc->cb_info || !width || !height) {
3692 LOGE("NULL pointer %p %p %p", pc, width, height);
3693 return CAMERA_ERROR_INVALID_PARAMETER;
3698 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3700 if (ret == CAMERA_ERROR_NONE) {
3701 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3702 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3705 LOGD("ret : 0x%x", ret);
3711 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3713 int ret = CAMERA_ERROR_NONE;
3714 camera_cli_s *pc = (camera_cli_s *)camera;
3715 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3717 if (!pc || !pc->cb_info || !format) {
3718 LOGE("NULL pointer %p %p", pc, format);
3719 return CAMERA_ERROR_INVALID_PARAMETER;
3724 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3726 if (ret == CAMERA_ERROR_NONE)
3727 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3729 LOGD("ret : 0x%x", ret);
3735 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3737 int ret = CAMERA_ERROR_NONE;
3738 camera_cli_s *pc = (camera_cli_s *)camera;
3739 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3741 if (!pc || !pc->cb_info || !format) {
3742 LOGE("NULL pointer %p %p", pc, format);
3743 return CAMERA_ERROR_INVALID_PARAMETER;
3748 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3750 if (ret == CAMERA_ERROR_NONE)
3751 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3753 LOGD("ret : 0x%x", ret);
3759 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3761 int ret = CAMERA_ERROR_NONE;
3762 camera_cli_s *pc = (camera_cli_s *)camera;
3763 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3765 if (!pc || !pc->cb_info || !facing_direction) {
3766 LOGE("NULL pointer %p %p", pc, facing_direction);
3767 return CAMERA_ERROR_INVALID_PARAMETER;
3772 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3774 if (ret == CAMERA_ERROR_NONE)
3775 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3777 LOGD("ret : 0x%x", ret);
3783 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3785 int ret = CAMERA_ERROR_NONE;
3786 camera_cli_s *pc = (camera_cli_s *)camera;
3787 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3789 if (!pc || !pc->cb_info || !callback) {
3790 LOGE("NULL pointer %p %p", pc, callback);
3791 return CAMERA_ERROR_INVALID_PARAMETER;
3796 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3798 if (ret == CAMERA_ERROR_NONE) {
3799 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3801 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3802 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3804 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3806 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3809 LOGD("ret : 0x%x", ret);
3815 int camera_unset_preview_cb(camera_h camera)
3817 int ret = CAMERA_ERROR_NONE;
3818 camera_cli_s *pc = (camera_cli_s *)camera;
3819 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3821 if (!pc || !pc->cb_info) {
3822 LOGE("NULL handle");
3823 return CAMERA_ERROR_INVALID_PARAMETER;
3828 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3830 if (ret == CAMERA_ERROR_NONE) {
3831 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3833 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3834 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3836 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3838 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3841 LOGD("ret : 0x%x", ret);
3847 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3849 int ret = CAMERA_ERROR_NONE;
3850 camera_cli_s *pc = (camera_cli_s *)camera;
3851 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3853 if (!pc || !pc->cb_info) {
3854 LOGE("NULL handle");
3855 return CAMERA_ERROR_INVALID_PARAMETER;
3858 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3859 LOGE("NOT SUPPORTED");
3860 return CAMERA_ERROR_NOT_SUPPORTED;
3863 if (callback == NULL) {
3864 LOGE("NULL callback");
3865 return CAMERA_ERROR_INVALID_PARAMETER;
3870 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3872 if (ret == CAMERA_ERROR_NONE) {
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3877 LOGD("ret : 0x%x", ret);
3883 int camera_unset_media_packet_preview_cb(camera_h camera)
3885 int ret = CAMERA_ERROR_NONE;
3886 camera_cli_s *pc = (camera_cli_s *)camera;
3887 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3889 if (!pc || !pc->cb_info) {
3890 LOGE("NULL handle");
3891 return CAMERA_ERROR_INVALID_PARAMETER;
3896 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3898 if (ret == CAMERA_ERROR_NONE) {
3899 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3900 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3903 LOGD("ret : 0x%x", ret);
3909 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3911 int ret = CAMERA_ERROR_NONE;
3912 camera_cli_s *pc = (camera_cli_s *)camera;
3913 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3915 if (!pc || !pc->cb_info || !callback) {
3916 LOGE("NULL pointer %p %p", pc, callback);
3917 return CAMERA_ERROR_INVALID_PARAMETER;
3922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3924 if (ret == CAMERA_ERROR_NONE) {
3925 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3926 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3929 LOGD("ret : 0x%x", ret);
3935 int camera_unset_state_changed_cb(camera_h camera)
3937 int ret = CAMERA_ERROR_NONE;
3938 camera_cli_s *pc = (camera_cli_s *)camera;
3939 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3941 if (!pc || !pc->cb_info) {
3942 LOGE("NULL handle");
3943 return CAMERA_ERROR_INVALID_PARAMETER;
3948 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3950 if (ret == CAMERA_ERROR_NONE) {
3951 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3952 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3955 LOGD("ret : 0x%x", ret);
3961 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3963 int ret = CAMERA_ERROR_NONE;
3964 camera_cli_s *pc = (camera_cli_s *)camera;
3965 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3967 if (!pc || !pc->cb_info || !callback) {
3968 LOGE("NULL pointer %p %p", pc, callback);
3969 return CAMERA_ERROR_INVALID_PARAMETER;
3974 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3976 if (ret == CAMERA_ERROR_NONE) {
3977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3981 LOGD("ret : 0x%x", ret);
3987 int camera_unset_interrupted_cb(camera_h camera)
3989 int ret = CAMERA_ERROR_NONE;
3990 camera_cli_s *pc = (camera_cli_s *)camera;
3991 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3993 if (!pc || !pc->cb_info) {
3994 LOGE("NULL handle");
3995 return CAMERA_ERROR_INVALID_PARAMETER;
4000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4002 if (ret == CAMERA_ERROR_NONE) {
4003 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4004 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4007 LOGD("ret : 0x%x", ret);
4013 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4015 int ret = CAMERA_ERROR_NONE;
4016 camera_cli_s *pc = (camera_cli_s *)camera;
4017 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4019 if (!pc || !pc->cb_info || !callback) {
4020 LOGE("NULL pointer %p %p", pc, callback);
4021 return CAMERA_ERROR_INVALID_PARAMETER;
4026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4028 if (ret == CAMERA_ERROR_NONE) {
4029 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4030 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4033 LOGD("ret : 0x%x", ret);
4039 int camera_unset_interrupt_started_cb(camera_h camera)
4041 int ret = CAMERA_ERROR_NONE;
4042 camera_cli_s *pc = (camera_cli_s *)camera;
4043 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4045 if (!pc || !pc->cb_info) {
4046 LOGE("NULL handle");
4047 return CAMERA_ERROR_INVALID_PARAMETER;
4052 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4054 if (ret == CAMERA_ERROR_NONE) {
4055 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4056 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4059 LOGD("ret : 0x%x", ret);
4065 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4067 int ret = CAMERA_ERROR_NONE;
4068 camera_cli_s *pc = (camera_cli_s *)camera;
4069 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4071 if (!pc || !pc->cb_info || !callback) {
4072 LOGE("NULL pointer %p %p", pc, callback);
4073 return CAMERA_ERROR_INVALID_PARAMETER;
4078 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4080 if (ret == CAMERA_ERROR_NONE) {
4081 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4082 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4085 LOGD("ret : 0x%x", ret);
4091 int camera_unset_focus_changed_cb(camera_h camera)
4093 int ret = CAMERA_ERROR_NONE;
4094 camera_cli_s *pc = (camera_cli_s *)camera;
4095 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4097 if (!pc || !pc->cb_info) {
4098 LOGE("NULL handle");
4099 return CAMERA_ERROR_INVALID_PARAMETER;
4104 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4106 if (ret == CAMERA_ERROR_NONE) {
4107 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4108 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4111 LOGD("ret : 0x%x", ret);
4117 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4119 int ret = CAMERA_ERROR_NONE;
4120 camera_cli_s *pc = (camera_cli_s *)camera;
4121 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4123 if (!pc || !pc->cb_info || !callback) {
4124 LOGE("NULL pointer %p %p", pc, callback);
4125 return CAMERA_ERROR_INVALID_PARAMETER;
4130 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4132 if (ret == CAMERA_ERROR_NONE) {
4133 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4134 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4137 LOGD("ret : 0x%x", ret);
4143 int camera_unset_error_cb(camera_h camera)
4145 int ret = CAMERA_ERROR_NONE;
4146 camera_cli_s *pc = (camera_cli_s *)camera;
4147 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4149 if (!pc || !pc->cb_info) {
4150 LOGE("NULL handle");
4151 return CAMERA_ERROR_INVALID_PARAMETER;
4156 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4158 if (ret == CAMERA_ERROR_NONE) {
4159 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4160 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4163 LOGD("ret : 0x%x", ret);
4169 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4171 int ret = CAMERA_ERROR_NONE;
4172 camera_cli_s *pc = (camera_cli_s *)camera;
4173 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4175 if (!pc || !pc->cb_info || !foreach_cb) {
4176 LOGE("NULL pointer %p %p", pc, foreach_cb);
4177 return CAMERA_ERROR_INVALID_PARAMETER;
4182 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4183 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4185 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4187 LOGD("ret : 0x%x", ret);
4193 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4195 int ret = CAMERA_ERROR_NONE;
4196 camera_cli_s *pc = (camera_cli_s *)camera;
4197 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4199 if (!pc || !pc->cb_info || !foreach_cb) {
4200 LOGE("NULL pointer %p %p", pc, foreach_cb);
4201 return CAMERA_ERROR_INVALID_PARAMETER;
4206 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4207 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4209 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4211 LOGD("ret : 0x%x", ret);
4217 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4219 int ret = CAMERA_ERROR_NONE;
4220 camera_cli_s *pc = (camera_cli_s *)camera;
4221 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4223 if (!pc || !pc->cb_info || !foreach_cb) {
4224 LOGE("NULL pointer %p %p", pc, foreach_cb);
4225 return CAMERA_ERROR_INVALID_PARAMETER;
4230 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4231 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4233 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4235 LOGD("ret : 0x%x", ret);
4241 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4243 int ret = CAMERA_ERROR_NONE;
4244 camera_cli_s *pc = (camera_cli_s *)camera;
4245 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4247 if (!pc || !pc->cb_info || !foreach_cb) {
4248 LOGE("NULL pointer %p %p", pc, foreach_cb);
4249 return CAMERA_ERROR_INVALID_PARAMETER;
4254 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4255 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4257 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4259 LOGD("ret : 0x%x", ret);
4265 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4267 int ret = CAMERA_ERROR_NONE;
4268 camera_cli_s *pc = (camera_cli_s *)camera;
4269 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4271 if (!pc || !pc->cb_info || !width || !height) {
4272 LOGE("NULL pointer %p %p %p", pc, width, height);
4273 return CAMERA_ERROR_INVALID_PARAMETER;
4277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4279 if (ret == CAMERA_ERROR_NONE) {
4280 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4281 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4284 LOGD("ret : 0x%x", ret);
4290 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4292 int ret = CAMERA_ERROR_NONE;
4293 camera_cli_s *pc = (camera_cli_s *)camera;
4294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4296 if (!pc || !pc->cb_info || !angle) {
4297 LOGE("NULL pointer %p %p", pc, angle);
4298 return CAMERA_ERROR_INVALID_PARAMETER;
4303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4305 if (ret == CAMERA_ERROR_NONE)
4306 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4308 LOGD("ret : 0x%x", ret);
4314 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4316 int ret = CAMERA_ERROR_NONE;
4317 camera_cli_s *pc = (camera_cli_s *)camera;
4318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4319 camera_msg_param param;
4320 int set_mode = (int)mode;
4322 if (!pc || !pc->cb_info) {
4323 LOGE("NULL handle");
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4329 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4331 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4333 LOGD("ret : 0x%x", ret);
4339 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4341 int ret = CAMERA_ERROR_NONE;
4342 camera_cli_s *pc = (camera_cli_s *)camera;
4343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4345 if (!pc || !pc->cb_info || !mode) {
4346 LOGE("NULL pointer %p %p", pc, mode);
4347 return CAMERA_ERROR_INVALID_PARAMETER;
4352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4354 if (ret == CAMERA_ERROR_NONE)
4355 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4357 LOGD("ret : 0x%x", ret);
4363 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4369 if (!pc || !pc->cb_info || !foreach_cb) {
4370 LOGE("NULL pointer %p %p", pc, foreach_cb);
4371 return CAMERA_ERROR_INVALID_PARAMETER;
4376 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4377 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4381 LOGD("Finish, return :%x", ret);
4387 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4389 int ret = CAMERA_ERROR_NONE;
4390 camera_cli_s *pc = (camera_cli_s *)camera;
4391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4392 camera_msg_param param;
4393 int set_fps = (int)fps;
4395 if (!pc || !pc->cb_info) {
4396 LOGE("NULL handle");
4397 return CAMERA_ERROR_INVALID_PARAMETER;
4402 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4406 LOGD("ret : 0x%x", ret);
4412 int camera_attr_set_image_quality(camera_h camera, int quality)
4414 int ret = CAMERA_ERROR_NONE;
4415 camera_cli_s *pc = (camera_cli_s *)camera;
4416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4417 camera_msg_param param;
4419 if (!pc || !pc->cb_info) {
4420 LOGE("NULL handle");
4421 return CAMERA_ERROR_INVALID_PARAMETER;
4426 CAMERA_MSG_PARAM_SET(param, INT, quality);
4428 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4430 LOGD("ret : 0x%x", ret);
4436 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4438 int ret = CAMERA_ERROR_NONE;
4439 camera_cli_s *pc = (camera_cli_s *)camera;
4440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4442 if (!pc || !pc->cb_info || !fps) {
4443 LOGE("NULL pointer %p %p", pc, fps);
4444 return CAMERA_ERROR_INVALID_PARAMETER;
4449 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4451 if (ret == CAMERA_ERROR_NONE)
4452 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4454 LOGD("ret : 0x%x", ret);
4460 int camera_attr_get_image_quality(camera_h camera, int *quality)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4466 if (!pc || !pc->cb_info || !quality) {
4467 LOGE("NULL pointer %p %p", pc, quality);
4468 return CAMERA_ERROR_INVALID_PARAMETER;
4473 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4475 if (ret == CAMERA_ERROR_NONE)
4476 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4478 LOGD("ret : 0x%x", ret);
4484 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4486 int ret = CAMERA_ERROR_NONE;
4487 camera_cli_s *pc = (camera_cli_s *)camera;
4488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4490 if (!pc || !pc->cb_info || !bitrate) {
4491 LOGE("NULL pointer %p %p", pc, bitrate);
4492 return CAMERA_ERROR_INVALID_PARAMETER;
4497 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4499 if (ret == CAMERA_ERROR_NONE)
4500 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4502 LOGD("ret : 0x%x", ret);
4508 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4510 int ret = CAMERA_ERROR_NONE;
4511 camera_cli_s *pc = (camera_cli_s *)camera;
4512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4513 camera_msg_param param;
4514 int set_bitrate = bitrate;
4516 if (!pc || !pc->cb_info) {
4517 LOGE("NULL handle");
4518 return CAMERA_ERROR_INVALID_PARAMETER;
4523 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4525 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4527 LOGD("ret : 0x%x", ret);
4533 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4535 int ret = CAMERA_ERROR_NONE;
4536 camera_cli_s *pc = (camera_cli_s *)camera;
4537 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4539 if (!pc || !pc->cb_info || !interval) {
4540 LOGE("NULL pointer %p %p", pc, interval);
4541 return CAMERA_ERROR_INVALID_PARAMETER;
4546 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4548 if (ret == CAMERA_ERROR_NONE)
4549 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4551 LOGD("ret : 0x%x", ret);
4557 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4559 int ret = CAMERA_ERROR_NONE;
4560 camera_cli_s *pc = (camera_cli_s *)camera;
4561 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4562 camera_msg_param param;
4563 int set_gop_interval = interval;
4565 if (!pc || !pc->cb_info) {
4566 LOGE("NULL handle");
4567 return CAMERA_ERROR_INVALID_PARAMETER;
4572 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4574 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4576 LOGD("ret : 0x%x", ret);
4582 int camera_attr_set_zoom(camera_h camera, int zoom)
4584 int ret = CAMERA_ERROR_NONE;
4585 camera_cli_s *pc = (camera_cli_s *)camera;
4586 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4587 camera_msg_param param;
4589 if (!pc || !pc->cb_info) {
4590 LOGE("NULL handle");
4591 return CAMERA_ERROR_INVALID_PARAMETER;
4594 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4596 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4598 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4600 LOGD("ret : 0x%x", ret);
4606 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4608 int ret = CAMERA_ERROR_NONE;
4609 camera_cli_s *pc = (camera_cli_s *)camera;
4610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4611 camera_msg_param param;
4612 int set_mode = (int)mode;
4614 if (!pc || !pc->cb_info) {
4615 LOGE("NULL handle");
4616 return CAMERA_ERROR_INVALID_PARAMETER;
4619 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4621 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4623 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4629 int camera_attr_set_af_area(camera_h camera, int x, int y)
4631 int ret = CAMERA_ERROR_NONE;
4632 camera_cli_s *pc = (camera_cli_s *)camera;
4633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4634 camera_msg_param param;
4637 if (!pc || !pc->cb_info) {
4638 LOGE("NULL handle");
4639 return CAMERA_ERROR_INVALID_PARAMETER;
4642 LOGD("Enter - %d,%d", x, y);
4644 value = (x << 16) | y;
4645 CAMERA_MSG_PARAM_SET(param, INT, value);
4647 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4649 LOGD("ret : 0x%x", ret);
4655 int camera_attr_clear_af_area(camera_h camera)
4657 int ret = CAMERA_ERROR_NONE;
4658 camera_cli_s *pc = (camera_cli_s *)camera;
4659 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4661 if (!pc || !pc->cb_info) {
4662 LOGE("NULL handle");
4663 return CAMERA_ERROR_INVALID_PARAMETER;
4668 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4670 LOGD("ret : 0x%x", ret);
4676 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4678 int ret = CAMERA_ERROR_NONE;
4679 camera_cli_s *pc = (camera_cli_s *)camera;
4680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4681 camera_msg_param param;
4682 int set_mode = (int)mode;
4684 if (!pc || !pc->cb_info) {
4685 LOGE("NULL handle");
4686 return CAMERA_ERROR_INVALID_PARAMETER;
4691 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4693 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4695 LOGD("ret : 0x%x", ret);
4701 int camera_attr_set_exposure(camera_h camera, int value)
4703 int ret = CAMERA_ERROR_NONE;
4704 camera_cli_s *pc = (camera_cli_s *)camera;
4705 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4706 camera_msg_param param;
4708 if (!pc || !pc->cb_info) {
4709 LOGE("NULL handle");
4710 return CAMERA_ERROR_INVALID_PARAMETER;
4715 CAMERA_MSG_PARAM_SET(param, INT, value);
4717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4719 LOGD("ret : 0x%x", ret);
4725 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4727 int ret = CAMERA_ERROR_NONE;
4728 camera_cli_s *pc = (camera_cli_s *)camera;
4729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4730 camera_msg_param param;
4731 int set_iso = (int)iso;
4733 if (!pc || !pc->cb_info) {
4734 LOGE("NULL handle");
4735 return CAMERA_ERROR_INVALID_PARAMETER;
4740 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4742 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4744 LOGD("ret : 0x%x", ret);
4750 int camera_attr_set_brightness(camera_h camera, int level)
4752 int ret = CAMERA_ERROR_NONE;
4753 camera_cli_s *pc = (camera_cli_s *)camera;
4754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4755 camera_msg_param param;
4757 if (!pc || !pc->cb_info) {
4758 LOGE("NULL handle");
4759 return CAMERA_ERROR_INVALID_PARAMETER;
4764 CAMERA_MSG_PARAM_SET(param, INT, level);
4766 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4768 LOGD("ret : 0x%x", ret);
4774 int camera_attr_set_contrast(camera_h camera, int level)
4776 int ret = CAMERA_ERROR_NONE;
4777 camera_cli_s *pc = (camera_cli_s *)camera;
4778 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4779 camera_msg_param param;
4781 if (!pc || !pc->cb_info) {
4782 LOGE("NULL handle");
4783 return CAMERA_ERROR_INVALID_PARAMETER;
4788 CAMERA_MSG_PARAM_SET(param, INT, level);
4790 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4792 LOGD("ret : 0x%x", ret);
4798 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4800 int ret = CAMERA_ERROR_NONE;
4801 camera_cli_s *pc = (camera_cli_s *)camera;
4802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4803 camera_msg_param param;
4804 int set_whitebalance = (int)wb;
4806 if (!pc || !pc->cb_info) {
4807 LOGE("NULL handle");
4808 return CAMERA_ERROR_INVALID_PARAMETER;
4813 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4815 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4817 LOGD("ret : 0x%x", ret);
4823 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4825 int ret = CAMERA_ERROR_NONE;
4826 camera_cli_s *pc = (camera_cli_s *)camera;
4827 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4828 camera_msg_param param;
4829 int set_effect = (int)effect;
4831 if (!pc || !pc->cb_info) {
4832 LOGE("NULL handle");
4833 return CAMERA_ERROR_INVALID_PARAMETER;
4838 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4840 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4842 LOGD("ret : 0x%x", ret);
4848 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4850 int ret = CAMERA_ERROR_NONE;
4851 camera_cli_s *pc = (camera_cli_s *)camera;
4852 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4853 camera_msg_param param;
4854 int set_mode = (int)mode;
4856 if (!pc || !pc->cb_info) {
4857 LOGE("NULL handle");
4858 return CAMERA_ERROR_INVALID_PARAMETER;
4863 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4865 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4867 LOGD("ret : 0x%x", ret);
4873 int camera_attr_enable_tag(camera_h camera, bool enable)
4875 int ret = CAMERA_ERROR_NONE;
4876 camera_cli_s *pc = (camera_cli_s *)camera;
4877 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4878 camera_msg_param param;
4879 int set_enable = (int)enable;
4881 if (!pc || !pc->cb_info) {
4882 LOGE("NULL handle");
4883 return CAMERA_ERROR_INVALID_PARAMETER;
4888 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4890 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4892 LOGD("ret : 0x%x", ret);
4898 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4900 int ret = CAMERA_ERROR_NONE;
4901 camera_cli_s *pc = (camera_cli_s *)camera;
4902 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4903 camera_msg_param param;
4905 if (!pc || !pc->cb_info || !description) {
4906 LOGE("NULL pointer %p %p", pc, description);
4907 return CAMERA_ERROR_INVALID_PARAMETER;
4912 CAMERA_MSG_PARAM_SET(param, STRING, description);
4914 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4916 LOGD("ret : 0x%x", ret);
4922 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4924 int ret = CAMERA_ERROR_NONE;
4925 camera_cli_s *pc = (camera_cli_s *)camera;
4926 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4927 camera_msg_param param;
4928 int set_orientation = (int)orientation;
4930 if (!pc || !pc->cb_info) {
4931 LOGE("NULL handle");
4932 return CAMERA_ERROR_INVALID_PARAMETER;
4937 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4939 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4941 LOGD("ret : 0x%x", ret);
4947 int camera_attr_set_tag_software(camera_h camera, const char *software)
4949 int ret = CAMERA_ERROR_NONE;
4950 camera_cli_s *pc = (camera_cli_s *)camera;
4951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4952 camera_msg_param param;
4954 if (!pc || !pc->cb_info || !software) {
4955 LOGE("NULL pointer %p %p", pc, software);
4956 return CAMERA_ERROR_INVALID_PARAMETER;
4959 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4961 CAMERA_MSG_PARAM_SET(param, STRING, software);
4963 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4965 LOGD("ret : 0x%x", ret);
4971 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4973 int ret = CAMERA_ERROR_NONE;
4974 camera_cli_s *pc = (camera_cli_s *)camera;
4975 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4976 double set_geotag[3] = {latitude, longitude, altitude};
4981 if (!pc || !pc->cb_info) {
4982 LOGE("NULL handle");
4983 return CAMERA_ERROR_INVALID_PARAMETER;
4988 length = sizeof(set_geotag) / sizeof(int) + \
4989 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4991 msg = muse_core_msg_new(api,
4992 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4995 LOGE("msg creation failed: api %d", api);
4996 return CAMERA_ERROR_OUT_OF_MEMORY;
4999 if (pc->cb_info->is_server_connected) {
5000 __camera_update_api_waiting(pc->cb_info, api, 1);
5002 g_mutex_lock(&pc->cb_info->fd_lock);
5003 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5004 g_mutex_unlock(&pc->cb_info->fd_lock);
5008 LOGE("message send failed");
5009 ret = CAMERA_ERROR_INVALID_OPERATION;
5011 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5014 __camera_update_api_waiting(pc->cb_info, api, -1);
5016 muse_core_msg_free(msg);
5018 LOGD("ret : 0x%x", ret);
5024 int camera_attr_remove_geotag(camera_h camera)
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_REMOVE_GEOTAG;
5030 if (!pc || !pc->cb_info) {
5031 LOGE("NULL handle");
5032 return CAMERA_ERROR_INVALID_PARAMETER;
5037 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5039 LOGD("ret : 0x%x", ret);
5045 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5047 int ret = CAMERA_ERROR_NONE;
5048 camera_cli_s *pc = (camera_cli_s *)camera;
5049 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5050 camera_msg_param param;
5051 int set_mode = (int)mode;
5053 if (!pc || !pc->cb_info) {
5054 LOGE("NULL handle");
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5060 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5064 LOGD("ret : 0x%x", ret);
5070 int camera_attr_get_zoom(camera_h camera, int *zoom)
5072 int ret = CAMERA_ERROR_NONE;
5073 camera_cli_s *pc = (camera_cli_s *)camera;
5074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5076 if (!pc || !pc->cb_info || !zoom) {
5077 LOGE("NULL pointer %p %p", pc, zoom);
5078 return CAMERA_ERROR_INVALID_PARAMETER;
5083 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5085 if (ret == CAMERA_ERROR_NONE)
5086 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5088 LOGD("ret : 0x%x", ret);
5094 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5096 int ret = CAMERA_ERROR_NONE;
5097 camera_cli_s *pc = (camera_cli_s *)camera;
5098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5100 if (!pc || !pc->cb_info || !min || !max) {
5101 LOGE("NULL pointer %p %p %p", pc, min, max);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5107 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE) {
5110 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5111 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5114 LOGD("ret : 0x%x", ret);
5120 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5122 int ret = CAMERA_ERROR_NONE;
5123 camera_cli_s *pc = (camera_cli_s *)camera;
5124 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5126 if (!pc || !pc->cb_info || !mode) {
5127 LOGE("NULL pointer %p %p", pc, mode);
5128 return CAMERA_ERROR_INVALID_PARAMETER;
5133 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5135 if (ret == CAMERA_ERROR_NONE)
5136 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5138 LOGD("ret : 0x%x", ret);
5144 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5146 int ret = CAMERA_ERROR_NONE;
5147 camera_cli_s *pc = (camera_cli_s *)camera;
5148 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5150 if (!pc || !pc->cb_info || !mode) {
5151 LOGE("NULL pointer %p %p", pc, mode);
5152 return CAMERA_ERROR_INVALID_PARAMETER;
5157 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5159 if (ret == CAMERA_ERROR_NONE)
5160 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5162 LOGD("ret : 0x%x", ret);
5168 int camera_attr_get_exposure(camera_h camera, int *value)
5170 int ret = CAMERA_ERROR_NONE;
5171 camera_cli_s *pc = (camera_cli_s *)camera;
5172 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5174 if (!pc || !pc->cb_info || !value) {
5175 LOGE("NULL pointer %p %p", pc, value);
5176 return CAMERA_ERROR_INVALID_PARAMETER;
5181 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5183 if (ret == CAMERA_ERROR_NONE)
5184 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5186 LOGD("ret : 0x%x", ret);
5192 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5194 int ret = CAMERA_ERROR_NONE;
5195 camera_cli_s *pc = (camera_cli_s *)camera;
5196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5198 if (!pc || !pc->cb_info || !min || !max) {
5199 LOGE("NULL pointer %p %p %p", pc, min, max);
5200 return CAMERA_ERROR_INVALID_PARAMETER;
5205 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5207 if (ret == CAMERA_ERROR_NONE) {
5208 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5209 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5212 LOGD("ret : 0x%x", ret);
5218 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5220 int ret = CAMERA_ERROR_NONE;
5221 camera_cli_s *pc = (camera_cli_s *)camera;
5222 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5224 if (!pc || !pc->cb_info || !iso) {
5225 LOGE("NULL pointer %p %p", pc, iso);
5226 return CAMERA_ERROR_INVALID_PARAMETER;
5231 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5233 if (ret == CAMERA_ERROR_NONE)
5234 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5236 LOGD("ret : 0x%x", ret);
5242 int camera_attr_get_brightness(camera_h camera, int *level)
5244 int ret = CAMERA_ERROR_NONE;
5245 camera_cli_s *pc = (camera_cli_s *)camera;
5246 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5248 if (!pc || !pc->cb_info || !level) {
5249 LOGE("NULL pointer %p %p", pc, level);
5250 return CAMERA_ERROR_INVALID_PARAMETER;
5255 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5257 if (ret == CAMERA_ERROR_NONE)
5258 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5260 LOGD("ret : 0x%x", ret);
5266 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5268 int ret = CAMERA_ERROR_NONE;
5269 camera_cli_s *pc = (camera_cli_s *)camera;
5270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5272 if (!pc || !pc->cb_info || !min || !max) {
5273 LOGE("NULL pointer %p %p %p", pc, min, max);
5274 return CAMERA_ERROR_INVALID_PARAMETER;
5279 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5281 if (ret == CAMERA_ERROR_NONE) {
5282 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5283 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5286 LOGD("ret : 0x%x", ret);
5292 int camera_attr_get_contrast(camera_h camera, int *level)
5294 int ret = CAMERA_ERROR_NONE;
5295 camera_cli_s *pc = (camera_cli_s *)camera;
5296 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5298 if (!pc || !pc->cb_info || !level) {
5299 LOGE("NULL pointer %p %p", pc, level);
5300 return CAMERA_ERROR_INVALID_PARAMETER;
5305 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5307 if (ret == CAMERA_ERROR_NONE)
5308 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5310 LOGD("ret : 0x%x", ret);
5316 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5318 int ret = CAMERA_ERROR_NONE;
5319 camera_cli_s *pc = (camera_cli_s *)camera;
5320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5322 if (!pc || !pc->cb_info || !min || !max) {
5323 LOGE("NULL pointer %p %p %p", pc, min, max);
5324 return CAMERA_ERROR_INVALID_PARAMETER;
5329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5331 if (ret == CAMERA_ERROR_NONE) {
5332 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5333 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5334 LOGD("min %d, max %d", *min, *max);
5337 LOGD("ret : 0x%x", ret);
5343 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
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_WHITEBALANCE;
5349 if (!pc || !pc->cb_info || !wb) {
5350 LOGE("NULL pointer %p %p", pc, wb);
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 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5361 LOGD("ret : 0x%x", ret);
5367 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5369 int ret = CAMERA_ERROR_NONE;
5370 camera_cli_s *pc = (camera_cli_s *)camera;
5371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5373 if (!pc || !pc->cb_info || !effect) {
5374 LOGE("NULL pointer %p %p", pc, effect);
5375 return CAMERA_ERROR_INVALID_PARAMETER;
5380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5382 if (ret == CAMERA_ERROR_NONE)
5383 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5385 LOGD("ret : 0x%x", ret);
5391 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5393 int ret = CAMERA_ERROR_NONE;
5394 camera_cli_s *pc = (camera_cli_s *)camera;
5395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5397 if (!pc || !pc->cb_info || !mode) {
5398 LOGE("NULL pointer %p %p", pc, mode);
5399 return CAMERA_ERROR_INVALID_PARAMETER;
5404 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5406 if (ret == CAMERA_ERROR_NONE)
5407 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5409 LOGD("ret : 0x%x", ret);
5415 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5417 int ret = CAMERA_ERROR_NONE;
5418 camera_cli_s *pc = (camera_cli_s *)camera;
5419 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5421 if (!pc || !pc->cb_info || !enable) {
5422 LOGE("NULL pointer %p %p", pc, enable);
5423 return CAMERA_ERROR_INVALID_PARAMETER;
5428 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5430 if (ret == CAMERA_ERROR_NONE)
5431 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5433 LOGD("ret : 0x%x", ret);
5439 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5441 int ret = CAMERA_ERROR_NONE;
5442 camera_cli_s *pc = (camera_cli_s *)camera;
5443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5445 if (!pc || !pc->cb_info || !description) {
5446 LOGE("NULL pointer %p %p", pc, description);
5447 return CAMERA_ERROR_INVALID_PARAMETER;
5452 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5454 if (ret == CAMERA_ERROR_NONE)
5455 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5457 LOGD("ret : 0x%x", ret);
5463 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5465 int ret = CAMERA_ERROR_NONE;
5466 camera_cli_s *pc = (camera_cli_s *)camera;
5467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5469 if (!pc || !pc->cb_info || !orientation) {
5470 LOGE("NULL pointer %p %p", pc, orientation);
5471 return CAMERA_ERROR_INVALID_PARAMETER;
5476 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5478 if (ret == CAMERA_ERROR_NONE)
5479 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5481 LOGD("ret : 0x%x", ret);
5487 int camera_attr_get_tag_software(camera_h camera, char **software)
5489 int ret = CAMERA_ERROR_NONE;
5490 camera_cli_s *pc = (camera_cli_s *)camera;
5491 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5493 if (!pc || !pc->cb_info || !software) {
5494 LOGE("NULL pointer %p %p", pc, software);
5495 return CAMERA_ERROR_INVALID_PARAMETER;
5500 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5502 if (ret == CAMERA_ERROR_NONE)
5503 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5505 LOGD("ret : 0x%x", ret);
5511 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5513 int ret = CAMERA_ERROR_NONE;
5514 camera_cli_s *pc = (camera_cli_s *)camera;
5515 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5517 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5518 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5519 return CAMERA_ERROR_INVALID_PARAMETER;
5524 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5526 if (ret == CAMERA_ERROR_NONE) {
5527 *latitude = pc->cb_info->get_geotag[0];
5528 *longitude = pc->cb_info->get_geotag[1];
5529 *altitude = pc->cb_info->get_geotag[2];
5532 LOGD("ret : 0x%x", ret);
5538 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5540 int ret = CAMERA_ERROR_NONE;
5541 camera_cli_s *pc = (camera_cli_s *)camera;
5542 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5544 if (!pc || !pc->cb_info || !mode) {
5545 LOGE("NULL pointer %p %p", pc, mode);
5546 return CAMERA_ERROR_INVALID_PARAMETER;
5551 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5553 if (ret == CAMERA_ERROR_NONE)
5554 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5556 LOGD("ret : 0x%x", ret);
5562 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5564 int ret = CAMERA_ERROR_NONE;
5565 int get_flash_state = 0;
5568 LOGE("NULL pointer");
5569 return CAMERA_ERROR_INVALID_PARAMETER;
5572 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5573 (int)device, "get_flash_state", &get_flash_state);
5575 if (ret == CAMERA_ERROR_NONE) {
5576 *state = (camera_flash_state_e)get_flash_state;
5577 LOGD("flash state %d", *state);
5579 LOGE("failed 0x%x", ret);
5586 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5588 int ret = CAMERA_ERROR_NONE;
5589 camera_cli_s *pc = (camera_cli_s *)camera;
5590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5592 if (!pc || !pc->cb_info || !foreach_cb) {
5593 LOGE("NULL pointer %p %p", pc, foreach_cb);
5594 return CAMERA_ERROR_INVALID_PARAMETER;
5599 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5600 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5602 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5604 LOGD("ret : 0x%x", ret);
5610 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5612 int ret = CAMERA_ERROR_NONE;
5613 camera_cli_s *pc = (camera_cli_s *)camera;
5614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5616 if (!pc || !pc->cb_info || !foreach_cb) {
5617 LOGE("NULL pointer %p %p", pc, foreach_cb);
5618 return CAMERA_ERROR_INVALID_PARAMETER;
5623 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5624 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5626 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5628 LOGD("ret : 0x%x", ret);
5634 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5636 int ret = CAMERA_ERROR_NONE;
5637 camera_cli_s *pc = (camera_cli_s *)camera;
5638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5640 if (!pc || !pc->cb_info || !foreach_cb) {
5641 LOGE("NULL pointer %p %p", pc, foreach_cb);
5642 return CAMERA_ERROR_INVALID_PARAMETER;
5647 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5648 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5650 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5652 LOGD("ret : 0x%x", ret);
5658 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5660 int ret = CAMERA_ERROR_NONE;
5661 camera_cli_s *pc = (camera_cli_s *)camera;
5662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5664 if (!pc || !pc->cb_info || !foreach_cb) {
5665 LOGE("NULL pointer %p %p", pc, foreach_cb);
5666 return CAMERA_ERROR_INVALID_PARAMETER;
5671 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5672 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5676 LOGD("ret : 0x%x", ret);
5682 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5684 int ret = CAMERA_ERROR_NONE;
5685 camera_cli_s *pc = (camera_cli_s *)camera;
5686 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5688 if (!pc || !pc->cb_info || !foreach_cb) {
5689 LOGE("NULL pointer %p %p", pc, foreach_cb);
5690 return CAMERA_ERROR_INVALID_PARAMETER;
5695 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5696 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5698 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5700 LOGD("ret : 0x%x", ret);
5706 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5708 int ret = CAMERA_ERROR_NONE;
5709 camera_cli_s *pc = (camera_cli_s *)camera;
5710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5712 if (!pc || !pc->cb_info || !foreach_cb) {
5713 LOGE("NULL pointer %p %p", pc, foreach_cb);
5714 return CAMERA_ERROR_INVALID_PARAMETER;
5719 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5720 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5722 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5724 LOGD("ret : 0x%x", ret);
5730 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5732 int ret = CAMERA_ERROR_NONE;
5733 camera_cli_s *pc = (camera_cli_s *)camera;
5734 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5736 if (!pc || !pc->cb_info || !foreach_cb) {
5737 LOGE("NULL pointer %p %p", pc, foreach_cb);
5738 return CAMERA_ERROR_INVALID_PARAMETER;
5743 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5744 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5746 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5748 LOGD("ret : 0x%x", ret);
5754 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5760 if (!pc || !pc->cb_info || !foreach_cb) {
5761 LOGE("NULL pointer %p %p", pc, foreach_cb);
5762 return CAMERA_ERROR_INVALID_PARAMETER;
5767 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5768 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5772 LOGD("Enter, handle :%x", pc->remote_handle);
5778 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)
5780 int ret = CAMERA_ERROR_NONE;
5781 camera_cli_s *pc = (camera_cli_s *)camera;
5782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5783 camera_msg_param param;
5786 if (!pc || !pc->cb_info || !foreach_cb) {
5787 LOGE("NULL pointer %p %p", pc, foreach_cb);
5788 return CAMERA_ERROR_INVALID_PARAMETER;
5793 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5794 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5796 value = (width << 16) | height;
5797 CAMERA_MSG_PARAM_SET(param, INT, value);
5799 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5801 LOGD("ret : 0x%x", ret);
5807 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_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_STREAM_FLIP;
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_STREAM_FLIP] = foreach_cb;
5821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = 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_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_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_STREAM_ROTATION;
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_STREAM_ROTATION] = foreach_cb;
5845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5849 LOGD("ret : 0x%x", ret);
5855 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
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_SET_STREAM_ROTATION;
5860 camera_msg_param param;
5861 int set_rotation = (int)rotation;
5863 if (!pc || !pc->cb_info) {
5864 LOGE("NULL handle");
5865 return CAMERA_ERROR_INVALID_PARAMETER;
5870 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5872 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5874 LOGD("ret : 0x%x", ret);
5880 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5882 int ret = CAMERA_ERROR_NONE;
5883 camera_cli_s *pc = (camera_cli_s *)camera;
5884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5886 if (!pc || !pc->cb_info || !rotation) {
5887 LOGE("NULL pointer %p %p", pc, rotation);
5888 return CAMERA_ERROR_INVALID_PARAMETER;
5893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5895 if (ret == CAMERA_ERROR_NONE)
5896 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5898 LOGD("ret : 0x%x", ret);
5904 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5906 int ret = CAMERA_ERROR_NONE;
5907 camera_cli_s *pc = (camera_cli_s *)camera;
5908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5909 camera_msg_param param;
5910 int set_flip = (int)flip;
5912 if (!pc || !pc->cb_info) {
5913 LOGE("NULL handle");
5914 return CAMERA_ERROR_INVALID_PARAMETER;
5919 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5921 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5923 LOGD("ret : 0x%x", ret);
5929 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5931 int ret = CAMERA_ERROR_NONE;
5932 camera_cli_s *pc = (camera_cli_s *)camera;
5933 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5935 if (!pc || !pc->cb_info || !flip) {
5936 LOGE("NULL pointer %p %p", pc, flip);
5937 return CAMERA_ERROR_INVALID_PARAMETER;
5942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5944 if (ret == CAMERA_ERROR_NONE)
5945 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5947 LOGD("ret : 0x%x", ret);
5952 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5954 int ret = CAMERA_ERROR_NONE;
5955 camera_cli_s *pc = (camera_cli_s *)camera;
5956 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5957 camera_msg_param param;
5958 int set_mode = (int)mode;
5960 if (!pc || !pc->cb_info) {
5961 LOGE("NULL handle");
5962 return CAMERA_ERROR_INVALID_PARAMETER;
5967 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5969 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5971 LOGD("ret : 0x%x", ret);
5977 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5979 int ret = CAMERA_ERROR_NONE;
5980 camera_cli_s *pc = (camera_cli_s *)camera;
5981 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5983 if (!pc || !pc->cb_info || !mode) {
5984 LOGE("NULL pointer %p %p", pc, mode);
5985 return CAMERA_ERROR_INVALID_PARAMETER;
5990 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5992 if (ret == CAMERA_ERROR_NONE)
5993 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5995 LOGD("ret : 0x%x", ret);
6001 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6003 int ret = CAMERA_ERROR_NONE;
6004 camera_cli_s *pc = (camera_cli_s *)camera;
6005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6007 if (!pc || !pc->cb_info) {
6008 LOGE("NULL handle");
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6014 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6017 LOGE("error is occurred 0x%x", ret);
6021 LOGD("ret : %d", ret);
6027 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6033 if (!pc || !pc->cb_info) {
6034 LOGE("NULL handle");
6035 return CAMERA_ERROR_INVALID_PARAMETER;
6040 if (!camera_attr_is_supported_hdr_capture(camera)) {
6041 LOGE("HDR not supported");
6042 return CAMERA_ERROR_NOT_SUPPORTED;
6046 LOGE("NULL callback");
6047 return CAMERA_ERROR_INVALID_PARAMETER;
6050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6052 if (ret == CAMERA_ERROR_NONE) {
6053 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6054 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6057 LOGD("ret : 0x%x", ret);
6063 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6065 int ret = CAMERA_ERROR_NONE;
6066 camera_cli_s *pc = (camera_cli_s *)camera;
6067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6069 if (!pc || !pc->cb_info) {
6070 LOGE("NULL handle");
6071 return CAMERA_ERROR_INVALID_PARAMETER;
6076 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6078 if (ret == CAMERA_ERROR_NONE) {
6079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6083 LOGD("ret : 0x%x", ret);
6089 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6091 int ret = CAMERA_ERROR_NONE;
6092 camera_cli_s *pc = (camera_cli_s *)camera;
6093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6094 camera_msg_param param;
6095 int set_enable = (int)enable;
6097 if (!pc || !pc->cb_info) {
6098 LOGE("NULL handle");
6099 return CAMERA_ERROR_INVALID_PARAMETER;
6104 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6106 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6108 LOGD("ret : 0x%x", ret);
6114 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6120 if (!pc || !pc->cb_info || !enabled) {
6121 LOGE("NULL pointer %p %p", pc, enabled);
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6127 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6129 if (ret == CAMERA_ERROR_NONE)
6130 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6132 LOGD("ret : 0x%x", ret);
6138 bool camera_attr_is_supported_anti_shake(camera_h camera)
6140 int ret = CAMERA_ERROR_NONE;
6141 camera_cli_s *pc = (camera_cli_s *)camera;
6142 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6144 if (!pc || !pc->cb_info) {
6145 LOGE("NULL handle");
6146 return CAMERA_ERROR_INVALID_PARAMETER;
6151 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6154 LOGE("error is occurred 0x%x", ret);
6158 LOGD("ret : %d", ret);
6164 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6166 int ret = CAMERA_ERROR_NONE;
6167 camera_cli_s *pc = (camera_cli_s *)camera;
6168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6169 camera_msg_param param;
6170 int set_enable = (int)enable;
6172 if (!pc || !pc->cb_info) {
6173 LOGE("NULL handle");
6174 return CAMERA_ERROR_INVALID_PARAMETER;
6179 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6181 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6183 LOGD("ret : 0x%x", ret);
6189 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6191 int ret = CAMERA_ERROR_NONE;
6192 camera_cli_s *pc = (camera_cli_s *)camera;
6193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6195 if (!pc || !pc->cb_info || !enabled) {
6196 LOGE("NULL pointer %p %p", pc, enabled);
6197 return CAMERA_ERROR_INVALID_PARAMETER;
6202 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6204 if (ret == CAMERA_ERROR_NONE)
6205 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6207 LOGD("ret : 0x%x", ret);
6213 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6215 int ret = CAMERA_ERROR_NONE;
6216 camera_cli_s *pc = (camera_cli_s *)camera;
6217 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6219 if (!pc || !pc->cb_info) {
6220 LOGE("NULL handle");
6221 return CAMERA_ERROR_INVALID_PARAMETER;
6226 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6229 LOGE("error is occurred 0x%x", ret);
6233 LOGD("ret : %d", ret);
6239 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6241 int ret = CAMERA_ERROR_NONE;
6242 camera_cli_s *pc = (camera_cli_s *)camera;
6243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6244 camera_msg_param param;
6245 int set_enable = (int)enable;
6247 if (!pc || !pc->cb_info) {
6248 LOGE("NULL handle");
6249 return CAMERA_ERROR_INVALID_PARAMETER;
6254 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6256 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6258 LOGD("ret : 0x%x", ret);
6264 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6266 int ret = CAMERA_ERROR_NONE;
6267 camera_cli_s *pc = (camera_cli_s *)camera;
6268 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6270 if (!pc || !pc->cb_info || !enabled) {
6271 LOGE("NULL pointer %p %p", pc, enabled);
6272 return CAMERA_ERROR_INVALID_PARAMETER;
6277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6279 if (ret == CAMERA_ERROR_NONE)
6280 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6282 LOGD("ret : 0x%x", ret);
6288 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6290 int ret = CAMERA_ERROR_NONE;
6291 camera_cli_s *pc = (camera_cli_s *)camera;
6292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6294 if (!pc || !pc->cb_info) {
6295 LOGE("NULL handle");
6296 return CAMERA_ERROR_INVALID_PARAMETER;
6301 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6304 LOGE("error is occurred 0x%x", ret);
6308 LOGD("ret : %d", ret);
6314 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6316 int ret = CAMERA_ERROR_NONE;
6317 camera_cli_s *pc = (camera_cli_s *)camera;
6318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6319 camera_msg_param param;
6320 int set_disable = (int)disable;
6322 if (!pc || !pc->cb_info) {
6323 LOGE("NULL handle");
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6329 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6331 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6333 LOGD("ret : 0x%x", ret);
6339 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6341 int ret = CAMERA_ERROR_NONE;
6342 camera_cli_s *pc = (camera_cli_s *)camera;
6343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6344 camera_msg_param param;
6345 int set_move_type = (int)move_type;
6348 if (!pc || !pc->cb_info) {
6349 LOGE("NULL handle");
6350 return CAMERA_ERROR_INVALID_PARAMETER;
6355 value = (set_move_type << 16) | pan_step;
6356 CAMERA_MSG_PARAM_SET(param, INT, value);
6358 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6360 LOGD("ret : 0x%x", ret);
6366 int camera_attr_get_pan(camera_h camera, int *pan_step)
6368 int ret = CAMERA_ERROR_NONE;
6369 camera_cli_s *pc = (camera_cli_s *)camera;
6370 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6372 if (!pc || !pc->cb_info || !pan_step) {
6373 LOGE("NULL pointer %p %p", pc, pan_step);
6374 return CAMERA_ERROR_INVALID_PARAMETER;
6379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6381 if (ret == CAMERA_ERROR_NONE)
6382 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6384 LOGD("ret : 0x%x", ret);
6390 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6392 int ret = CAMERA_ERROR_NONE;
6393 camera_cli_s *pc = (camera_cli_s *)camera;
6394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6396 if (!pc || !pc->cb_info || !min || !max) {
6397 LOGE("NULL pointer %p %p %p", pc, min, max);
6398 return CAMERA_ERROR_INVALID_PARAMETER;
6403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6405 if (ret == CAMERA_ERROR_NONE) {
6406 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6407 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6410 LOGD("ret : 0x%x", ret);
6416 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6418 int ret = CAMERA_ERROR_NONE;
6419 camera_cli_s *pc = (camera_cli_s *)camera;
6420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6421 camera_msg_param param;
6422 int set_move_type = (int)move_type;
6425 if (!pc || !pc->cb_info) {
6426 LOGE("NULL handle");
6427 return CAMERA_ERROR_INVALID_PARAMETER;
6432 value = (set_move_type << 16) | tilt_step;
6433 CAMERA_MSG_PARAM_SET(param, INT, value);
6435 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6437 LOGD("ret : 0x%x", ret);
6443 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6445 int ret = CAMERA_ERROR_NONE;
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6449 if (!pc || !pc->cb_info || !tilt_step) {
6450 LOGE("NULL pointer %p %p", pc, tilt_step);
6451 return CAMERA_ERROR_INVALID_PARAMETER;
6456 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6458 if (ret == CAMERA_ERROR_NONE)
6459 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6461 LOGD("ret : 0x%x", ret);
6467 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6469 int ret = CAMERA_ERROR_NONE;
6470 camera_cli_s *pc = (camera_cli_s *)camera;
6471 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6473 if (!pc || !pc->cb_info || !min || !max) {
6474 LOGE("NULL pointer %p %p %p", pc, min, max);
6475 return CAMERA_ERROR_INVALID_PARAMETER;
6480 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6482 if (ret == CAMERA_ERROR_NONE) {
6483 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6484 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6487 LOGD("ret : 0x%x", ret);
6493 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6495 int ret = CAMERA_ERROR_NONE;
6496 camera_cli_s *pc = (camera_cli_s *)camera;
6497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6498 camera_msg_param param;
6499 int set_ptz_type = (int)ptz_type;
6501 if (!pc || !pc->cb_info) {
6502 LOGE("NULL handle");
6503 return CAMERA_ERROR_INVALID_PARAMETER;
6508 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6510 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6512 LOGD("ret : 0x%x", ret);
6518 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6520 int ret = CAMERA_ERROR_NONE;
6521 camera_cli_s *pc = (camera_cli_s *)camera;
6522 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6524 if (!pc || !pc->cb_info || !foreach_cb) {
6525 LOGE("NULL pointer %p %p", pc, foreach_cb);
6526 return CAMERA_ERROR_INVALID_PARAMETER;
6531 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6532 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6534 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6536 LOGD("ret : 0x%x", ret);
6542 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6544 int ret = CAMERA_ERROR_NONE;
6545 camera_cli_s *pc = (camera_cli_s *)camera;
6546 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6547 int set_display_roi_area[4] = {x, y, width, height};
6552 if (!pc || !pc->cb_info) {
6553 LOGE("NULL handle");
6554 return CAMERA_ERROR_INVALID_PARAMETER;
6559 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6560 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6561 g_mutex_lock(&pc->cb_info->evas_mutex);
6563 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6565 g_mutex_unlock(&pc->cb_info->evas_mutex);
6567 if (ret != MM_ERROR_NONE) {
6568 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6569 return CAMERA_ERROR_INVALID_OPERATION;
6572 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6574 length = sizeof(set_display_roi_area) / sizeof(int) + \
6575 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6577 msg = muse_core_msg_new(api,
6578 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6581 LOGE("msg creation failed: api %d", api);
6582 return CAMERA_ERROR_OUT_OF_MEMORY;
6585 if (pc->cb_info->is_server_connected) {
6586 __camera_update_api_waiting(pc->cb_info, api, 1);
6588 g_mutex_lock(&pc->cb_info->fd_lock);
6589 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6590 g_mutex_unlock(&pc->cb_info->fd_lock);
6594 LOGE("message send failed");
6595 ret = CAMERA_ERROR_INVALID_OPERATION;
6597 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6600 __camera_update_api_waiting(pc->cb_info, api, -1);
6602 muse_core_msg_free(msg);
6604 LOGD("ret : 0x%x", ret);
6610 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6612 camera_cli_s *pc = (camera_cli_s *)camera;
6613 int ret = CAMERA_ERROR_NONE;
6614 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6616 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6617 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6618 return CAMERA_ERROR_INVALID_PARAMETER;
6623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6625 if (ret == CAMERA_ERROR_NONE) {
6626 *x = pc->cb_info->get_display_roi_area[0];
6627 *y = pc->cb_info->get_display_roi_area[1];
6628 *width = pc->cb_info->get_display_roi_area[2];
6629 *height = pc->cb_info->get_display_roi_area[3];
6632 LOGD("ret : 0x%x", ret);
6638 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6640 int ret = CAMERA_ERROR_NONE;
6641 int get_device_state = 0;
6644 LOGE("NULL pointer");
6645 return CAMERA_ERROR_INVALID_PARAMETER;
6648 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6649 (int)device, "get_device_state", &get_device_state);
6651 if (ret == CAMERA_ERROR_NONE) {
6652 *state = (camera_device_state_e)get_device_state;
6653 LOGD("device state %d", *state);
6655 LOGE("failed 0x%x", ret);
6662 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6664 int ret = CAMERA_ERROR_NONE;
6665 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6666 camera_cb_info *info = NULL;
6668 if (!callback || !cb_id) {
6669 LOGE("invalid pointer %p %p", callback, cb_id);
6670 return CAMERA_ERROR_INVALID_PARAMETER;
6673 /* check camera support */
6674 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6675 if (ret != CAMERA_ERROR_NONE) {
6676 LOGE("get device state failed");
6680 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6682 info = g_new0(camera_cb_info, 1);
6684 LOGE("info failed");
6685 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6689 info->id = ++g_cam_dev_state_changed_cb_id;
6690 info->callback = (void *)callback;
6691 info->user_data = user_data;
6695 /* subscribe dbus signal for camera state change */
6696 if (!g_cam_dev_state_changed_cb_conn) {
6697 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6698 if (!g_cam_dev_state_changed_cb_conn) {
6699 LOGE("failed to get gdbus connection");
6700 ret = CAMERA_ERROR_INVALID_OPERATION;
6704 LOGD("subscribe signal %s - %s - %s",
6705 MM_CAMCORDER_DBUS_OBJECT,
6706 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6707 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6709 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6710 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6711 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6712 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6713 LOGE("failed to get gdbus connection");
6714 ret = CAMERA_ERROR_INVALID_OPERATION;
6718 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6721 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6723 LOGD("callback id %d", info->id);
6726 if (ret != CAMERA_ERROR_NONE) {
6732 if (g_cam_dev_state_changed_cb_conn) {
6733 g_object_unref(g_cam_dev_state_changed_cb_conn);
6734 g_cam_dev_state_changed_cb_conn = NULL;
6738 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6744 int camera_remove_device_state_changed_cb(int cb_id)
6746 int ret = CAMERA_ERROR_NONE;
6747 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6748 GList *tmp_list = NULL;
6749 camera_cb_info *info = NULL;
6751 /* check camera support */
6752 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6753 if (ret != CAMERA_ERROR_NONE) {
6754 LOGE("get device state failed");
6758 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6760 if (!g_cam_dev_state_changed_cb_list) {
6761 LOGE("there is no callback info");
6762 ret = CAMERA_ERROR_INVALID_OPERATION;
6766 tmp_list = g_cam_dev_state_changed_cb_list;
6769 info = tmp_list->data;
6770 tmp_list = tmp_list->next;
6777 if (info->id == cb_id) {
6778 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6783 if (!g_cam_dev_state_changed_cb_list) {
6784 /* no remained callback */
6785 if (g_cam_dev_state_changed_cb_conn) {
6786 /* unsubscribe signal */
6787 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6788 g_cam_dev_state_changed_cb_subscribe_id = 0;
6790 /* unref connection */
6791 g_object_unref(g_cam_dev_state_changed_cb_conn);
6792 g_cam_dev_state_changed_cb_conn = NULL;
6796 LOGD("id %d callback removed", cb_id);
6797 ret = CAMERA_ERROR_NONE;
6803 LOGE("id %d callback not found", cb_id);
6804 ret = CAMERA_ERROR_INVALID_PARAMETER;
6807 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);