/*
-* 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.
-*/
+ * 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mm.h>
-#include <audio-session-manager-types.h>
-#include <mm_camcorder.h>
#include <mm_types.h>
-#include <math.h>
#include <camera.h>
+#include <muse_camera.h>
+#include <muse_camera_msg.h>
#include <camera_private.h>
-#include <glib.h>
+#include <muse_core.h>
+#include <muse_client.h>
#include <dlog.h>
-#include <gst/gst.h>
-#include <tbm_bufmgr.h>
+#include <Elementary.h>
#include <tbm_surface_internal.h>
#include <Evas.h>
-#include <Ecore.h>
-#include <Elementary.h>
+#include <Ecore_Wayland.h>
+#include <wayland-client.h>
+#include <tizen-extension-client-protocol.h>
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+#include <mm_evas_renderer.h>
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+#include <gio/gio.h>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "TIZEN_N_CAMERA"
-static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data);
-static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
+/* for device changed callback */
+static GMutex g_cam_dev_state_changed_cb_lock;
+static GList *g_cam_dev_state_changed_cb_list;
+static int g_cam_dev_state_changed_cb_id;
+static GDBusConnection *g_cam_dev_state_changed_cb_conn;
+static guint g_cam_dev_state_changed_cb_subscribe_id;
+
+static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
+ int *ret, int timeout);
+static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param, int timeout);
+static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
+static void _camera_release_imported_bo(tbm_bo *bo);
+static 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);
+static 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);
+static 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);
+static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
+
+
+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;
+ }
-void _camera_remove_cb_message(camera_s *handle){
- int ret = 0;
- GList *list = NULL;
- camera_cb_data *cb_data = NULL;
+ tz_surface = (struct tizen_surface **)data;
- if( handle == NULL ){
- LOGE("handle is NULL");
+ if (!interface) {
+ LOGW("NULL interface");
return;
}
- LOGI("start");
+ /*LOGI("interface %s", interface);*/
- g_mutex_lock(&handle->idle_cb_lock);
+ if (strcmp(interface, "tizen_surface") == 0) {
+ LOGD("binding tizen surface for wayland");
- if( handle->cb_data_list ){
- list = handle->cb_data_list;
+ *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
+ if (*tz_surface == NULL)
+ LOGE("failed to bind");
- while( list ){
- cb_data = list->data;
- list = g_list_next(list);
+ LOGD("done");
+ }
- if( !cb_data ){
- LOGW("cb_data is NULL");
- } else {
- ret = g_idle_remove_by_data (cb_data);
- LOGW("Remove cb_data[%p]. ret[%d]", cb_data, ret);
+ return;
+}
- handle->cb_data_list = g_list_remove(handle->cb_data_list, cb_data);
- free(cb_data);
- cb_data = NULL;
- }
- }
+static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
+{
+ LOGD("enter");
+ return;
+}
- g_list_free(handle->cb_data_list);
- handle->cb_data_list = NULL;
- } else {
- LOGW("There is no remained callback");
+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;
}
- g_mutex_unlock(&handle->idle_cb_lock);
+ *((unsigned int *)data) = id;
- LOGI("done");
+ LOGD("[CLIENT] got parent_id [%u] from server", id);
return;
}
+static const struct tizen_resource_listener _camera_tz_resource_listener = {
+ __parent_id_getter
+};
-int __convert_camera_error_code(const char* func, int code){
+int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
+{
int ret = CAMERA_ERROR_NONE;
- const char *errorstr = NULL;
+ Ecore_Wl_Window *window = NULL;
+ struct wl_display *display = NULL;
+ struct wl_display *display_wrapper = NULL;
+ struct wl_surface *surface = NULL;
+ struct wl_registry *registry = NULL;
+ struct wl_event_queue *queue = 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;
+ }
- switch( code ){
- case MM_ERROR_NONE:
- ret = CAMERA_ERROR_NONE;
- errorstr = "ERROR_NONE";
- break;
- case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
- case MM_ERROR_COMMON_INVALID_ATTRTYPE:
- ret = CAMERA_ERROR_INVALID_PARAMETER;
- errorstr = "INVALID_PARAMETER";
- break;
- case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
- case MM_ERROR_CAMCORDER_INVALID_STATE:
- ret = CAMERA_ERROR_INVALID_STATE;
- errorstr = "INVALID_STATE";
- break;
- case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
- ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
- errorstr = "DEVICE_NOT_FOUND";
- break;
- case MM_ERROR_CAMCORDER_DEVICE_BUSY:
- case MM_ERROR_CAMCORDER_DEVICE_OPEN:
- case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
- ret = CAMERA_ERROR_DEVICE_BUSY;
- errorstr = "DEVICE_BUSY";
- break;
- case MM_ERROR_CAMCORDER_DEVICE:
- case MM_ERROR_CAMCORDER_DEVICE_IO:
- case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
- case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
- case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
- ret = CAMERA_ERROR_DEVICE;
- errorstr = "ERROR_DEVICE";
- break;
+ window = elm_win_wl_window_get(obj);
+ if (!window) {
+ LOGE("failed to get wayland window");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
- case MM_ERROR_CAMCORDER_GST_CORE:
- case MM_ERROR_CAMCORDER_GST_LIBRARY:
- case MM_ERROR_CAMCORDER_GST_RESOURCE:
- case MM_ERROR_CAMCORDER_GST_STREAM:
- case MM_ERROR_CAMCORDER_GST_STATECHANGE:
- case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
- case MM_ERROR_CAMCORDER_GST_LINK:
- case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
- case MM_ERROR_CAMCORDER_ENCODER:
- case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
- case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
- case MM_ERROR_CAMCORDER_ENCODER_WORKING:
- case MM_ERROR_CAMCORDER_INTERNAL:
- case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
- case MM_ERROR_CAMCORDER_DSP_FAIL:
- case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
- case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
- case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
- case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
- case MM_ERROR_CAMCORDER_INVALID_CONDITION:
- ret = CAMERA_ERROR_INVALID_OPERATION;
- errorstr = "INVALID_OPERATION";
- break;
+ ecore_wl_window_video_has(window, EINA_TRUE);
- case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
- case MM_ERROR_COMMON_OUT_OF_MEMORY:
- ret = CAMERA_ERROR_OUT_OF_MEMORY;
- errorstr = "OUT_OF_MEMORY";
- break;
+ 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;
+ }
- case MM_ERROR_POLICY_BLOCKED:
- ret = CAMERA_ERROR_SOUND_POLICY;
- errorstr = "ERROR_SOUND_POLICY";
- break;
- case MM_ERROR_POLICY_BLOCKED_BY_CALL:
- ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
- errorstr = "ERROR_SOUND_POLICY_BY_CALL";
- break;
- case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
- ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
- errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
- break;
- case MM_ERROR_POLICY_RESTRICTED:
- ret = CAMERA_ERROR_SECURITY_RESTRICTED;
- errorstr = "ERROR_RESTRICTED";
- break;
- case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
- ret = CAMERA_ERROR_ESD;
- errorstr = "ERROR_ESD";
- break;
- case MM_ERROR_COMMON_INVALID_PERMISSION:
- ret = CAMERA_ERROR_PERMISSION_DENIED;
- errorstr = "ERROR_PERMISSION_DENIED";
- break;
- case MM_ERROR_COMMON_OUT_OF_ARRAY:
- case MM_ERROR_COMMON_OUT_OF_RANGE:
- case MM_ERROR_COMMON_ATTR_NOT_EXIST:
- case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
- ret = CAMERA_ERROR_NOT_SUPPORTED;
- errorstr = "ERROR_NOT_SUPPORTED";
- break;
- default:
- ret = CAMERA_ERROR_INVALID_OPERATION;
- errorstr = "INVALID_OPERATION";
+ display = (struct wl_display *)ecore_wl_display_get();
+ if (!display) {
+ LOGE("failed to get wayland display");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
}
- if( code != MM_ERROR_NONE ){
- LOGE("%s(0x%08x) : core frameworks error code(0x%08x)", errorstr, ret, code);
+ display_wrapper = wl_proxy_create_wrapper(display);
+ if (!display_wrapper) {
+ LOGE("failed to create wl display wrapper");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
}
- return ret;
-}
+ queue = wl_display_create_queue(display);
+ if (!queue) {
+ LOGE("failed to create wl display queue");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+ wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
-static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){
- if( user_data == NULL || stream == NULL)
- return 0;
+ registry = wl_display_get_registry(display_wrapper);
+ if (!registry) {
+ LOGE("failed to get wayland registry");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
- camera_s * handle = (camera_s*)user_data;
- if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ){
- camera_preview_data_s frame;
- frame.format = stream->format;
- if( frame.format == (camera_pixel_format_e)MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
- frame.format = MM_PIXEL_FORMAT_UYVY;
- frame.width = stream->width;
- frame.height = stream->height;
- frame.timestamp = stream->timestamp;
- frame.num_of_planes = stream->num_planes;
- switch( stream->data_type ){
- case MM_CAM_STREAM_DATA_YUV420 :
- frame.data.single_plane.yuv = stream->data.yuv420.yuv;
- frame.data.single_plane.size = stream->data.yuv420.length_yuv;
- break;
- case MM_CAM_STREAM_DATA_YUV422:
- frame.data.single_plane.yuv = stream->data.yuv422.yuv;
- frame.data.single_plane.size = stream->data.yuv422.length_yuv;
- break;
- case MM_CAM_STREAM_DATA_YUV420SP:
- frame.data.double_plane.y = stream->data.yuv420sp.y;
- frame.data.double_plane.uv = stream->data.yuv420sp.uv;
- frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
- frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
- break;
- case MM_CAM_STREAM_DATA_YUV420P:
- frame.data.triple_plane.y = stream->data.yuv420p.y;
- frame.data.triple_plane.u = stream->data.yuv420p.u;
- frame.data.triple_plane.v = stream->data.yuv420p.v;
- 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;
- break;
- case MM_CAM_STREAM_DATA_YUV422P:
- frame.data.triple_plane.y = stream->data.yuv422p.y;
- frame.data.triple_plane.u = stream->data.yuv422p.u;
- frame.data.triple_plane.v = stream->data.yuv422p.v;
- frame.data.triple_plane.y_size = stream->data.yuv422p.length_y;
- frame.data.triple_plane.u_size = stream->data.yuv422p.length_u;
- frame.data.triple_plane.v_size = stream->data.yuv422p.length_v;
- break;
- default :
- break;
- }
- ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(&frame, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]);
+ wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
+
+ wl_display_dispatch_queue(display, queue);
+ wl_display_roundtrip_queue(display, queue);
+
+ if (!tz_surface) {
+ LOGE("failed to get tizen surface");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
}
- if( handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ){
- media_packet_h pkt = NULL;
- tbm_surface_h tsurf = NULL;
- uint32_t bo_format = 0;
- int i;
- int bo_num;
- int ret = 0;
- media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
- bool make_pkt_fmt = false;
+ /* 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;
+ }
- /* create tbm surface */
- for( i = 0, bo_num = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++ ){
- if( stream->bo[i] ){
- bo_num++;
- }
- }
+ wl_info->parent_id = 0;
- /* get tbm surface format */
- ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
- ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
+ tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
- if( bo_num > 0 && ret == CAMERA_ERROR_NONE ){
- tsurf = tbm_surface_internal_create_with_bos(stream->width, stream->height, bo_format, (tbm_bo *)stream->bo, bo_num);
- /*LOGD("tbm surface %p", tsurf);*/
- }
+ wl_display_roundtrip_queue(display, queue);
- if( tsurf ){
- /* check media packet format */
- if( handle->pkt_fmt ){
- int pkt_fmt_width = 0;
- int pkt_fmt_height = 0;
- media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
+ if (wl_info->parent_id > 0) {
+ int rotation = 0;
+ Ecore_Evas *ecore_evas = NULL;
+ ret = CAMERA_ERROR_NONE;
- media_format_get_video_info(handle->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("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
- pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
- media_format_unref(handle->pkt_fmt);
- handle->pkt_fmt = NULL;
- make_pkt_fmt = true;
- }
- } else {
- make_pkt_fmt = true;
- }
+ evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
+ &wl_info->window_width, &wl_info->window_height);
- /* create packet format */
- if( make_pkt_fmt ){
- LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
- ret = media_format_create(&handle->pkt_fmt);
- if (ret == MEDIA_FORMAT_ERROR_NONE) {
- ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
- ret |= media_format_set_video_width(handle->pkt_fmt, stream->width);
- ret |= media_format_set_video_height(handle->pkt_fmt, stream->height);
- LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
- } else {
- LOGW("media_format_create failed");
- }
- }
+ 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;
- /* create media packet */
- ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)handle, &pkt);
- if( ret != MEDIA_PACKET_ERROR_NONE ){
- LOGE("media_packet_create_from_tbm_surface failed");
+ LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
+ wl_info->window_width = wl_info->window_height;
+ wl_info->window_height = temp;
}
} else {
- LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", stream->width, stream->height, stream->format, bo_num);
+ LOGW("failed to get ecore_evas.. skip rotation check");
}
- if( pkt ){
- /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
-
- /* set internal buffer */
- ret = media_packet_set_extra(pkt, stream->internal_buffer);
- if( ret != MEDIA_PACKET_ERROR_NONE ){
- LOGE("media_packet_set_extra failed");
-
- 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");
- }
-
- /* increase ref count of gst buffer */
- gst_buffer_ref((GstBuffer *)stream->internal_buffer);
+ LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
+ 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");
+ }
- /* call media packet callback */
- ((camera_media_packet_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt, handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
- }
- }
+_DONE:
+ if (tz_surface) {
+ tizen_surface_destroy(tz_surface);
+ tz_surface = NULL;
}
- return 1;
-}
-
-static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){
- if( user_data == NULL || frame == NULL)
- return 0;
-
- camera_s * handle = (camera_s*)user_data;
- handle->current_capture_count++;
- if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ){
- MMCamcorderCaptureDataType *scrnl = NULL;
- int size = 0;
- camera_image_data_s image = { NULL, 0, 0, 0, 0, NULL, 0 };
- camera_image_data_s thumb = { NULL, 0, 0, 0, 0, NULL, 0 };
- camera_image_data_s postview = { NULL, 0, 0, 0, 0, NULL, 0 };
- if( frame ){
- int ret;
- unsigned char *exif;
- int exif_size;
- image.data = frame->data;
- image.size = frame->length;
- image.width = frame->width;
- image.height = frame->height;
- image.format = frame->format;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, "captured-exif-raw-data", &exif, &exif_size, NULL);
- if( ret == MM_ERROR_NONE ){
- image.exif = exif;
- image.exif_size = exif_size;
- }
- }
+ if (tz_resource) {
+ tizen_resource_destroy(tz_resource);
+ tz_resource = NULL;
+ }
- if( thumbnail ){
- thumb.data = thumbnail->data;
- thumb.size = thumbnail->length;
- thumb.width = thumbnail->width;
- thumb.height = thumbnail->height;
- thumb.format = thumbnail->format;
- }
- mm_camcorder_get_attributes( handle->mm_handle, NULL, "captured-screennail", &scrnl, &size,NULL );
- if( scrnl ){
- postview.data = scrnl->data;
- postview.size = scrnl->length;
- postview.width = scrnl->width;
- postview.height = scrnl->height;
- postview.format = scrnl->format;
- }
+ if (registry) {
+ wl_registry_destroy(registry);
+ registry = NULL;
+ }
- ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(&image, scrnl ? &postview : NULL, thumbnail ? &thumb : NULL, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]);
+ if (queue) {
+ wl_event_queue_destroy(queue);
+ queue = NULL;
}
- // update captured state
- if( handle->capture_count == 1 && handle->hdr_keep_mode ){
- if( handle->current_capture_count == 2 ){
- handle->is_capture_completed = true;
- }
- } else if( handle->capture_count == handle->current_capture_count || handle->is_continuous_shot_break){
- handle->is_capture_completed = true;
+
+ if (display_wrapper) {
+ wl_proxy_wrapper_destroy(display_wrapper);
+ display_wrapper = NULL;
}
- return 1;
+ return ret;
}
-static camera_state_e __camera_state_convert(MMCamcorderStateType mm_state){
- camera_state_e state = CAMERA_STATE_NONE;
- switch( mm_state ){
- case MM_CAMCORDER_STATE_NONE:
- state = CAMERA_STATE_NONE;
- break;
- case MM_CAMCORDER_STATE_NULL:
- state = CAMERA_STATE_CREATED;
- break;
- case MM_CAMCORDER_STATE_READY:
- state = CAMERA_STATE_CREATED;
- break;
- case MM_CAMCORDER_STATE_PREPARE:
- state = CAMERA_STATE_PREVIEW;
- break;
- case MM_CAMCORDER_STATE_CAPTURING:
- state = CAMERA_STATE_CAPTURING;
- break;
- case MM_CAMCORDER_STATE_RECORDING:
- state = CAMERA_STATE_PREVIEW;
- break;
- case MM_CAMCORDER_STATE_PAUSED:
- state = CAMERA_STATE_PREVIEW;
- break;
- default:
- state = CAMERA_STATE_NONE;
- break;
+static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
+{
+ if (!cb_info ||
+ api < 0 || api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
+ return;
}
- return state;
-}
-
-
-static int __mm_camera_message_callback(int message, void *param, void *user_data){
- if( user_data == NULL || param == NULL )
- return 0;
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
- camera_s * handle = (camera_s*)user_data;
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
- if( handle->relay_message_callback )
- handle->relay_message_callback(message, param, handle->relay_user_data);
+ return;
+}
- MMMessageParamType *m = (MMMessageParamType*)param;
- camera_state_e previous_state;
+static void __camera_device_state_changed_cb(GDBusConnection *connection,
+ const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
+ const gchar *signal_name, GVariant *param, gpointer user_data)
+{
+ int value = 0;
+ camera_device_e device = CAMERA_DEVICE_CAMERA0;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ GList *tmp_list = NULL;
+ camera_cb_info *info = NULL;
- switch(message){
- case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
- case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
- case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
- if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED && (m->state.previous < MM_CAMCORDER_STATE_NONE || m->state.previous > MM_CAMCORDER_STATE_PAUSED || m->state.code != 0) ){
- LOGI( "Invalid state changed message");
- break;
- }
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
- previous_state = handle->state;
- handle->state = __camera_state_convert(m->state.current );
- camera_policy_e policy = CAMERA_POLICY_NONE;
- if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
- switch (m->state.code) {
- case ASM_EVENT_SOURCE_CALL_START:
- policy = CAMERA_POLICY_SOUND_BY_CALL;
- LOGW("CAMERA_POLICY_SOUND_BY_CALL");
- break;
- case ASM_EVENT_SOURCE_ALARM_START:
- case ASM_EVENT_SOURCE_ALARM_END:
- policy = CAMERA_POLICY_SOUND_BY_ALARM;
- LOGW("CAMERA_POLICY_SOUND_BY_ALARM");
- break;
- default:
- policy = CAMERA_POLICY_SOUND;
- LOGW("CAMERA_POLICY_SOUND");
- break;
- }
- } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
- policy = CAMERA_POLICY_SECURITY;
- LOGW("CAMERA_POLICY_SECURITY");
- }
+ if (!g_cam_dev_state_changed_cb_list || !param) {
+ LOGW("no callback or NULL param %p", param);
+ goto _DONE;
+ }
- if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
- ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy, handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
- }
+ /* get device and state */
+ g_variant_get(param, "(i)", &value);
- // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
- if( policy != CAMERA_POLICY_NONE &&
- m->state.current == MM_CAMCORDER_STATE_NULL ){
- if( handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]){
- ((camera_interrupted_cb)handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED]);
- } else {
- LOGW("_CAMERA_EVENT_TYPE_INTERRUPTED cb is NULL");
- }
- }
+ device = value >> 16;
+ state = 0x0000ffff & value;
- break;
- case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED :
- if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){
- ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
- }
- break;
- case MM_MESSAGE_CAMCORDER_CAPTURED:
- {
- handle->current_capture_complete_count = m->code;
- if( handle->capture_count == 1 || m->code == handle->capture_count ||(handle->is_continuous_shot_break && handle->state == CAMERA_STATE_CAPTURING) ){
- //pseudo state change
- previous_state = handle->state ;
- handle->state = CAMERA_STATE_CAPTURED;
- if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
- ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, 0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
- }
- if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
- ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
- }
- }
- break;
- }
- case MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED:
- case MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED:
- {
- MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
- if( report != NULL && report->recording_filename ){
- free(report->recording_filename );
- report->recording_filename = NULL;
- }
- if( report ){
- free(report);
- report = NULL;
- }
- break;
- }
- case MM_MESSAGE_CAMCORDER_VIDEO_SNAPSHOT_CAPTURED:
- {
- if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
- ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
- }
- break;
- }
- case MM_MESSAGE_CAMCORDER_ERROR:
- {
- int errorcode = m->code;
- int camera_error = 0;
- switch( errorcode ){
- case MM_ERROR_CAMCORDER_DEVICE :
- case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
- case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
- camera_error = CAMERA_ERROR_DEVICE;
- break;
- case MM_ERROR_CAMCORDER_GST_CORE:
- case MM_ERROR_CAMCORDER_GST_LIBRARY:
- case MM_ERROR_CAMCORDER_GST_RESOURCE:
- case MM_ERROR_CAMCORDER_GST_STREAM:
- case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
- case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
- case MM_ERROR_CAMCORDER_ENCODER:
- case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
- case MM_ERROR_CAMCORDER_ENCODER_WORKING:
- case MM_ERROR_CAMCORDER_MNOTE_CREATION:
- case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY:
- case MM_ERROR_CAMCORDER_INTERNAL:
- case MM_ERROR_FILE_NOT_FOUND:
- case MM_ERROR_FILE_READ:
- camera_error = CAMERA_ERROR_INVALID_OPERATION;
- break;
- case MM_ERROR_CAMCORDER_LOW_MEMORY:
- case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
- camera_error = CAMERA_ERROR_OUT_OF_MEMORY;
- break;
- case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
- camera_error = CAMERA_ERROR_ESD;
- break;
- default :
- camera_error = CAMERA_ERROR_INVALID_OPERATION;
- break;
- }
+ LOGD("device %d, state %d", device, state);
- /* set capture completed flag as true to release camera handle */
- handle->is_capture_completed = true;
+ tmp_list = g_cam_dev_state_changed_cb_list;
- if( camera_error != 0 && handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] )
- ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(camera_error, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]);
+ do {
+ info = (camera_cb_info *)tmp_list->data;
- break;
- }
- case MM_MESSAGE_CAMCORDER_HDR_PROGRESS:
- {
- int percent = m->code;
- if( handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] )
- ((camera_attr_hdr_progress_cb)handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS])(percent, handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
- break;
- }
- case MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO:
- {
- MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)(m->data);
- if ( cam_fd_info ) {
- camera_detected_face_s faces[cam_fd_info->num_of_faces];
- handle->num_of_faces = cam_fd_info->num_of_faces > MAX_DETECTED_FACE ? MAX_DETECTED_FACE : cam_fd_info->num_of_faces;
- int i;
- for(i=0; i < handle->num_of_faces ; i++){
- faces[i].id = cam_fd_info->face_info[i].id;
- faces[i].score = cam_fd_info->face_info[i].score;
- faces[i].x = cam_fd_info->face_info[i].rect.x;
- faces[i].y = cam_fd_info->face_info[i].rect.y;
- faces[i].width = cam_fd_info->face_info[i].rect.width;
- faces[i].height = cam_fd_info->face_info[i].rect.height;
- handle->faceinfo[i] = faces[i]; //cache face coordinate
- }
- if( handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] )
- ((camera_face_detected_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces, handle->num_of_faces, handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION]);
- }else{
- handle->num_of_faces = 0;
+ if (info) {
+ if (info->callback) {
+ LOGD("start id[%d] callback", info->id);
+ ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
+ LOGD("returned id[%d] callback", info->id);
+ } else {
+ LOGW("NULL callback for id %d", info->id);
}
- break;
}
- default:
- break;
- }
- return 1;
-}
+ tmp_list = tmp_list->next;
+ } while (tmp_list);
-static int __capture_completed_event_cb(void *data){
- camera_s *handle = (camera_s*)data;
- if( handle->current_capture_count > 0 && handle->current_capture_count == handle->current_capture_complete_count && handle->state == CAMERA_STATE_CAPTURING ){
- //pseudo state change
- camera_state_e previous_state = handle->state;
- handle->state = CAMERA_STATE_CAPTURED;
- if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
- ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, 0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
- }
- if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){
- ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]);
- }
- }
- return false;
+_DONE:
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
+
+ return;
}
-int camera_create(camera_device_e device, camera_h* camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
+{
+ int i = 0;
+ int ret = 0;
+ int num_buffer_key = 0;
+ int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
+ int tbm_key = 0;
+ int data_key = 0;
+ unsigned char *buf_pos = NULL;
+ camera_msg_param param;
+
+ tbm_bo bo = NULL;
+ tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
+ tbm_bo_handle bo_handle = {.ptr = 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;
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+ media_packet_h pkt_evas = NULL;
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+ if (!cb_info || !recv_msg) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
}
- int ret;
- MMCamPreset info;
- int preview_format;
- int rotation;
-
- LOGW("device name = [%d]",device);
+ 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);
- info.videodev_type = device;
+ memset(&frame, 0x0, sizeof(camera_preview_data_s));
- camera_s* handle = (camera_s*)malloc( sizeof(camera_s) );
- if( handle==NULL ){
- LOGE("malloc fail");
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
- memset(handle, 0 , sizeof(camera_s));
-
- ret = mm_camcorder_create(&handle->mm_handle, &info);
- if( ret != MM_ERROR_NONE ){
- free(handle);
- return __convert_camera_error_code(__func__,ret);
+ if (tbm_key <= 0) {
+ LOGE("invalid key %d", tbm_key);
+ return;
}
- preview_format = MM_PIXEL_FORMAT_YUYV;
- rotation = MM_DISPLAY_ROTATION_NONE;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format,
- MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation,
- MMCAM_CAPTURE_WIDTH, &handle->capture_width,
- MMCAM_CAPTURE_HEIGHT, &handle->capture_height,
- NULL);
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
- char *error;
- ret = mm_camcorder_set_attributes(handle->mm_handle, &error,
- MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO_CAPTURE,
- MMCAM_CAMERA_FORMAT, preview_format,
- MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
- MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
- MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL,
- MMCAM_DISPLAY_ROTATION, rotation,
- MMCAM_CAPTURE_COUNT, 1,
- (void*)NULL);
-
- handle->display_type = CAMERA_DISPLAY_TYPE_NONE;
-
- if( ret != MM_ERROR_NONE ){
- LOGE("mm_camcorder_set_attributes fail(%x, %s)", ret, error);
- mm_camcorder_destroy(handle->mm_handle);
- free(error);
- free(handle);
- return __convert_camera_error_code(__func__, ret);
+ if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
+ LOGE("invalid num buffer key %d", num_buffer_key);
+ goto _PREVIEW_CB_HANDLER_DONE;
}
- handle->state = CAMERA_STATE_CREATED;
- handle->relay_message_callback = NULL;
- handle->relay_user_data = NULL;
- handle->capture_resolution_modified = false;
- handle->hdr_keep_mode = false;
- handle->focus_area_valid = false;
- handle->is_used_in_recorder = false;
- handle->on_continuous_focusing = false;
- handle->cached_focus_mode = -1;
- g_mutex_init(&handle->idle_cb_lock);
- mm_camcorder_set_message_callback(handle->mm_handle, __mm_camera_message_callback, (void*)handle);
-
- LOGW("camera handle %p", handle);
-
- *camera = (camera_h)handle;
- return __convert_camera_error_code(__func__, ret);
-}
-
- int camera_destroy(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ 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);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
}
- int ret;
- camera_s *handle = (camera_s*)camera;
- if( handle->is_used_in_recorder ){
- LOGE("camera is using in another recorder.");
- return CAMERA_ERROR_INVALID_OPERATION;
+ /* 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);
+ goto _PREVIEW_CB_HANDLER_DONE;
}
- LOGW("camera handle %p", handle);
-
- ret = mm_camcorder_destroy(handle->mm_handle);
+ buf_pos = (unsigned char *)bo_handle.ptr;
- if( handle->pkt_fmt ){
- media_format_unref(handle->pkt_fmt);
- handle->pkt_fmt = NULL;
- }
+ /* get stream info */
+ stream = (camera_stream_data_s *)buf_pos;
- if( ret == MM_ERROR_NONE ){
- _camera_remove_cb_message(handle);
- g_mutex_clear(&handle->idle_cb_lock);
- free(handle);
+ 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]);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
}
- return __convert_camera_error_code(__func__, ret);
+ /* 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);
-}
-
-int camera_start_preview(camera_h camera){
- LOGW("start");
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
+ cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
}
- int ret;
- camera_s *handle = (camera_s*)camera;
- camera_state_e capi_state;
- camera_get_state(camera, &capi_state);
+ 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( capi_state == CAMERA_STATE_CAPTURED ){
- ret = mm_camcorder_capture_stop(handle->mm_handle);
- return __convert_camera_error_code(__func__, ret);
+ if (ret == CAMERA_ERROR_NONE) {
+ ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("create pkt for evas failed");
+ _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 */
}
- /*for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback*/
- mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)__mm_capture_callback, (void*)handle);
+ /* 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);
- MMCamcorderStateType state;
- mm_camcorder_get_state(handle->mm_handle, &state);
- if( state != MM_CAMCORDER_STATE_READY ){
- ret = mm_camcorder_realize(handle->mm_handle);
- if( ret != MM_ERROR_NONE ){
- return __convert_camera_error_code(__func__, ret);
+ 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;
+ }
}
}
- ret = mm_camcorder_start(handle->mm_handle);
- if( ret != MM_ERROR_NONE ){
- /*start fail */
- mm_camcorder_unrealize(handle->mm_handle);
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+ /* call evas renderer */
+ if (pkt_evas) {
+ g_mutex_lock(&cb_info->evas_mutex);
+ if (cb_info->run_evas_render) {
+ mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
+ } else {
+ LOGW("evas renderer is stopped, skip this buffer...");
+ media_packet_destroy(pkt_evas);
+ }
+ pkt_evas = NULL;
+ g_mutex_unlock(&cb_info->evas_mutex);
}
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- return __convert_camera_error_code(__func__, ret);
-}
-
-int camera_stop_preview(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ /* 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);
- int ret;
- camera_s *handle = (camera_s*)camera;
- MMCamcorderStateType state ;
- mm_camcorder_get_state(handle->mm_handle, &state);
+_PREVIEW_CB_HANDLER_DONE:
+ if (mp_data == NULL) {
+ /* release imported bo */
+ for (i = 0 ; i < num_buffer_key ; i++)
+ _camera_release_imported_bo(&buffer_bo[i]);
- if( state == MM_CAMCORDER_STATE_PREPARE ){
- ret = mm_camcorder_stop(handle->mm_handle);
- if( ret != MM_ERROR_NONE ){
- return __convert_camera_error_code(__func__, ret);
- }
- }
+ /* unmap and unref tbm bo */
+ _camera_release_imported_bo(&data_bo);
+ _camera_release_imported_bo(&bo);
- camera_stop_face_detection(camera);
+ /* return buffer */
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
- ret = mm_camcorder_unrealize(handle->mm_handle);
+ /*LOGD("return buffer Done");*/
+ }
- return __convert_camera_error_code(__func__, ret);
+ return;
}
-int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- camera_s * handle = (camera_s*)camera;
- int ret;
- MMCamcorderStateType state;
- mm_camcorder_get_state(handle->mm_handle, &state);
- if( state != MM_CAMCORDER_STATE_PREPARE &&
- state != MM_CAMCORDER_STATE_RECORDING &&
- state != MM_CAMCORDER_STATE_PAUSED ){
- LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
- return CAMERA_ERROR_INVALID_STATE;
- }
+static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
+{
+ int tbm_key = 0;
+ int tbm_key_main = 0;
+ int tbm_key_post = 0;
+ int tbm_key_thumb = 0;
+ unsigned char *buf_pos = NULL;
- if( handle->capture_resolution_modified ){
- mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAPTURE_WIDTH, handle->capture_width,
- MMCAM_CAPTURE_HEIGHT, handle->capture_height,
- NULL);
- handle->capture_resolution_modified = false;
- }
- mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAPTURE_COUNT , 1,NULL);
+ camera_msg_param param;
+ camera_image_data_s *rImage = NULL;
+ camera_image_data_s *rPostview = NULL;
+ camera_image_data_s *rThumbnail = NULL;
- handle->capture_count = 1;
- handle->is_continuous_shot_break = false;
- handle->current_capture_count = 0;
- handle->current_capture_complete_count = 0;
- handle->is_capture_completed = false;
+ tbm_bo bo_main = NULL;
+ tbm_bo bo_post = NULL;
+ tbm_bo bo_thumb = NULL;
+ tbm_bo_handle bo_main_handle = {.ptr = NULL};
+ tbm_bo_handle bo_post_handle = {.ptr = NULL};
+ tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
- ret = mm_camcorder_capture_start(handle->mm_handle);
- if( ret != 0 ){
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
+ if (!cb_info || !recv_msg) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
}
- return __convert_camera_error_code(__func__, ret);
-}
+ 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);
-bool camera_is_supported_continuous_capture(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
+ /*
+ 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);
+ */
- int ret = MM_ERROR_NONE;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_COUNT , &info);
- set_last_result(__convert_camera_error_code(__func__, ret));
- if( ret != MM_ERROR_NONE ){
- return false;
+ if (tbm_key_main <= 0) {
+ LOGE("invalid key %d", tbm_key_main);
+ goto _CAPTURE_CB_HANDLER_DONE;
}
- if( info.int_range.max > 1){
- return true;
- } else {
- return false;
- }
-}
-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){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
+ LOGW("NULL callback");
+ goto _CAPTURE_CB_HANDLER_DONE;
}
- if( camera_is_supported_continuous_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ /* import tbm bo and get virtual address */
+ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
+ LOGE("failed to import key [%d] for main", tbm_key_main);
+ goto _CAPTURE_CB_HANDLER_DONE;
}
- if( count < 2 || interval < 0 ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ buf_pos = (unsigned char *)bo_main_handle.ptr;
+ rImage = (camera_image_data_s *)buf_pos;
+ rImage->data = buf_pos + sizeof(camera_image_data_s);
+ if (rImage->exif && rImage->exif_size > 0) {
+ rImage->exif = rImage->data + rImage->size;
+ } else {
+ rImage->exif = NULL;
+ rImage->exif_size = 0;
}
- camera_s * handle = (camera_s*)camera;
+ LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
+ rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
- MMCamcorderStateType state;
- mm_camcorder_get_state(handle->mm_handle, &state);
- if( state != MM_CAMCORDER_STATE_PREPARE ){
- LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
- return CAMERA_ERROR_INVALID_STATE;
+ 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)) {
+ 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);
+ } else {
+ LOGE("failed to import key [%d] for postview", tbm_key_post);
+ }
}
- int supported_zsl = FALSE;
-
- int ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAPTURE_COUNT, count,
- MMCAM_CAPTURE_INTERVAL, interval,
- NULL);
- if( ret != 0 ){
- LOGE("(%x) error set continuous shot attribute", ret);
- return __convert_camera_error_code(__func__, ret);
+ 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)) {
+ 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);
+ } else {
+ LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
+ }
}
- handle->capture_count = count;
- handle->is_continuous_shot_break = false;
- handle->current_capture_count = 0;
- handle->current_capture_complete_count = 0;
- handle->is_capture_completed = false;
+ ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
+ rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
- if( ret != 0 ){
- LOGE("(%x) error get continuous shot attribute", ret);
- }
+_CAPTURE_CB_HANDLER_DONE:
+ /* return buffer */
+ if (tbm_key_main > 0) {
+ _camera_release_imported_bo(&bo_main);
- if( !supported_zsl ){
- int preview_width;
- int preview_height;
- int capture_width;
- int capture_height;
+ tbm_key = tbm_key_main;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
- mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_WIDTH, &preview_width,
- MMCAM_CAMERA_HEIGHT, &preview_height,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- MMCAM_CAPTURE_HEIGHT, &capture_height,
- NULL);
- if( preview_width != capture_width || preview_height != capture_height ){
- mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAPTURE_WIDTH, preview_width,
- MMCAM_CAPTURE_HEIGHT, preview_height,
- NULL);
- handle->capture_resolution_modified = true;
- }
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
}
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)capturing_cb;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data;
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)completed_cb;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data;
+ if (tbm_key_post > 0) {
+ _camera_release_imported_bo(&bo_post);
- ret = mm_camcorder_capture_start(handle->mm_handle);
- if( ret != 0 ){
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = NULL;
+ tbm_key = tbm_key_post;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
}
- return __convert_camera_error_code(__func__,ret);
+ if (tbm_key_thumb > 0) {
+ _camera_release_imported_bo(&bo_thumb);
-}
+ tbm_key = tbm_key_thumb;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
-int camera_stop_continuous_capture(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
}
- if( camera_is_supported_continuous_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ LOGD("return buffer done");
- camera_s *handle = (camera_s*)camera;
+ return;
+}
- int ret;
- camera_state_e state;
- camera_get_state(camera, &state);
- if( state != CAMERA_STATE_CAPTURING && handle->capture_count > 1 ){
- LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
- return CAMERA_ERROR_INVALID_STATE;
- }
+static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
+{
+ int count = 0;
+ int tbm_key = 0;
+ camera_detected_face_s *faces = NULL;
+ camera_msg_param param;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-break-cont-shot", 1, NULL);
- if( ret == MM_ERROR_NONE ){
- handle->is_continuous_shot_break = true;
- if( handle->current_capture_count > 0 ){
- handle->is_capture_completed = true;
- }
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __capture_completed_event_cb, handle, NULL);
+ tbm_bo bo = NULL;
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+
+ if (!cb_info || !recv_msg) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
}
- return __convert_camera_error_code(__func__,ret);
-}
+ muse_camera_msg_get(count, recv_msg);
+ muse_camera_msg_get(tbm_key, recv_msg);
-bool camera_is_supported_face_detection(camera_h camera){
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
+ if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
+ LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
- int i = 0;
- int ret = MM_ERROR_NONE;
- camera_s *handle = (camera_s *)camera;
- MMCamAttrsInfo info;
-
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DETECT_MODE , &info);
- set_last_result(__convert_camera_error_code(__func__, ret));
- if( ret != MM_ERROR_NONE ){
- LOGE("MMCAM_DETECT_MODE get attr info failed");
- return false;
- }
+ if (tbm_key > 0) {
- if( info.validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY ){
- for( i = 0 ; i < info.int_array.count ; i++ ){
- if( info.int_array.array[i] == MM_CAMCORDER_DETECT_MODE_ON ){
- LOGD("face detection supported");
- return true;
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
+ /* set face info */
+ faces = bo_handle.ptr;
}
}
+
+ ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
+ count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ /* release bo */
+ _camera_release_imported_bo(&bo);
+ } else {
+ LOGW("skip face detection message [count %d, key %d, cb %p",
+ count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
}
- LOGD("face detection NOT supported");
+ /* return buffer */
+ if (tbm_key > 0) {
+ 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");*/
+ }
- return false;
+ return;
}
-bool camera_is_supported_zero_shutter_lag(camera_h camera){
- int ret = MM_ERROR_NONE;
- int supported_zsl = false;
- camera_s *handle = (camera_s *)camera;
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
+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, };
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_SUPPORT_ZSL_CAPTURE, &supported_zsl, NULL);
- set_last_result(__convert_camera_error_code(__func__, ret));
- if( ret != MM_ERROR_NONE ){
- LOGE("MMCAM_SUPPORT_ZSL_CAPTURE get failed");
+ if (!bufmgr || !bo || !bo_handle || !tbm_key) {
+ LOGE("invalid parameter - %p %p %p, key %d",
+ bufmgr, bo, bo_handle, tbm_key);
return false;
}
- LOGD("support zero shutter lag : %d", supported_zsl);
-
- return supported_zsl;
-}
-
-bool camera_is_supported_media_packet_preview_cb(camera_h camera){
- int ret = MM_ERROR_NONE;
- int supported = false;
- camera_s *handle = (camera_s *)camera;
-
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ tmp_bo = tbm_bo_import(bufmgr, tbm_key);
+ if (tmp_bo == NULL) {
+ LOGE("import failed - key %d", tbm_key);
return false;
}
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, &supported,
- NULL);
- set_last_result(__convert_camera_error_code(__func__, ret));
- if( ret != MM_ERROR_NONE ){
- LOGE("MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB get failed");
+ 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;
}
- LOGD("support media packet preview callback : %d", supported);
+ tbm_bo_unmap(tmp_bo);
- return supported;
-}
+ /* set bo and bo_handle */
+ *bo = tmp_bo;
+ *bo_handle = tmp_bo_handle;
-int camera_get_device_count(camera_h camera, int *device_count){
- int ret = MM_ERROR_NONE;
- camera_s *handle = (camera_s *)camera;
+ return true;
+}
- if( camera == NULL || device_count == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+static void _camera_release_imported_bo(tbm_bo *bo)
+{
+ if (!bo || !(*bo)) {
+ /*LOGW("NULL bo");*/
+ return;
}
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_DEVICE_COUNT, device_count,
- NULL);
+ tbm_bo_unref(*bo);
+ *bo = NULL;
- return __convert_camera_error_code(__func__, ret);
+ return;
}
-int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+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);*/
+
+ if (!cb_info->is_server_connected) {
+ LOGE("server is disconnected");
+ return CAMERA_ERROR_SERVICE_DISCONNECTED;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+
+ if (cb_info->api_activating[api] == 0) {
+ if (time_out == CAMERA_CB_NO_TIMEOUT) {
+ LOGW("wait for api %d", api);
+ g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
+ ret = cb_info->api_ret[api];
+ cb_info->api_activating[api] = 0;
+ LOGW("api %d returned 0x%x", api, ret);
+ } else {
+ 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)
+{
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info) {
+ LOGE("NULL info - api %d", api);
+
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+ return;
+ }
+
+ msg = muse_core_msg_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 (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 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);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_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)
+{
+ int send_ret = 0;
+ 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_new(api,
+ param->type, param->name, param->value.value_INT,
+ NULL);
+ break;
+ case MUSE_TYPE_STRING:
+ msg = muse_core_msg_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 (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 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);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_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;
+}
+
+static 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;
+}
+
+static 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;
+}
+
+static 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;
+}
+
+static 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;
+
+ 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);*/
+
+ g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
+ if (cb_info->user_cb[event] == NULL) {
+ if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
+ event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+ LOGW("NULL callback for event %d, return here", event);
+ return;
+ }
+
+ /* return buffer message should be sent for some events.
+ - MUSE_CAMERA_EVENT_TYPE_PREVIEW
+ - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
+ - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
+ - MUSE_CAMERA_EVENT_TYPE_CAPTURE
+ */
+ }
+
+ 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:
+ __camera_event_handler_preview(cb_info, recv_msg);
+ 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_INTERRUPT_STARTED:
+ {
+ int policy = 0;
+ int state = 0;
+
+ muse_camera_msg_get(policy, recv_msg);
+ muse_camera_msg_get(state, recv_msg);
+
+ LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
+
+ 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_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
+ (camera_state_e)state, cb_info->user_data[event]);
+ }
+ break;
+ case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
+ __camera_event_handler_face_detection(cb_info, recv_msg);
+ 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_event_handler_capture(cb_info, recv_msg);
+ break;
+ default:
+ LOGW("unhandled event %d", event);
+ break;
+ }
+
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
+ 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 %p %d", cam_idle_event, 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(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("NULL handler %p", 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)) {
+ if (cb_info->api_waiting[api] > 0) {
+ 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 {
+ LOGW("no waiting for this api [%d]", 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);
+ strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
+
+ /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->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_deactivate_idle_event_all(camera_cb_info_s *cb_info)
+{
+ camera_idle_event_s *cam_idle_event = NULL;
+ 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)) {
+ LOGW("lock failed, %p event is calling now", cam_idle_event);
+
+ 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");
+
+ continue;
+ }
+
+ LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
+ cam_idle_event, cam_idle_event->event);
+
+ cam_idle_event->cb_info = NULL;
+
+ 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);
+ }
+
+ 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_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
+{
+ camera_message_s *cam_msg = NULL;
+
+ if (!cb_info || !msg) {
+ LOGE("NULL pointer %p %p", cb_info, msg);
+ return;
+ }
+
+ cam_msg = g_new0(camera_message_s, 1);
+ if (!cam_msg) {
+ LOGE("failed to alloc cam_msg for [%s]", msg);
+ return;
+ }
+
+ cam_msg->api = api;
+ cam_msg->event = event;
+ cam_msg->event_class = event_class;
+
+ strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
+
+ /*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);
+ }
+
+ cam_msg = NULL;
+
+ return;
+}
+
+
+static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
+{
+ int ret = CAMERA_ERROR_NONE;
+ int api = -1;
+ int api_class = -1;
+ int event = -1;
+ int event_class = -1;
+ int get_type = -1;
+ int get_index = -1;
+
+ if (!cb_info || !msg) {
+ LOGE("invalid ptr %p %p", cb_info, msg);
+ return;
+ }
+
+ /*LOGD("msg [%s]", msg);*/
+
+ if (!muse_camera_msg_get(api, msg)) {
+ LOGE("failed to get camera api");
+ return;
+ }
+
+ if (api == MUSE_CAMERA_CB_EVENT) {
+ if (!muse_camera_msg_get(event, msg) ||
+ !muse_camera_msg_get(event_class, msg)) {
+ LOGE("failed to get camera event or event_class [%s]", msg);
+ return;
+ }
+ } else {
+ if (!muse_camera_msg_get(api_class, msg)) {
+ LOGE("failed to get camera api_class [%s]", msg);
+ return;
+ }
+ }
+
+ if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
+ if (api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid api %d", api);
+ return;
+ }
+
+ if (!muse_camera_msg_get(ret, msg)) {
+ LOGE("failed to get camera ret");
+ return;
+ }
+
+ g_mutex_lock(&cb_info->api_mutex[api]);
+
+ switch (api) {
+ case 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);
+ }
+ break;
+ case 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");
+ }
+ break;
+ default:
+ muse_camera_msg_get(get_type, msg);
+ if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
+ if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
+ muse_camera_msg_get(get_index, msg);
+
+ switch (get_type) {
+ case MUSE_CAMERA_GET_TYPE_INT:
+ muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
+ break;
+ case MUSE_CAMERA_GET_TYPE_INT_PAIR:
+ muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
+ muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
+ break;
+ case MUSE_CAMERA_GET_TYPE_ARRAY:
+ if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
+ muse_core_msg_deserialize("get_value",
+ msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
+ LOGD("get display roi %d,%d,%dx%d",
+ cb_info->get_display_roi_area[0],
+ cb_info->get_display_roi_area[1],
+ cb_info->get_display_roi_area[2],
+ cb_info->get_display_roi_area[3]);
+ } else {
+ muse_core_msg_deserialize("get_value",
+ msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
+ LOGD("get geotag %lf, %lf, %lf",
+ cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
+ }
+ break;
+ case MUSE_CAMERA_GET_TYPE_STRING:
+ muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
+ break;
+ default:
+ LOGW("unknown type %d", get_type);
+ break;
+ }
+ }
+ break;
+ }
+
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGW("no waiting for this api [%d]", 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_add_msg_to_queue(cb_info, api, event, event_class, msg);
+ } else {
+ LOGW("unknown camera api %d, class %d", api, api_class);
+ }
+
+ return;
+}
+
+
+static void *_camera_msg_recv_func(gpointer data)
+{
+ int recv_length = 0;
+ int single_length = 0;
+ int remained_length = 0;
+ char *recv_msg = NULL;
+ char *single_msg = NULL;
+ char *remained_msg = NULL;
+ int num_msg = 0;
+ int cur_pos = 0;
+ int prev_pos = 0;
+ camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
+
+ if (!cb_info) {
+ LOGE("cb_info NULL");
+ return NULL;
+ }
+
+ LOGD("start");
+
+ single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
+ if (!single_msg) {
+ LOGE("single_msg malloc failed");
+ return NULL;
+ }
+
+ recv_msg = cb_info->recv_msg;
+
+ while (g_atomic_int_get(&cb_info->msg_recv_running)) {
+ recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
+ if (recv_length <= 0) {
+ cb_info->is_server_connected = FALSE;
+ LOGE("receive msg failed - server disconnected");
+ break;
+ }
+
+ cur_pos = 0;
+ prev_pos = 0;
+ num_msg = 0;
+
+ /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
+
+ /* Need to split the combined entering msgs */
+ for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
+ if (recv_msg[cur_pos] == '}') {
+ single_length = cur_pos - prev_pos + 1;
+
+ if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
+ /* check remained msg */
+ if (remained_length > 0) {
+ if (remained_msg) {
+ strncpy(single_msg, remained_msg, remained_length);
+ strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
+ single_msg[remained_length + single_length] = '\0';
+
+ free(remained_msg);
+ remained_msg = NULL;
+ } else {
+ strncpy(single_msg, recv_msg + prev_pos, single_length);
+ single_msg[single_length] = '\0';
+ LOGE("lost msg [%s], skip...", single_msg);
+ }
+
+ remained_length = 0;
+ } else {
+ strncpy(single_msg, recv_msg + prev_pos, single_length);
+ single_msg[single_length] = '\0';
+ }
+
+ if (single_msg[0] == '{') {
+ num_msg++;
+ /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
+ /* process each message */
+ __camera_process_msg(cb_info, single_msg);
+ } else {
+ LOGE("invalid msg [%s]", single_msg);
+ }
+ } else {
+ LOGE("too long message [len %d] skip...", single_length);
+ }
+
+ prev_pos = cur_pos + 1;
+ }
+ }
+
+ /* check incompleted message */
+ if (recv_msg[recv_length - 1] != '}') {
+ remained_length = recv_length - prev_pos;
+
+ LOGW("incompleted message [len %d]", remained_length);
+
+ if (remained_msg) {
+ free(remained_msg);
+ remained_msg = NULL;
+ }
+
+ remained_msg = (char *)malloc(remained_length + 1);
+ if (remained_msg) {
+ strncpy(remained_msg, recv_msg + prev_pos, remained_length);
+ remained_msg[remained_length] = '\0';
+ } else {
+ LOGE("failed to alloc for remained msg");
+ }
+ } else {
+ remained_length = 0;
+ }
+ }
+
+ LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
+
+ if (!cb_info->is_server_connected) {
+ /* send error msg for server disconnection */
+ char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
+ MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
+ MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
+ NULL);
+
+ if (!error_msg) {
+ LOGE("error_msg failed");
+ goto CB_HANDLER_EXIT;
+ }
+
+ __camera_add_msg_to_queue(cb_info,
+ MUSE_CAMERA_CB_EVENT,
+ MUSE_CAMERA_EVENT_TYPE_ERROR,
+ MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
+ error_msg);
+
+ muse_core_msg_free(error_msg);
+ error_msg = NULL;
+
+ LOGE("add error msg for service disconnection done");
+ }
+
+CB_HANDLER_EXIT:
+ if (single_msg) {
+ free(single_msg);
+ single_msg = NULL;
+ }
+
+ if (remained_msg) {
+ free(remained_msg);
+ remained_msg = 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);
+ 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)
+{
+ 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;
+ }
+
+ cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
+
+ 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->fd_lock);
+ 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 */
+
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
+
+ /* 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;
+ }
+
+ cb_info->is_server_connected = TRUE;
+
+ 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);
+
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
+ g_mutex_clear(&cb_info->fd_lock);
+ 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);
+ 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);
+
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
+ g_mutex_clear(&cb_info->fd_lock);
+ 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_client_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_independent_request(int api, int device_type, const char *key, int *value)
+{
+ int ret = CAMERA_ERROR_NONE;
+ int sock_fd = -1;
+ char *msg = NULL;
+ char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
+
+ /* create muse connection */
+ if (!key || !value) {
+ LOGE("NULL pointer");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ sock_fd = muse_client_new();
+ if (sock_fd < 0) {
+ LOGE("muse_client_new failed");
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
+
+ msg = muse_core_msg_new(api,
+ MUSE_TYPE_INT, "module", MUSE_CAMERA,
+ MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
+ 0);
+ if (!msg) {
+ LOGE("msg failed");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _REQUEST_EXIT;
+ }
+
+ ret = muse_core_msg_send(sock_fd, msg);
+
+ muse_core_msg_free(msg);
+ msg = NULL;
+
+ if (ret < 0) {
+ LOGE("send msg failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
+
+ ret = muse_core_msg_recv(sock_fd, recv_msg);
+ if (ret <= 0) {
+ LOGE("recv msg failed %d", errno);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
+
+ if (!muse_camera_msg_get(ret, recv_msg)) {
+ LOGE("failed to get return value from msg [%s]", recv_msg);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
+
+ if (ret == CAMERA_ERROR_NONE)
+ muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
+
+ LOGD("api %d - value %d", api, *value);
+
+_REQUEST_EXIT:
+ if (sock_fd > -1) {
+ muse_client_close(sock_fd);
+ sock_fd = -1;
+ }
+
+ 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_client_new();
+ if (sock_fd < 0) {
+ LOGE("muse_client_new failed - returned fd %d", sock_fd);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto ErrorExit;
+ }
+
+ pid = getpid();
+
+ send_msg = muse_core_msg_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_msg_send(sock_fd, send_msg);
+
+ muse_core_msg_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);
+ 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);
+
+ pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
+
+ 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_client_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 i = 0;
+ 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);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ /* reset callback and user data */
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
+ pc->cb_info->user_cb[i] = NULL;
+ pc->cb_info->user_data[i] = NULL;
+ }
+ UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ }
+
+ 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");
+
+ if (pc->cb_info->is_server_connected)
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ else
+ LOGW("server disconnected. release resource without send message.");
+
+ if (ret == CAMERA_ERROR_NONE) {
+ _camera_deactivate_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_NO_TIMEOUT);
+ 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);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", 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;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
+
+ 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);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", 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);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", 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);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", 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;
+
+ 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)
+ *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
+ 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);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
+ 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;
+
+ 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)
+ *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_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) {
+ int send_ret = 0;
+
+ length = sizeof(camera_wl_info_s) / sizeof(int) + \
+ (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
+
+ msg = muse_core_msg_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 (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
+ g_mutex_lock(&pc->cb_info->fd_lock);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+ g_mutex_unlock(&pc->cb_info->fd_lock);
+ }
+
+ if (send_ret < 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);
+ }
+
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_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_state_e current_state = CAMERA_STATE_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;
+ }
+
+ 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, true);
+ if (ret != CAMERA_ERROR_NONE)
+ return ret;
+ }
+ }
+
+ 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);
+
+ if (current_state == CAMERA_STATE_PREVIEW) {
+ LOGW("restart evas rendering");
+ _camera_start_evas_rendering(camera);
+ }
+
+ 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;
+
+ 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) {
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
+ }
+
+ 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;
+ 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)
+ *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_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;
+ 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)
+ *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_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;
+ 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)
+ *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_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;
+ 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)
+ *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_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;
+ 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) {
+ *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_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;
+
+ 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) {
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
+ }
+
+ 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;
+
+ 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)
+ *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_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;
+
+ 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)
+ *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_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;
+
+ 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)
+ *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+
+ 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+
+ 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
+ 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_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_INTERRUPT_STARTED_CB;
+
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_unset_interrupt_started_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_INTERRUPT_STARTED_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);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
+ 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+ }
+
+ 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");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
}
- if( camera_is_supported_face_detection(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ 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;
}
- camera_s * handle = (camera_s*)camera;
- camera_state_e state = CAMERA_STATE_NONE;
- int ret;
- camera_get_state(camera, &state);
- if( state != CAMERA_STATE_PREVIEW ){
- LOGE("INVALID_STATE(0x%08x)",CAMERA_ERROR_INVALID_STATE);
- return CAMERA_ERROR_INVALID_STATE;
+ 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;
}
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_ON,
- NULL);
- if( ret == MM_ERROR_NONE ){
- handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = (void*)user_data;
- handle->num_of_faces = 0;
+ 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;
}
- return __convert_camera_error_code(__func__,ret);
+ 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_stop_face_detection(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !width || !height) {
+ LOGE("NULL pointer %p %p %p", pc, width, height);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- int ret;
- if( camera_is_supported_face_detection(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ LOGD("Enter");
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
}
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DETECT_MODE, MM_CAMCORDER_DETECT_MODE_OFF, NULL);
- handle->user_cb[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
- handle->num_of_faces = 0;
- return __convert_camera_error_code(__func__,ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_get_state(camera_h camera, camera_state_e * state){
- if( camera == NULL || state == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !angle) {
+ LOGE("NULL pointer %p %p", pc, angle);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s*)camera;
- camera_state_e capi_state;
- MMCamcorderStateType mmstate ;
- mm_camcorder_get_state(handle->mm_handle, &mmstate);
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- capi_state = __camera_state_convert(mmstate);
+ if (ret == CAMERA_ERROR_NONE)
+ *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
- if( (handle->state == CAMERA_STATE_CAPTURED || handle->is_capture_completed) && (handle->current_capture_count > 0 || handle->is_capture_completed) && mmstate == MM_CAMCORDER_STATE_CAPTURING ){
- capi_state = CAMERA_STATE_CAPTURED;
+ 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;
}
- *state = capi_state;
- return CAMERA_ERROR_NONE;
+ 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_start_focusing( camera_h camera, bool continuous ){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s*)camera;
- if( handle->cached_focus_mode != -1 ){
- LOGD("apply cached focus mode %d", handle->cached_focus_mode);
- mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_AF_SCAN_RANGE , handle->cached_focus_mode, NULL);
- handle->cached_focus_mode = -1;
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_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;
}
- if( continuous )
- return __camera_start_continuous_focusing(camera);
- else{
- mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, handle->focus_area_valid ? MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO : MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
- return __convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle));
+ 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_start_continuous_focusing(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- camera_s *handle = (camera_s*)camera;
- int ret;
- int mode;
- handle->on_continuous_focusing = true;
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &mode, NULL);
+ LOGD("Enter");
- if( mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS )
- ret = mm_camcorder_start_focusing(handle->mm_handle);
- else
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_CONTINUOUS, NULL);
- return __convert_camera_error_code(__func__, ret);
+ 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_cancel_focusing(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !fps) {
+ LOGE("NULL pointer %p %p", pc, fps);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s*)camera;
- handle->on_continuous_focusing = false;
- return __convert_camera_error_code(__func__, mm_camcorder_stop_focusing(handle->mm_handle));
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
+
+ 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 = MM_ERROR_NONE;
- int set_surface = MM_DISPLAY_SURFACE_X;
- void *set_handle = NULL;
- camera_s *handle = NULL;
- Evas_Object *obj = NULL;
- const char *object_type = NULL;
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+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;
+
+ if (!pc || !pc->cb_info || !quality) {
+ LOGE("NULL pointer %p %p", pc, quality);
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);
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_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;
+
+ if (!pc || !pc->cb_info || !bitrate) {
+ LOGE("NULL pointer %p %p", pc, bitrate);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- handle = (camera_s *)camera;
- handle->display_type = type;
+ LOGD("Enter");
- if( type == CAMERA_DISPLAY_TYPE_NONE ){
- /* NULL surface */
- set_surface = MM_DISPLAY_SURFACE_NULL;
- handle->display_handle = 0;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- 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") ){
- /* x window overlay surface */
- handle->display_handle = (void *)elm_win_xwindow_get(obj);
- set_surface = MM_DISPLAY_SURFACE_X;
- set_handle = &(handle->display_handle);
-
- LOGD("display type OVERLAY : handle %p, %d", set_handle, (int)handle->display_handle);
- } else if( type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image") ) {
- /* evas object surface */
- handle->display_handle = display;
- set_surface = MM_DISPLAY_SURFACE_EVAS;
- set_handle = display;
+ if (ret == CAMERA_ERROR_NONE)
+ *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
- LOGD("display type EVAS : handle %p", set_handle);
- } 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;
- }
+ 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;
+
+ 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)
+ *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_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;
}
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
- MMCAM_DISPLAY_SURFACE, set_surface,
- NULL);
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if( ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE ){
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *), NULL);
+ 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;
}
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_set_preview_resolution(camera_h camera, int width, int height){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL);
- return __convert_camera_error_code(__func__, ret);
-}
-int camera_set_capture_resolution(camera_h camera, int width, int height){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ LOGD("Enter");
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL);
+ CAMERA_MSG_PARAM_SET(param, INT, value);
- if( ret == MM_ERROR_NONE ){
- handle->capture_width = width;
- handle->capture_height = height;
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_iso);
- return __convert_camera_error_code(__func__, ret);
+ _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){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- if( format == CAMERA_PIXEL_FORMAT_UYVY ){
- bool supported_ITLV_UYVY = false;
- MMCamAttrsInfo supported_format;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &supported_format);
- int i;
- for( i=0 ; i < supported_format.int_array.count ; i++ ){
- if( supported_format.int_array.array[i] == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
- supported_ITLV_UYVY = true;
- }
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FORMAT, supported_ITLV_UYVY ? MM_PIXEL_FORMAT_ITLV_JPEG_UYVY : MM_PIXEL_FORMAT_UYVY,
- NULL);
- } else {
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL);
- }
+ CAMERA_MSG_PARAM_SET(param, INT, level);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_get_preview_resolution(camera_h camera, int *width, int *height){
- if( camera == NULL || width == NULL || height == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_WIDTH, width,
- MMCAM_CAMERA_HEIGHT, height,
- NULL);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, level);
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- if( rotation > CAMERA_ROTATION_270 )
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
- int ret;
- camera_s * handle = (camera_s*)camera;
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_ROTATION, rotation,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_get_display_rotation( camera_h camera, camera_rotation_e *rotation){
- if( camera == NULL || rotation == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL);
- return __convert_camera_error_code(__func__, ret);
+ 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_set_display_flip(camera_h camera, camera_flip_e flip){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- if( flip > CAMERA_FLIP_BOTH )
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter");
- int ret;
- camera_s * handle = (camera_s*)camera;
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_FLIP, flip,
- NULL);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_get_display_flip(camera_h camera, camera_flip_e *flip){
- if( camera == NULL || flip == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_FLIP, flip,
- NULL);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_set_display_visible(camera_h camera, bool visible){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, STRING, description);
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_VISIBLE, visible,
- NULL);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_is_display_visible(camera_h camera, bool* visible){
- if( camera == NULL || visible == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- int result;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_VISIBLE, &result,
- NULL);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- if( ret == MM_ERROR_NONE)
- *visible = result;
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_set_display_mode(camera_h camera, camera_display_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- if( mode > CAMERA_DISPLAY_MODE_CROPPED_FULL )
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter, remote_handle : %x", pc->remote_handle);
+
+ CAMERA_MSG_PARAM_SET(param, STRING, software);
- int ret;
- camera_s * handle = (camera_s*)camera;
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode){
- if( camera == NULL || mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+ int send_ret = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
- NULL);
+ length = sizeof(set_geotag) / sizeof(int) + \
+ (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
- return __convert_camera_error_code(__func__, ret);
-}
+ msg = muse_core_msg_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;
+ }
-int camera_get_capture_resolution(camera_h camera, int *width, int *height){
- if( camera == NULL || width== NULL || height == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
+ g_mutex_lock(&pc->cb_info->fd_lock);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+ g_mutex_unlock(&pc->cb_info->fd_lock);
}
- camera_s * handle = (camera_s*)camera;
- *width = handle->capture_width;
- *height = handle->capture_height;
+ if (send_ret < 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);
+ }
- return CAMERA_ERROR_NONE;
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){
- if( camera == NULL || format == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAPTURE_FORMAT, format,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){
- if( camera == NULL || format == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FORMAT, format,
- NULL);
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
- if( (MMPixelFormatType)*format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
- *format = CAMERA_PIXEL_FORMAT_UYVY;
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data){
- if( camera == NULL || callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !zoom) {
+ LOGE("NULL pointer %p %p", pc, zoom);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s *)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data;
+ LOGD("Enter");
- mm_camcorder_set_video_stream_callback(handle->mm_handle,
- (mm_camcorder_video_stream_callback)__mm_videostream_callback,
- (void *)handle);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
+ if (ret == CAMERA_ERROR_NONE)
+ *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_unset_preview_cb( camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s *)camera;
+ LOGD("Enter");
- if( handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL ){
- mm_camcorder_set_video_stream_callback(handle->mm_handle,
- (mm_camcorder_video_stream_callback)NULL,
- (void *)NULL);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
}
- handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if( camera_is_supported_media_packet_preview_cb(camera) == false ){
- LOGE("NOT SUPPORTED");
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+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;
- if( callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *handle = (camera_s *)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)user_data;
+ LOGD("Enter");
- mm_camcorder_set_video_stream_callback(handle->mm_handle,
- (mm_camcorder_video_stream_callback)__mm_videostream_callback,
- (void *)handle);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_unset_media_packet_preview_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if( camera_is_supported_media_packet_preview_cb(camera) == false ){
- LOGE("NOT SUPPORTED");
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ LOGD("Enter");
- camera_s *handle = (camera_s *)camera;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] == NULL ){
- mm_camcorder_set_video_stream_callback(handle->mm_handle,
- (mm_camcorder_video_stream_callback)NULL,
- (void*)NULL);
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
- handle->user_cb[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void*)NULL;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){
- if( camera == NULL || callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data;
+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;
- return CAMERA_ERROR_NONE;
-}
-int camera_unset_state_changed_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !value) {
+ LOGE("NULL pointer %p %p", pc, value);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL;
+ LOGD("Enter");
- return CAMERA_ERROR_NONE;
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data){
- if( camera == NULL || callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)user_data;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_unset_interrupted_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_INTERRUPTED] = (void*)NULL;
+ LOGD("Enter");
- return CAMERA_ERROR_NONE;
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){
- if( camera == NULL || callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
}
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_unset_focus_changed_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL;
- return CAMERA_ERROR_NONE;
-}
+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 camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){
- if( camera == NULL || callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !iso) {
+ LOGE("NULL pointer %p %p", pc, iso);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data;
+ LOGD("Enter");
- return CAMERA_ERROR_NONE;
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_unset_error_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !level) {
+ LOGE("NULL pointer %p %p", pc, level);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo preview_width;
- MMCamAttrsInfo preview_height;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width);
- ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < preview_width.int_array.count ; i++ ){
- if( !foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo capture_width;
- MMCamAttrsInfo capture_height;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width);
- ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height);
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ LOGD("Enter");
- int i;
- for( i=0 ; i < capture_width.int_array.count ; i++)
- {
- if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) )
- break;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
}
- return CAMERA_ERROR_NONE;
+
+ 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){
- if( camera == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !level) {
+ LOGE("NULL pointer %p %p", pc, level);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo format;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < format.int_array.count ; i++ ){
- if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY )
- if ( !foreach_cb(format.int_array.array[i], user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo format;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < format.int_array.count ; i++ ){
- if( format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY /* || format.int_array.array[i] != MM_PIXEL_FORMAT_ITLV_JPEG_NV12 */)
- if ( !foreach_cb(format.int_array.array[i], user_data) )
- break;
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
+ LOGD("min %d, max %d", *min, *max);
}
- return CAMERA_ERROR_NONE;
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height){
- if( camera == NULL || width == NULL || height == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- enum MMCamcorderPreviewType wide;
- int capture_w, capture_h;
- double ratio;
- int ret;
- camera_s * handle = (camera_s*)camera;
+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;
- camera_get_capture_resolution(camera, &capture_w, &capture_h);
- ratio = (double)capture_w/(double)capture_h;
- if( ratio > 1.5 ){
- wide = MM_CAMCORDER_PREVIEW_TYPE_WIDE;
- } else if( ratio == 1.0 ){
- wide = MM_CAMCORDER_PREVIEW_TYPE_SQUARE;
- } else {
- wide = MM_CAMCORDER_PREVIEW_TYPE_NORMAL;
+ if (!pc || !pc->cb_info || !wb) {
+ LOGE("NULL pointer %p %p", pc, wb);
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
- MMCamAttrsInfo width_info, height_info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_WIDTH , &width_info);
- ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_RECOMMEND_CAMERA_HEIGHT, &height_info);
-
- if( ret != 0 )
- return __convert_camera_error_code(__func__, ret);
+ LOGD("Enter");
- if( width && (unsigned int)width_info.int_array.count > wide ){
- *width = width_info.int_array.array[wide];
- } else {
- LOGE("there is no width value for resolution %dx%d type %d", capture_w, capture_h, wide);
- return CAMERA_ERROR_INVALID_OPERATION;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if( height && (unsigned int)height_info.int_array.count > wide ){
- *height = height_info.int_array.array[wide];
- } else {
- LOGE("there is no height value for resolution %dx%d type %d", capture_w, capture_h, wide);
- return CAMERA_ERROR_INVALID_OPERATION;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
- LOGI("recommend resolution %dx%d, type %d", *width, *height, wide);
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_attr_get_lens_orientation(camera_h camera, int *angle){
- if( camera == NULL || angle == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !effect) {
+ LOGE("NULL pointer %p %p", pc, effect);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- int rotation;
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL);
+ LOGD("Enter");
- switch( rotation ){
- case MM_DISPLAY_ROTATION_NONE:
- *angle = 0;
- break;
- case MM_DISPLAY_ROTATION_90:
- *angle = 270;
- break;
- case MM_DISPLAY_ROTATION_180:
- *angle = 180;
- break;
- case MM_DISPLAY_ROTATION_270:
- *angle = 90;
- break;
- default :
- *angle = 0;
- break;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE, mode, NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode){
- if( camera == NULL || mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_MODE , mode, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !enable) {
+ LOGE("NULL pointer %p %p", pc, enable);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_DISPLAY_MODE , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for (i=0 ; i < info.int_array.count ; i++ ){
- if ( !foreach_cb(info.int_array.array[i],user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
- return CAMERA_ERROR_NONE;
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !description) {
+ LOGE("NULL pointer %p %p", pc, description);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- if( fps == CAMERA_ATTR_FPS_AUTO ){
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FPS_AUTO, 1,
- NULL);
- } else {
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FPS_AUTO, 0,
- MMCAM_CAMERA_FPS, fps,
- NULL);
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
+
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_image_quality(camera_h camera, int quality){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !orientation) {
+ LOGE("NULL pointer %p %p", pc, orientation);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){
- if( camera == NULL || fps == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !software) {
+ LOGE("NULL pointer %p %p", pc, software);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- int mm_fps;
- int is_auto;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL);
+ if (ret == CAMERA_ERROR_NONE)
+ *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
- if( is_auto )
- *fps = CAMERA_ATTR_FPS_AUTO;
- else
- *fps = mm_fps;
- return __convert_camera_error_code(__func__, 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;
-int camera_attr_get_image_quality(camera_h camera, int *quality){
- if( camera == NULL || quality == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
+ LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_attr_set_zoom(camera_h camera, int zoom){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (ret == CAMERA_ERROR_NONE) {
+ *latitude = pc->cb_info->get_geotag[0];
+ *longitude = pc->cb_info->get_geotag[1];
+ *altitude = pc->cb_info->get_geotag[2];
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_INVALID_PARAMETER;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
- int focus_mode;
- bool should_change_focus_mode = false;
- mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
- NULL);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if( focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO && focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && focus_mode != MM_CAMCORDER_FOCUS_MODE_AUTO )
- should_change_focus_mode = true;
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
- if( mode != CAMERA_ATTR_AF_NONE && focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS && !handle->on_continuous_focusing ){
- handle->cached_focus_mode = mode;
- LOGD("af mode will be set actually start focusing");
- return __convert_camera_error_code(__func__, 0);
- } else {
- handle->cached_focus_mode = -1;
- }
+ LOGD("ret : 0x%x", ret);
- if( mode != CAMERA_ATTR_AF_NONE && should_change_focus_mode ){
- mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_AUTO, NULL);
- }
+ return ret;
+}
- switch( mode ){
- case CAMERA_ATTR_AF_NONE:
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_NONE,
- MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NONE,
- NULL);
- break;
- case CAMERA_ATTR_AF_NORMAL:
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_NORMAL,
- NULL);
- break;
- case CAMERA_ATTR_AF_MACRO:
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_MACRO,
- NULL);
- break;
- case CAMERA_ATTR_AF_FULL:
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_AF_SCAN_RANGE, MM_CAMCORDER_AUTO_FOCUS_FULL,
- NULL);
- break;
- default:
- return ret;
- }
- return __convert_camera_error_code(__func__, ret);
-}
+int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
+{
+ int ret = CAMERA_ERROR_NONE;
+ int get_flash_state = 0;
-int camera_attr_set_af_area(camera_h camera, int x, int y){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!state) {
+ LOGE("NULL pointer");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_INVALID_PARAMETER;
- camera_s * handle = (camera_s*)camera;
- camera_attr_af_mode_e mode;
- camera_attr_get_af_mode(camera, &mode);
+ ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
+ (int)device, "get_flash_state", &get_flash_state);
- if( mode == CAMERA_ATTR_AF_NONE ){
- LOGE("INVALID_OPERATION(0x%08x) AF mode is CAMERA_ATTR_AF_NONE",CAMERA_ERROR_INVALID_OPERATION);
- return CAMERA_ERROR_INVALID_OPERATION;
+ if (ret == CAMERA_ERROR_NONE) {
+ *state = (camera_flash_state_e)get_flash_state;
+ LOGD("flash state %d", *state);
+ } else {
+ LOGE("failed 0x%x", ret);
}
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_AF_TOUCH_X, x,
- MMCAM_CAMERA_AF_TOUCH_Y, y,
- NULL);
+ return ret;
+}
- if( ret == MM_ERROR_NONE )
- handle->focus_area_valid = true;
- return __convert_camera_error_code(__func__, 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;
-int camera_attr_clear_af_area(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- handle->focus_area_valid = false;
-
- return CAMERA_ERROR_NONE;
-}
+ LOGD("Enter");
-int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ 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;
- int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF
- MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL
- MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER
- MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT
- MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM
- };
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_EXPOSURE_MODE, maptable[abs(mode%5)],
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_exposure(camera_h camera, int value){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_EXPOSURE_VALUE, value,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_ISO, iso,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_brightness(camera_h camera, int level){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_BRIGHTNESS, level,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_contrast(camera_h camera, int level){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_CONTRAST, level,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_WB, wb,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_COLOR_TONE, effect,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_SCENE_MODE, mode,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_enable_tag(camera_h camera, bool enable){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_ENABLE, enable,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_tag_image_description(camera_h camera, const char *description){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_IMAGE_DESCRIPTION, description, strlen(description),
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_ORIENTATION, orientation,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_tag_software(camera_h camera, const char *software){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_SOFTWARE, software, strlen(software),
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_GPS_ENABLE, 1,
- MMCAM_TAG_LATITUDE, latitude,
- MMCAM_TAG_LONGITUDE, longitude,
- MMCAM_TAG_ALTITUDE, altitude,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_remove_geotag(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_GPS_ENABLE, 0,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_STROBE_MODE, mode,
- NULL);
+ LOGD("Enter, handle :%x", pc->remote_handle);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_zoom(camera_h camera, int *zoom){
- if( camera == NULL || zoom == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_DIGITAL_ZOOM, zoom,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_get_zoom_range(camera_h camera, int *min, int *max){
- if( camera == NULL || min == NULL || max == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ value = (width << 16) | height;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo ainfo;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- if( min )
- *min = ainfo.int_range.min;
- if( max )
- *max = ainfo.int_range.max;
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){
- if( camera == NULL || mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- int focus_mode;
- int af_range;
- int detect_mode;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
- MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
- MMCAM_DETECT_MODE, &detect_mode,
- NULL);
+ LOGD("Enter");
- if( ret == CAMERA_ERROR_NONE ){
- switch( focus_mode ){
- case MM_CAMCORDER_FOCUS_MODE_NONE :
- case MM_CAMCORDER_FOCUS_MODE_PAN :
- case MM_CAMCORDER_FOCUS_MODE_MANUAL :
- *mode = CAMERA_ATTR_AF_NONE;
- break;
- case MM_CAMCORDER_FOCUS_MODE_AUTO:
- case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
- case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
- switch ( af_range ){
- case MM_CAMCORDER_AUTO_FOCUS_NONE :
- *mode = CAMERA_ATTR_AF_NORMAL;
- break;
- case MM_CAMCORDER_AUTO_FOCUS_NORMAL:
- *mode = CAMERA_ATTR_AF_NORMAL;
- break;
- case MM_CAMCORDER_AUTO_FOCUS_MACRO:
- *mode = CAMERA_ATTR_AF_MACRO;
- break;
- case MM_CAMCORDER_AUTO_FOCUS_FULL:
- *mode = CAMERA_ATTR_AF_FULL;
- break;
- default :
- *mode = CAMERA_ATTR_AF_NORMAL;
- break;
- }
- break;
- default :
- *mode = CAMERA_ATTR_AF_NONE;
- break;
- }
- }
+ 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;
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){
- if( camera == NULL|| mode == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int maptable[] = {
- CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
- CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
- CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
- CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
- CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
- CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
- CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
- CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
- CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
- };
- int ret;
- int exposure_mode;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_EXPOSURE_MODE, &exposure_mode, NULL);
- if( ret == CAMERA_ERROR_NONE ){
- *mode = maptable[abs(exposure_mode%9)];
- }
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ 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;
-int camera_attr_get_exposure(camera_h camera, int *value){
- if( camera == NULL || value == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_EXPOSURE_VALUE, value, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){
- if( camera == NULL || min == NULL || max == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo ainfo;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- if( min )
- *min = ainfo.int_range.min;
- if( max )
- *max = ainfo.int_range.max;
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){
- if( camera == NULL || iso == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !rotation) {
+ LOGE("NULL pointer %p %p", pc, rotation);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_ISO, iso,
- NULL);
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_attr_get_brightness(camera_h camera, int *level){
- if( camera == NULL || level == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_BRIGHTNESS, level,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){
- if( camera == NULL || min == NULL || max == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo ainfo;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo);
-
- if( min )
- *min = ainfo.int_range.min;
- if( max )
- *max = ainfo.int_range.max;
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ CAMERA_MSG_PARAM_SET(param, INT, set_flip);
-int camera_attr_get_contrast(camera_h camera, int *level){
- if( camera == NULL || level == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_CONTRAST, level,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){
- if( camera == NULL || min == NULL || max == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !flip) {
+ LOGE("NULL pointer %p %p", pc, flip);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo ainfo;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo);
-
- if( min )
- *min = ainfo.int_range.min;
- if( max )
- *max = ainfo.int_range.max;
+ LOGD("Enter");
- return __convert_camera_error_code(__func__, ret);
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){
- if( camera == NULL || wb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_WB, wb,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){
- if( camera == NULL || effect == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- int tone;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_COLOR_TONE, &tone,
- NULL);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
- *effect = (camera_attr_effect_mode_e)tone;
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
-}
+ LOGD("ret : 0x%x", ret);
-int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){
- if( camera == NULL || mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ return ret;
+}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_FILTER_SCENE_MODE, mode,
- NULL);
- return __convert_camera_error_code(__func__, 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 camera_attr_is_enabled_tag(camera_h camera, bool *enable){
- if( camera == NULL || enable == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_ENABLE, enable,
- NULL);
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_get_tag_image_description(camera_h camera, char **description){
- if( camera == NULL || description == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- int ret;
- camera_s * handle = (camera_s*)camera;
- char *ndescription = NULL;
- int desc_size;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_IMAGE_DESCRIPTION, &ndescription, &desc_size, NULL);
+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( ret == CAMERA_ERROR_NONE ){
- if( ndescription != NULL )
- *description = strdup(ndescription);
- else
- *description = strdup("");
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
- return __convert_camera_error_code(__func__, ret);
-}
+ LOGD("Enter");
-int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){
- if( camera == NULL || orientation == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_ORIENTATION, orientation,
- NULL);
+ LOGD("ret : %d", ret);
- return __convert_camera_error_code(__func__, ret);
+ return (bool)ret;
}
-int camera_attr_get_tag_software(camera_h camera, char **software){
- if( camera == NULL || software == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- char *soft;
- int soft_size;
+ LOGD("Enter");
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_TAG_SOFTWARE, &soft, &soft_size, NULL);
-
- if( ret == CAMERA_ERROR_NONE ){
- if( soft != NULL )
- *software = strdup(soft);
- else
- *software = strdup("");
+ if (!camera_attr_is_supported_hdr_capture(camera)) {
+ LOGE("HDR not supported");
+ return CAMERA_ERROR_NOT_SUPPORTED;
}
- return __convert_camera_error_code(__func__, ret);
-}
-
-int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude){
- if( camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!callback) {
+ LOGE("NULL callback");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_TAG_LATITUDE, latitude,
- MMCAM_TAG_LONGITUDE, longitude,
- MMCAM_TAG_ALTITUDE, altitude,
- NULL);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
-}
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
-int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){
- if( camera == NULL || mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- 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;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
- MMCAM_STROBE_MODE, mode,
- NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- int i;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo af_range;
- MMCamAttrsInfo focus_mode;
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE, &af_range);
- ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE, &focus_mode);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
- for( i=0 ; i < af_range.int_array.count ; i++ ) {
- if( !foreach_cb(af_range.int_array.array[i],user_data) )
- goto ENDCALLBACK;
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
- ENDCALLBACK:
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int maptable[] = {
- CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF
- CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL
- CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1
- -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2
- -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3
- CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1
- -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2
- CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1
- -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2
- };
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
- int i;
- for( i=0 ; i < info.int_array.count ; i++ ){
- if( maptable[info.int_array.array[i]] != -1 ){
- if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) )
- break;
- }
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++ ){
- if( !foreach_cb(info.int_array.array[i],user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB, &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++ ){
- if ( !foreach_cb(info.int_array.array[i],user_data) )
- break;
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
}
- return CAMERA_ERROR_NONE;
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
-int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
- int i;
- for( i=0 ; i < info.int_array.count ; i++){
- int effect = info.int_array.array[i];
- if( !foreach_cb(effect,user_data) )
- break;
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++){
- if ( !foreach_cb(info.int_array.array[i],user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++){
- if( !foreach_cb(info.int_array.array[i],user_data) )
- break;
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
}
- return CAMERA_ERROR_NONE;
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
-int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
- int i;
- for( i=0 ; i < info.int_array.count ; i++){
- if( !foreach_cb(info.int_array.array[i],user_data) )
- break;
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FLIP , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++){
- if( !foreach_cb(info.int_array.array[i], user_data) )
- break;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
- return CAMERA_ERROR_NONE;
+ 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){
- if( camera == NULL || foreach_cb == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ROTATION , &info);
+ LOGD("Enter");
- if( ret != CAMERA_ERROR_NONE )
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- int i;
- for( i=0 ; i < info.int_array.count ; i++ ){
- if( !foreach_cb(info.int_array.array[i], user_data) )
- break;
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
}
- return CAMERA_ERROR_NONE;
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
-int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation){
- if( camera == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
}
- if( rotation > CAMERA_ROTATION_270 )
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_disable);
- int ret;
- camera_s * handle = (camera_s*)camera;
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
- return __convert_camera_error_code(__func__, 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;
-int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation){
- if( camera == NULL || rotation == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- camera_s * handle = (camera_s*)camera;
+ 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);
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ROTATION, rotation, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !pan_step) {
+ LOGE("NULL pointer %p %p", pc, pan_step);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if( flip > CAMERA_FLIP_BOTH )
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter");
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
- MMCAM_CAMERA_FLIP, flip,
- NULL);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- return __convert_camera_error_code(__func__, ret);
-}
+ if (ret == CAMERA_ERROR_NONE)
+ *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
-int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip){
- if( camera == NULL || flip == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FLIP, flip, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int _camera_set_use(camera_h camera, bool used){
- camera_s * handle = (camera_s*)camera;
- handle->is_used_in_recorder = used;
- return CAMERA_ERROR_NONE;
-}
-bool _camera_is_used(camera_h camera){
- camera_s * handle = (camera_s*)camera;
- return handle->is_used_in_recorder;
-}
+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 _camera_get_mm_handle(camera_h camera , MMHandleType *handle){
- if( camera == NULL || handle == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s *camera_handle = (camera_s*)camera;
- *handle = camera_handle->mm_handle;
- return CAMERA_ERROR_NONE;
-}
+ LOGD("Enter");
-int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
}
- camera_s *handle = (camera_s*)camera;
- handle->relay_message_callback = callback;
- handle->relay_user_data = user_data;
+ LOGD("ret : 0x%x", ret);
- return CAMERA_ERROR_NONE;
+ return ret;
}
-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);
+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;
}
- return CAMERA_ERROR_NONE;
-}
+ LOGD("Enter");
-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;
- }
+ value = (set_move_type << 16) | tilt_step;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
- 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;
- }
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- return CAMERA_ERROR_NONE;
-}
+ LOGD("ret : 0x%x", ret);
-int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data){
- int ret = 0;
- void *internal_buffer = NULL;
- tbm_surface_h tsurf = NULL;
+ return ret;
+}
- if( pkt == NULL || user_data == NULL ){
- LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
- return MEDIA_PACKET_FINALIZE;
- }
- ret = media_packet_get_extra(pkt, &internal_buffer);
+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;
- if( ret != MEDIA_PACKET_ERROR_NONE ){
- LOGE("media_packet_get_extra failed 0x%x", ret);
- return MEDIA_PACKET_FINALIZE;
+ if (!pc || !pc->cb_info || !tilt_step) {
+ LOGE("NULL pointer %p %p", pc, tilt_step);
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
- /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/
+ LOGD("Enter");
- if( internal_buffer ){
- gst_buffer_unref((GstBuffer *)internal_buffer);
- internal_buffer = NULL;
- }
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- ret = media_packet_get_tbm_surface(pkt, &tsurf);
- if( ret != MEDIA_PACKET_ERROR_NONE ){
- LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
- return MEDIA_PACKET_FINALIZE;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
- if( tsurf ){
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
- }
+ LOGD("ret : 0x%x", ret);
- return MEDIA_PACKET_FINALIZE;
+ return ret;
}
-int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+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;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if( camera_attr_is_supported_hdr_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ LOGD("Enter");
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, mode, NULL);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if( ret == MM_ERROR_NONE ){
- if( mode == CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL )
- handle->hdr_keep_mode = true;
- else
- handle->hdr_keep_mode = false;
+ if (ret == CAMERA_ERROR_NONE) {
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
}
- return __convert_camera_error_code(__func__, ret);
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if( camera_attr_is_supported_hdr_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+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( mode == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - mode",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret;
- int result;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_HDR_CAPTURE, &result, NULL);
+ LOGD("Enter");
- if( ret == MM_ERROR_NONE ){
- *mode = result;
- }
+ CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
- return __convert_camera_error_code(__func__, ret);
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
}
-bool camera_attr_is_supported_hdr_capture(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
- int ret;
- int i;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo hdr_info;
- ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HDR_CAPTURE, &hdr_info);
- set_last_result(__convert_camera_error_code(__func__, ret));
- if( ret != MM_ERROR_NONE ){
- LOGE("MMCAM_CAMERA_HDR_CAPTURE get attr info failed");
- return false;
- }
+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;
- for( i = 0; i < hdr_info.int_array.count ; i++ ){
- if( hdr_info.int_array.array[i] >= MM_CAMCORDER_HDR_ON ){
- LOGD("HDR capture supported");
- return true;
- }
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
- LOGD("HDR capture NOT supported");
+ LOGD("Enter");
- return false;
+ 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_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if( camera_attr_is_supported_hdr_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+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;
+ int send_ret = 0;
- if( callback == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)callback;
- handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)user_data;
- return CAMERA_ERROR_NONE;
-}
+ LOGD("Enter");
-int camera_attr_unset_hdr_capture_progress_cb(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- 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);
- if( camera_attr_is_supported_hdr_capture(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ 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 */
- camera_s * handle = (camera_s*)camera;
- handle->user_cb[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
- handle->user_data[_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void*)NULL;
+ length = sizeof(set_display_roi_area) / sizeof(int) + \
+ (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
- return CAMERA_ERROR_NONE;
-}
+ msg = muse_core_msg_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;
+ }
-int camera_attr_enable_anti_shake(camera_h camera, bool enable){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
+ g_mutex_lock(&pc->cb_info->fd_lock);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+ g_mutex_unlock(&pc->cb_info->fd_lock);
}
- if( camera_attr_is_supported_anti_shake(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ if (send_ret < 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);
}
- int ret;
- int mode = MM_CAMCORDER_AHS_OFF;
+ __camera_update_api_waiting(pc->cb_info, api, -1);
- if( enable )
- mode = MM_CAMCORDER_AHS_ON;
+ muse_core_msg_free(msg);
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, mode, NULL);
+ LOGD("ret : 0x%x", ret);
- return __convert_camera_error_code(__func__, ret);
+ return ret;
}
-int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if( camera_attr_is_supported_anti_shake(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+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;
+ muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
- if( enabled == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
+ 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;
}
- int ret;
- int mode = MM_CAMCORDER_AHS_OFF;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_ANTI_HANDSHAKE, &mode, NULL);
+ LOGD("Enter");
- if( ret == MM_ERROR_NONE )
- *enabled = mode;
-
- return __convert_camera_error_code(__func__, ret);
-}
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-bool camera_attr_is_supported_anti_shake(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
+ if (ret == CAMERA_ERROR_NONE) {
+ *x = pc->cb_info->get_display_roi_area[0];
+ *y = pc->cb_info->get_display_roi_area[1];
+ *width = pc->cb_info->get_display_roi_area[2];
+ *height = pc->cb_info->get_display_roi_area[3];
}
- int i;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo ash_info;
- int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ANTI_HANDSHAKE , &ash_info);
- set_last_result(__convert_camera_error_code(__func__, ret));
-
- for( i=0 ; i < ash_info.int_array.count ; i++ ){
- if( ash_info.int_array.array[i] == MM_CAMCORDER_AHS_ON )
- return true;
- }
+ LOGD("ret : 0x%x", ret);
- return false;
+ return ret;
}
-int camera_attr_enable_video_stabilization(camera_h camera, bool enable){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
+
+int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
+{
+ int ret = CAMERA_ERROR_NONE;
+ int get_device_state = 0;
+
+ if (!state) {
+ LOGE("NULL pointer");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if( camera_attr_is_supported_video_stabilization(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
+ (int)device, "get_device_state", &get_device_state);
- int ret;
- int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
+ if (ret == CAMERA_ERROR_NONE) {
+ *state = (camera_device_state_e)get_device_state;
+ LOGD("device state %d", *state);
+ } else {
+ LOGE("failed 0x%x", ret);
+ }
- if( enable )
- mode = MM_CAMCORDER_VIDEO_STABILIZATION_ON;
+ return ret;
+}
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, mode, NULL);
- return __convert_camera_error_code(__func__, ret);
-}
+int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ camera_cb_info *info = NULL;
-int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle",CAMERA_ERROR_INVALID_PARAMETER);
+ if (!callback || !cb_id) {
+ LOGE("invalid pointer %p %p", callback, cb_id);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if( camera_attr_is_supported_video_stabilization(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+ /* check camera support */
+ ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get device state failed");
+ return ret;
}
- if( enabled == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+
+ info = g_new0(camera_cb_info, 1);
+ if (!info) {
+ LOGE("info failed");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _DONE;
}
- int ret;
- int mode = MM_CAMCORDER_VIDEO_STABILIZATION_OFF;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_VIDEO_STABILIZATION, &mode, NULL);
+ info->id = ++g_cam_dev_state_changed_cb_id;
+ info->callback = (void *)callback;
+ info->user_data = user_data;
- if( ret == MM_ERROR_NONE )
- *enabled = (mode == MM_CAMCORDER_VIDEO_STABILIZATION_ON);
+ *cb_id = info->id;
- return __convert_camera_error_code(__func__, ret);
-}
+ /* subscribe dbus signal for camera state change */
+ if (!g_cam_dev_state_changed_cb_conn) {
+ g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ if (!g_cam_dev_state_changed_cb_conn) {
+ LOGE("failed to get gdbus connection");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
-bool camera_attr_is_supported_video_stabilization(camera_h camera){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
+ LOGD("subscribe signal %s - %s - %s",
+ MM_CAMCORDER_DBUS_OBJECT,
+ MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
+ MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
- int i;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo vs_info;
- int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_VIDEO_STABILIZATION , &vs_info);
- set_last_result(__convert_camera_error_code(__func__, ret));
+ g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
+ NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
+ if (!g_cam_dev_state_changed_cb_subscribe_id) {
+ LOGE("failed to get gdbus connection");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
- for( i=0 ; i < vs_info.int_array.count ; i++ ){
- if( vs_info.int_array.array[i] == MM_CAMCORDER_VIDEO_STABILIZATION_ON )
- return true;
+ LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
}
- return false;
-}
+ g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
-int camera_attr_enable_auto_contrast(camera_h camera, bool enable){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ LOGD("callback id %d", info->id);
- if( camera_attr_is_supported_auto_contrast(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
+_DONE:
+ if (ret != CAMERA_ERROR_NONE) {
+ if (info) {
+ g_free(info);
+ info = NULL;
+ }
+
+ if (g_cam_dev_state_changed_cb_conn) {
+ g_object_unref(g_cam_dev_state_changed_cb_conn);
+ g_cam_dev_state_changed_cb_conn = NULL;
+ }
}
- int ret;
- int mode = MM_CAMCORDER_WDR_OFF;
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
- if( enable )
- mode = MM_CAMCORDER_WDR_ON;
+ return ret;
+}
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_WDR, mode, NULL);
- return __convert_camera_error_code(__func__, ret);
-}
+int camera_remove_device_state_changed_cb(int cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ GList *tmp_list = NULL;
+ camera_cb_info *info = NULL;
-int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled){
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ /* check camera support */
+ ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get device state failed");
+ return ret;
}
- if( camera_attr_is_supported_auto_contrast(camera) == false ){
- LOGE("NOT_SUPPORTED(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
- if( enabled == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (!g_cam_dev_state_changed_cb_list) {
+ LOGE("there is no callback info");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
}
- int ret;
- int mode = MM_CAMCORDER_WDR_OFF;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WDR , &mode, NULL);
+ tmp_list = g_cam_dev_state_changed_cb_list;
- if( ret == MM_ERROR_NONE )
- *enabled = mode;
+ do {
+ info = tmp_list->data;
+ tmp_list = tmp_list->next;
- return __convert_camera_error_code(__func__, ret);
-}
+ if (!info) {
+ LOGW("NULL info");
+ continue;
+ }
-bool camera_attr_is_supported_auto_contrast(camera_h camera) {
- if( camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
+ if (info->id == cb_id) {
+ g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
- int i;
- camera_s * handle = (camera_s*)camera;
- MMCamAttrsInfo info;
- int ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WDR, &info);
- set_last_result(__convert_camera_error_code(__func__, ret));
+ g_free(info);
+ info = NULL;
- for( i=0 ; i < info.int_array.count ; i++ ) {
- if( info.int_array.array[i] == MM_CAMCORDER_WDR_ON )
- return true;
- }
+ if (!g_cam_dev_state_changed_cb_list) {
+ /* no remained callback */
+ if (g_cam_dev_state_changed_cb_conn) {
+ /* unsubscribe signal */
+ g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
+ g_cam_dev_state_changed_cb_subscribe_id = 0;
- return false;
-}
+ /* unref connection */
+ g_object_unref(g_cam_dev_state_changed_cb_conn);
+ g_cam_dev_state_changed_cb_conn = NULL;
+ }
+ }
-int camera_attr_disable_shutter_sound(camera_h camera, bool disable){
- if (camera == NULL ){
- LOGE("INVALID_PARAMETER(0x%08x)",CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ LOGD("id %d callback removed", cb_id);
+ ret = CAMERA_ERROR_NONE;
- int ret;
- camera_s * handle = (camera_s*)camera;
- ret = mm_camcorder_set_attributes(handle->mm_handle, NULL, "capture-sound-enable", !disable, NULL);
+ goto _DONE;
+ }
+ } while (tmp_list);
- if( ret != 0 ){
- LOGE("CAMERA_ERROR_INVALID_OPERATION : not permitted disable shutter sound");
- return CAMERA_ERROR_INVALID_OPERATION;
- }
+ LOGE("id %d callback not found", cb_id);
+ ret = CAMERA_ERROR_INVALID_PARAMETER;
- return CAMERA_ERROR_NONE;
+_DONE:
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
+
+ return ret;
}