/* * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef TIZEN_FEATURE_EVAS_RENDERER #include #endif /* TIZEN_FEATURE_EVAS_RENDERER */ #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "TIZEN_N_CAMERA" static void __global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { struct tizen_surface **tz_surface = NULL; if (!data) { LOGE("NULL data"); return; } tz_surface = (struct tizen_surface **)data; if (!interface) { LOGW("NULL interface"); return; } /*LOGI("interface %s", interface);*/ if (strcmp(interface, "tizen_surface") == 0) { LOGD("binding tizen surface for wayland"); *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version); if (*tz_surface == NULL) LOGE("failed to bind"); LOGD("done"); } return; } static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name) { LOGD("enter"); return; } static const struct wl_registry_listener _camera_wl_registry_listener = { __global, __global_remove }; void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id) { if (!data) { LOGE("NULL data"); return; } *((unsigned int *)data) = id; LOGD("[CLIENT] got parent_id [%u] from server", id); return; } static const struct tizen_resource_listener _camera_tz_resource_listener = { __parent_id_getter }; int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) { int ret = CAMERA_ERROR_NONE; Ecore_Wl_Window *window = NULL; struct wl_display *display = NULL; struct wl_surface *surface = NULL; struct wl_registry *registry = NULL; struct tizen_surface *tz_surface = NULL; struct tizen_resource *tz_resource = NULL; if (!obj || !wl_info) { LOGE("NULL parameter %p %p", obj, wl_info); return CAMERA_ERROR_INVALID_OPERATION; } window = elm_win_wl_window_get(obj); if (!window) { LOGE("failed to get wayland window"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } surface = (struct wl_surface *)ecore_wl_window_surface_get(window); if (!surface) { LOGE("failed to get wayland surface"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } display = (struct wl_display *)ecore_wl_display_get(); if (!display) { LOGE("failed to get wayland display"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } registry = wl_display_get_registry(display); if (!registry) { LOGE("failed to get wayland registry"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface); wl_display_dispatch(display); wl_display_roundtrip(display); if (!tz_surface) { LOGE("failed to get tizen surface"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } /* Get parent_id which is unique in a entire systemw. */ tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface); if (!tz_resource) { LOGE("failed to get tizen resurce"); ret = CAMERA_ERROR_INVALID_OPERATION; goto _DONE; } wl_info->parent_id = 0; tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id); wl_display_roundtrip(display); if (wl_info->parent_id > 0) { int rotation = 0; Ecore_Evas *ecore_evas = NULL; ret = CAMERA_ERROR_NONE; wl_info->evas_obj = obj; evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y, &wl_info->window_width, &wl_info->window_height); ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj)); if (ecore_evas) { rotation = ecore_evas_rotation_get(ecore_evas); if (rotation == 90 || rotation == 270) { int temp = wl_info->window_width; LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height); wl_info->window_width = wl_info->window_height; wl_info->window_height = temp; } } else { LOGW("failed to get ecore_evas.. skip rotation check"); } LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d", wl_info->evas_obj, rotation, wl_info->parent_id, wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height); } else { ret = CAMERA_ERROR_INVALID_OPERATION; LOGE("failed to get parent id"); } _DONE: if (tz_surface) { tizen_surface_destroy(tz_surface); tz_surface = NULL; } if (tz_resource) { tizen_resource_destroy(tz_resource); tz_resource = NULL; } if (registry) { wl_registry_destroy(registry); registry = NULL; } return ret; } static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle) { tbm_bo tmp_bo = NULL; tbm_bo_handle tmp_bo_handle = {NULL, }; if (!bufmgr || !bo || !bo_handle || !tbm_key) { LOGE("invalid parameter - %p %p %p, key %d", bufmgr, bo, bo_handle, tbm_key); return false; } tmp_bo = tbm_bo_import(bufmgr, tbm_key); if (tmp_bo == NULL) { LOGE("import failed - key %d", tbm_key); return false; } tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ); if (tmp_bo_handle.ptr == NULL) { LOGE("map failed %p", tmp_bo); tbm_bo_unref(tmp_bo); tmp_bo = NULL; return false; } tbm_bo_unmap(tmp_bo); /* set bo and bo_handle */ *bo = tmp_bo; *bo_handle = tmp_bo_handle; return true; } static void _camera_release_imported_bo(tbm_bo *bo) { if (!bo || !(*bo)) { LOGW("NULL bo"); return; } tbm_bo_unref(*bo); *bo = NULL; return; } static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out) { int ret = CAMERA_ERROR_NONE; gint64 end_time; /*LOGD("Enter api : %d", api);*/ g_mutex_lock(&(cb_info->api_mutex[api])); if (cb_info->api_activating[api] == 0) { end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND; if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) { ret = cb_info->api_ret[api]; cb_info->api_activating[api] = 0; /*LOGD("return value : 0x%x", ret);*/ } else { ret = CAMERA_ERROR_INVALID_OPERATION; LOGE("api %d was TIMED OUT!", api); } } else { ret = cb_info->api_ret[api]; cb_info->api_activating[api] = 0; /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/ } g_mutex_unlock(&(cb_info->api_mutex[api])); if (ret != CAMERA_ERROR_NONE) { LOGE("api %d : error 0x%x", api, ret); if (ret == CAMERA_ERROR_SOUND_POLICY) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release."); else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release."); else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release."); } return ret; } static void _camera_msg_send(int api, camera_cb_info_s *cb_info, int *ret, int timeout) { char *msg = NULL; if (!cb_info) { LOGE("NULL info - api %d", api); if (ret) *ret = CAMERA_ERROR_INVALID_PARAMETER; return; } msg = muse_core_msg_json_factory_new(api, NULL); if (!msg) { LOGE("msg failed: api %d", api); if (ret) *ret = CAMERA_ERROR_OUT_OF_MEMORY; return; } /*LOGD("send msg %s", msg);*/ if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) { LOGE("msg send failed"); if (ret) *ret = CAMERA_ERROR_INVALID_OPERATION; } else { if (ret) *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout); } muse_core_msg_json_factory_free(msg); return; } static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, int *ret, camera_msg_param *param, int timeout) { char *msg = NULL; if (!cb_info || !param) { LOGE("invalid pointer : api %d - %p %p", api, cb_info, param); if (ret) *ret = CAMERA_ERROR_INVALID_PARAMETER; return; } /*LOGD("type %d, name %s", param->type, param->name);*/ switch (param->type) { case MUSE_TYPE_INT: msg = muse_core_msg_json_factory_new(api, param->type, param->name, param->value.value_INT, NULL); break; case MUSE_TYPE_STRING: msg = muse_core_msg_json_factory_new(api, param->type, param->name, param->value.value_STRING, NULL); break; default: LOGE("unknown type %d", param->type); break; } if (!msg) { LOGE("msg failed: api %d", api); if (ret) *ret = CAMERA_ERROR_OUT_OF_MEMORY; return; } /*LOGD("send msg %s", msg);*/ if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) { LOGE("msg send failed"); if (ret) *ret = CAMERA_ERROR_INVALID_OPERATION; } else { if (ret) *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout); } muse_core_msg_json_factory_free(msg); return; } int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format) { if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || out_format == NULL) { LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format); return CAMERA_ERROR_INVALID_PARAMETER; } switch (in_format) { case MM_PIXEL_FORMAT_NV12: case MM_PIXEL_FORMAT_NV12T: *out_format = TBM_FORMAT_NV12; break; case MM_PIXEL_FORMAT_NV16: *out_format = TBM_FORMAT_NV16; break; case MM_PIXEL_FORMAT_NV21: *out_format = TBM_FORMAT_NV21; break; case MM_PIXEL_FORMAT_YUYV: *out_format = TBM_FORMAT_YUYV; break; case MM_PIXEL_FORMAT_UYVY: case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY: *out_format = TBM_FORMAT_UYVY; break; case MM_PIXEL_FORMAT_422P: *out_format = TBM_FORMAT_YUV422; break; case MM_PIXEL_FORMAT_I420: *out_format = TBM_FORMAT_YUV420; break; case MM_PIXEL_FORMAT_YV12: *out_format = TBM_FORMAT_YVU420; break; case MM_PIXEL_FORMAT_RGB565: *out_format = TBM_FORMAT_RGB565; break; case MM_PIXEL_FORMAT_RGB888: *out_format = TBM_FORMAT_RGB888; break; case MM_PIXEL_FORMAT_RGBA: *out_format = TBM_FORMAT_RGBA8888; break; case MM_PIXEL_FORMAT_ARGB: *out_format = TBM_FORMAT_ARGB8888; break; default: LOGE("invalid in_format %d", in_format); return CAMERA_ERROR_INVALID_PARAMETER; } return CAMERA_ERROR_NONE; } int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype) { if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || mimetype == NULL) { LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype); return CAMERA_ERROR_INVALID_PARAMETER; } switch (in_format) { case MM_PIXEL_FORMAT_NV12: case MM_PIXEL_FORMAT_NV12T: *mimetype = MEDIA_FORMAT_NV12; break; case MM_PIXEL_FORMAT_NV16: *mimetype = MEDIA_FORMAT_NV16; break; case MM_PIXEL_FORMAT_NV21: *mimetype = MEDIA_FORMAT_NV21; break; case MM_PIXEL_FORMAT_YUYV: *mimetype = MEDIA_FORMAT_YUYV; break; case MM_PIXEL_FORMAT_UYVY: case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY: *mimetype = MEDIA_FORMAT_UYVY; break; case MM_PIXEL_FORMAT_422P: *mimetype = MEDIA_FORMAT_422P; break; case MM_PIXEL_FORMAT_I420: *mimetype = MEDIA_FORMAT_I420; break; case MM_PIXEL_FORMAT_YV12: *mimetype = MEDIA_FORMAT_YV12; break; case MM_PIXEL_FORMAT_RGB565: *mimetype = MEDIA_FORMAT_RGB565; break; case MM_PIXEL_FORMAT_RGB888: *mimetype = MEDIA_FORMAT_RGB888; break; case MM_PIXEL_FORMAT_RGBA: *mimetype = MEDIA_FORMAT_RGBA; break; case MM_PIXEL_FORMAT_ARGB: *mimetype = MEDIA_FORMAT_ARGB; break; default: LOGE("invalid in_format %d", in_format); return CAMERA_ERROR_INVALID_PARAMETER; } return CAMERA_ERROR_NONE; } void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key, tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame) { int total_size = 0; unsigned char *buf_pos = NULL; if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) { LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle); return; } /* set frame info */ if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) frame->format = MM_PIXEL_FORMAT_UYVY; else frame->format = stream->format; frame->width = stream->width; frame->height = stream->height; frame->timestamp = stream->timestamp; frame->num_of_planes = stream->num_planes; if (num_buffer_key == 0) { /* non-zero copy */ if (!data_bo_handle || !data_bo_handle->ptr) { LOGE("NULL pointer"); return; } buf_pos = data_bo_handle->ptr; if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) { frame->data.encoded_plane.data = buf_pos; frame->data.encoded_plane.size = stream->data.encoded.length_data; total_size = stream->data.encoded.length_data; } else { switch (stream->num_planes) { case 1: frame->data.single_plane.yuv = buf_pos; frame->data.single_plane.size = stream->data.yuv420.length_yuv; total_size = stream->data.yuv420.length_yuv; break; case 2: frame->data.double_plane.y = buf_pos; frame->data.double_plane.y_size = stream->data.yuv420sp.length_y; buf_pos += stream->data.yuv420sp.length_y; frame->data.double_plane.uv = buf_pos; frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv; total_size = stream->data.yuv420sp.length_y + \ stream->data.yuv420sp.length_uv; break; case 3: frame->data.triple_plane.y = buf_pos; frame->data.triple_plane.y_size = stream->data.yuv420p.length_y; buf_pos += stream->data.yuv420p.length_y; frame->data.triple_plane.u = buf_pos; frame->data.triple_plane.u_size = stream->data.yuv420p.length_u; buf_pos += stream->data.yuv420p.length_u; frame->data.triple_plane.v = buf_pos; frame->data.triple_plane.v_size = stream->data.yuv420p.length_v; total_size = stream->data.yuv420p.length_y + \ stream->data.yuv420p.length_u + \ stream->data.yuv420p.length_v; break; default: break; } } } else { /* zero copy */ switch (stream->num_planes) { case 1: frame->data.single_plane.yuv = buffer_bo_handle[0].ptr; frame->data.single_plane.size = stream->data.yuv420.length_yuv; total_size = stream->data.yuv420.length_yuv; break; case 2: frame->data.double_plane.y = buffer_bo_handle[0].ptr; if (stream->num_planes == (unsigned int)num_buffer_key) frame->data.double_plane.uv = buffer_bo_handle[1].ptr; else frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y; frame->data.double_plane.y_size = stream->data.yuv420sp.length_y; frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv; total_size = stream->data.yuv420sp.length_y + \ stream->data.yuv420sp.length_uv; break; case 3: frame->data.triple_plane.y = buffer_bo_handle[0].ptr; if (stream->num_planes == (unsigned int)num_buffer_key) { frame->data.triple_plane.u = buffer_bo_handle[1].ptr; frame->data.triple_plane.v = buffer_bo_handle[2].ptr; } else { frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y; frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u; } frame->data.triple_plane.y_size = stream->data.yuv420p.length_y; frame->data.triple_plane.u_size = stream->data.yuv420p.length_u; frame->data.triple_plane.v_size = stream->data.yuv420p.length_v; total_size = stream->data.yuv420p.length_y + \ stream->data.yuv420p.length_u + \ stream->data.yuv420p.length_v; break; default: break; } } /* LOGD("format %d, %dx%d, size %d plane num %d", frame.format, frame.width, frame.height, total_size, frame.num_of_planes); */ return; } int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo, tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data) { int i = 0; int ret = CAMERA_ERROR_NONE; camera_media_packet_data *tmp_mp_data = NULL; if (*mp_data == NULL) { tmp_mp_data = g_new0(camera_media_packet_data, 1); if (tmp_mp_data) { tmp_mp_data->tbm_key = tbm_key; tmp_mp_data->num_buffer_key = num_buffer_key; tmp_mp_data->bo = bo; tmp_mp_data->data_bo = data_bo; tmp_mp_data->ref_cnt++; for (i = 0 ; i < num_buffer_key ; i++) tmp_mp_data->buffer_bo[i] = buffer_bo[i]; *mp_data = tmp_mp_data; /*LOGD("mp_data %p", tmp_mp_data);*/ } else { ret = CAMERA_ERROR_OUT_OF_MEMORY; LOGE("failed to alloc media packet data"); } } else { ((camera_media_packet_data *)*mp_data)->ref_cnt++; } return ret; } void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info) { int i = 0; int tbm_key = 0; camera_msg_param param; if (!mp_data || !cb_info) { LOGE("NULL pointer %p %p", mp_data, cb_info); return; } if (mp_data->ref_cnt > 1) { mp_data->ref_cnt--; LOGD("ref count %d", mp_data->ref_cnt); } else { /* release imported bo */ for (i = 0 ; i < mp_data->num_buffer_key ; i++) { tbm_bo_unref(mp_data->buffer_bo[i]); mp_data->buffer_bo[i] = NULL; } /* unref tbm bo */ _camera_release_imported_bo(&mp_data->bo); _camera_release_imported_bo(&mp_data->data_bo); /* return buffer */ tbm_key = mp_data->tbm_key; CAMERA_MSG_PARAM_SET(param, INT, tbm_key); _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); g_free(mp_data); mp_data = NULL; } return; } int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream, camera_media_packet_data *mp_data, media_packet_h *packet) { media_packet_h pkt = NULL; bool make_pkt_fmt = false; tbm_surface_h tsurf = NULL; tbm_surface_info_s tsurf_info; media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12; uint32_t bo_format = 0; int ret = 0; int i = 0; int num_buffer_key = 0; tbm_bo *buffer_bo = NULL; if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) { LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p", cb_info, stream, mp_data, packet); return CAMERA_ERROR_INVALID_PARAMETER; } memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s)); buffer_bo = mp_data->buffer_bo; num_buffer_key = mp_data->num_buffer_key; /* create tbm surface */ for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) tsurf_info.planes[i].stride = stream->stride[i]; /* get tbm surface format */ ret = _camera_get_tbm_surface_format(stream->format, &bo_format); ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype); if (ret == CAMERA_ERROR_NONE) { tsurf_info.width = stream->width; tsurf_info.height = stream->height; tsurf_info.format = bo_format; tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format); tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format); if (num_buffer_key > 0) { switch (bo_format) { case TBM_FORMAT_NV12: case TBM_FORMAT_NV21: tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0]; tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1]; tsurf_info.planes[0].offset = 0; if (num_buffer_key == 1) tsurf_info.planes[1].offset = tsurf_info.planes[0].size; tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size; break; case TBM_FORMAT_YUV420: case TBM_FORMAT_YVU420: tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0]; tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1]; tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2]; tsurf_info.planes[0].offset = 0; if (num_buffer_key == 1) { tsurf_info.planes[1].offset = tsurf_info.planes[0].size; tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size; } tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size; break; case TBM_FORMAT_UYVY: case TBM_FORMAT_YUYV: tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1; tsurf_info.planes[0].offset = 0; tsurf_info.size = tsurf_info.planes[0].size; break; default: break; } tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key); } else if (mp_data->data_bo) { switch (bo_format) { case TBM_FORMAT_NV12: case TBM_FORMAT_NV21: tsurf_info.planes[0].size = stream->width * stream->height; tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1; tsurf_info.planes[0].offset = 0; tsurf_info.planes[1].offset = tsurf_info.planes[0].size; tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size; break; case TBM_FORMAT_YUV420: case TBM_FORMAT_YVU420: tsurf_info.planes[0].size = stream->width * stream->height; tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1); tsurf_info.planes[2].size = tsurf_info.planes[1].size; tsurf_info.planes[0].offset = 0; tsurf_info.planes[1].offset = tsurf_info.planes[0].size; tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size; tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size; break; case TBM_FORMAT_UYVY: case TBM_FORMAT_YUYV: tsurf_info.planes[0].size = (stream->width * stream->height) << 1; tsurf_info.planes[0].offset = 0; tsurf_info.size = tsurf_info.planes[0].size; break; default: break; } tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1); } /*LOGD("tbm surface %p", tsurf);*/ } if (tsurf) { /* check media packet format */ if (cb_info->pkt_fmt) { int pkt_fmt_width = 0; int pkt_fmt_height = 0; media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12; media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL); if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != stream->width || pkt_fmt_height != stream->height) { LOGW("change fmt: current 0x%x, %dx%d", pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height); media_format_unref(cb_info->pkt_fmt); cb_info->pkt_fmt = NULL; make_pkt_fmt = true; } } else { make_pkt_fmt = true; } /* create packet format */ if (make_pkt_fmt) { LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height); ret = media_format_create(&cb_info->pkt_fmt); if (ret == MEDIA_FORMAT_ERROR_NONE) { ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype); ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width); ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height); LOGW("media_format_set : 0x%x", ret); } else { LOGW("media_format_create failed 0x%x", ret); } } /* create media packet */ ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)cb_info, &pkt); if (ret != MEDIA_PACKET_ERROR_NONE) { LOGE("media_packet_create failed 0x%x", ret); tbm_surface_destroy(tsurf); tsurf = NULL; } } else { LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p", stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo); } if (pkt) { /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/ /* set media packet data */ ret = media_packet_set_extra(pkt, (void *)mp_data); if (ret != MEDIA_PACKET_ERROR_NONE) { LOGE("media_packet_set_extra failed"); _camera_media_packet_data_release(mp_data, cb_info); mp_data = NULL; media_packet_destroy(pkt); pkt = NULL; } else { /* set timestamp : msec -> nsec */ if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE) LOGW("media_packet_set_pts failed"); *packet = pkt; } } return ret; } int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data) { int ret = 0; camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data; camera_media_packet_data *mp_data = NULL; tbm_surface_h tsurf = NULL; if (!pkt || !cb_info) { LOGE("NULL pointer %p %p", pkt, cb_info); return MEDIA_PACKET_FINALIZE; } ret = media_packet_get_extra(pkt, (void **)&mp_data); if (ret != MEDIA_PACKET_ERROR_NONE) { LOGE("media_packet_get_extra failed 0x%x", ret); return MEDIA_PACKET_FINALIZE; } /*LOGD("mp_data %p", mp_data);*/ g_mutex_lock(&cb_info->mp_data_mutex); _camera_media_packet_data_release(mp_data, cb_info); mp_data = NULL; g_mutex_unlock(&cb_info->mp_data_mutex); ret = media_packet_get_tbm_surface(pkt, &tsurf); if (ret != MEDIA_PACKET_ERROR_NONE) LOGE("get tbm_surface failed 0x%x", ret); if (tsurf) { tbm_surface_destroy(tsurf); tsurf = NULL; } return MEDIA_PACKET_FINALIZE; } static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event) { int param1 = 0; int param2 = 0; int tbm_key = 0; tbm_bo bo = NULL; tbm_bo_handle bo_handle = {NULL, }; camera_msg_param param; if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) { LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event); return; } /*LOGD("get camera msg %s, event %d", recv_msg, event);*/ if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) { if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) { LOGW("all preview callback from user are NULL"); return; } } else if (cb_info->user_cb[event] == NULL) { LOGW("user callback for event %d is not set", event); return; } switch (event) { case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE: { int previous = 0; int current = 0; int by_policy = 0; muse_camera_msg_get(previous, recv_msg); muse_camera_msg_get(current, recv_msg); muse_camera_msg_get(by_policy, recv_msg); LOGD("STATE CHANGE - previous %d, current %d, by_policy %d", previous, current, by_policy); ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous, (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]); } break; case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE: { int state = 0; muse_camera_msg_get(state, recv_msg); LOGD("FOCUS state - %d", state); ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]); } break; case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE: LOGD("CAPTURE_COMPLETED"); ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]); break; case MUSE_CAMERA_EVENT_TYPE_PREVIEW: case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW: { int i = 0; int ret = 0; int num_buffer_key = 0; int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, }; int data_key = 0; unsigned char *buf_pos = NULL; tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, }; tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, }; tbm_bo data_bo = NULL; tbm_bo_handle data_bo_handle = {.ptr = NULL}; camera_preview_data_s frame; camera_stream_data_s *stream = NULL; camera_media_packet_data *mp_data = NULL; media_packet_h pkt = NULL; muse_camera_msg_get(tbm_key, recv_msg); muse_camera_msg_get(num_buffer_key, recv_msg); muse_camera_msg_get_array(buffer_key, recv_msg); muse_camera_msg_get(data_key, recv_msg); memset(&frame, 0x0, sizeof(camera_preview_data_s)); if (tbm_key <= 0) { LOGE("invalid key %d", tbm_key); break; } CAMERA_MSG_PARAM_SET(param, INT, tbm_key); if (data_key > 0) { /* import tbm data_bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) { LOGE("failed to import data key %d", data_key); _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); break; } } /* import tbm bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) { LOGE("failed to import key %d", tbm_key); _camera_release_imported_bo(&data_bo); _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); break; } buf_pos = (unsigned char *)bo_handle.ptr; /* get stream info */ stream = (camera_stream_data_s *)buf_pos; for (i = 0 ; i < num_buffer_key ; i++) { /* import buffer bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) { LOGE("failed to import buffer key %d", buffer_key[i]); /* release imported bo */ _camera_release_imported_bo(&data_bo); _camera_release_imported_bo(&bo); for (i -= 1 ; i >= 0 ; i--) _camera_release_imported_bo(&buffer_bo[i]); /* send return buffer */ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); return; } } /* call preview callback */ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) { _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame); ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]); } /* call media packet callback */ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) { ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data); if (ret == CAMERA_ERROR_NONE) { ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt); if (ret == CAMERA_ERROR_NONE) { ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]); } else { _camera_media_packet_data_release(mp_data, cb_info); mp_data = NULL; } } } /* call evas renderer */ if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) { #ifdef TIZEN_FEATURE_EVAS_RENDERER ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data); if (ret == CAMERA_ERROR_NONE) { ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt); if (ret == CAMERA_ERROR_NONE) { g_mutex_lock(&cb_info->evas_mutex); if (cb_info->run_evas_render) { mm_evas_renderer_write(pkt, cb_info->evas_info); } else { LOGW("evas renderer is stopped, skip this buffer..."); media_packet_destroy(pkt); } pkt = NULL; g_mutex_unlock(&cb_info->evas_mutex); } else { _camera_media_packet_data_release(mp_data, cb_info); mp_data = NULL; } } #else /* TIZEN_FEATURE_EVAS_RENDERER */ LOGW("evas renderer is not supported"); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ } /* send message for preview callback return */ if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0); if (mp_data == NULL) { /* release imported bo */ for (i = 0 ; i < num_buffer_key ; i++) _camera_release_imported_bo(&buffer_bo[i]); /* unmap and unref tbm bo */ _camera_release_imported_bo(&data_bo); _camera_release_imported_bo(&bo); /* return buffer */ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); /*LOGD("return buffer Done");*/ } } break; case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS: { int percent = 0; muse_camera_msg_get(percent, recv_msg); LOGD("HDR progress - %d \%", percent); ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]); } break; case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED: { int policy = 0; int previous = 0; int current = 0; muse_camera_msg_get(policy, recv_msg); muse_camera_msg_get(previous, recv_msg); muse_camera_msg_get(current, recv_msg); LOGW("INTERRUPTED - policy %d, state previous %d, current %d", policy, previous, current); if (policy == CAMERA_POLICY_SOUND) LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release."); else if (policy == CAMERA_POLICY_SOUND_BY_CALL) LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release."); else if (policy == CAMERA_POLICY_SOUND_BY_ALARM) LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release."); ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy, (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]); } break; case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION: { int count = 0; camera_detected_face_s *faces = NULL; muse_camera_msg_get(count, recv_msg); muse_camera_msg_get(tbm_key, recv_msg); if (count > 0 && tbm_key > 0) { LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key); if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) break; /* set face info */ faces = bo_handle.ptr; ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]); #if 0 { int i = 0; for (i = 0 ; i < count ; i++) { LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)", i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height); } } #endif /* release bo */ _camera_release_imported_bo(&bo); /* return buffer */ CAMERA_MSG_PARAM_SET(param, INT, tbm_key); _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); /*LOGD("return buffer done");*/ } else { LOGE("invalid message - count %d, key %d", count, tbm_key); } } break; case MUSE_CAMERA_EVENT_TYPE_ERROR: { int error = 0; int current_state = 0; muse_camera_msg_get(error, recv_msg); muse_camera_msg_get(current_state, recv_msg); LOGE("ERROR - error 0x%x, current_state %d", error, current_state); if (error == CAMERA_ERROR_SOUND_POLICY) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release."); else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release."); else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM) LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release."); ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error, (camera_state_e)current_state, cb_info->user_data[event]); } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION: muse_camera_msg_get(param1, recv_msg); muse_camera_msg_get(param2, recv_msg); /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/ if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { cb_info->user_cb[event] = NULL; cb_info->user_data[event] = NULL; LOGW("stop foreach callback for event %d", event); } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE: /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE: muse_camera_msg_get(param1, recv_msg); /*LOGD("event %d SUPPORTED %d ", event, param1);*/ if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) { cb_info->user_cb[event] = NULL; cb_info->user_data[event] = NULL; LOGW("stop foreach callback for event %d", event); } break; case MUSE_CAMERA_EVENT_TYPE_CAPTURE: { camera_image_data_s *rImage = NULL; camera_image_data_s *rPostview = NULL; camera_image_data_s *rThumbnail = NULL; unsigned char *buf_pos = NULL; int tbm_key_main = 0; int tbm_key_post = 0; int tbm_key_thumb = 0; tbm_bo bo_main = NULL; tbm_bo bo_post = NULL; tbm_bo bo_thumb = NULL; tbm_bo_handle bo_main_handle = {NULL, }; tbm_bo_handle bo_post_handle = {NULL, }; tbm_bo_handle bo_thumb_handle = {NULL, }; muse_camera_msg_get(tbm_key_main, recv_msg); muse_camera_msg_get(tbm_key_post, recv_msg); muse_camera_msg_get(tbm_key_thumb, recv_msg); /* LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d", tbm_key_main, tbm_key_post, tbm_key_thumb); */ if (tbm_key_main <= 0) { LOGE("invalid key %d", tbm_key_main); break; } /* import tbm bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) break; buf_pos = (unsigned char *)bo_main_handle.ptr; rImage = (camera_image_data_s *)buf_pos; rImage->data = buf_pos + sizeof(camera_image_data_s); LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size); if (tbm_key_post > 0) { /* import tbm bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) break; buf_pos = (unsigned char *)bo_post_handle.ptr; rPostview = (camera_image_data_s *)buf_pos; LOGD("rPostview->size : %d", rPostview->size); rPostview->data = buf_pos + sizeof(camera_image_data_s); } if (tbm_key_thumb > 0) { /* import tbm bo and get virtual address */ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) break; buf_pos = (unsigned char *)bo_thumb_handle.ptr; rThumbnail = (camera_image_data_s *)buf_pos; LOGD("rThumbnail->size : %d", rThumbnail->size); rThumbnail->data = buf_pos + sizeof(camera_image_data_s); } ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]); /* unmap and unref tbm bo */ _camera_release_imported_bo(&bo_main); /* return buffer */ tbm_key = tbm_key_main; CAMERA_MSG_PARAM_SET(param, INT, tbm_key); _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); if (tbm_key_post > 0) { /* unmap and unref tbm bo */ _camera_release_imported_bo(&bo_post); /* return buffer */ param.value.value_INT = tbm_key_post; _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); } if (tbm_key_thumb > 0) { /* unmap and unref tbm bo */ _camera_release_imported_bo(&bo_thumb); /* return buffer */ param.value.value_INT = tbm_key_thumb; _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); } LOGD("return buffer done"); } break; case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR: break; default: LOGW("Unknown event : %d", event); break; } return; } static bool _camera_idle_event_callback(void *data) { camera_cb_info_s *cb_info = NULL; camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data; if (cam_idle_event == NULL) { LOGE("cam_idle_event is NULL"); return false; } /* lock event */ g_mutex_lock(&cam_idle_event->event_mutex); cb_info = cam_idle_event->cb_info; if (cb_info == NULL) { LOGW("camera cb_info is NULL. event %d", cam_idle_event->event); goto IDLE_EVENT_CALLBACK_DONE; } /* remove event from list */ g_mutex_lock(&cb_info->idle_event_mutex); if (cb_info->idle_event_list) cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event); /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/ g_mutex_unlock(&cb_info->idle_event_mutex); /* user callback */ _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event); /* send signal for waiting thread */ g_cond_signal(&cb_info->idle_event_cond); IDLE_EVENT_CALLBACK_DONE: /* unlock and release event */ g_mutex_unlock(&cam_idle_event->event_mutex); g_mutex_clear(&cam_idle_event->event_mutex); g_free(cam_idle_event); cam_idle_event = NULL; return false; } static void *_camera_msg_handler_func(gpointer data) { int api = 0; int type = 0; camera_message_s *cam_msg = NULL; camera_idle_event_s *cam_idle_event = NULL; camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data; camera_cb_info_s *cb_info = NULL; if (!handler_info || !handler_info->cb_info) { LOGE("t:%d NULL handler %p", type, handler_info); return NULL; } cb_info = (camera_cb_info_s *)handler_info->cb_info; type = handler_info->type; LOGD("t:%d start", type); g_mutex_lock(&handler_info->mutex); while (g_atomic_int_get(&handler_info->running)) { if (g_queue_is_empty(handler_info->queue)) { /*LOGD("t:%d signal wait...", type);*/ g_cond_wait(&handler_info->cond, &handler_info->mutex); /*LOGD("t:%d signal received", type);*/ if (g_atomic_int_get(&handler_info->running) == 0) { LOGD("t:%d stop event thread", type); break; } } cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue); g_mutex_unlock(&handler_info->mutex); if (cam_msg == NULL) { LOGE("t:%d NULL message", type); g_mutex_lock(&handler_info->mutex); continue; } api = cam_msg->api; if (api < MUSE_CAMERA_API_MAX) { int ret = 0; g_mutex_lock(&cb_info->api_mutex[api]); if (muse_camera_msg_get(ret, cam_msg->recv_msg)) { cb_info->api_ret[api] = ret; cb_info->api_activating[api] = 1; /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/ g_cond_signal(&cb_info->api_cond[api]); } else { LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg); } g_mutex_unlock(&cb_info->api_mutex[api]); } else if (api == MUSE_CAMERA_CB_EVENT) { switch (cam_msg->event_class) { case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB: _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event); break; case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN: cam_idle_event = g_new0(camera_idle_event_s, 1); if (cam_idle_event == NULL) { LOGE("t:%d cam_idle_event alloc failed", type); break; } cam_idle_event->event = cam_msg->event; cam_idle_event->cb_info = cb_info; g_mutex_init(&cam_idle_event->event_mutex); memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg)); /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, event, cam_idle_event);*/ g_mutex_lock(&cb_info->idle_event_mutex); cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event); g_mutex_unlock(&cb_info->idle_event_mutex); g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)_camera_idle_event_callback, (gpointer)cam_idle_event, NULL); break; default: LOGE("t:%d not handled event class %d", type, cam_msg->event_class); break; } } else { LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg); } g_free(cam_msg); cam_msg = NULL; g_mutex_lock(&handler_info->mutex); } /* remove remained event */ while (!g_queue_is_empty(handler_info->queue)) { cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue); if (cam_msg) { LOGD("t:%d remove camera message %p", type, cam_msg); free(cam_msg); cam_msg = NULL; } else { LOGW("t:%d NULL camera message", type); } } g_mutex_unlock(&handler_info->mutex); LOGD("t:%d return", type); return NULL; } static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info) { camera_idle_event_s *cam_idle_event = NULL; gboolean ret = TRUE; GList *list = NULL; gint64 end_time = 0; if (cb_info == NULL) { LOGE("cb_info is NULL"); return; } g_mutex_lock(&cb_info->idle_event_mutex); if (cb_info->idle_event_list == NULL) { LOGD("No remained idle event"); g_mutex_unlock(&cb_info->idle_event_mutex); return; } list = cb_info->idle_event_list; while (list) { cam_idle_event = list->data; list = g_list_next(list); if (!cam_idle_event) { LOGW("Fail to remove idle event. The event is NULL"); continue; } if (g_mutex_trylock(&cam_idle_event->event_mutex)) { ret = g_idle_remove_by_data(cam_idle_event); LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret); if (!ret) { cam_idle_event->cb_info = NULL; LOGW("idle event %p will be called later", cam_idle_event); } cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event); g_mutex_unlock(&cam_idle_event->event_mutex); if (ret) { g_mutex_clear(&cam_idle_event->event_mutex); g_free(cam_idle_event); cam_idle_event = NULL; LOGD("remove idle event done"); } continue; } LOGW("event lock failed. it's being called..."); end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100; if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time)) LOGW("signal received"); else LOGW("timeout"); } g_list_free(cb_info->idle_event_list); cb_info->idle_event_list = NULL; g_mutex_unlock(&cb_info->idle_event_mutex); return; } static void *_camera_msg_recv_func(gpointer data) { int i = 0; int ret = 0; int api = 0; int api_class = 0; int event = 0; int event_class = 0; int num_token = 0; int str_pos = 0; int prev_pos = 0; char *recv_msg = NULL; char **parse_str = NULL; camera_cb_info_s *cb_info = (camera_cb_info_s *)data; if (!cb_info) { LOGE("cb_info NULL"); return NULL; } LOGD("start"); parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE); if (parse_str == NULL) { LOGE("parse_str malloc failed"); return NULL; } for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) { parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH); if (parse_str[i] == NULL) { LOGE("parse_str[%d] malloc failed", i); goto CB_HANDLER_EXIT; } } recv_msg = cb_info->recv_msg; while (g_atomic_int_get(&cb_info->msg_recv_running)) { ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg); if (ret <= 0) break; recv_msg[ret] = '\0'; str_pos = 0; prev_pos = 0; num_token = 0; /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/ /* Need to split the combined entering msgs. This module supports up to 200 combined msgs. */ for (str_pos = 0; str_pos < ret; str_pos++) { if (recv_msg[str_pos] == '}') { strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1); /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/ prev_pos = str_pos + 1; num_token++; } } /*LOGD("num_token : %d", num_token);*/ /* Re-construct to the useful single msg. */ for (i = 0; i < num_token; i++) { if (i >= CAMERA_PARSE_STRING_SIZE) { LOGE("invalid token index %d", i); break; } api = -1; api_class = -1; event = -1; event_class = -1; if (!muse_camera_msg_get(api, parse_str[i])) { LOGE("failed to get camera api"); continue; } if (api == MUSE_CAMERA_CB_EVENT) { if (!muse_camera_msg_get(event, parse_str[i]) || !muse_camera_msg_get(event_class, parse_str[i])) { LOGE("failed to get camera event or event_class [%s]", parse_str[i]); continue; } } else { if (!muse_camera_msg_get(api_class, parse_str[i])) { LOGE("failed to get camera api_class [%s]", parse_str[i]); continue; } } if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) { if (api >= MUSE_CAMERA_API_MAX) { LOGE("invalid api %d", api); continue; } g_mutex_lock(&cb_info->api_mutex[api]); if (!muse_camera_msg_get(ret, parse_str[i])) { LOGE("failed to get camera ret"); g_mutex_unlock(&cb_info->api_mutex[api]); continue; } cb_info->api_ret[api] = ret; cb_info->api_activating[api] = 1; if (api == MUSE_CAMERA_API_CREATE) { if (ret != CAMERA_ERROR_NONE) { g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGE("camera create error 0x%x. close client cb handler", ret); } } else if (api == MUSE_CAMERA_API_DESTROY) { if (ret == CAMERA_ERROR_NONE) { g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGD("camera destroy done. close client cb handler"); } } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE) { g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGD("get flash state done. close client cb handler"); } g_cond_signal(&cb_info->api_cond[api]); g_mutex_unlock(&cb_info->api_mutex[api]); } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) { camera_message_s *cam_msg = g_new0(camera_message_s, 1); if (cam_msg == NULL) { LOGE("failed to alloc cam_msg"); continue; } cam_msg->api = api; cam_msg->event = event; cam_msg->event_class = event_class; memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg)); /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/ if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) { g_mutex_lock(&cb_info->preview_cb_info.mutex); g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg); g_cond_signal(&cb_info->preview_cb_info.cond); g_mutex_unlock(&cb_info->preview_cb_info.mutex); } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) { g_mutex_lock(&cb_info->capture_cb_info.mutex); g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg); g_cond_signal(&cb_info->capture_cb_info.cond); g_mutex_unlock(&cb_info->capture_cb_info.mutex); } else { g_mutex_lock(&cb_info->msg_handler_info.mutex); g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg); g_cond_signal(&cb_info->msg_handler_info.cond); g_mutex_unlock(&cb_info->msg_handler_info.mutex); } } else { LOGW("unknown camera api %d, class %d", api, api_class); } } } LOGD("client cb exit"); CB_HANDLER_EXIT: if (parse_str) { for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) { if (parse_str[i]) { free(parse_str[i]); parse_str[i] = NULL; } } free(parse_str); parse_str = NULL; } return NULL; } static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info, int type, const char *thread_name, camera_cb_info_s *cb_info) { if (!handler_info || !thread_name || !cb_info) { LOGE("t:%d NULL %p %p %p", type, handler_info, thread_name, cb_info); return false; } LOGD("t:%d", type); handler_info->type = type; handler_info->queue = g_queue_new(); if (handler_info->queue == NULL) { LOGE("t:%d queue failed", type); return false; } g_mutex_init(&handler_info->mutex); g_cond_init(&handler_info->cond); handler_info->cb_info = (void *)cb_info; g_atomic_int_set(&handler_info->running, 1); handler_info->thread = g_thread_try_new(thread_name, _camera_msg_handler_func, (gpointer)handler_info, NULL); if (handler_info->thread == NULL) { LOGE("t:%d thread failed", type); g_mutex_clear(&handler_info->mutex); g_cond_clear(&handler_info->cond); g_queue_free(handler_info->queue); handler_info->queue = NULL; return false; } LOGD("t:%d done", type); return true; } static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info) { int type = 0; if (!handler_info) { LOGE("NULL handler"); return; } if (!handler_info->thread) { LOGW("thread is not created"); return; } type = handler_info->type; LOGD("t:%d thread %p", type, handler_info->thread); g_mutex_lock(&handler_info->mutex); g_atomic_int_set(&handler_info->running, 0); g_cond_signal(&handler_info->cond); g_mutex_unlock(&handler_info->mutex); g_thread_join(handler_info->thread); g_thread_unref(handler_info->thread); handler_info->thread = NULL; g_mutex_clear(&handler_info->mutex); g_cond_clear(&handler_info->cond); g_queue_free(handler_info->queue); handler_info->queue = NULL; LOGD("t:%d done", type); return; } static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread) { camera_cb_info_s *cb_info = NULL; gint i = 0; g_return_val_if_fail(sockfd > 0, NULL); cb_info = g_new0(camera_cb_info_s, 1); if (cb_info == NULL) { LOGE("cb_info failed"); goto ErrorExit; } for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) { g_mutex_init(&cb_info->api_mutex[i]); g_cond_init(&cb_info->api_cond[i]); } g_mutex_init(&cb_info->idle_event_mutex); g_cond_init(&cb_info->idle_event_cond); g_mutex_init(&cb_info->mp_data_mutex); #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_init(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ if (need_msg_handler_thread) { /* message handler thread */ if (!__create_msg_handler_thread(&cb_info->msg_handler_info, CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) { LOGE("msg_handler_info failed"); goto ErrorExit; } /* message handler thread for preview callback */ if (!__create_msg_handler_thread(&cb_info->preview_cb_info, CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) { LOGE("preview_cb_info failed"); goto ErrorExit; } /* message handler thread for capture callback */ if (!__create_msg_handler_thread(&cb_info->capture_cb_info, CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) { LOGE("capture_cb_info failed"); goto ErrorExit; } } cb_info->fd = sockfd; cb_info->preview_cb_flag = 0; #ifdef TIZEN_FEATURE_EVAS_RENDERER cb_info->evas_info = NULL; #endif /* TIZEN_FEATURE_EVAS_RENDERER */ /* message receive thread */ g_atomic_int_set(&cb_info->msg_recv_running, 1); cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv", _camera_msg_recv_func, (gpointer)cb_info, NULL); if (cb_info->msg_recv_thread == NULL) { LOGE("message receive thread creation failed"); goto ErrorExit; } return cb_info; ErrorExit: if (cb_info) { __destroy_msg_handler_thread(&cb_info->msg_handler_info); __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_clear(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) { g_mutex_clear(&cb_info->api_mutex[i]); g_cond_clear(&cb_info->api_cond[i]); } g_free(cb_info); cb_info = NULL; } return NULL; } static void _camera_client_callback_destroy(camera_cb_info_s *cb_info) { int i = 0; g_return_if_fail(cb_info != NULL); LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread); g_thread_join(cb_info->msg_recv_thread); g_thread_unref(cb_info->msg_recv_thread); cb_info->msg_recv_thread = NULL; LOGD("msg_recv thread removed"); /* destroy msg handler threads */ __destroy_msg_handler_thread(&cb_info->msg_handler_info); __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_clear(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) { g_mutex_clear(&cb_info->api_mutex[i]); g_cond_clear(&cb_info->api_cond[i]); } if (cb_info->fd > -1) { muse_core_connection_close(cb_info->fd); cb_info->fd = -1; } if (cb_info->bufmgr) { tbm_bufmgr_deinit(cb_info->bufmgr); cb_info->bufmgr = NULL; } if (cb_info->pkt_fmt) { media_format_unref(cb_info->pkt_fmt); cb_info->pkt_fmt = NULL; } #ifdef TIZEN_FEATURE_EVAS_RENDERER if (cb_info->evas_info) mm_evas_renderer_destroy(&cb_info->evas_info); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ cb_info->preview_cb_flag = 0; g_free(cb_info); cb_info = NULL; return; } int _camera_start_evas_rendering(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("start"); if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { LOGE("EVAS surface is not set"); return CAMERA_ERROR_NONE; } #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_lock(&pc->cb_info->evas_mutex); /* set evas render flag as RUN */ pc->cb_info->run_evas_render = true; ret = CAMERA_ERROR_NONE; g_mutex_unlock(&pc->cb_info->evas_mutex); #else /* TIZEN_FEATURE_EVAS_RENDERER */ LOGW("evas renderer is not supported"); ret = CAMERA_ERROR_NOT_SUPPORTED; #endif /* TIZEN_FEATURE_EVAS_RENDERER */ return ret; } int _camera_stop_evas_rendering(camera_h camera, bool keep_screen) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("stop - keep screen %d", keep_screen); if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { LOGE("EVAS surface is not set"); return CAMERA_ERROR_NONE; } #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_lock(&pc->cb_info->evas_mutex); /* set evas render flag as STOP and release buffers */ pc->cb_info->run_evas_render = false; ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen); if (ret != MM_ERROR_NONE) { LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret); ret = CAMERA_ERROR_INVALID_OPERATION; } g_mutex_unlock(&pc->cb_info->evas_mutex); #else /* TIZEN_FEATURE_EVAS_RENDERER */ LOGW("evas renderer is not supported"); ret = CAMERA_ERROR_NOT_SUPPORTED; #endif /* TIZEN_FEATURE_EVAS_RENDERER */ return ret; } int camera_create(camera_device_e device, camera_h *camera) { int sock_fd = -1; char *send_msg = NULL; int send_ret = 0; int ret = CAMERA_ERROR_NONE; int pid = 0; camera_cli_s *pc = NULL; tbm_bufmgr bufmgr = NULL; muse_camera_api_e api = MUSE_CAMERA_API_CREATE; muse_core_api_module_e muse_module = MUSE_CAMERA; int device_type = (int)device; if (!camera) { LOGE("NULL pointer"); return CAMERA_ERROR_INVALID_PARAMETER; } sock_fd = muse_core_client_new(); if (sock_fd < 0) { LOGE("muse_core_client_new failed - returned fd %d", sock_fd); ret = CAMERA_ERROR_INVALID_OPERATION; goto ErrorExit; } pid = getpid(); send_msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_INT, "module", muse_module, MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type, MUSE_TYPE_INT, "pid", pid, 0); if (!send_msg) { LOGE("NULL msg"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto ErrorExit; } send_ret = muse_core_ipc_send_msg(sock_fd, send_msg); muse_core_msg_json_factory_free(send_msg); send_msg = NULL; if (send_ret < 0) { LOGE("send msg failed %d", errno); ret = CAMERA_ERROR_INVALID_OPERATION; goto ErrorExit; } pc = g_new0(camera_cli_s, 1); if (pc == NULL) { LOGE("camera_cli_s alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto ErrorExit; } bufmgr = tbm_bufmgr_init(-1); if (bufmgr == NULL) { LOGE("get tbm bufmgr failed"); ret = CAMERA_ERROR_INVALID_OPERATION; goto ErrorExit; } pc->cb_info = _camera_client_callback_new(sock_fd, true); if (pc->cb_info == NULL) { LOGE("cb_info alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto ErrorExit; } sock_fd = -1; LOGD("cb info : %d", pc->cb_info->fd); ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { intptr_t handle = 0; muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg); if (handle == 0) { LOGE("Receiving Handle Failed!!"); ret = CAMERA_ERROR_INVALID_OPERATION; goto ErrorExit; } pc->remote_handle = handle; pc->cb_info->bufmgr = bufmgr; ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL); if (ret != CAMERA_ERROR_NONE) { LOGE("init display failed 0x%x", ret); goto ErrorExit; } LOGD("camera create 0x%x", pc->remote_handle); *camera = (camera_h)pc; } else { goto ErrorExit; } return ret; ErrorExit: if (bufmgr) { tbm_bufmgr_deinit(bufmgr); bufmgr = NULL; } if (sock_fd > -1) { muse_core_connection_close(sock_fd); sock_fd = -1; } if (pc) { if (pc->cb_info) { _camera_client_callback_destroy(pc->cb_info); pc->cb_info = NULL; } g_free(pc); pc = NULL; } LOGE("camera create error : 0x%x", ret); return ret; } int camera_change_device(camera_h camera, camera_device_e device) { int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } CAMERA_MSG_PARAM_SET(param, INT, device); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_destroy(camera_h camera) { int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_DESTROY; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { _camera_remove_idle_event_all(pc->cb_info); _camera_client_callback_destroy(pc->cb_info); pc->cb_info = NULL; g_free(pc); pc = NULL; } return ret; } int camera_start_preview(camera_h camera) { int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG); if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { ret = _camera_start_evas_rendering(camera); if (ret != CAMERA_ERROR_NONE) { LOGE("stop preview because of error"); _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0); } } LOGD("ret : 0x%x", ret); return ret; } int camera_stop_preview(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW; camera_state_e current_state = CAMERA_STATE_NONE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { ret = camera_get_state(camera, ¤t_state); if (ret != CAMERA_ERROR_NONE) { LOGE("failed to get current state 0x%x", ret); return ret; } if (current_state == CAMERA_STATE_PREVIEW) { ret = _camera_stop_evas_rendering(camera, false); if (ret != CAMERA_ERROR_NONE) return ret; } } /* send stop preview message */ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret != CAMERA_ERROR_NONE && current_state == CAMERA_STATE_PREVIEW) { LOGW("restart evas rendering"); _camera_start_evas_rendering(camera); } LOGD("ret : 0x%x", ret); return ret; } int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } bool camera_is_supported_continuous_capture(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return (bool)ret; } 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) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE; camera_msg_param param; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; value = (count << 16) | interval; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_stop_continuous_capture(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } bool camera_is_supported_face_detection(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return (bool)ret; } bool camera_is_supported_zero_shutter_lag(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return (bool)ret; } bool camera_is_supported_media_packet_preview_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return (bool)ret; } int camera_get_device_count(camera_h camera, int *device_count) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT; int get_device_count = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg); *device_count = get_device_count; } LOGD("ret : 0x%x", ret); return ret; } int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_stop_face_detection(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_get_state(camera_h camera, camera_state_e *state) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE; int get_state = CAMERA_STATE_NONE; if (!pc || !pc->cb_info || !state) { LOGE("NULL pointer %p %p", pc, state); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_state, pc->cb_info->recv_msg); *state = (camera_state_e)get_state; } LOGD("ret : 0x%x", ret); return ret; } int camera_start_focusing(camera_h camera, bool continuous) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING; camera_msg_param param; int is_continuous = (int)continuous; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, is_continuous); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_cancel_focusing(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter, remote_handle : %x", pc->remote_handle); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display) { int ret = CAMERA_ERROR_NONE; void *set_display_handle = NULL; Evas_Object *obj = NULL; const char *object_type = NULL; camera_cli_s *pc = (camera_cli_s *)camera; camera_cb_info_s *cb_info = NULL; muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY; camera_state_e current_state = CAMERA_STATE_NONE; camera_msg_param param; char *msg = NULL; int length = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) { LOGE("invalid type %d", type); return CAMERA_ERROR_INVALID_PARAMETER; } if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) { LOGE("display type[%d] is not NONE, but display handle is NULL", type); return CAMERA_ERROR_INVALID_PARAMETER; } cb_info = (camera_cb_info_s *)pc->cb_info; ret = camera_get_state(camera, ¤t_state); if (ret != CAMERA_ERROR_NONE) { LOGE("failed to get current state 0x%x", ret); return ret; } if (current_state != CAMERA_STATE_CREATED) { LOGE("INVALID_STATE : current %d", current_state); return CAMERA_ERROR_INVALID_STATE; } LOGD("Enter - display : %p", display); if (type == CAMERA_DISPLAY_TYPE_NONE) { set_display_handle = 0; LOGD("display type NONE"); } else { obj = (Evas_Object *)display; object_type = evas_object_type_get(obj); if (object_type) { if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) { /* get wayland parent id */ if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) { LOGE("failed to get wayland info"); return CAMERA_ERROR_INVALID_OPERATION; } set_display_handle = (void *)&pc->wl_info; LOGD("display type OVERLAY : handle %p", set_display_handle); } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) { /* evas object surface */ set_display_handle = (void *)display; LOGD("display type EVAS : handle %p", set_display_handle); #ifdef TIZEN_FEATURE_EVAS_RENDERER g_mutex_lock(&cb_info->evas_mutex); if (cb_info->evas_info) { LOGW("destroy existed evas renderer %p", cb_info->evas_info); ret = mm_evas_renderer_destroy(&cb_info->evas_info); if (ret != MM_ERROR_NONE) { LOGE("failed to destroy evas renderer %p", cb_info->evas_info); g_mutex_unlock(&cb_info->evas_mutex); return CAMERA_ERROR_INVALID_OPERATION; } } /* create evas renderer */ ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle); if (ret == MM_ERROR_NONE) { camera_flip_e flip = CAMERA_FLIP_NONE; camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX; camera_rotation_e rotation = CAMERA_ROTATION_NONE; bool visible = 0; int x = 0; int y = 0; int width = 0; int height = 0; camera_get_display_flip(camera, &flip); camera_get_display_mode(camera, &mode); camera_get_display_rotation(camera, &rotation); camera_is_display_visible(camera, &visible); camera_attr_get_display_roi_area(camera, &x, &y, &width, &height); LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d", flip, mode, rotation, visible, x, y, width, height); ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip); ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode); ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation); ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible); if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI) ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height); } g_mutex_unlock(&cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("mm_evas_renderer error 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } #else /* TIZEN_FEATURE_EVAS_RENDERER */ LOGE("EVAS surface is not supported"); return CAMERA_ERROR_NOT_SUPPORTED; #endif /* TIZEN_FEATURE_EVAS_RENDERER */ } else { LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type); return CAMERA_ERROR_INVALID_PARAMETER; } } else { LOGE("failed to get evas object type from %p", obj); return CAMERA_ERROR_INVALID_PARAMETER; } } pc->display_handle = (intptr_t)set_display_handle; if (type == CAMERA_DISPLAY_TYPE_OVERLAY) { length = sizeof(camera_wl_info_s) / sizeof(int) + \ (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0); msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_INT, "type", type, MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info, NULL); if (!msg) { LOGE("msg creation failed: api %d", api); return CAMERA_ERROR_OUT_OF_MEMORY; } if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { LOGE("message send failed"); ret = CAMERA_ERROR_INVALID_OPERATION; } else { ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); } muse_core_msg_json_factory_free(msg); LOGD("wayland parent id : %d, window %d,%d,%dx%d", pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y, pc->wl_info.window_width, pc->wl_info.window_height); } else { CAMERA_MSG_PARAM_SET(param, INT, type); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); } if (ret != CAMERA_ERROR_NONE) LOGE("set display error 0x%x", ret); else if (type == CAMERA_DISPLAY_TYPE_EVAS) SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS); return ret; } int camera_set_preview_resolution(camera_h camera, int width, int height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION; camera_msg_param param; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } value = (width << 16) | height; CAMERA_MSG_PARAM_SET(param, INT, value); LOGD("%dx%d -> 0x%x", width, height, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_capture_resolution(camera_h camera, int width, int height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION; camera_msg_param param; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); value = (width << 16) | height; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_capture_format(camera_h camera, camera_pixel_format_e format) { int ret = CAMERA_ERROR_NONE; int set_format = (int)format; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter - format %d", set_format); CAMERA_MSG_PARAM_SET(param, INT, set_format); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_preview_format(camera_h camera, camera_pixel_format_e format) { int ret = CAMERA_ERROR_NONE; int set_format = (int)format; camera_msg_param param; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter - capture_format %d", set_format); CAMERA_MSG_PARAM_SET(param, INT, set_format); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_get_preview_resolution(camera_h camera, int *width, int *height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION; int get_width = 0; int get_height = 0; if (!pc || !pc->cb_info || !width || !height) { LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); muse_camera_msg_get(get_height, pc->cb_info->recv_msg); *width = get_width; *height = get_height; } LOGD("ret : 0x%x", ret); return ret; } int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation) { int ret = CAMERA_ERROR_NONE; int set_rotation = (int)rotation; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { g_mutex_lock(&pc->cb_info->evas_mutex); ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation); g_mutex_unlock(&pc->cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("failed to set rotation for evas surface 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ CAMERA_MSG_PARAM_SET(param, INT, set_rotation); _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation) { int ret = CAMERA_ERROR_NONE; int get_rotation = CAMERA_ROTATION_NONE; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info || !rotation) { LOGE("NULL pointer %p %p", pc, rotation); return CAMERA_ERROR_INVALID_PARAMETER; } _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); *rotation = (camera_rotation_e)get_rotation; } return ret; } int camera_set_display_flip(camera_h camera, camera_flip_e flip) { int ret = CAMERA_ERROR_NONE; int set_flip = (int)flip; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { g_mutex_lock(&pc->cb_info->evas_mutex); ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip); g_mutex_unlock(&pc->cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("failed to set flip for evas surface 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ CAMERA_MSG_PARAM_SET(param, INT, set_flip); _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_get_display_flip(camera_h camera, camera_flip_e *flip) { int ret = CAMERA_ERROR_NONE; int get_flip = CAMERA_FLIP_NONE; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info || !flip) { LOGE("NULL pointer %p %p", pc, flip); return CAMERA_ERROR_INVALID_PARAMETER; } _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); *flip = (camera_flip_e)get_flip; } return ret; } int camera_set_display_visible(camera_h camera, bool visible) { int ret = CAMERA_ERROR_NONE; int set_visible = (int)visible; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { g_mutex_lock(&pc->cb_info->evas_mutex); ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible); g_mutex_unlock(&pc->cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("failed to set visible for evas surface 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ CAMERA_MSG_PARAM_SET(param, INT, set_visible); _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_is_display_visible(camera_h camera, bool *visible) { int ret = CAMERA_ERROR_NONE; int get_visible = true; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info || !visible) { LOGE("NULL pointer %p %p", pc, visible); return CAMERA_ERROR_INVALID_PARAMETER; } _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_visible, pc->cb_info->recv_msg); *visible = (bool)get_visible; } return ret; } int camera_set_display_mode(camera_h camera, camera_display_mode_e mode) { int ret = CAMERA_ERROR_NONE; int set_mode = (int)mode; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { g_mutex_lock(&pc->cb_info->evas_mutex); ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode); g_mutex_unlock(&pc->cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("failed to set geometry for evas surface 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode) { int ret = CAMERA_ERROR_NONE; int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX; camera_cli_s *pc = (camera_cli_s *)camera; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_display_mode_e)get_mode; } return ret; } int camera_set_display_reuse_hint(camera_h camera, bool hint) { int ret = CAMERA_ERROR_NONE; int set_hint = (int)hint; camera_cli_s *pc = (camera_cli_s *)camera; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter - hint %d", set_hint); CAMERA_MSG_PARAM_SET(param, INT, set_hint); _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_get_display_reuse_hint(camera_h camera, bool *hint) { int ret = CAMERA_ERROR_NONE; int get_hint = 0; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT; if (!pc || !pc->cb_info || !hint) { LOGE("NULL pointer %p %p", pc, hint); return CAMERA_ERROR_INVALID_PARAMETER; } _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_hint, pc->cb_info->recv_msg); *hint = (bool)get_hint; LOGD("display reuse hint %d", *hint); } return ret; } int camera_get_capture_resolution(camera_h camera, int *width, int *height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION; int get_width = 0; int get_height = 0; if (!pc || !pc->cb_info || !width || !height) { LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); muse_camera_msg_get(get_height, pc->cb_info->recv_msg); *width = get_width; *height = get_height; } LOGD("ret : 0x%x", ret); return ret; } int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT; int get_format = 0; if (!pc || !pc->cb_info || !format) { LOGE("NULL pointer %p %p", pc, format); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_format, pc->cb_info->recv_msg); *format = (camera_pixel_format_e)get_format; } LOGD("ret : 0x%x", ret); return ret; } int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT; int get_format = 0; if (!pc || !pc->cb_info || !format) { LOGE("NULL pointer %p %p", pc, format); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_format, pc->cb_info->recv_msg); *format = (camera_pixel_format_e)get_format; } LOGD("ret : 0x%x", ret); return ret; } int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION; int get_facing_direction = 0; if (!pc || !pc->cb_info || !facing_direction) { LOGE("NULL pointer %p %p", pc, facing_direction); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg); *facing_direction = (camera_facing_direction_e)get_facing_direction; } LOGD("ret : 0x%x", ret); return ret; } int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB; if (!pc || !pc->cb_info || !callback) { LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data; SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_preview_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } if (camera_is_supported_media_packet_preview_cb(camera) == false) { LOGE("NOT SUPPORTED"); return CAMERA_ERROR_NOT_SUPPORTED; } if (callback == NULL) { LOGE("NULL callback"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_media_packet_preview_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB; if (!pc || !pc->cb_info || !callback) { LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_state_changed_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB; if (!pc || !pc->cb_info || !callback) { LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_interrupted_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB; if (!pc || !pc->cb_info || !callback) { LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_focus_changed_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB; if (!pc || !pc->cb_info || !callback) { LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_unset_error_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION; int get_width = 0; int get_height = 0; if (!pc || !pc->cb_info || !width || !height) { LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); muse_camera_msg_get(get_height, pc->cb_info->recv_msg); *width = get_width; *height = get_height; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_lens_orientation(camera_h camera, int *angle) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION; int get_angle = 0; if (!pc || !pc->cb_info || !angle) { LOGE("NULL pointer %p %p", pc, angle); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_angle, pc->cb_info->recv_msg); *angle = get_angle; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_theater_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("Finish, return :%x", ret); return ret; } int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS; camera_msg_param param; int set_fps = (int)fps; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_fps); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_image_quality(camera_h camera, int quality) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, quality); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS; int get_fps = 0; if (!pc || !pc->cb_info || !fps) { LOGE("NULL pointer %p %p", pc, fps); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_fps, pc->cb_info->recv_msg); *fps = (camera_attr_fps_e)get_fps; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_image_quality(camera_h camera, int *quality) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY; int get_quality = 0; if (!pc || !pc->cb_info || !quality) { LOGE("NULL pointer %p %p", pc, quality); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_quality, pc->cb_info->recv_msg); *quality = get_quality; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE; int get_bitrate = 0; if (!pc || !pc->cb_info || !bitrate) { LOGE("NULL pointer %p %p", pc, bitrate); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg); *bitrate = get_bitrate; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE; camera_msg_param param; int set_bitrate = bitrate; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_bitrate); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL; int get_gop_interval = 0; if (!pc || !pc->cb_info || !interval) { LOGE("NULL pointer %p %p", pc, interval); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg); *interval = get_gop_interval; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL; camera_msg_param param; int set_gop_interval = interval; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_zoom(camera_h camera, int zoom) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter, remote_handle : %x", pc->remote_handle); CAMERA_MSG_PARAM_SET(param, INT, zoom); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter, remote_handle : %x", pc->remote_handle); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } int camera_attr_set_af_area(camera_h camera, int x, int y) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA; camera_msg_param param; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter - %d,%d", x, y); value = (x << 16) | y; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_clear_af_area(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_exposure(camera_h camera, int value) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO; camera_msg_param param; int set_iso = (int)iso; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_iso); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_brightness(camera_h camera, int level) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, level); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_contrast(camera_h camera, int level) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST; camera_msg_param param; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, level); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE; camera_msg_param param; int set_whitebalance = (int)wb; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT; camera_msg_param param; int set_effect = (int)effect; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_effect); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_enable_tag(camera_h camera, bool enable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG; camera_msg_param param; int set_enable = (int)enable; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_enable); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_tag_image_description(camera_h camera, const char *description) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION; camera_msg_param param; if (!pc || !pc->cb_info || !description) { LOGE("NULL pointer %p %p", pc, description); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, STRING, description); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION; camera_msg_param param; int set_orientation = (int)orientation; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_orientation); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_tag_software(camera_h camera, const char *software) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE; camera_msg_param param; if (!pc || !pc->cb_info || !software) { LOGE("NULL pointer %p %p", pc, software); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter, remote_handle : %x", pc->remote_handle); CAMERA_MSG_PARAM_SET(param, STRING, software); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG; double set_geotag[3] = {latitude, longitude, altitude}; char *msg = NULL; int length = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); length = sizeof(set_geotag) / sizeof(int) + \ (sizeof(set_geotag) % sizeof(int) ? 1 : 0); msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag, NULL); if (!msg) { LOGE("msg creation failed: api %d", api); return CAMERA_ERROR_OUT_OF_MEMORY; } if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { LOGE("message send failed"); ret = CAMERA_ERROR_INVALID_OPERATION; } else { ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); } muse_core_msg_json_factory_free(msg); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_remove_geotag(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_zoom(camera_h camera, int *zoom) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM; int get_zoom = 0; if (!pc || !pc->cb_info || !zoom) { LOGE("NULL pointer %p %p", pc, zoom); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg); *zoom = get_zoom; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_zoom_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_af_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_exposure_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_exposure(camera_h camera, int *value) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE; int get_value = 0; if (!pc || !pc->cb_info || !value) { LOGE("NULL pointer %p %p", pc, value); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_value, pc->cb_info->recv_msg); *value = get_value; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_exposure_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO; int get_iso = 0; if (!pc || !pc->cb_info || !iso) { LOGE("NULL pointer %p %p", pc, iso); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_iso, pc->cb_info->recv_msg); *iso = (camera_attr_iso_e)get_iso; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_brightness(camera_h camera, int *level) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS; int get_level = 0; if (!pc || !pc->cb_info || !level) { LOGE("NULL pointer %p %p", pc, level); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_level, pc->cb_info->recv_msg); *level = get_level; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_brightness_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_contrast(camera_h camera, int *level) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST; int get_level = 0; if (!pc || !pc->cb_info || !level) { LOGE("NULL pointer %p %p", pc, level); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_level, pc->cb_info->recv_msg); *level = get_level; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_contrast_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE; int get_wb = 0; if (!pc || !pc->cb_info || !wb) { LOGE("NULL pointer %p %p", pc, wb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_wb, pc->cb_info->recv_msg); *wb = (camera_attr_whitebalance_e)get_wb; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT; int get_effect = 0; if (!pc || !pc->cb_info || !effect) { LOGE("NULL pointer %p %p", pc, effect); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_effect, pc->cb_info->recv_msg); *effect = (camera_attr_effect_mode_e)get_effect; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_scene_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_is_enabled_tag(camera_h camera, bool *enable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG; int get_enabled = 0; if (!pc || !pc->cb_info || !enable) { LOGE("NULL pointer %p %p", pc, enable); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enable = (bool)get_enabled; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_tag_image_description(camera_h camera, char **description) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION; char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, }; if (!pc || !pc->cb_info || !description) { LOGE("NULL pointer %p %p", pc, description); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg); *description = strdup(get_description); } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION; int get_orientation = 0; if (!pc || !pc->cb_info || !orientation) { LOGE("NULL pointer %p %p", pc, orientation); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg); *orientation = (camera_attr_tag_orientation_e)get_orientation; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_tag_software(camera_h camera, char **software) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE; char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, }; if (!pc || !pc->cb_info || !software) { LOGE("NULL pointer %p %p", pc, software); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg); *software = strdup(get_software); } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG; double get_geotag[3] = {0.0, }; if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) { LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg); *latitude = get_geotag[0]; *longitude = get_geotag[1]; *altitude = get_geotag[2]; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_flash_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state) { int sock_fd = -1; char *msg = NULL; int ret = CAMERA_ERROR_NONE; int send_ret = 0; camera_cli_s *pc = NULL; int get_flash_state = 0; /* create muse connection */ muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE; muse_core_api_module_e muse_module = MUSE_CAMERA; int device_type = (int)device; if (!state) { LOGE("NULL pointer"); return CAMERA_ERROR_INVALID_PARAMETER; } sock_fd = muse_core_client_new(); if (sock_fd < 0) { LOGE("muse_core_client_new failed"); return CAMERA_ERROR_INVALID_OPERATION; } msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_INT, "module", muse_module, MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type, 0); if (!msg) { LOGE("msg failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto Exit; } send_ret = muse_core_ipc_send_msg(sock_fd, msg); muse_core_msg_json_factory_free(msg); msg = NULL; if (send_ret < 0) { LOGE("send msg failed"); ret = CAMERA_ERROR_INVALID_OPERATION; goto Exit; } pc = g_new0(camera_cli_s, 1); if (!pc) { LOGE("handle alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto Exit; } pc->cb_info = _camera_client_callback_new(sock_fd, false); if (!pc->cb_info) { LOGE("cb_info alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto Exit; } sock_fd = -1; ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg); *state = (camera_flash_state_e)get_flash_state; } LOGD("Flash state : %d", *state); Exit: /* release resources */ if (pc) { if (pc->cb_info) { _camera_client_callback_destroy(pc->cb_info); pc->cb_info = NULL; } g_free(pc); pc = NULL; } if (sock_fd > -1) { muse_core_connection_close(sock_fd); sock_fd = -1; } return ret; } int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("Enter, handle :%x", pc->remote_handle); return ret; } 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) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION; camera_msg_param param; int value = 0; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data; value = (width << 16) | height; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION; camera_msg_param param; int set_rotation = (int)rotation; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_rotation); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION; int get_rotation = 0; if (!pc || !pc->cb_info || !rotation) { LOGE("NULL pointer %p %p", pc, rotation); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); *rotation = (camera_rotation_e)get_rotation; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP; camera_msg_param param; int set_flip = (int)flip; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_flip); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP; int get_flip = 0; if (!pc || !pc->cb_info || !flip) { LOGE("NULL pointer %p %p", pc, flip); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); *flip = (camera_flip_e)get_flip; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE; camera_msg_param param; int set_mode = (int)mode; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_mode); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE; int get_mode = 0; if (!pc || !pc->cb_info || !mode) { LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_hdr_mode_e)get_mode; } LOGD("ret : 0x%x", ret); return ret; } bool camera_attr_is_supported_hdr_capture(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return (bool)ret; } int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); if (!camera_attr_is_supported_hdr_capture(camera)) { LOGE("HDR not supported"); return CAMERA_ERROR_NOT_SUPPORTED; } if (!callback) { LOGE("NULL callback"); return CAMERA_ERROR_INVALID_PARAMETER; } pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_unset_hdr_capture_progress_cb(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_enable_anti_shake(camera_h camera, bool enable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE; camera_msg_param param; int set_enable = (int)enable; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_enable); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE; int get_enabled = 0; if (!pc || !pc->cb_info || !enabled) { LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } LOGD("ret : 0x%x", ret); return ret; } bool camera_attr_is_supported_anti_shake(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_enable_video_stabilization(camera_h camera, bool enable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION; camera_msg_param param; int set_enable = (int)enable; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_enable); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION; int get_enabled = 0; if (!pc || !pc->cb_info || !enabled) { LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } LOGD("ret : 0x%x", ret); return ret; } bool camera_attr_is_supported_video_stabilization(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_enable_auto_contrast(camera_h camera, bool enable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST; camera_msg_param param; int set_enable = (int)enable; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_enable); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST; int get_enabled = 0; if (!pc || !pc->cb_info || !enabled) { LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } LOGD("ret : 0x%x", ret); return ret; } bool camera_attr_is_supported_auto_contrast(camera_h camera) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_disable_shutter_sound(camera_h camera, bool disable) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND; camera_msg_param param; int set_disable = (int)disable; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_disable); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN; camera_msg_param param; int set_move_type = (int)move_type; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); value = (set_move_type << 16) | pan_step; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_pan(camera_h camera, int *pan_step) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN; int get_pan_step = 0; if (!pc || !pc->cb_info || !pan_step) { LOGE("NULL pointer %p %p", pc, pan_step); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg); *pan_step = get_pan_step; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_pan_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT; camera_msg_param param; int set_move_type = (int)move_type; int value = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); value = (set_move_type << 16) | tilt_step; CAMERA_MSG_PARAM_SET(param, INT, value); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_tilt(camera_h camera, int *tilt_step) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT; int get_tilt_step = 0; if (!pc || !pc->cb_info || !tilt_step) { LOGE("NULL pointer %p %p", pc, tilt_step); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg); *tilt_step = get_tilt_step; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_tilt_range(camera_h camera, int *min, int *max) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE; int get_min = 0; int get_max = 0; if (!pc || !pc->cb_info || !min || !max) { LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); muse_camera_msg_get(get_max, pc->cb_info->recv_msg); *min = get_min; *max = get_max; } LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE; camera_msg_param param; int set_ptz_type = (int)ptz_type; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type); _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE; if (!pc || !pc->cb_info || !foreach_cb) { LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data; _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height) { int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA; int set_display_roi_area[4] = {x, y, width, height}; char *msg = NULL; int length = 0; if (!pc || !pc->cb_info) { LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { g_mutex_lock(&pc->cb_info->evas_mutex); ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height); g_mutex_unlock(&pc->cb_info->evas_mutex); if (ret != MM_ERROR_NONE) { LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret); return CAMERA_ERROR_INVALID_OPERATION; } } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ length = sizeof(set_display_roi_area) / sizeof(int) + \ (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0); msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area, NULL); if (!msg) { LOGE("msg creation failed: api %d", api); return CAMERA_ERROR_OUT_OF_MEMORY; } if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { LOGE("message send failed"); ret = CAMERA_ERROR_INVALID_OPERATION; } else { ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); } muse_core_msg_json_factory_free(msg); LOGD("ret : 0x%x", ret); return ret; } int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height) { camera_cli_s *pc = (camera_cli_s *)camera; int ret = CAMERA_ERROR_NONE; int get_display_roi_area[4] = {0,}; muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA; if (!pc || !pc->cb_info || !x || !y || !width || !height) { LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } LOGD("Enter"); _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg); *x = get_display_roi_area[0]; *y = get_display_roi_area[1]; *width = get_display_roi_area[2]; *height = get_display_roi_area[3]; } LOGD("ret : 0x%x", ret); return ret; }