2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <muse_core_ipc.h>
27 #include <muse_core_module.h>
28 #include <camera_private.h>
29 #include <muse_core.h>
31 #include <Elementary.h>
32 #include <tbm_surface_internal.h>
34 #include <Ecore_Wayland.h>
35 #include <wayland-client.h>
36 #include <tizen-extension-client-protocol.h>
37 #ifdef TIZEN_FEATURE_EVAS_RENDERER
38 #include <mm_evas_renderer.h>
39 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
45 #define LOG_TAG "TIZEN_N_CAMERA"
47 /* for device changed callback */
48 static GMutex g_cam_dev_state_changed_cb_lock;
49 static GList *g_cam_dev_state_changed_cb_list;
50 static int g_cam_dev_state_changed_cb_id;
51 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
52 static guint g_cam_dev_state_changed_cb_subscribe_id;
56 static void __global(void *data, struct wl_registry *registry,
57 uint32_t name, const char *interface, uint32_t version)
59 struct tizen_surface **tz_surface = NULL;
66 tz_surface = (struct tizen_surface **)data;
69 LOGW("NULL interface");
73 /*LOGI("interface %s", interface);*/
75 if (strcmp(interface, "tizen_surface") == 0) {
76 LOGD("binding tizen surface for wayland");
78 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
79 if (*tz_surface == NULL)
80 LOGE("failed to bind");
88 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
94 static const struct wl_registry_listener _camera_wl_registry_listener = {
99 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
106 *((unsigned int *)data) = id;
108 LOGD("[CLIENT] got parent_id [%u] from server", id);
113 static const struct tizen_resource_listener _camera_tz_resource_listener = {
117 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
119 int ret = CAMERA_ERROR_NONE;
120 Ecore_Wl_Window *window = NULL;
121 struct wl_display *display = NULL;
122 struct wl_display *display_wrapper = NULL;
123 struct wl_surface *surface = NULL;
124 struct wl_registry *registry = NULL;
125 struct wl_event_queue *queue = NULL;
126 struct tizen_surface *tz_surface = NULL;
127 struct tizen_resource *tz_resource = NULL;
129 if (!obj || !wl_info) {
130 LOGE("NULL parameter %p %p", obj, wl_info);
131 return CAMERA_ERROR_INVALID_OPERATION;
134 window = elm_win_wl_window_get(obj);
136 LOGE("failed to get wayland window");
137 ret = CAMERA_ERROR_INVALID_OPERATION;
141 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
143 LOGE("failed to get wayland surface");
144 ret = CAMERA_ERROR_INVALID_OPERATION;
148 display = (struct wl_display *)ecore_wl_display_get();
150 LOGE("failed to get wayland display");
151 ret = CAMERA_ERROR_INVALID_OPERATION;
155 display_wrapper = wl_proxy_create_wrapper(display);
156 if (!display_wrapper) {
157 LOGE("failed to create wl display wrapper");
158 ret = CAMERA_ERROR_INVALID_OPERATION;
162 queue = wl_display_create_queue(display);
164 LOGE("failed to create wl display queue");
165 ret = CAMERA_ERROR_INVALID_OPERATION;
169 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
171 registry = wl_display_get_registry(display_wrapper);
173 LOGE("failed to get wayland registry");
174 ret = CAMERA_ERROR_INVALID_OPERATION;
178 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
180 wl_display_dispatch_queue(display, queue);
181 wl_display_roundtrip_queue(display, queue);
184 LOGE("failed to get tizen surface");
185 ret = CAMERA_ERROR_INVALID_OPERATION;
189 /* Get parent_id which is unique in a entire systemw. */
190 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
192 LOGE("failed to get tizen resurce");
193 ret = CAMERA_ERROR_INVALID_OPERATION;
197 wl_info->parent_id = 0;
199 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
201 wl_display_roundtrip_queue(display, queue);
203 if (wl_info->parent_id > 0) {
205 Ecore_Evas *ecore_evas = NULL;
206 ret = CAMERA_ERROR_NONE;
208 wl_info->evas_obj = obj;
210 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
211 &wl_info->window_width, &wl_info->window_height);
213 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
215 rotation = ecore_evas_rotation_get(ecore_evas);
216 if (rotation == 90 || rotation == 270) {
217 int temp = wl_info->window_width;
219 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
221 wl_info->window_width = wl_info->window_height;
222 wl_info->window_height = temp;
225 LOGW("failed to get ecore_evas.. skip rotation check");
228 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
229 wl_info->evas_obj, rotation, wl_info->parent_id,
230 wl_info->window_x, wl_info->window_y,
231 wl_info->window_width, wl_info->window_height);
233 ret = CAMERA_ERROR_INVALID_OPERATION;
234 LOGE("failed to get parent id");
239 tizen_surface_destroy(tz_surface);
244 tizen_resource_destroy(tz_resource);
249 wl_registry_destroy(registry);
254 wl_event_queue_destroy(queue);
258 if (display_wrapper) {
259 wl_proxy_wrapper_destroy(display_wrapper);
260 display_wrapper = NULL;
268 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
271 api < 0 || api >= MUSE_CAMERA_API_MAX) {
272 LOGE("invalid param %p %d", cb_info, api);
276 g_mutex_lock(&(cb_info->api_mutex[api]));
277 cb_info->api_waiting[api] += value;
278 g_mutex_unlock(&(cb_info->api_mutex[api]));
280 /*LOGD("api %d, value %d, waiting %d",
281 api, value, cb_info->api_waiting[api]);*/
287 static void __camera_device_state_changed_cb(GDBusConnection *connection,
288 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
289 const gchar *signal_name, GVariant *param, gpointer user_data)
292 camera_device_e device = CAMERA_DEVICE_CAMERA0;
293 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
294 GList *tmp_list = NULL;
295 camera_cb_info *info = NULL;
297 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
299 if (!g_cam_dev_state_changed_cb_list || !param) {
300 LOGW("no callback or NULL param %p", param);
304 /* get device and state */
305 g_variant_get(param, "(i)", &value);
307 device = value >> 16;
308 state = 0x0000ffff & value;
310 LOGD("device %d, state %d", device, state);
312 tmp_list = g_cam_dev_state_changed_cb_list;
315 info = (camera_cb_info *)tmp_list->data;
318 if (info->callback) {
319 LOGD("start id[%d] callback", info->id);
320 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
321 LOGD("returned id[%d] callback", info->id);
323 LOGW("NULL callback for id %d", info->id);
327 tmp_list = tmp_list->next;
331 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
337 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
339 tbm_bo tmp_bo = NULL;
340 tbm_bo_handle tmp_bo_handle = {NULL, };
342 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
343 LOGE("invalid parameter - %p %p %p, key %d",
344 bufmgr, bo, bo_handle, tbm_key);
348 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
349 if (tmp_bo == NULL) {
350 LOGE("import failed - key %d", tbm_key);
354 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
355 if (tmp_bo_handle.ptr == NULL) {
356 LOGE("map failed %p", tmp_bo);
357 tbm_bo_unref(tmp_bo);
362 tbm_bo_unmap(tmp_bo);
364 /* set bo and bo_handle */
366 *bo_handle = tmp_bo_handle;
371 static void _camera_release_imported_bo(tbm_bo *bo)
384 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
386 int ret = CAMERA_ERROR_NONE;
389 /*LOGD("Enter api : %d", api);*/
391 if (!cb_info->is_server_connected) {
392 LOGE("server is disconnected");
393 return CAMERA_ERROR_SERVICE_DISCONNECTED;
396 g_mutex_lock(&(cb_info->api_mutex[api]));
398 if (cb_info->api_activating[api] == 0) {
399 if (time_out == CAMERA_CB_NO_TIMEOUT) {
400 LOGW("wait for api %d", api);
401 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
402 ret = cb_info->api_ret[api];
403 cb_info->api_activating[api] = 0;
404 LOGW("api %d returned 0x%x", api, ret);
406 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
407 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
408 ret = cb_info->api_ret[api];
409 cb_info->api_activating[api] = 0;
410 /*LOGD("return value : 0x%x", ret);*/
412 ret = CAMERA_ERROR_INVALID_OPERATION;
413 LOGE("api %d was TIMED OUT!", api);
417 ret = cb_info->api_ret[api];
418 cb_info->api_activating[api] = 0;
420 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
423 g_mutex_unlock(&(cb_info->api_mutex[api]));
425 if (ret != CAMERA_ERROR_NONE) {
426 LOGE("api %d : error 0x%x", api, ret);
428 if (ret == CAMERA_ERROR_SOUND_POLICY)
429 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
430 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
431 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
432 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
433 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
440 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
441 int *ret, int timeout)
447 LOGE("NULL info - api %d", api);
450 *ret = CAMERA_ERROR_INVALID_PARAMETER;
455 msg = muse_core_msg_json_factory_new(api, NULL);
457 LOGE("msg failed: api %d", api);
460 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
465 /*LOGD("send msg %s", msg);*/
467 if (cb_info->is_server_connected) {
468 __camera_update_api_waiting(cb_info, api, 1);
470 g_mutex_lock(&cb_info->fd_lock);
471 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
472 g_mutex_unlock(&cb_info->fd_lock);
476 LOGE("msg send failed");
478 *ret = CAMERA_ERROR_INVALID_OPERATION;
481 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
484 __camera_update_api_waiting(cb_info, api, -1);
486 muse_core_msg_json_factory_free(msg);
492 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
493 int *ret, camera_msg_param *param, int timeout)
498 if (!cb_info || !param) {
499 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
502 *ret = CAMERA_ERROR_INVALID_PARAMETER;
507 /*LOGD("type %d, name %s", param->type, param->name);*/
509 switch (param->type) {
511 msg = muse_core_msg_json_factory_new(api,
512 param->type, param->name, param->value.value_INT,
515 case MUSE_TYPE_STRING:
516 msg = muse_core_msg_json_factory_new(api,
517 param->type, param->name, param->value.value_STRING,
521 LOGE("unknown type %d", param->type);
526 LOGE("msg failed: api %d", api);
529 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
534 /*LOGD("send msg %s", msg);*/
536 if (cb_info->is_server_connected) {
537 __camera_update_api_waiting(cb_info, api, 1);
539 g_mutex_lock(&cb_info->fd_lock);
540 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
541 g_mutex_unlock(&cb_info->fd_lock);
545 LOGE("msg send failed");
548 *ret = CAMERA_ERROR_INVALID_OPERATION;
551 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
554 __camera_update_api_waiting(cb_info, api, -1);
556 muse_core_msg_json_factory_free(msg);
562 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
564 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
565 in_format >= MM_PIXEL_FORMAT_NUM ||
566 out_format == NULL) {
567 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
568 return CAMERA_ERROR_INVALID_PARAMETER;
572 case MM_PIXEL_FORMAT_NV12:
573 case MM_PIXEL_FORMAT_NV12T:
574 *out_format = TBM_FORMAT_NV12;
577 case MM_PIXEL_FORMAT_NV16:
578 *out_format = TBM_FORMAT_NV16;
580 case MM_PIXEL_FORMAT_NV21:
581 *out_format = TBM_FORMAT_NV21;
583 case MM_PIXEL_FORMAT_YUYV:
584 *out_format = TBM_FORMAT_YUYV;
586 case MM_PIXEL_FORMAT_UYVY:
587 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
588 *out_format = TBM_FORMAT_UYVY;
590 case MM_PIXEL_FORMAT_422P:
591 *out_format = TBM_FORMAT_YUV422;
593 case MM_PIXEL_FORMAT_I420:
594 *out_format = TBM_FORMAT_YUV420;
596 case MM_PIXEL_FORMAT_YV12:
597 *out_format = TBM_FORMAT_YVU420;
599 case MM_PIXEL_FORMAT_RGB565:
600 *out_format = TBM_FORMAT_RGB565;
602 case MM_PIXEL_FORMAT_RGB888:
603 *out_format = TBM_FORMAT_RGB888;
605 case MM_PIXEL_FORMAT_RGBA:
606 *out_format = TBM_FORMAT_RGBA8888;
608 case MM_PIXEL_FORMAT_ARGB:
609 *out_format = TBM_FORMAT_ARGB8888;
612 LOGE("invalid in_format %d", in_format);
613 return CAMERA_ERROR_INVALID_PARAMETER;
617 return CAMERA_ERROR_NONE;
621 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
623 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
624 in_format >= MM_PIXEL_FORMAT_NUM ||
626 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
627 return CAMERA_ERROR_INVALID_PARAMETER;
631 case MM_PIXEL_FORMAT_NV12:
632 case MM_PIXEL_FORMAT_NV12T:
633 *mimetype = MEDIA_FORMAT_NV12;
636 case MM_PIXEL_FORMAT_NV16:
637 *mimetype = MEDIA_FORMAT_NV16;
639 case MM_PIXEL_FORMAT_NV21:
640 *mimetype = MEDIA_FORMAT_NV21;
642 case MM_PIXEL_FORMAT_YUYV:
643 *mimetype = MEDIA_FORMAT_YUYV;
645 case MM_PIXEL_FORMAT_UYVY:
646 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
647 *mimetype = MEDIA_FORMAT_UYVY;
649 case MM_PIXEL_FORMAT_422P:
650 *mimetype = MEDIA_FORMAT_422P;
652 case MM_PIXEL_FORMAT_I420:
653 *mimetype = MEDIA_FORMAT_I420;
655 case MM_PIXEL_FORMAT_YV12:
656 *mimetype = MEDIA_FORMAT_YV12;
658 case MM_PIXEL_FORMAT_RGB565:
659 *mimetype = MEDIA_FORMAT_RGB565;
661 case MM_PIXEL_FORMAT_RGB888:
662 *mimetype = MEDIA_FORMAT_RGB888;
664 case MM_PIXEL_FORMAT_RGBA:
665 *mimetype = MEDIA_FORMAT_RGBA;
667 case MM_PIXEL_FORMAT_ARGB:
668 *mimetype = MEDIA_FORMAT_ARGB;
671 LOGE("invalid in_format %d", in_format);
672 return CAMERA_ERROR_INVALID_PARAMETER;
676 return CAMERA_ERROR_NONE;
679 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
680 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
683 unsigned char *buf_pos = NULL;
685 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
686 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
691 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
692 frame->format = MM_PIXEL_FORMAT_UYVY;
694 frame->format = stream->format;
696 frame->width = stream->width;
697 frame->height = stream->height;
698 frame->timestamp = stream->timestamp;
699 frame->num_of_planes = stream->num_planes;
701 if (num_buffer_key == 0) {
704 if (!data_bo_handle || !data_bo_handle->ptr) {
705 LOGE("NULL pointer");
709 buf_pos = data_bo_handle->ptr;
711 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
712 frame->data.encoded_plane.data = buf_pos;
713 frame->data.encoded_plane.size = stream->data.encoded.length_data;
714 total_size = stream->data.encoded.length_data;
716 switch (stream->num_planes) {
718 frame->data.single_plane.yuv = buf_pos;
719 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
720 total_size = stream->data.yuv420.length_yuv;
723 frame->data.double_plane.y = buf_pos;
724 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
725 buf_pos += stream->data.yuv420sp.length_y;
726 frame->data.double_plane.uv = buf_pos;
727 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
728 total_size = stream->data.yuv420sp.length_y + \
729 stream->data.yuv420sp.length_uv;
732 frame->data.triple_plane.y = buf_pos;
733 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
734 buf_pos += stream->data.yuv420p.length_y;
735 frame->data.triple_plane.u = buf_pos;
736 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
737 buf_pos += stream->data.yuv420p.length_u;
738 frame->data.triple_plane.v = buf_pos;
739 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
740 total_size = stream->data.yuv420p.length_y + \
741 stream->data.yuv420p.length_u + \
742 stream->data.yuv420p.length_v;
751 switch (stream->num_planes) {
754 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
755 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
756 total_size = stream->data.yuv420.length_yuv;
760 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
761 if (stream->num_planes == (unsigned int)num_buffer_key)
762 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
764 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
765 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
766 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
767 total_size = stream->data.yuv420sp.length_y + \
768 stream->data.yuv420sp.length_uv;
772 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
773 if (stream->num_planes == (unsigned int)num_buffer_key) {
774 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
775 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
777 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
778 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
780 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
781 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
782 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
783 total_size = stream->data.yuv420p.length_y + \
784 stream->data.yuv420p.length_u + \
785 stream->data.yuv420p.length_v;
794 LOGD("format %d, %dx%d, size %d plane num %d",
795 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
801 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
802 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
805 int ret = CAMERA_ERROR_NONE;
806 camera_media_packet_data *tmp_mp_data = NULL;
808 if (*mp_data == NULL) {
809 tmp_mp_data = g_new0(camera_media_packet_data, 1);
811 tmp_mp_data->tbm_key = tbm_key;
812 tmp_mp_data->num_buffer_key = num_buffer_key;
813 tmp_mp_data->bo = bo;
814 tmp_mp_data->data_bo = data_bo;
815 tmp_mp_data->ref_cnt++;
817 for (i = 0 ; i < num_buffer_key ; i++)
818 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
820 *mp_data = tmp_mp_data;
821 /*LOGD("mp_data %p", tmp_mp_data);*/
823 ret = CAMERA_ERROR_OUT_OF_MEMORY;
824 LOGE("failed to alloc media packet data");
827 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
833 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
837 camera_msg_param param;
839 if (!mp_data || !cb_info) {
840 LOGE("NULL pointer %p %p", mp_data, cb_info);
844 if (mp_data->ref_cnt > 1) {
846 LOGD("ref count %d", mp_data->ref_cnt);
848 /* release imported bo */
849 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
850 tbm_bo_unref(mp_data->buffer_bo[i]);
851 mp_data->buffer_bo[i] = NULL;
855 _camera_release_imported_bo(&mp_data->bo);
856 _camera_release_imported_bo(&mp_data->data_bo);
859 tbm_key = mp_data->tbm_key;
861 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
863 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
872 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
873 camera_media_packet_data *mp_data, media_packet_h *packet)
875 media_packet_h pkt = NULL;
876 bool make_pkt_fmt = false;
877 tbm_surface_h tsurf = NULL;
878 tbm_surface_info_s tsurf_info;
879 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
880 uint32_t bo_format = 0;
883 int num_buffer_key = 0;
884 tbm_bo *buffer_bo = NULL;
886 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
887 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
888 cb_info, stream, mp_data, packet);
889 return CAMERA_ERROR_INVALID_PARAMETER;
892 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
893 buffer_bo = mp_data->buffer_bo;
894 num_buffer_key = mp_data->num_buffer_key;
896 /* create tbm surface */
897 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
898 tsurf_info.planes[i].stride = stream->stride[i];
900 /* get tbm surface format */
901 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
902 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
904 if (ret == CAMERA_ERROR_NONE) {
905 tsurf_info.width = stream->width;
906 tsurf_info.height = stream->height;
907 tsurf_info.format = bo_format;
908 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
909 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
911 if (num_buffer_key > 0) {
913 case TBM_FORMAT_NV12:
914 case TBM_FORMAT_NV21:
915 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
916 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
917 tsurf_info.planes[0].offset = 0;
918 if (num_buffer_key == 1)
919 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
920 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
923 case TBM_FORMAT_YUV420:
924 case TBM_FORMAT_YVU420:
925 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
926 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
927 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
928 tsurf_info.planes[0].offset = 0;
929 if (num_buffer_key == 1) {
930 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
931 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
933 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
935 case TBM_FORMAT_UYVY:
936 case TBM_FORMAT_YUYV:
937 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
938 tsurf_info.planes[0].offset = 0;
939 tsurf_info.size = tsurf_info.planes[0].size;
946 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
947 } else if (mp_data->data_bo) {
950 case TBM_FORMAT_NV12:
951 case TBM_FORMAT_NV21:
952 tsurf_info.planes[0].size = stream->width * stream->height;
953 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
954 tsurf_info.planes[0].offset = 0;
955 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
956 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
958 case TBM_FORMAT_YUV420:
959 case TBM_FORMAT_YVU420:
960 tsurf_info.planes[0].size = stream->width * stream->height;
961 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
962 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
963 tsurf_info.planes[0].offset = 0;
964 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
965 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
966 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
968 case TBM_FORMAT_UYVY:
969 case TBM_FORMAT_YUYV:
970 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
971 tsurf_info.planes[0].offset = 0;
972 tsurf_info.size = tsurf_info.planes[0].size;
978 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
981 /*LOGD("tbm surface %p", tsurf);*/
985 /* check media packet format */
986 if (cb_info->pkt_fmt) {
987 int pkt_fmt_width = 0;
988 int pkt_fmt_height = 0;
989 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
991 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
992 if (pkt_fmt_mimetype != mimetype ||
993 pkt_fmt_width != stream->width ||
994 pkt_fmt_height != stream->height) {
995 LOGW("change fmt: current 0x%x, %dx%d",
996 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
997 media_format_unref(cb_info->pkt_fmt);
998 cb_info->pkt_fmt = NULL;
1002 make_pkt_fmt = true;
1005 /* create packet format */
1007 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1008 ret = media_format_create(&cb_info->pkt_fmt);
1009 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1010 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1011 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1012 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1013 LOGW("media_format_set : 0x%x", ret);
1015 LOGW("media_format_create failed 0x%x", ret);
1019 /* create media packet */
1020 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1021 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1022 (void *)cb_info, &pkt);
1023 if (ret != MEDIA_PACKET_ERROR_NONE) {
1024 LOGE("media_packet_create failed 0x%x", ret);
1025 tbm_surface_destroy(tsurf);
1029 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1030 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1034 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1035 /* set media packet data */
1036 ret = media_packet_set_extra(pkt, (void *)mp_data);
1037 if (ret != MEDIA_PACKET_ERROR_NONE) {
1038 LOGE("media_packet_set_extra failed");
1040 _camera_media_packet_data_release(mp_data, cb_info);
1043 media_packet_destroy(pkt);
1046 /* set timestamp : msec -> nsec */
1047 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1048 LOGW("media_packet_set_pts failed");
1057 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1060 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1061 camera_media_packet_data *mp_data = NULL;
1062 tbm_surface_h tsurf = NULL;
1064 if (!pkt || !cb_info) {
1065 LOGE("NULL pointer %p %p", pkt, cb_info);
1066 return MEDIA_PACKET_FINALIZE;
1069 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1070 if (ret != MEDIA_PACKET_ERROR_NONE) {
1071 LOGE("media_packet_get_extra failed 0x%x", ret);
1072 return MEDIA_PACKET_FINALIZE;
1075 /*LOGD("mp_data %p", mp_data);*/
1077 g_mutex_lock(&cb_info->mp_data_mutex);
1079 _camera_media_packet_data_release(mp_data, cb_info);
1082 g_mutex_unlock(&cb_info->mp_data_mutex);
1084 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1085 if (ret != MEDIA_PACKET_ERROR_NONE)
1086 LOGE("get tbm_surface failed 0x%x", ret);
1089 tbm_surface_destroy(tsurf);
1093 return MEDIA_PACKET_FINALIZE;
1096 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1102 tbm_bo_handle bo_handle = {NULL, };
1103 camera_msg_param param;
1105 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1106 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1110 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1112 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1113 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1114 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1115 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1116 /* return preview callback */
1117 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1120 muse_camera_msg_get(tbm_key, recv_msg);
1121 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1123 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1124 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1128 } else if (cb_info->user_cb[event] == NULL) {
1129 LOGW("user callback for event %d is not set", event);
1134 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1140 muse_camera_msg_get(previous, recv_msg);
1141 muse_camera_msg_get(current, recv_msg);
1142 muse_camera_msg_get(by_policy, recv_msg);
1144 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1145 previous, current, by_policy);
1147 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1148 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1151 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1155 muse_camera_msg_get(state, recv_msg);
1157 LOGD("FOCUS state - %d", state);
1159 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1162 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1163 LOGD("CAPTURE_COMPLETED");
1164 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1166 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1167 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1171 int num_buffer_key = 0;
1172 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1174 unsigned char *buf_pos = NULL;
1176 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1177 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1178 tbm_bo data_bo = NULL;
1179 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1181 camera_preview_data_s frame;
1182 camera_stream_data_s *stream = NULL;
1183 camera_media_packet_data *mp_data = NULL;
1184 media_packet_h pkt = NULL;
1185 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1186 media_packet_h pkt_evas = NULL;
1187 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1189 muse_camera_msg_get(tbm_key, recv_msg);
1190 muse_camera_msg_get(num_buffer_key, recv_msg);
1191 muse_camera_msg_get_array(buffer_key, recv_msg);
1192 muse_camera_msg_get(data_key, recv_msg);
1194 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1197 LOGE("invalid key %d", tbm_key);
1201 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1203 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1204 LOGE("invalid num buffer key %d", num_buffer_key);
1205 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1210 /* import tbm data_bo and get virtual address */
1211 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1212 LOGE("failed to import data key %d", data_key);
1213 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1218 /* import tbm bo and get virtual address */
1219 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1220 LOGE("failed to import key %d", tbm_key);
1221 _camera_release_imported_bo(&data_bo);
1222 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1226 buf_pos = (unsigned char *)bo_handle.ptr;
1228 /* get stream info */
1229 stream = (camera_stream_data_s *)buf_pos;
1231 for (i = 0 ; i < num_buffer_key ; i++) {
1232 /* import buffer bo and get virtual address */
1233 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1234 LOGE("failed to import buffer key %d", buffer_key[i]);
1236 /* release imported bo */
1237 _camera_release_imported_bo(&data_bo);
1238 _camera_release_imported_bo(&bo);
1240 for (i -= 1 ; i >= 0 ; i--)
1241 _camera_release_imported_bo(&buffer_bo[i]);
1243 /* send return buffer */
1244 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1250 /* call preview callback */
1251 g_mutex_lock(&cb_info->preview_cb_mutex);
1253 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1254 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1256 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1257 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1260 g_mutex_unlock(&cb_info->preview_cb_mutex);
1262 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1263 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1264 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1266 if (ret == CAMERA_ERROR_NONE) {
1267 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1268 if (ret != CAMERA_ERROR_NONE) {
1269 LOGE("create pkt for evas failed");
1270 _camera_media_packet_data_release(mp_data, cb_info);
1274 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1275 LOGW("evas renderer is not supported");
1276 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1279 /* call media packet callback */
1280 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1281 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1283 if (ret == CAMERA_ERROR_NONE) {
1284 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1286 if (ret == CAMERA_ERROR_NONE) {
1287 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1288 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1290 _camera_media_packet_data_release(mp_data, cb_info);
1296 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1297 /* call evas renderer */
1299 g_mutex_lock(&cb_info->evas_mutex);
1300 if (cb_info->run_evas_render) {
1301 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1303 LOGW("evas renderer is stopped, skip this buffer...");
1304 media_packet_destroy(pkt_evas);
1307 g_mutex_unlock(&cb_info->evas_mutex);
1309 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1311 /* send message for preview callback return */
1312 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1313 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1315 if (mp_data == NULL) {
1316 /* release imported bo */
1317 for (i = 0 ; i < num_buffer_key ; i++)
1318 _camera_release_imported_bo(&buffer_bo[i]);
1320 /* unmap and unref tbm bo */
1321 _camera_release_imported_bo(&data_bo);
1322 _camera_release_imported_bo(&bo);
1325 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1327 /*LOGD("return buffer Done");*/
1332 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1336 muse_camera_msg_get(percent, recv_msg);
1338 LOGD("HDR progress - %d \%", percent);
1340 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1343 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1349 muse_camera_msg_get(policy, recv_msg);
1350 muse_camera_msg_get(previous, recv_msg);
1351 muse_camera_msg_get(current, recv_msg);
1353 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1354 policy, previous, current);
1356 if (policy == CAMERA_POLICY_SOUND)
1357 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1358 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1359 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1360 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1361 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1363 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1364 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1367 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1372 muse_camera_msg_get(policy, recv_msg);
1373 muse_camera_msg_get(state, recv_msg);
1375 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1377 if (policy == CAMERA_POLICY_SOUND)
1378 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1379 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1380 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1381 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1382 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1384 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1385 (camera_state_e)state, cb_info->user_data[event]);
1388 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1391 camera_detected_face_s *faces = NULL;
1393 muse_camera_msg_get(count, recv_msg);
1394 muse_camera_msg_get(tbm_key, recv_msg);
1397 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1401 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1403 faces = bo_handle.ptr;
1407 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1410 _camera_release_imported_bo(&bo);
1414 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1415 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1416 /*LOGD("return buffer done");*/
1419 LOGE("invalid message - count %d, key %d", count, tbm_key);
1423 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1426 int current_state = 0;
1428 muse_camera_msg_get(error, recv_msg);
1429 muse_camera_msg_get(current_state, recv_msg);
1431 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1433 if (error == CAMERA_ERROR_SOUND_POLICY)
1434 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1435 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1436 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1437 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1438 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1440 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1441 (camera_state_e)current_state, cb_info->user_data[event]);
1445 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1447 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1448 muse_camera_msg_get(param1, recv_msg);
1449 muse_camera_msg_get(param2, recv_msg);
1451 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1453 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1454 cb_info->user_cb[event] = NULL;
1455 cb_info->user_data[event] = NULL;
1456 LOGW("stop foreach callback for event %d", event);
1459 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1461 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1463 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1465 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1467 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1469 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1471 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1473 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1475 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1477 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1479 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1481 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1483 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1486 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1488 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1489 muse_camera_msg_get(param1, recv_msg);
1491 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1493 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1494 cb_info->user_cb[event] = NULL;
1495 cb_info->user_data[event] = NULL;
1496 LOGW("stop foreach callback for event %d", event);
1500 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1502 camera_image_data_s *rImage = NULL;
1503 camera_image_data_s *rPostview = NULL;
1504 camera_image_data_s *rThumbnail = NULL;
1505 unsigned char *buf_pos = NULL;
1506 int tbm_key_main = 0;
1507 int tbm_key_post = 0;
1508 int tbm_key_thumb = 0;
1509 tbm_bo bo_main = NULL;
1510 tbm_bo bo_post = NULL;
1511 tbm_bo bo_thumb = NULL;
1512 tbm_bo_handle bo_main_handle = {NULL, };
1513 tbm_bo_handle bo_post_handle = {NULL, };
1514 tbm_bo_handle bo_thumb_handle = {NULL, };
1516 muse_camera_msg_get(tbm_key_main, recv_msg);
1517 muse_camera_msg_get(tbm_key_post, recv_msg);
1518 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1521 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1522 tbm_key_main, tbm_key_post, tbm_key_thumb);
1525 if (tbm_key_main <= 0) {
1526 LOGE("invalid key %d", tbm_key_main);
1530 /* import tbm bo and get virtual address */
1531 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1534 buf_pos = (unsigned char *)bo_main_handle.ptr;
1535 rImage = (camera_image_data_s *)buf_pos;
1536 rImage->data = buf_pos + sizeof(camera_image_data_s);
1537 if (rImage->exif && rImage->exif_size > 0) {
1538 rImage->exif = rImage->data + rImage->size;
1540 rImage->exif = NULL;
1541 rImage->exif_size = 0;
1544 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1545 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1547 if (tbm_key_post > 0) {
1548 /* import tbm bo and get virtual address */
1549 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1552 buf_pos = (unsigned char *)bo_post_handle.ptr;
1553 rPostview = (camera_image_data_s *)buf_pos;
1554 LOGD("rPostview->size : %d", rPostview->size);
1555 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1558 if (tbm_key_thumb > 0) {
1559 /* import tbm bo and get virtual address */
1560 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1563 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1565 rThumbnail = (camera_image_data_s *)buf_pos;
1566 LOGD("rThumbnail->size : %d", rThumbnail->size);
1567 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1570 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1572 /* unmap and unref tbm bo */
1573 _camera_release_imported_bo(&bo_main);
1576 tbm_key = tbm_key_main;
1578 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1580 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1582 if (tbm_key_post > 0) {
1583 /* unmap and unref tbm bo */
1584 _camera_release_imported_bo(&bo_post);
1587 param.value.value_INT = tbm_key_post;
1588 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1591 if (tbm_key_thumb > 0) {
1592 /* unmap and unref tbm bo */
1593 _camera_release_imported_bo(&bo_thumb);
1596 param.value.value_INT = tbm_key_thumb;
1597 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1600 LOGD("return buffer done");
1604 LOGW("unhandled event %d", event);
1611 static bool _camera_idle_event_callback(void *data)
1613 camera_cb_info_s *cb_info = NULL;
1614 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1616 if (cam_idle_event == NULL) {
1617 LOGE("cam_idle_event is NULL");
1622 g_mutex_lock(&cam_idle_event->event_mutex);
1624 cb_info = cam_idle_event->cb_info;
1625 if (cb_info == NULL) {
1626 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1627 goto IDLE_EVENT_CALLBACK_DONE;
1630 /* remove event from list */
1631 g_mutex_lock(&cb_info->idle_event_mutex);
1633 if (cb_info->idle_event_list)
1634 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1636 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1637 g_mutex_unlock(&cb_info->idle_event_mutex);
1640 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1642 /* send signal for waiting thread */
1643 g_cond_signal(&cb_info->idle_event_cond);
1645 IDLE_EVENT_CALLBACK_DONE:
1646 /* unlock and release event */
1647 g_mutex_unlock(&cam_idle_event->event_mutex);
1648 g_mutex_clear(&cam_idle_event->event_mutex);
1650 g_free(cam_idle_event);
1651 cam_idle_event = NULL;
1656 static void *_camera_msg_handler_func(gpointer data)
1660 camera_message_s *cam_msg = NULL;
1661 camera_idle_event_s *cam_idle_event = NULL;
1662 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1663 camera_cb_info_s *cb_info = NULL;
1665 if (!handler_info || !handler_info->cb_info) {
1666 LOGE("NULL handler %p", handler_info);
1670 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1671 type = handler_info->type;
1673 LOGD("t:%d start", type);
1675 g_mutex_lock(&handler_info->mutex);
1677 while (g_atomic_int_get(&handler_info->running)) {
1678 if (g_queue_is_empty(handler_info->queue)) {
1679 /*LOGD("t:%d signal wait...", type);*/
1680 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1681 /*LOGD("t:%d signal received", type);*/
1683 if (g_atomic_int_get(&handler_info->running) == 0) {
1684 LOGD("t:%d stop event thread", type);
1689 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1691 g_mutex_unlock(&handler_info->mutex);
1693 if (cam_msg == NULL) {
1694 LOGE("t:%d NULL message", type);
1695 g_mutex_lock(&handler_info->mutex);
1701 if (api < MUSE_CAMERA_API_MAX) {
1704 g_mutex_lock(&cb_info->api_mutex[api]);
1706 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1707 if (cb_info->api_waiting[api] > 0) {
1708 cb_info->api_ret[api] = ret;
1709 cb_info->api_activating[api] = 1;
1711 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1713 g_cond_signal(&cb_info->api_cond[api]);
1715 LOGW("no waiting for this api [%d]", api);
1718 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1721 g_mutex_unlock(&cb_info->api_mutex[api]);
1722 } else if (api == MUSE_CAMERA_CB_EVENT) {
1723 switch (cam_msg->event_class) {
1724 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1725 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1727 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1728 cam_idle_event = g_new0(camera_idle_event_s, 1);
1729 if (cam_idle_event == NULL) {
1730 LOGE("t:%d cam_idle_event alloc failed", type);
1734 cam_idle_event->event = cam_msg->event;
1735 cam_idle_event->cb_info = cb_info;
1736 g_mutex_init(&cam_idle_event->event_mutex);
1737 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1739 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1741 g_mutex_lock(&cb_info->idle_event_mutex);
1742 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1743 g_mutex_unlock(&cb_info->idle_event_mutex);
1745 g_idle_add_full(G_PRIORITY_DEFAULT,
1746 (GSourceFunc)_camera_idle_event_callback,
1747 (gpointer)cam_idle_event,
1751 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1755 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1761 g_mutex_lock(&handler_info->mutex);
1764 /* remove remained event */
1765 while (!g_queue_is_empty(handler_info->queue)) {
1766 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1768 LOGD("t:%d remove camera message %p", type, cam_msg);
1772 LOGW("t:%d NULL camera message", type);
1776 g_mutex_unlock(&handler_info->mutex);
1778 LOGD("t:%d return", type);
1784 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1786 camera_idle_event_s *cam_idle_event = NULL;
1788 gint64 end_time = 0;
1790 if (cb_info == NULL) {
1791 LOGE("cb_info is NULL");
1795 g_mutex_lock(&cb_info->idle_event_mutex);
1797 if (cb_info->idle_event_list == NULL) {
1798 LOGD("No remained idle event");
1799 g_mutex_unlock(&cb_info->idle_event_mutex);
1803 list = cb_info->idle_event_list;
1806 cam_idle_event = list->data;
1807 list = g_list_next(list);
1809 if (!cam_idle_event) {
1810 LOGW("Fail to remove idle event. The event is NULL");
1814 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1815 LOGW("lock failed, %p event is calling now", cam_idle_event);
1817 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1819 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1820 LOGW("signal received");
1827 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1828 cam_idle_event, cam_idle_event->event);
1830 cam_idle_event->cb_info = NULL;
1832 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1834 g_mutex_unlock(&cam_idle_event->event_mutex);
1837 g_list_free(cb_info->idle_event_list);
1838 cb_info->idle_event_list = NULL;
1840 g_mutex_unlock(&cb_info->idle_event_mutex);
1846 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1848 camera_message_s *cam_msg = NULL;
1850 if (!cb_info || !msg) {
1851 LOGE("NULL pointer %p %p", cb_info, msg);
1855 cam_msg = g_new0(camera_message_s, 1);
1857 LOGE("failed to alloc cam_msg for [%s]", msg);
1862 cam_msg->event = event;
1863 cam_msg->event_class = event_class;
1865 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1867 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1869 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1870 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1871 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1872 g_cond_signal(&cb_info->preview_cb_info.cond);
1873 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1874 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1875 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1876 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1877 g_cond_signal(&cb_info->capture_cb_info.cond);
1878 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1880 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1881 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1882 g_cond_signal(&cb_info->msg_handler_info.cond);
1883 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1892 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1894 int ret = CAMERA_ERROR_NONE;
1898 int event_class = -1;
1902 if (!cb_info || !msg) {
1903 LOGE("invalid ptr %p %p", cb_info, msg);
1907 /*LOGD("msg [%s]", msg);*/
1909 if (!muse_camera_msg_get(api, msg)) {
1910 LOGE("failed to get camera api");
1914 if (api == MUSE_CAMERA_CB_EVENT) {
1915 if (!muse_camera_msg_get(event, msg) ||
1916 !muse_camera_msg_get(event_class, msg)) {
1917 LOGE("failed to get camera event or event_class [%s]", msg);
1921 if (!muse_camera_msg_get(api_class, msg)) {
1922 LOGE("failed to get camera api_class [%s]", msg);
1927 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1928 if (api >= MUSE_CAMERA_API_MAX) {
1929 LOGE("invalid api %d", api);
1933 if (!muse_camera_msg_get(ret, msg)) {
1934 LOGE("failed to get camera ret");
1938 g_mutex_lock(&cb_info->api_mutex[api]);
1941 case MUSE_CAMERA_API_CREATE:
1942 if (ret != CAMERA_ERROR_NONE) {
1943 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1944 LOGE("camera create error 0x%x. close client cb handler", ret);
1947 case MUSE_CAMERA_API_DESTROY:
1948 if (ret == CAMERA_ERROR_NONE) {
1949 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1950 LOGD("camera destroy done. close client cb handler");
1954 muse_camera_msg_get(get_type, msg);
1955 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1956 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1957 muse_camera_msg_get(get_index, msg);
1960 case MUSE_CAMERA_GET_TYPE_INT:
1961 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1963 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1964 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1965 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1967 case MUSE_CAMERA_GET_TYPE_ARRAY:
1968 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1969 muse_core_msg_json_deserialize("get_value",
1970 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1971 LOGD("get display roi %d,%d,%dx%d",
1972 cb_info->get_display_roi_area[0],
1973 cb_info->get_display_roi_area[1],
1974 cb_info->get_display_roi_area[2],
1975 cb_info->get_display_roi_area[3]);
1977 muse_core_msg_json_deserialize("get_value",
1978 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1979 LOGD("get geotag %lf, %lf, %lf",
1980 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1983 case MUSE_CAMERA_GET_TYPE_STRING:
1984 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1987 LOGW("unknown type %d", get_type);
1994 if (cb_info->api_waiting[api] > 0) {
1995 cb_info->api_ret[api] = ret;
1996 cb_info->api_activating[api] = 1;
1998 g_cond_signal(&cb_info->api_cond[api]);
2000 LOGW("no waiting for this api [%d]", api);
2003 g_mutex_unlock(&cb_info->api_mutex[api]);
2004 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2005 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
2007 LOGW("unknown camera api %d, class %d", api, api_class);
2014 static void *_camera_msg_recv_func(gpointer data)
2016 int recv_length = 0;
2017 int single_length = 0;
2018 int remained_length = 0;
2019 char *recv_msg = NULL;
2020 char *single_msg = NULL;
2021 char *remained_msg = NULL;
2025 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2028 LOGE("cb_info NULL");
2034 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2036 LOGE("single_msg malloc failed");
2040 recv_msg = cb_info->recv_msg;
2042 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2043 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
2044 if (recv_length <= 0) {
2045 cb_info->is_server_connected = FALSE;
2046 LOGE("receive msg failed - server disconnected");
2054 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2056 /* Need to split the combined entering msgs */
2057 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2058 if (recv_msg[cur_pos] == '}') {
2059 single_length = cur_pos - prev_pos + 1;
2061 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2062 /* check remained msg */
2063 if (remained_length > 0) {
2065 strncpy(single_msg, remained_msg, remained_length);
2066 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2067 single_msg[remained_length + single_length] = '\0';
2070 remained_msg = NULL;
2072 strncpy(single_msg, recv_msg + prev_pos, single_length);
2073 single_msg[single_length] = '\0';
2074 LOGE("lost msg [%s], skip...", single_msg);
2077 remained_length = 0;
2079 strncpy(single_msg, recv_msg + prev_pos, single_length);
2080 single_msg[single_length] = '\0';
2083 if (single_msg[0] == '{') {
2085 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2086 /* process each message */
2087 __camera_process_msg(cb_info, single_msg);
2089 LOGE("invalid msg [%s]", single_msg);
2092 LOGE("too long message [len %d] skip...", single_length);
2095 prev_pos = cur_pos + 1;
2099 /* check incompleted message */
2100 if (recv_msg[recv_length - 1] != '}') {
2101 remained_length = recv_length - prev_pos;
2103 LOGW("incompleted message [len %d]", remained_length);
2105 remained_msg = (char *)malloc(remained_length + 1);
2107 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2108 remained_msg[remained_length] = '\0';
2110 LOGE("failed to alloc for remained msg");
2113 remained_length = 0;
2117 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2119 if (!cb_info->is_server_connected) {
2120 /* send error msg for server disconnection */
2121 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2122 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2123 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2127 LOGE("error_msg failed");
2128 goto CB_HANDLER_EXIT;
2131 __camera_add_msg_to_queue(cb_info,
2132 MUSE_CAMERA_CB_EVENT,
2133 MUSE_CAMERA_EVENT_TYPE_ERROR,
2134 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2137 muse_core_msg_json_factory_free(error_msg);
2140 LOGE("add error msg for service disconnection done");
2151 remained_msg = NULL;
2158 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2159 int type, const char *thread_name, camera_cb_info_s *cb_info)
2161 if (!handler_info || !thread_name || !cb_info) {
2162 LOGE("t:%d NULL %p %p %p",
2163 type, handler_info, thread_name, cb_info);
2169 handler_info->type = type;
2170 handler_info->queue = g_queue_new();
2171 if (handler_info->queue == NULL) {
2172 LOGE("t:%d queue failed", type);
2176 g_mutex_init(&handler_info->mutex);
2177 g_cond_init(&handler_info->cond);
2179 handler_info->cb_info = (void *)cb_info;
2180 g_atomic_int_set(&handler_info->running, 1);
2182 handler_info->thread = g_thread_try_new(thread_name,
2183 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2184 if (handler_info->thread == NULL) {
2185 LOGE("t:%d thread failed", type);
2187 g_mutex_clear(&handler_info->mutex);
2188 g_cond_clear(&handler_info->cond);
2189 g_queue_free(handler_info->queue);
2190 handler_info->queue = NULL;
2195 LOGD("t:%d done", type);
2201 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2205 if (!handler_info) {
2206 LOGE("NULL handler");
2210 if (!handler_info->thread) {
2211 LOGW("thread is not created");
2215 type = handler_info->type;
2217 LOGD("t:%d thread %p", type, handler_info->thread);
2219 g_mutex_lock(&handler_info->mutex);
2220 g_atomic_int_set(&handler_info->running, 0);
2221 g_cond_signal(&handler_info->cond);
2222 g_mutex_unlock(&handler_info->mutex);
2224 g_thread_join(handler_info->thread);
2225 handler_info->thread = NULL;
2227 g_mutex_clear(&handler_info->mutex);
2228 g_cond_clear(&handler_info->cond);
2229 g_queue_free(handler_info->queue);
2230 handler_info->queue = NULL;
2232 LOGD("t:%d done", type);
2238 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2240 camera_cb_info_s *cb_info = NULL;
2243 g_return_val_if_fail(sockfd > 0, NULL);
2245 cb_info = g_new0(camera_cb_info_s, 1);
2246 if (cb_info == NULL) {
2247 LOGE("cb_info failed");
2251 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2253 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2254 g_mutex_init(&cb_info->api_mutex[i]);
2255 g_cond_init(&cb_info->api_cond[i]);
2258 g_mutex_init(&cb_info->fd_lock);
2259 g_mutex_init(&cb_info->idle_event_mutex);
2260 g_cond_init(&cb_info->idle_event_cond);
2261 g_mutex_init(&cb_info->mp_data_mutex);
2262 g_mutex_init(&cb_info->preview_cb_mutex);
2263 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2264 g_mutex_init(&cb_info->evas_mutex);
2265 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2267 /* message handler thread */
2268 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2269 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2270 LOGE("msg_handler_info failed");
2274 /* message handler thread for preview callback */
2275 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2276 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2277 LOGE("preview_cb_info failed");
2281 /* message handler thread for capture callback */
2282 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2283 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2284 LOGE("capture_cb_info failed");
2288 cb_info->fd = sockfd;
2289 cb_info->preview_cb_flag = 0;
2290 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2291 cb_info->evas_info = NULL;
2292 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2294 /* message receive thread */
2295 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2296 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2297 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2298 if (cb_info->msg_recv_thread == NULL) {
2299 LOGE("message receive thread creation failed");
2303 cb_info->is_server_connected = TRUE;
2309 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2310 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2311 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2313 g_mutex_clear(&cb_info->fd_lock);
2314 g_mutex_clear(&cb_info->idle_event_mutex);
2315 g_cond_clear(&cb_info->idle_event_cond);
2316 g_mutex_clear(&cb_info->mp_data_mutex);
2317 g_mutex_clear(&cb_info->preview_cb_mutex);
2318 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2319 g_mutex_clear(&cb_info->evas_mutex);
2320 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2322 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2323 g_mutex_clear(&cb_info->api_mutex[i]);
2324 g_cond_clear(&cb_info->api_cond[i]);
2335 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2339 g_return_if_fail(cb_info != NULL);
2341 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2343 g_thread_join(cb_info->msg_recv_thread);
2344 cb_info->msg_recv_thread = NULL;
2346 LOGD("msg_recv thread removed");
2348 /* destroy msg handler threads */
2349 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2350 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2351 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2353 g_mutex_clear(&cb_info->fd_lock);
2354 g_mutex_clear(&cb_info->idle_event_mutex);
2355 g_cond_clear(&cb_info->idle_event_cond);
2356 g_mutex_clear(&cb_info->mp_data_mutex);
2357 g_mutex_clear(&cb_info->preview_cb_mutex);
2358 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2359 g_mutex_clear(&cb_info->evas_mutex);
2360 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2362 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2363 g_mutex_clear(&cb_info->api_mutex[i]);
2364 g_cond_clear(&cb_info->api_cond[i]);
2367 if (cb_info->fd > -1) {
2368 muse_core_connection_close(cb_info->fd);
2372 if (cb_info->bufmgr) {
2373 tbm_bufmgr_deinit(cb_info->bufmgr);
2374 cb_info->bufmgr = NULL;
2376 if (cb_info->pkt_fmt) {
2377 media_format_unref(cb_info->pkt_fmt);
2378 cb_info->pkt_fmt = NULL;
2381 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2382 if (cb_info->evas_info)
2383 mm_evas_renderer_destroy(&cb_info->evas_info);
2384 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2386 cb_info->preview_cb_flag = 0;
2395 int _camera_start_evas_rendering(camera_h camera)
2397 int ret = CAMERA_ERROR_NONE;
2398 camera_cli_s *pc = (camera_cli_s *)camera;
2400 if (!pc || !pc->cb_info) {
2401 LOGE("NULL handle");
2402 return CAMERA_ERROR_INVALID_PARAMETER;
2407 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2408 LOGE("EVAS surface is not set");
2409 return CAMERA_ERROR_NONE;
2412 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2413 g_mutex_lock(&pc->cb_info->evas_mutex);
2415 /* set evas render flag as RUN */
2416 pc->cb_info->run_evas_render = true;
2417 ret = CAMERA_ERROR_NONE;
2419 g_mutex_unlock(&pc->cb_info->evas_mutex);
2420 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2421 LOGW("evas renderer is not supported");
2422 ret = CAMERA_ERROR_NOT_SUPPORTED;
2423 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2429 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2431 int ret = CAMERA_ERROR_NONE;
2432 camera_cli_s *pc = (camera_cli_s *)camera;
2434 if (!pc || !pc->cb_info) {
2435 LOGE("NULL handle");
2436 return CAMERA_ERROR_INVALID_PARAMETER;
2439 LOGD("stop - keep screen %d", keep_screen);
2441 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2442 LOGE("EVAS surface is not set");
2443 return CAMERA_ERROR_NONE;
2446 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2447 g_mutex_lock(&pc->cb_info->evas_mutex);
2449 /* set evas render flag as STOP and release buffers */
2450 pc->cb_info->run_evas_render = false;
2452 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2453 if (ret != MM_ERROR_NONE) {
2454 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2455 ret = CAMERA_ERROR_INVALID_OPERATION;
2458 g_mutex_unlock(&pc->cb_info->evas_mutex);
2459 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2460 LOGW("evas renderer is not supported");
2461 ret = CAMERA_ERROR_NOT_SUPPORTED;
2462 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2468 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2470 int ret = CAMERA_ERROR_NONE;
2473 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2475 /* create muse connection */
2476 if (!key || !value) {
2477 LOGE("NULL pointer");
2478 return CAMERA_ERROR_INVALID_PARAMETER;
2481 sock_fd = muse_core_client_new();
2483 LOGE("muse_core_client_new failed");
2484 return CAMERA_ERROR_INVALID_OPERATION;
2487 msg = muse_core_msg_json_factory_new(api,
2488 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2489 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2493 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2497 ret = muse_core_ipc_send_msg(sock_fd, msg);
2499 muse_core_msg_json_factory_free(msg);
2503 LOGE("send msg failed");
2504 ret = CAMERA_ERROR_INVALID_OPERATION;
2508 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2510 LOGE("recv msg failed %d", errno);
2511 ret = CAMERA_ERROR_INVALID_OPERATION;
2515 if (!muse_camera_msg_get(ret, recv_msg)) {
2516 LOGE("failed to get return value from msg [%s]", recv_msg);
2517 ret = CAMERA_ERROR_INVALID_OPERATION;
2521 if (ret == CAMERA_ERROR_NONE)
2522 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2524 LOGD("api %d - value %d", api, *value);
2528 muse_core_connection_close(sock_fd);
2536 int camera_create(camera_device_e device, camera_h *camera)
2539 char *send_msg = NULL;
2541 int ret = CAMERA_ERROR_NONE;
2543 camera_cli_s *pc = NULL;
2544 tbm_bufmgr bufmgr = NULL;
2546 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2547 muse_core_api_module_e muse_module = MUSE_CAMERA;
2548 int device_type = (int)device;
2551 LOGE("NULL pointer");
2552 return CAMERA_ERROR_INVALID_PARAMETER;
2555 sock_fd = muse_core_client_new();
2557 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2558 ret = CAMERA_ERROR_INVALID_OPERATION;
2564 send_msg = muse_core_msg_json_factory_new(api,
2565 MUSE_TYPE_INT, "module", muse_module,
2566 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2567 MUSE_TYPE_INT, "pid", pid,
2572 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2576 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2578 muse_core_msg_json_factory_free(send_msg);
2582 LOGE("send msg failed %d", errno);
2583 ret = CAMERA_ERROR_INVALID_OPERATION;
2587 pc = g_new0(camera_cli_s, 1);
2589 LOGE("camera_cli_s alloc failed");
2590 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2594 bufmgr = tbm_bufmgr_init(-1);
2595 if (bufmgr == NULL) {
2596 LOGE("get tbm bufmgr failed");
2597 ret = CAMERA_ERROR_INVALID_OPERATION;
2601 pc->cb_info = _camera_client_callback_new(sock_fd);
2602 if (pc->cb_info == NULL) {
2603 LOGE("cb_info alloc failed");
2604 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2610 LOGD("cb info : %d", pc->cb_info->fd);
2612 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2614 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2616 if (ret == CAMERA_ERROR_NONE) {
2617 intptr_t handle = 0;
2618 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2620 LOGE("Receiving Handle Failed!!");
2621 ret = CAMERA_ERROR_INVALID_OPERATION;
2625 pc->remote_handle = handle;
2626 pc->cb_info->bufmgr = bufmgr;
2628 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2629 if (ret != CAMERA_ERROR_NONE) {
2630 LOGE("init display failed 0x%x", ret);
2634 LOGD("camera create 0x%x", pc->remote_handle);
2635 *camera = (camera_h)pc;
2644 tbm_bufmgr_deinit(bufmgr);
2649 muse_core_connection_close(sock_fd);
2655 _camera_client_callback_destroy(pc->cb_info);
2662 LOGE("camera create error : 0x%x", ret);
2669 int camera_change_device(camera_h camera, camera_device_e device)
2672 int ret = CAMERA_ERROR_NONE;
2673 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2674 camera_cli_s *pc = (camera_cli_s *)camera;
2675 camera_msg_param param;
2677 if (!pc || !pc->cb_info) {
2678 LOGE("NULL handle");
2679 return CAMERA_ERROR_INVALID_PARAMETER;
2682 CAMERA_MSG_PARAM_SET(param, INT, device);
2684 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2686 if (ret == CAMERA_ERROR_NONE) {
2687 /* reset callback and user data */
2688 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2689 pc->cb_info->user_cb[i] = NULL;
2690 pc->cb_info->user_data[i] = NULL;
2692 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2699 int camera_destroy(camera_h camera)
2701 int ret = CAMERA_ERROR_NONE;
2702 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2703 camera_cli_s *pc = (camera_cli_s *)camera;
2705 if (!pc || !pc->cb_info) {
2706 LOGE("NULL handle");
2707 return CAMERA_ERROR_INVALID_PARAMETER;
2712 if (pc->cb_info->is_server_connected)
2713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2715 LOGW("server disconnected. release resource without send message.");
2717 if (ret == CAMERA_ERROR_NONE) {
2718 _camera_deactivate_idle_event_all(pc->cb_info);
2719 _camera_client_callback_destroy(pc->cb_info);
2729 int camera_start_preview(camera_h camera)
2731 int ret = CAMERA_ERROR_NONE;
2732 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2733 camera_cli_s *pc = (camera_cli_s *)camera;
2735 if (!pc || !pc->cb_info) {
2736 LOGE("NULL handle");
2737 return CAMERA_ERROR_INVALID_PARAMETER;
2742 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2743 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2744 ret = _camera_start_evas_rendering(camera);
2745 if (ret != CAMERA_ERROR_NONE) {
2746 LOGE("stop preview because of error");
2747 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2751 LOGD("ret : 0x%x", ret);
2757 int camera_stop_preview(camera_h camera)
2759 int ret = CAMERA_ERROR_NONE;
2760 camera_cli_s *pc = (camera_cli_s *)camera;
2761 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2762 camera_state_e current_state = CAMERA_STATE_NONE;
2764 if (!pc || !pc->cb_info) {
2765 LOGE("NULL handle");
2766 return CAMERA_ERROR_INVALID_PARAMETER;
2772 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2773 ret = camera_get_state(camera, ¤t_state);
2774 if (ret != CAMERA_ERROR_NONE) {
2775 LOGE("failed to get current state 0x%x", ret);
2779 if (current_state == CAMERA_STATE_PREVIEW) {
2780 ret = _camera_stop_evas_rendering(camera, false);
2781 if (ret != CAMERA_ERROR_NONE)
2786 /* send stop preview message */
2787 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2789 if (ret != CAMERA_ERROR_NONE &&
2790 current_state == CAMERA_STATE_PREVIEW) {
2791 LOGW("restart evas rendering");
2792 _camera_start_evas_rendering(camera);
2795 LOGD("ret : 0x%x", ret);
2801 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2803 int ret = CAMERA_ERROR_NONE;
2804 camera_cli_s *pc = (camera_cli_s *)camera;
2805 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2807 if (!pc || !pc->cb_info) {
2808 LOGE("NULL handle");
2809 return CAMERA_ERROR_INVALID_PARAMETER;
2814 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2815 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2820 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2822 LOGD("ret : 0x%x", ret);
2828 bool camera_is_supported_continuous_capture(camera_h camera)
2830 int ret = CAMERA_ERROR_NONE;
2831 camera_cli_s *pc = (camera_cli_s *)camera;
2832 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2834 if (!pc || !pc->cb_info) {
2835 LOGE("NULL handle");
2836 return CAMERA_ERROR_INVALID_PARAMETER;
2841 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2844 LOGE("error is occurred 0x%x", ret);
2848 LOGD("ret : %d", ret);
2854 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)
2856 int ret = CAMERA_ERROR_NONE;
2857 camera_cli_s *pc = (camera_cli_s *)camera;
2858 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2859 camera_msg_param param;
2862 if (!pc || !pc->cb_info) {
2863 LOGE("NULL handle");
2864 return CAMERA_ERROR_INVALID_PARAMETER;
2869 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2870 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2872 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2873 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2875 value = (count << 16) | interval;
2876 CAMERA_MSG_PARAM_SET(param, INT, value);
2878 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2880 LOGD("ret : 0x%x", ret);
2886 int camera_stop_continuous_capture(camera_h camera)
2888 int ret = CAMERA_ERROR_NONE;
2889 camera_cli_s *pc = (camera_cli_s *)camera;
2890 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2892 if (!pc || !pc->cb_info) {
2893 LOGE("NULL handle");
2894 return CAMERA_ERROR_INVALID_PARAMETER;
2899 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2901 LOGD("ret : 0x%x", ret);
2907 bool camera_is_supported_face_detection(camera_h camera)
2909 int ret = CAMERA_ERROR_NONE;
2910 camera_cli_s *pc = (camera_cli_s *)camera;
2911 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2913 if (!pc || !pc->cb_info) {
2914 LOGE("NULL handle");
2915 return CAMERA_ERROR_INVALID_PARAMETER;
2920 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2923 LOGE("error is occurred 0x%x", ret);
2927 LOGD("ret : %d", ret);
2933 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2935 int ret = CAMERA_ERROR_NONE;
2936 camera_cli_s *pc = (camera_cli_s *)camera;
2937 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2939 if (!pc || !pc->cb_info) {
2940 LOGE("NULL handle");
2941 return CAMERA_ERROR_INVALID_PARAMETER;
2946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2949 LOGE("error is occurred 0x%x", ret);
2953 LOGD("ret : %d", ret);
2959 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2961 int ret = CAMERA_ERROR_NONE;
2962 camera_cli_s *pc = (camera_cli_s *)camera;
2963 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2965 if (!pc || !pc->cb_info) {
2966 LOGE("NULL handle");
2967 return CAMERA_ERROR_INVALID_PARAMETER;
2972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2975 LOGE("error is occurred 0x%x", ret);
2979 LOGD("ret : %d", ret);
2984 int camera_get_device_count(camera_h camera, int *device_count)
2986 int ret = CAMERA_ERROR_NONE;
2987 camera_cli_s *pc = (camera_cli_s *)camera;
2988 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2990 if (!pc || !pc->cb_info) {
2991 LOGE("NULL handle");
2992 return CAMERA_ERROR_INVALID_PARAMETER;
2997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2999 if (ret == CAMERA_ERROR_NONE)
3000 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3002 LOGD("ret : 0x%x", ret);
3007 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3009 int ret = CAMERA_ERROR_NONE;
3010 camera_cli_s *pc = (camera_cli_s *)camera;
3011 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3013 if (!pc || !pc->cb_info) {
3014 LOGE("NULL handle");
3015 return CAMERA_ERROR_INVALID_PARAMETER;
3020 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3021 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3025 LOGD("ret : 0x%x", ret);
3030 int camera_stop_face_detection(camera_h camera)
3032 int ret = CAMERA_ERROR_NONE;
3033 camera_cli_s *pc = (camera_cli_s *)camera;
3034 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3036 if (!pc || !pc->cb_info) {
3037 LOGE("NULL handle");
3038 return CAMERA_ERROR_INVALID_PARAMETER;
3043 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3045 LOGD("ret : 0x%x", ret);
3050 int camera_get_state(camera_h camera, camera_state_e *state)
3052 int ret = CAMERA_ERROR_NONE;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3056 if (!pc || !pc->cb_info || !state) {
3057 LOGE("NULL pointer %p %p", pc, state);
3058 return CAMERA_ERROR_INVALID_PARAMETER;
3063 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3065 if (ret == CAMERA_ERROR_NONE)
3066 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3068 LOGD("ret : 0x%x", ret);
3073 int camera_start_focusing(camera_h camera, bool continuous)
3075 int ret = CAMERA_ERROR_NONE;
3076 camera_cli_s *pc = (camera_cli_s *)camera;
3077 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3078 camera_msg_param param;
3079 int is_continuous = (int)continuous;
3081 if (!pc || !pc->cb_info) {
3082 LOGE("NULL handle");
3083 return CAMERA_ERROR_INVALID_PARAMETER;
3088 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3090 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3092 LOGD("ret : 0x%x", ret);
3097 int camera_cancel_focusing(camera_h camera)
3099 int ret = CAMERA_ERROR_NONE;
3100 camera_cli_s *pc = (camera_cli_s *)camera;
3101 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3103 if (!pc || !pc->cb_info) {
3104 LOGE("NULL handle");
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3108 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3110 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3112 LOGD("ret : 0x%x", ret);
3117 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3119 int ret = CAMERA_ERROR_NONE;
3120 void *set_display_handle = NULL;
3121 Evas_Object *obj = NULL;
3122 const char *object_type = NULL;
3123 camera_cli_s *pc = (camera_cli_s *)camera;
3124 camera_cb_info_s *cb_info = NULL;
3125 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3126 camera_state_e current_state = CAMERA_STATE_NONE;
3127 camera_msg_param param;
3131 if (!pc || !pc->cb_info) {
3132 LOGE("NULL handle");
3133 return CAMERA_ERROR_INVALID_PARAMETER;
3136 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3137 LOGE("invalid type %d", type);
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3142 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3143 return CAMERA_ERROR_INVALID_PARAMETER;
3146 cb_info = (camera_cb_info_s *)pc->cb_info;
3148 ret = camera_get_state(camera, ¤t_state);
3149 if (ret != CAMERA_ERROR_NONE) {
3150 LOGE("failed to get current state 0x%x", ret);
3154 if (current_state != CAMERA_STATE_CREATED) {
3155 LOGE("INVALID_STATE : current %d", current_state);
3156 return CAMERA_ERROR_INVALID_STATE;
3159 LOGD("Enter - display : %p", display);
3161 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3162 set_display_handle = 0;
3163 LOGD("display type NONE");
3166 obj = (Evas_Object *)display;
3167 object_type = evas_object_type_get(obj);
3169 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3170 /* get wayland parent id */
3171 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3172 LOGE("failed to get wayland info");
3173 return CAMERA_ERROR_INVALID_OPERATION;
3176 set_display_handle = (void *)&pc->wl_info;
3177 LOGD("display type OVERLAY : handle %p", set_display_handle);
3178 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3179 /* evas object surface */
3180 set_display_handle = (void *)display;
3181 LOGD("display type EVAS : handle %p", set_display_handle);
3183 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3184 g_mutex_lock(&cb_info->evas_mutex);
3186 if (cb_info->evas_info) {
3187 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3188 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3189 if (ret != MM_ERROR_NONE) {
3190 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3191 g_mutex_unlock(&cb_info->evas_mutex);
3192 return CAMERA_ERROR_INVALID_OPERATION;
3196 /* create evas renderer */
3197 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3198 if (ret == MM_ERROR_NONE) {
3199 camera_flip_e flip = CAMERA_FLIP_NONE;
3200 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3201 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3208 camera_get_display_flip(camera, &flip);
3209 camera_get_display_mode(camera, &mode);
3210 camera_get_display_rotation(camera, &rotation);
3211 camera_is_display_visible(camera, &visible);
3212 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3214 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3215 flip, mode, rotation, visible, x, y, width, height);
3217 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3218 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3219 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3220 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3222 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3223 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3226 g_mutex_unlock(&cb_info->evas_mutex);
3228 if (ret != MM_ERROR_NONE) {
3229 LOGE("mm_evas_renderer error 0x%x", ret);
3230 return CAMERA_ERROR_INVALID_OPERATION;
3232 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3233 LOGE("EVAS surface is not supported");
3234 return CAMERA_ERROR_NOT_SUPPORTED;
3235 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3237 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3238 return CAMERA_ERROR_INVALID_PARAMETER;
3241 LOGE("failed to get evas object type from %p", obj);
3242 return CAMERA_ERROR_INVALID_PARAMETER;
3246 pc->display_handle = (intptr_t)set_display_handle;
3248 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3251 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3252 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3254 msg = muse_core_msg_json_factory_new(api,
3255 MUSE_TYPE_INT, "type", type,
3256 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3259 LOGE("msg creation failed: api %d", api);
3260 return CAMERA_ERROR_OUT_OF_MEMORY;
3263 if (pc->cb_info->is_server_connected) {
3264 __camera_update_api_waiting(pc->cb_info, api, 1);
3266 g_mutex_lock(&pc->cb_info->fd_lock);
3267 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3268 g_mutex_unlock(&pc->cb_info->fd_lock);
3272 LOGE("message send failed");
3273 ret = CAMERA_ERROR_INVALID_OPERATION;
3275 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3278 __camera_update_api_waiting(pc->cb_info, api, -1);
3280 muse_core_msg_json_factory_free(msg);
3282 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3283 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3284 pc->wl_info.window_width, pc->wl_info.window_height);
3286 CAMERA_MSG_PARAM_SET(param, INT, type);
3288 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3291 if (ret != CAMERA_ERROR_NONE)
3292 LOGE("set display error 0x%x", ret);
3293 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3294 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3300 int camera_set_preview_resolution(camera_h camera, int width, int height)
3302 int ret = CAMERA_ERROR_NONE;
3303 camera_state_e current_state = CAMERA_STATE_NONE;
3304 camera_cli_s *pc = (camera_cli_s *)camera;
3305 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3306 camera_msg_param param;
3309 if (!pc || !pc->cb_info) {
3310 LOGE("NULL handle");
3311 return CAMERA_ERROR_INVALID_PARAMETER;
3314 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3315 ret = camera_get_state(camera, ¤t_state);
3316 if (ret != CAMERA_ERROR_NONE) {
3317 LOGE("failed to get current state 0x%x", ret);
3321 if (current_state == CAMERA_STATE_PREVIEW) {
3322 ret = _camera_stop_evas_rendering(camera, true);
3323 if (ret != CAMERA_ERROR_NONE)
3328 value = (width << 16) | height;
3329 CAMERA_MSG_PARAM_SET(param, INT, value);
3331 LOGD("%dx%d -> 0x%x", width, height, value);
3333 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3335 LOGD("ret : 0x%x", ret);
3337 if (current_state == CAMERA_STATE_PREVIEW) {
3338 LOGW("restart evas rendering");
3339 _camera_start_evas_rendering(camera);
3346 int camera_set_capture_resolution(camera_h camera, int width, int height)
3348 int ret = CAMERA_ERROR_NONE;
3349 camera_cli_s *pc = (camera_cli_s *)camera;
3350 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3351 camera_msg_param param;
3354 if (!pc || !pc->cb_info) {
3355 LOGE("NULL handle");
3356 return CAMERA_ERROR_INVALID_PARAMETER;
3361 value = (width << 16) | height;
3362 CAMERA_MSG_PARAM_SET(param, INT, value);
3364 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3366 LOGD("ret : 0x%x", ret);
3372 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3374 int ret = CAMERA_ERROR_NONE;
3375 int set_format = (int)format;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3377 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3378 camera_msg_param param;
3380 if (!pc || !pc->cb_info) {
3381 LOGE("NULL handle");
3382 return CAMERA_ERROR_INVALID_PARAMETER;
3385 LOGD("Enter - format %d", set_format);
3387 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3389 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3391 LOGD("ret : 0x%x", ret);
3397 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3399 int ret = CAMERA_ERROR_NONE;
3400 int set_format = (int)format;
3401 camera_msg_param param;
3402 camera_cli_s *pc = (camera_cli_s *)camera;
3403 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3405 if (!pc || !pc->cb_info) {
3406 LOGE("NULL handle");
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3410 LOGD("Enter - capture_format %d", set_format);
3412 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3414 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3416 LOGD("ret : 0x%x", ret);
3422 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3424 int ret = CAMERA_ERROR_NONE;
3425 camera_cli_s *pc = (camera_cli_s *)camera;
3426 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3428 if (!pc || !pc->cb_info || !width || !height) {
3429 LOGE("NULL pointer %p %p %p", pc, width, height);
3430 return CAMERA_ERROR_INVALID_PARAMETER;
3435 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3437 if (ret == CAMERA_ERROR_NONE) {
3438 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3439 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3442 LOGD("ret : 0x%x", ret);
3448 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3450 int ret = CAMERA_ERROR_NONE;
3451 int set_rotation = (int)rotation;
3452 camera_cli_s *pc = (camera_cli_s *)camera;
3453 camera_msg_param param;
3455 if (!pc || !pc->cb_info) {
3456 LOGE("NULL handle");
3457 return CAMERA_ERROR_INVALID_PARAMETER;
3460 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3461 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3462 g_mutex_lock(&pc->cb_info->evas_mutex);
3464 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3466 g_mutex_unlock(&pc->cb_info->evas_mutex);
3468 if (ret != MM_ERROR_NONE) {
3469 LOGE("failed to set rotation for evas surface 0x%x", ret);
3470 return CAMERA_ERROR_INVALID_OPERATION;
3473 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3475 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3477 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3483 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3485 int ret = CAMERA_ERROR_NONE;
3486 camera_cli_s *pc = (camera_cli_s *)camera;
3488 if (!pc || !pc->cb_info || !rotation) {
3489 LOGE("NULL pointer %p %p", pc, rotation);
3490 return CAMERA_ERROR_INVALID_PARAMETER;
3493 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3495 if (ret == CAMERA_ERROR_NONE)
3496 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3502 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3504 int ret = CAMERA_ERROR_NONE;
3505 int set_flip = (int)flip;
3506 camera_cli_s *pc = (camera_cli_s *)camera;
3507 camera_msg_param param;
3509 if (!pc || !pc->cb_info) {
3510 LOGE("NULL handle");
3511 return CAMERA_ERROR_INVALID_PARAMETER;
3514 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3515 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3516 g_mutex_lock(&pc->cb_info->evas_mutex);
3518 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3520 g_mutex_unlock(&pc->cb_info->evas_mutex);
3522 if (ret != MM_ERROR_NONE) {
3523 LOGE("failed to set flip for evas surface 0x%x", ret);
3524 return CAMERA_ERROR_INVALID_OPERATION;
3527 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3529 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3531 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3537 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3539 int ret = CAMERA_ERROR_NONE;
3540 camera_cli_s *pc = (camera_cli_s *)camera;
3542 if (!pc || !pc->cb_info || !flip) {
3543 LOGE("NULL pointer %p %p", pc, flip);
3544 return CAMERA_ERROR_INVALID_PARAMETER;
3547 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3549 if (ret == CAMERA_ERROR_NONE)
3550 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3556 int camera_set_display_visible(camera_h camera, bool visible)
3558 int ret = CAMERA_ERROR_NONE;
3559 int set_visible = (int)visible;
3560 camera_cli_s *pc = (camera_cli_s *)camera;
3561 camera_msg_param param;
3563 if (!pc || !pc->cb_info) {
3564 LOGE("NULL handle");
3565 return CAMERA_ERROR_INVALID_PARAMETER;
3568 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3569 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3570 g_mutex_lock(&pc->cb_info->evas_mutex);
3572 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3574 g_mutex_unlock(&pc->cb_info->evas_mutex);
3576 if (ret != MM_ERROR_NONE) {
3577 LOGE("failed to set visible for evas surface 0x%x", ret);
3578 return CAMERA_ERROR_INVALID_OPERATION;
3581 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3583 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3585 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3591 int camera_is_display_visible(camera_h camera, bool *visible)
3593 int ret = CAMERA_ERROR_NONE;
3594 camera_cli_s *pc = (camera_cli_s *)camera;
3596 if (!pc || !pc->cb_info || !visible) {
3597 LOGE("NULL pointer %p %p", pc, visible);
3598 return CAMERA_ERROR_INVALID_PARAMETER;
3601 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3603 if (ret == CAMERA_ERROR_NONE)
3604 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3610 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3612 int ret = CAMERA_ERROR_NONE;
3613 int set_mode = (int)mode;
3614 camera_cli_s *pc = (camera_cli_s *)camera;
3615 camera_msg_param param;
3617 if (!pc || !pc->cb_info) {
3618 LOGE("NULL handle");
3619 return CAMERA_ERROR_INVALID_PARAMETER;
3622 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3623 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3624 g_mutex_lock(&pc->cb_info->evas_mutex);
3626 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3628 g_mutex_unlock(&pc->cb_info->evas_mutex);
3630 if (ret != MM_ERROR_NONE) {
3631 LOGE("failed to set geometry for evas surface 0x%x", ret);
3632 return CAMERA_ERROR_INVALID_OPERATION;
3635 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3637 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3639 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3645 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3647 int ret = CAMERA_ERROR_NONE;
3648 camera_cli_s *pc = (camera_cli_s *)camera;
3650 if (!pc || !pc->cb_info || !mode) {
3651 LOGE("NULL pointer %p %p", pc, mode);
3652 return CAMERA_ERROR_INVALID_PARAMETER;
3655 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3657 if (ret == CAMERA_ERROR_NONE)
3658 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3664 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3666 int ret = CAMERA_ERROR_NONE;
3667 int set_hint = (int)hint;
3668 camera_cli_s *pc = (camera_cli_s *)camera;
3669 camera_msg_param param;
3671 if (!pc || !pc->cb_info) {
3672 LOGE("NULL handle");
3673 return CAMERA_ERROR_INVALID_PARAMETER;
3676 LOGD("Enter - hint %d", set_hint);
3678 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3680 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3686 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3688 int ret = CAMERA_ERROR_NONE;
3689 camera_cli_s *pc = (camera_cli_s *)camera;
3690 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3692 if (!pc || !pc->cb_info || !hint) {
3693 LOGE("NULL pointer %p %p", pc, hint);
3694 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE) {
3700 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3701 LOGD("display reuse hint %d", *hint);
3708 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3710 int ret = CAMERA_ERROR_NONE;
3711 camera_cli_s *pc = (camera_cli_s *)camera;
3712 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3714 if (!pc || !pc->cb_info || !width || !height) {
3715 LOGE("NULL pointer %p %p %p", pc, width, height);
3716 return CAMERA_ERROR_INVALID_PARAMETER;
3721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3723 if (ret == CAMERA_ERROR_NONE) {
3724 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3725 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3728 LOGD("ret : 0x%x", ret);
3734 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3736 int ret = CAMERA_ERROR_NONE;
3737 camera_cli_s *pc = (camera_cli_s *)camera;
3738 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3740 if (!pc || !pc->cb_info || !format) {
3741 LOGE("NULL pointer %p %p", pc, format);
3742 return CAMERA_ERROR_INVALID_PARAMETER;
3747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3749 if (ret == CAMERA_ERROR_NONE)
3750 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3752 LOGD("ret : 0x%x", ret);
3758 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3760 int ret = CAMERA_ERROR_NONE;
3761 camera_cli_s *pc = (camera_cli_s *)camera;
3762 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3764 if (!pc || !pc->cb_info || !format) {
3765 LOGE("NULL pointer %p %p", pc, format);
3766 return CAMERA_ERROR_INVALID_PARAMETER;
3771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3773 if (ret == CAMERA_ERROR_NONE)
3774 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3776 LOGD("ret : 0x%x", ret);
3782 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3784 int ret = CAMERA_ERROR_NONE;
3785 camera_cli_s *pc = (camera_cli_s *)camera;
3786 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3788 if (!pc || !pc->cb_info || !facing_direction) {
3789 LOGE("NULL pointer %p %p", pc, facing_direction);
3790 return CAMERA_ERROR_INVALID_PARAMETER;
3795 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3797 if (ret == CAMERA_ERROR_NONE)
3798 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3800 LOGD("ret : 0x%x", ret);
3806 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3808 int ret = CAMERA_ERROR_NONE;
3809 camera_cli_s *pc = (camera_cli_s *)camera;
3810 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3812 if (!pc || !pc->cb_info || !callback) {
3813 LOGE("NULL pointer %p %p", pc, callback);
3814 return CAMERA_ERROR_INVALID_PARAMETER;
3819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3821 if (ret == CAMERA_ERROR_NONE) {
3822 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3824 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3825 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3827 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3829 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3832 LOGD("ret : 0x%x", ret);
3838 int camera_unset_preview_cb(camera_h camera)
3840 int ret = CAMERA_ERROR_NONE;
3841 camera_cli_s *pc = (camera_cli_s *)camera;
3842 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3844 if (!pc || !pc->cb_info) {
3845 LOGE("NULL handle");
3846 return CAMERA_ERROR_INVALID_PARAMETER;
3851 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3853 if (ret == CAMERA_ERROR_NONE) {
3854 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3856 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3857 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3859 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3861 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3864 LOGD("ret : 0x%x", ret);
3870 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3872 int ret = CAMERA_ERROR_NONE;
3873 camera_cli_s *pc = (camera_cli_s *)camera;
3874 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3876 if (!pc || !pc->cb_info) {
3877 LOGE("NULL handle");
3878 return CAMERA_ERROR_INVALID_PARAMETER;
3881 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3882 LOGE("NOT SUPPORTED");
3883 return CAMERA_ERROR_NOT_SUPPORTED;
3886 if (callback == NULL) {
3887 LOGE("NULL callback");
3888 return CAMERA_ERROR_INVALID_PARAMETER;
3893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3895 if (ret == CAMERA_ERROR_NONE) {
3896 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3897 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3900 LOGD("ret : 0x%x", ret);
3906 int camera_unset_media_packet_preview_cb(camera_h camera)
3908 int ret = CAMERA_ERROR_NONE;
3909 camera_cli_s *pc = (camera_cli_s *)camera;
3910 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3912 if (!pc || !pc->cb_info) {
3913 LOGE("NULL handle");
3914 return CAMERA_ERROR_INVALID_PARAMETER;
3919 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3921 if (ret == CAMERA_ERROR_NONE) {
3922 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3923 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3926 LOGD("ret : 0x%x", ret);
3932 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3934 int ret = CAMERA_ERROR_NONE;
3935 camera_cli_s *pc = (camera_cli_s *)camera;
3936 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3938 if (!pc || !pc->cb_info || !callback) {
3939 LOGE("NULL pointer %p %p", pc, callback);
3940 return CAMERA_ERROR_INVALID_PARAMETER;
3945 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3947 if (ret == CAMERA_ERROR_NONE) {
3948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3952 LOGD("ret : 0x%x", ret);
3958 int camera_unset_state_changed_cb(camera_h camera)
3960 int ret = CAMERA_ERROR_NONE;
3961 camera_cli_s *pc = (camera_cli_s *)camera;
3962 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3964 if (!pc || !pc->cb_info) {
3965 LOGE("NULL handle");
3966 return CAMERA_ERROR_INVALID_PARAMETER;
3971 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3973 if (ret == CAMERA_ERROR_NONE) {
3974 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3975 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3978 LOGD("ret : 0x%x", ret);
3984 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3990 if (!pc || !pc->cb_info || !callback) {
3991 LOGE("NULL pointer %p %p", pc, callback);
3992 return CAMERA_ERROR_INVALID_PARAMETER;
3997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3999 if (ret == CAMERA_ERROR_NONE) {
4000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4004 LOGD("ret : 0x%x", ret);
4010 int camera_unset_interrupted_cb(camera_h camera)
4012 int ret = CAMERA_ERROR_NONE;
4013 camera_cli_s *pc = (camera_cli_s *)camera;
4014 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4016 if (!pc || !pc->cb_info) {
4017 LOGE("NULL handle");
4018 return CAMERA_ERROR_INVALID_PARAMETER;
4023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4025 if (ret == CAMERA_ERROR_NONE) {
4026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4030 LOGD("ret : 0x%x", ret);
4036 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4038 int ret = CAMERA_ERROR_NONE;
4039 camera_cli_s *pc = (camera_cli_s *)camera;
4040 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4042 if (!pc || !pc->cb_info || !callback) {
4043 LOGE("NULL pointer %p %p", pc, callback);
4044 return CAMERA_ERROR_INVALID_PARAMETER;
4049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4051 if (ret == CAMERA_ERROR_NONE) {
4052 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4053 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4056 LOGD("ret : 0x%x", ret);
4062 int camera_unset_interrupt_started_cb(camera_h camera)
4064 int ret = CAMERA_ERROR_NONE;
4065 camera_cli_s *pc = (camera_cli_s *)camera;
4066 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4068 if (!pc || !pc->cb_info) {
4069 LOGE("NULL handle");
4070 return CAMERA_ERROR_INVALID_PARAMETER;
4075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4077 if (ret == CAMERA_ERROR_NONE) {
4078 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4079 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4082 LOGD("ret : 0x%x", ret);
4088 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4090 int ret = CAMERA_ERROR_NONE;
4091 camera_cli_s *pc = (camera_cli_s *)camera;
4092 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4094 if (!pc || !pc->cb_info || !callback) {
4095 LOGE("NULL pointer %p %p", pc, callback);
4096 return CAMERA_ERROR_INVALID_PARAMETER;
4101 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4103 if (ret == CAMERA_ERROR_NONE) {
4104 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4105 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4108 LOGD("ret : 0x%x", ret);
4114 int camera_unset_focus_changed_cb(camera_h camera)
4116 int ret = CAMERA_ERROR_NONE;
4117 camera_cli_s *pc = (camera_cli_s *)camera;
4118 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4120 if (!pc || !pc->cb_info) {
4121 LOGE("NULL handle");
4122 return CAMERA_ERROR_INVALID_PARAMETER;
4127 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4129 if (ret == CAMERA_ERROR_NONE) {
4130 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4131 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4134 LOGD("ret : 0x%x", ret);
4140 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4142 int ret = CAMERA_ERROR_NONE;
4143 camera_cli_s *pc = (camera_cli_s *)camera;
4144 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4146 if (!pc || !pc->cb_info || !callback) {
4147 LOGE("NULL pointer %p %p", pc, callback);
4148 return CAMERA_ERROR_INVALID_PARAMETER;
4153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4155 if (ret == CAMERA_ERROR_NONE) {
4156 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4157 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4160 LOGD("ret : 0x%x", ret);
4166 int camera_unset_error_cb(camera_h camera)
4168 int ret = CAMERA_ERROR_NONE;
4169 camera_cli_s *pc = (camera_cli_s *)camera;
4170 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4172 if (!pc || !pc->cb_info) {
4173 LOGE("NULL handle");
4174 return CAMERA_ERROR_INVALID_PARAMETER;
4179 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4181 if (ret == CAMERA_ERROR_NONE) {
4182 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4183 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4186 LOGD("ret : 0x%x", ret);
4192 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4194 int ret = CAMERA_ERROR_NONE;
4195 camera_cli_s *pc = (camera_cli_s *)camera;
4196 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4198 if (!pc || !pc->cb_info || !foreach_cb) {
4199 LOGE("NULL pointer %p %p", pc, foreach_cb);
4200 return CAMERA_ERROR_INVALID_PARAMETER;
4205 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4206 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4208 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4210 LOGD("ret : 0x%x", ret);
4216 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4218 int ret = CAMERA_ERROR_NONE;
4219 camera_cli_s *pc = (camera_cli_s *)camera;
4220 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4222 if (!pc || !pc->cb_info || !foreach_cb) {
4223 LOGE("NULL pointer %p %p", pc, foreach_cb);
4224 return CAMERA_ERROR_INVALID_PARAMETER;
4229 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4230 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4232 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4234 LOGD("ret : 0x%x", ret);
4240 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4242 int ret = CAMERA_ERROR_NONE;
4243 camera_cli_s *pc = (camera_cli_s *)camera;
4244 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4246 if (!pc || !pc->cb_info || !foreach_cb) {
4247 LOGE("NULL pointer %p %p", pc, foreach_cb);
4248 return CAMERA_ERROR_INVALID_PARAMETER;
4253 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4254 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4256 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4258 LOGD("ret : 0x%x", ret);
4264 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4266 int ret = CAMERA_ERROR_NONE;
4267 camera_cli_s *pc = (camera_cli_s *)camera;
4268 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4270 if (!pc || !pc->cb_info || !foreach_cb) {
4271 LOGE("NULL pointer %p %p", pc, foreach_cb);
4272 return CAMERA_ERROR_INVALID_PARAMETER;
4277 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4278 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4280 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4282 LOGD("ret : 0x%x", ret);
4288 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4290 int ret = CAMERA_ERROR_NONE;
4291 camera_cli_s *pc = (camera_cli_s *)camera;
4292 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4294 if (!pc || !pc->cb_info || !width || !height) {
4295 LOGE("NULL pointer %p %p %p", pc, width, height);
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4300 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4302 if (ret == CAMERA_ERROR_NONE) {
4303 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4304 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4307 LOGD("ret : 0x%x", ret);
4313 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4315 int ret = CAMERA_ERROR_NONE;
4316 camera_cli_s *pc = (camera_cli_s *)camera;
4317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4319 if (!pc || !pc->cb_info || !angle) {
4320 LOGE("NULL pointer %p %p", pc, angle);
4321 return CAMERA_ERROR_INVALID_PARAMETER;
4326 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4328 if (ret == CAMERA_ERROR_NONE)
4329 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4331 LOGD("ret : 0x%x", ret);
4337 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4339 int ret = CAMERA_ERROR_NONE;
4340 camera_cli_s *pc = (camera_cli_s *)camera;
4341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4342 camera_msg_param param;
4343 int set_mode = (int)mode;
4345 if (!pc || !pc->cb_info) {
4346 LOGE("NULL handle");
4347 return CAMERA_ERROR_INVALID_PARAMETER;
4352 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4354 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4356 LOGD("ret : 0x%x", ret);
4362 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4364 int ret = CAMERA_ERROR_NONE;
4365 camera_cli_s *pc = (camera_cli_s *)camera;
4366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4368 if (!pc || !pc->cb_info || !mode) {
4369 LOGE("NULL pointer %p %p", pc, mode);
4370 return CAMERA_ERROR_INVALID_PARAMETER;
4375 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4377 if (ret == CAMERA_ERROR_NONE)
4378 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4380 LOGD("ret : 0x%x", ret);
4386 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4388 int ret = CAMERA_ERROR_NONE;
4389 camera_cli_s *pc = (camera_cli_s *)camera;
4390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4392 if (!pc || !pc->cb_info || !foreach_cb) {
4393 LOGE("NULL pointer %p %p", pc, foreach_cb);
4394 return CAMERA_ERROR_INVALID_PARAMETER;
4399 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4400 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4402 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4404 LOGD("Finish, return :%x", ret);
4410 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4412 int ret = CAMERA_ERROR_NONE;
4413 camera_cli_s *pc = (camera_cli_s *)camera;
4414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4415 camera_msg_param param;
4416 int set_fps = (int)fps;
4418 if (!pc || !pc->cb_info) {
4419 LOGE("NULL handle");
4420 return CAMERA_ERROR_INVALID_PARAMETER;
4425 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4427 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4429 LOGD("ret : 0x%x", ret);
4435 int camera_attr_set_image_quality(camera_h camera, int quality)
4437 int ret = CAMERA_ERROR_NONE;
4438 camera_cli_s *pc = (camera_cli_s *)camera;
4439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4440 camera_msg_param param;
4442 if (!pc || !pc->cb_info) {
4443 LOGE("NULL handle");
4444 return CAMERA_ERROR_INVALID_PARAMETER;
4449 CAMERA_MSG_PARAM_SET(param, INT, quality);
4451 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4453 LOGD("ret : 0x%x", ret);
4459 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4461 int ret = CAMERA_ERROR_NONE;
4462 camera_cli_s *pc = (camera_cli_s *)camera;
4463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4465 if (!pc || !pc->cb_info || !fps) {
4466 LOGE("NULL pointer %p %p", pc, fps);
4467 return CAMERA_ERROR_INVALID_PARAMETER;
4472 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4474 if (ret == CAMERA_ERROR_NONE)
4475 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4477 LOGD("ret : 0x%x", ret);
4483 int camera_attr_get_image_quality(camera_h camera, int *quality)
4485 int ret = CAMERA_ERROR_NONE;
4486 camera_cli_s *pc = (camera_cli_s *)camera;
4487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4489 if (!pc || !pc->cb_info || !quality) {
4490 LOGE("NULL pointer %p %p", pc, quality);
4491 return CAMERA_ERROR_INVALID_PARAMETER;
4496 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4498 if (ret == CAMERA_ERROR_NONE)
4499 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4501 LOGD("ret : 0x%x", ret);
4507 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4509 int ret = CAMERA_ERROR_NONE;
4510 camera_cli_s *pc = (camera_cli_s *)camera;
4511 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4513 if (!pc || !pc->cb_info || !bitrate) {
4514 LOGE("NULL pointer %p %p", pc, bitrate);
4515 return CAMERA_ERROR_INVALID_PARAMETER;
4520 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4522 if (ret == CAMERA_ERROR_NONE)
4523 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4525 LOGD("ret : 0x%x", ret);
4531 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4533 int ret = CAMERA_ERROR_NONE;
4534 camera_cli_s *pc = (camera_cli_s *)camera;
4535 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4536 camera_msg_param param;
4537 int set_bitrate = bitrate;
4539 if (!pc || !pc->cb_info) {
4540 LOGE("NULL handle");
4541 return CAMERA_ERROR_INVALID_PARAMETER;
4546 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4548 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4550 LOGD("ret : 0x%x", ret);
4556 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4558 int ret = CAMERA_ERROR_NONE;
4559 camera_cli_s *pc = (camera_cli_s *)camera;
4560 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4562 if (!pc || !pc->cb_info || !interval) {
4563 LOGE("NULL pointer %p %p", pc, interval);
4564 return CAMERA_ERROR_INVALID_PARAMETER;
4569 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4571 if (ret == CAMERA_ERROR_NONE)
4572 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4574 LOGD("ret : 0x%x", ret);
4580 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4582 int ret = CAMERA_ERROR_NONE;
4583 camera_cli_s *pc = (camera_cli_s *)camera;
4584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4585 camera_msg_param param;
4586 int set_gop_interval = interval;
4588 if (!pc || !pc->cb_info) {
4589 LOGE("NULL handle");
4590 return CAMERA_ERROR_INVALID_PARAMETER;
4595 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4597 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4599 LOGD("ret : 0x%x", ret);
4605 int camera_attr_set_zoom(camera_h camera, int zoom)
4607 int ret = CAMERA_ERROR_NONE;
4608 camera_cli_s *pc = (camera_cli_s *)camera;
4609 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4610 camera_msg_param param;
4612 if (!pc || !pc->cb_info) {
4613 LOGE("NULL handle");
4614 return CAMERA_ERROR_INVALID_PARAMETER;
4617 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4619 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4621 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4623 LOGD("ret : 0x%x", ret);
4629 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4631 int ret = CAMERA_ERROR_NONE;
4632 camera_cli_s *pc = (camera_cli_s *)camera;
4633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4634 camera_msg_param param;
4635 int set_mode = (int)mode;
4637 if (!pc || !pc->cb_info) {
4638 LOGE("NULL handle");
4639 return CAMERA_ERROR_INVALID_PARAMETER;
4642 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4644 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4646 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4652 int camera_attr_set_af_area(camera_h camera, int x, int y)
4654 int ret = CAMERA_ERROR_NONE;
4655 camera_cli_s *pc = (camera_cli_s *)camera;
4656 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4657 camera_msg_param param;
4660 if (!pc || !pc->cb_info) {
4661 LOGE("NULL handle");
4662 return CAMERA_ERROR_INVALID_PARAMETER;
4665 LOGD("Enter - %d,%d", x, y);
4667 value = (x << 16) | y;
4668 CAMERA_MSG_PARAM_SET(param, INT, value);
4670 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4672 LOGD("ret : 0x%x", ret);
4678 int camera_attr_clear_af_area(camera_h camera)
4680 int ret = CAMERA_ERROR_NONE;
4681 camera_cli_s *pc = (camera_cli_s *)camera;
4682 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4684 if (!pc || !pc->cb_info) {
4685 LOGE("NULL handle");
4686 return CAMERA_ERROR_INVALID_PARAMETER;
4691 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4693 LOGD("ret : 0x%x", ret);
4699 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4701 int ret = CAMERA_ERROR_NONE;
4702 camera_cli_s *pc = (camera_cli_s *)camera;
4703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4704 camera_msg_param param;
4705 int set_mode = (int)mode;
4707 if (!pc || !pc->cb_info) {
4708 LOGE("NULL handle");
4709 return CAMERA_ERROR_INVALID_PARAMETER;
4714 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4716 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4718 LOGD("ret : 0x%x", ret);
4724 int camera_attr_set_exposure(camera_h camera, int value)
4726 int ret = CAMERA_ERROR_NONE;
4727 camera_cli_s *pc = (camera_cli_s *)camera;
4728 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4729 camera_msg_param param;
4731 if (!pc || !pc->cb_info) {
4732 LOGE("NULL handle");
4733 return CAMERA_ERROR_INVALID_PARAMETER;
4738 CAMERA_MSG_PARAM_SET(param, INT, value);
4740 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4742 LOGD("ret : 0x%x", ret);
4748 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4750 int ret = CAMERA_ERROR_NONE;
4751 camera_cli_s *pc = (camera_cli_s *)camera;
4752 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4753 camera_msg_param param;
4754 int set_iso = (int)iso;
4756 if (!pc || !pc->cb_info) {
4757 LOGE("NULL handle");
4758 return CAMERA_ERROR_INVALID_PARAMETER;
4763 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4765 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4767 LOGD("ret : 0x%x", ret);
4773 int camera_attr_set_brightness(camera_h camera, int level)
4775 int ret = CAMERA_ERROR_NONE;
4776 camera_cli_s *pc = (camera_cli_s *)camera;
4777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4778 camera_msg_param param;
4780 if (!pc || !pc->cb_info) {
4781 LOGE("NULL handle");
4782 return CAMERA_ERROR_INVALID_PARAMETER;
4787 CAMERA_MSG_PARAM_SET(param, INT, level);
4789 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4791 LOGD("ret : 0x%x", ret);
4797 int camera_attr_set_contrast(camera_h camera, int level)
4799 int ret = CAMERA_ERROR_NONE;
4800 camera_cli_s *pc = (camera_cli_s *)camera;
4801 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4802 camera_msg_param param;
4804 if (!pc || !pc->cb_info) {
4805 LOGE("NULL handle");
4806 return CAMERA_ERROR_INVALID_PARAMETER;
4811 CAMERA_MSG_PARAM_SET(param, INT, level);
4813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4815 LOGD("ret : 0x%x", ret);
4821 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4823 int ret = CAMERA_ERROR_NONE;
4824 camera_cli_s *pc = (camera_cli_s *)camera;
4825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4826 camera_msg_param param;
4827 int set_whitebalance = (int)wb;
4829 if (!pc || !pc->cb_info) {
4830 LOGE("NULL handle");
4831 return CAMERA_ERROR_INVALID_PARAMETER;
4836 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4838 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4840 LOGD("ret : 0x%x", ret);
4846 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4848 int ret = CAMERA_ERROR_NONE;
4849 camera_cli_s *pc = (camera_cli_s *)camera;
4850 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4851 camera_msg_param param;
4852 int set_effect = (int)effect;
4854 if (!pc || !pc->cb_info) {
4855 LOGE("NULL handle");
4856 return CAMERA_ERROR_INVALID_PARAMETER;
4861 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4863 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4876 camera_msg_param param;
4877 int set_mode = (int)mode;
4879 if (!pc || !pc->cb_info) {
4880 LOGE("NULL handle");
4881 return CAMERA_ERROR_INVALID_PARAMETER;
4886 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4888 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4890 LOGD("ret : 0x%x", ret);
4896 int camera_attr_enable_tag(camera_h camera, bool enable)
4898 int ret = CAMERA_ERROR_NONE;
4899 camera_cli_s *pc = (camera_cli_s *)camera;
4900 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4901 camera_msg_param param;
4902 int set_enable = (int)enable;
4904 if (!pc || !pc->cb_info) {
4905 LOGE("NULL handle");
4906 return CAMERA_ERROR_INVALID_PARAMETER;
4911 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4913 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4915 LOGD("ret : 0x%x", ret);
4921 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4923 int ret = CAMERA_ERROR_NONE;
4924 camera_cli_s *pc = (camera_cli_s *)camera;
4925 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4926 camera_msg_param param;
4928 if (!pc || !pc->cb_info || !description) {
4929 LOGE("NULL pointer %p %p", pc, description);
4930 return CAMERA_ERROR_INVALID_PARAMETER;
4935 CAMERA_MSG_PARAM_SET(param, STRING, description);
4937 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4939 LOGD("ret : 0x%x", ret);
4945 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4947 int ret = CAMERA_ERROR_NONE;
4948 camera_cli_s *pc = (camera_cli_s *)camera;
4949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4950 camera_msg_param param;
4951 int set_orientation = (int)orientation;
4953 if (!pc || !pc->cb_info) {
4954 LOGE("NULL handle");
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4960 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4962 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4964 LOGD("ret : 0x%x", ret);
4970 int camera_attr_set_tag_software(camera_h camera, const char *software)
4972 int ret = CAMERA_ERROR_NONE;
4973 camera_cli_s *pc = (camera_cli_s *)camera;
4974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4975 camera_msg_param param;
4977 if (!pc || !pc->cb_info || !software) {
4978 LOGE("NULL pointer %p %p", pc, software);
4979 return CAMERA_ERROR_INVALID_PARAMETER;
4982 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4984 CAMERA_MSG_PARAM_SET(param, STRING, software);
4986 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4988 LOGD("ret : 0x%x", ret);
4994 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4996 int ret = CAMERA_ERROR_NONE;
4997 camera_cli_s *pc = (camera_cli_s *)camera;
4998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4999 double set_geotag[3] = {latitude, longitude, altitude};
5004 if (!pc || !pc->cb_info) {
5005 LOGE("NULL handle");
5006 return CAMERA_ERROR_INVALID_PARAMETER;
5011 length = sizeof(set_geotag) / sizeof(int) + \
5012 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5014 msg = muse_core_msg_json_factory_new(api,
5015 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5018 LOGE("msg creation failed: api %d", api);
5019 return CAMERA_ERROR_OUT_OF_MEMORY;
5022 if (pc->cb_info->is_server_connected) {
5023 __camera_update_api_waiting(pc->cb_info, api, 1);
5025 g_mutex_lock(&pc->cb_info->fd_lock);
5026 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
5027 g_mutex_unlock(&pc->cb_info->fd_lock);
5031 LOGE("message send failed");
5032 ret = CAMERA_ERROR_INVALID_OPERATION;
5034 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5037 __camera_update_api_waiting(pc->cb_info, api, -1);
5039 muse_core_msg_json_factory_free(msg);
5041 LOGD("ret : 0x%x", ret);
5047 int camera_attr_remove_geotag(camera_h camera)
5049 int ret = CAMERA_ERROR_NONE;
5050 camera_cli_s *pc = (camera_cli_s *)camera;
5051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5053 if (!pc || !pc->cb_info) {
5054 LOGE("NULL handle");
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5060 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5062 LOGD("ret : 0x%x", ret);
5068 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5070 int ret = CAMERA_ERROR_NONE;
5071 camera_cli_s *pc = (camera_cli_s *)camera;
5072 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5073 camera_msg_param param;
5074 int set_mode = (int)mode;
5076 if (!pc || !pc->cb_info) {
5077 LOGE("NULL handle");
5078 return CAMERA_ERROR_INVALID_PARAMETER;
5083 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5085 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5087 LOGD("ret : 0x%x", ret);
5093 int camera_attr_get_zoom(camera_h camera, int *zoom)
5095 int ret = CAMERA_ERROR_NONE;
5096 camera_cli_s *pc = (camera_cli_s *)camera;
5097 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5099 if (!pc || !pc->cb_info || !zoom) {
5100 LOGE("NULL pointer %p %p", pc, zoom);
5101 return CAMERA_ERROR_INVALID_PARAMETER;
5106 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5108 if (ret == CAMERA_ERROR_NONE)
5109 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5111 LOGD("ret : 0x%x", ret);
5117 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5119 int ret = CAMERA_ERROR_NONE;
5120 camera_cli_s *pc = (camera_cli_s *)camera;
5121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5123 if (!pc || !pc->cb_info || !min || !max) {
5124 LOGE("NULL pointer %p %p %p", pc, min, max);
5125 return CAMERA_ERROR_INVALID_PARAMETER;
5130 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5132 if (ret == CAMERA_ERROR_NONE) {
5133 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5134 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5137 LOGD("ret : 0x%x", ret);
5143 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5145 int ret = CAMERA_ERROR_NONE;
5146 camera_cli_s *pc = (camera_cli_s *)camera;
5147 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5149 if (!pc || !pc->cb_info || !mode) {
5150 LOGE("NULL pointer %p %p", pc, mode);
5151 return CAMERA_ERROR_INVALID_PARAMETER;
5156 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5158 if (ret == CAMERA_ERROR_NONE)
5159 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5161 LOGD("ret : 0x%x", ret);
5167 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5169 int ret = CAMERA_ERROR_NONE;
5170 camera_cli_s *pc = (camera_cli_s *)camera;
5171 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5173 if (!pc || !pc->cb_info || !mode) {
5174 LOGE("NULL pointer %p %p", pc, mode);
5175 return CAMERA_ERROR_INVALID_PARAMETER;
5180 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5182 if (ret == CAMERA_ERROR_NONE)
5183 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5185 LOGD("ret : 0x%x", ret);
5191 int camera_attr_get_exposure(camera_h camera, int *value)
5193 int ret = CAMERA_ERROR_NONE;
5194 camera_cli_s *pc = (camera_cli_s *)camera;
5195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5197 if (!pc || !pc->cb_info || !value) {
5198 LOGE("NULL pointer %p %p", pc, value);
5199 return CAMERA_ERROR_INVALID_PARAMETER;
5204 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5206 if (ret == CAMERA_ERROR_NONE)
5207 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5209 LOGD("ret : 0x%x", ret);
5215 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5217 int ret = CAMERA_ERROR_NONE;
5218 camera_cli_s *pc = (camera_cli_s *)camera;
5219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5221 if (!pc || !pc->cb_info || !min || !max) {
5222 LOGE("NULL pointer %p %p %p", pc, min, max);
5223 return CAMERA_ERROR_INVALID_PARAMETER;
5228 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5230 if (ret == CAMERA_ERROR_NONE) {
5231 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5232 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5235 LOGD("ret : 0x%x", ret);
5241 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5243 int ret = CAMERA_ERROR_NONE;
5244 camera_cli_s *pc = (camera_cli_s *)camera;
5245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5247 if (!pc || !pc->cb_info || !iso) {
5248 LOGE("NULL pointer %p %p", pc, iso);
5249 return CAMERA_ERROR_INVALID_PARAMETER;
5254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5256 if (ret == CAMERA_ERROR_NONE)
5257 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5259 LOGD("ret : 0x%x", ret);
5265 int camera_attr_get_brightness(camera_h camera, int *level)
5267 int ret = CAMERA_ERROR_NONE;
5268 camera_cli_s *pc = (camera_cli_s *)camera;
5269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5271 if (!pc || !pc->cb_info || !level) {
5272 LOGE("NULL pointer %p %p", pc, level);
5273 return CAMERA_ERROR_INVALID_PARAMETER;
5278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 if (ret == CAMERA_ERROR_NONE)
5281 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5283 LOGD("ret : 0x%x", ret);
5289 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5295 if (!pc || !pc->cb_info || !min || !max) {
5296 LOGE("NULL pointer %p %p %p", pc, min, max);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE) {
5305 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5306 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_get_contrast(camera_h camera, int *level)
5317 int ret = CAMERA_ERROR_NONE;
5318 camera_cli_s *pc = (camera_cli_s *)camera;
5319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5321 if (!pc || !pc->cb_info || !level) {
5322 LOGE("NULL pointer %p %p", pc, level);
5323 return CAMERA_ERROR_INVALID_PARAMETER;
5328 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5330 if (ret == CAMERA_ERROR_NONE)
5331 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5333 LOGD("ret : 0x%x", ret);
5339 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5345 if (!pc || !pc->cb_info || !min || !max) {
5346 LOGE("NULL pointer %p %p %p", pc, min, max);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE) {
5355 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5356 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5357 LOGD("min %d, max %d", *min, *max);
5360 LOGD("ret : 0x%x", ret);
5366 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5368 int ret = CAMERA_ERROR_NONE;
5369 camera_cli_s *pc = (camera_cli_s *)camera;
5370 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5372 if (!pc || !pc->cb_info || !wb) {
5373 LOGE("NULL pointer %p %p", pc, wb);
5374 return CAMERA_ERROR_INVALID_PARAMETER;
5379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5381 if (ret == CAMERA_ERROR_NONE)
5382 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5384 LOGD("ret : 0x%x", ret);
5390 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5392 int ret = CAMERA_ERROR_NONE;
5393 camera_cli_s *pc = (camera_cli_s *)camera;
5394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5396 if (!pc || !pc->cb_info || !effect) {
5397 LOGE("NULL pointer %p %p", pc, effect);
5398 return CAMERA_ERROR_INVALID_PARAMETER;
5403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5405 if (ret == CAMERA_ERROR_NONE)
5406 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5408 LOGD("ret : 0x%x", ret);
5414 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5416 int ret = CAMERA_ERROR_NONE;
5417 camera_cli_s *pc = (camera_cli_s *)camera;
5418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5420 if (!pc || !pc->cb_info || !mode) {
5421 LOGE("NULL pointer %p %p", pc, mode);
5422 return CAMERA_ERROR_INVALID_PARAMETER;
5427 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5429 if (ret == CAMERA_ERROR_NONE)
5430 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5432 LOGD("ret : 0x%x", ret);
5438 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5440 int ret = CAMERA_ERROR_NONE;
5441 camera_cli_s *pc = (camera_cli_s *)camera;
5442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5444 if (!pc || !pc->cb_info || !enable) {
5445 LOGE("NULL pointer %p %p", pc, enable);
5446 return CAMERA_ERROR_INVALID_PARAMETER;
5451 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5453 if (ret == CAMERA_ERROR_NONE)
5454 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5456 LOGD("ret : 0x%x", ret);
5462 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5464 int ret = CAMERA_ERROR_NONE;
5465 camera_cli_s *pc = (camera_cli_s *)camera;
5466 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5468 if (!pc || !pc->cb_info || !description) {
5469 LOGE("NULL pointer %p %p", pc, description);
5470 return CAMERA_ERROR_INVALID_PARAMETER;
5475 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5477 if (ret == CAMERA_ERROR_NONE)
5478 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5480 LOGD("ret : 0x%x", ret);
5486 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5488 int ret = CAMERA_ERROR_NONE;
5489 camera_cli_s *pc = (camera_cli_s *)camera;
5490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5492 if (!pc || !pc->cb_info || !orientation) {
5493 LOGE("NULL pointer %p %p", pc, orientation);
5494 return CAMERA_ERROR_INVALID_PARAMETER;
5499 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5501 if (ret == CAMERA_ERROR_NONE)
5502 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5504 LOGD("ret : 0x%x", ret);
5510 int camera_attr_get_tag_software(camera_h camera, char **software)
5512 int ret = CAMERA_ERROR_NONE;
5513 camera_cli_s *pc = (camera_cli_s *)camera;
5514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5516 if (!pc || !pc->cb_info || !software) {
5517 LOGE("NULL pointer %p %p", pc, software);
5518 return CAMERA_ERROR_INVALID_PARAMETER;
5523 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5525 if (ret == CAMERA_ERROR_NONE)
5526 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5528 LOGD("ret : 0x%x", ret);
5534 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5540 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5541 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5547 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5549 if (ret == CAMERA_ERROR_NONE) {
5550 *latitude = pc->cb_info->get_geotag[0];
5551 *longitude = pc->cb_info->get_geotag[1];
5552 *altitude = pc->cb_info->get_geotag[2];
5555 LOGD("ret : 0x%x", ret);
5561 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5563 int ret = CAMERA_ERROR_NONE;
5564 camera_cli_s *pc = (camera_cli_s *)camera;
5565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5567 if (!pc || !pc->cb_info || !mode) {
5568 LOGE("NULL pointer %p %p", pc, mode);
5569 return CAMERA_ERROR_INVALID_PARAMETER;
5574 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5576 if (ret == CAMERA_ERROR_NONE)
5577 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5579 LOGD("ret : 0x%x", ret);
5585 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5587 int ret = CAMERA_ERROR_NONE;
5588 int get_flash_state = 0;
5591 LOGE("NULL pointer");
5592 return CAMERA_ERROR_INVALID_PARAMETER;
5595 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5596 (int)device, "get_flash_state", &get_flash_state);
5598 if (ret == CAMERA_ERROR_NONE) {
5599 *state = (camera_flash_state_e)get_flash_state;
5600 LOGD("flash state %d", *state);
5602 LOGE("failed 0x%x", ret);
5609 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5611 int ret = CAMERA_ERROR_NONE;
5612 camera_cli_s *pc = (camera_cli_s *)camera;
5613 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5615 if (!pc || !pc->cb_info || !foreach_cb) {
5616 LOGE("NULL pointer %p %p", pc, foreach_cb);
5617 return CAMERA_ERROR_INVALID_PARAMETER;
5622 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5623 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5625 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5627 LOGD("ret : 0x%x", ret);
5633 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5635 int ret = CAMERA_ERROR_NONE;
5636 camera_cli_s *pc = (camera_cli_s *)camera;
5637 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5639 if (!pc || !pc->cb_info || !foreach_cb) {
5640 LOGE("NULL pointer %p %p", pc, foreach_cb);
5641 return CAMERA_ERROR_INVALID_PARAMETER;
5646 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5649 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5651 LOGD("ret : 0x%x", ret);
5657 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5659 int ret = CAMERA_ERROR_NONE;
5660 camera_cli_s *pc = (camera_cli_s *)camera;
5661 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5663 if (!pc || !pc->cb_info || !foreach_cb) {
5664 LOGE("NULL pointer %p %p", pc, foreach_cb);
5665 return CAMERA_ERROR_INVALID_PARAMETER;
5670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5673 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5675 LOGD("ret : 0x%x", ret);
5681 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5683 int ret = CAMERA_ERROR_NONE;
5684 camera_cli_s *pc = (camera_cli_s *)camera;
5685 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5687 if (!pc || !pc->cb_info || !foreach_cb) {
5688 LOGE("NULL pointer %p %p", pc, foreach_cb);
5689 return CAMERA_ERROR_INVALID_PARAMETER;
5694 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5699 LOGD("ret : 0x%x", ret);
5705 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5707 int ret = CAMERA_ERROR_NONE;
5708 camera_cli_s *pc = (camera_cli_s *)camera;
5709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5711 if (!pc || !pc->cb_info || !foreach_cb) {
5712 LOGE("NULL pointer %p %p", pc, foreach_cb);
5713 return CAMERA_ERROR_INVALID_PARAMETER;
5718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5723 LOGD("ret : 0x%x", ret);
5729 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5735 if (!pc || !pc->cb_info || !foreach_cb) {
5736 LOGE("NULL pointer %p %p", pc, foreach_cb);
5737 return CAMERA_ERROR_INVALID_PARAMETER;
5742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5747 LOGD("ret : 0x%x", ret);
5753 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5755 int ret = CAMERA_ERROR_NONE;
5756 camera_cli_s *pc = (camera_cli_s *)camera;
5757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5759 if (!pc || !pc->cb_info || !foreach_cb) {
5760 LOGE("NULL pointer %p %p", pc, foreach_cb);
5761 return CAMERA_ERROR_INVALID_PARAMETER;
5766 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5769 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5771 LOGD("ret : 0x%x", ret);
5777 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5779 int ret = CAMERA_ERROR_NONE;
5780 camera_cli_s *pc = (camera_cli_s *)camera;
5781 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5783 if (!pc || !pc->cb_info || !foreach_cb) {
5784 LOGE("NULL pointer %p %p", pc, foreach_cb);
5785 return CAMERA_ERROR_INVALID_PARAMETER;
5790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5793 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5795 LOGD("Enter, handle :%x", pc->remote_handle);
5801 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)
5803 int ret = CAMERA_ERROR_NONE;
5804 camera_cli_s *pc = (camera_cli_s *)camera;
5805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5806 camera_msg_param param;
5809 if (!pc || !pc->cb_info || !foreach_cb) {
5810 LOGE("NULL pointer %p %p", pc, foreach_cb);
5811 return CAMERA_ERROR_INVALID_PARAMETER;
5816 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5817 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5819 value = (width << 16) | height;
5820 CAMERA_MSG_PARAM_SET(param, INT, value);
5822 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5824 LOGD("ret : 0x%x", ret);
5830 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5832 int ret = CAMERA_ERROR_NONE;
5833 camera_cli_s *pc = (camera_cli_s *)camera;
5834 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5836 if (!pc || !pc->cb_info || !foreach_cb) {
5837 LOGE("NULL pointer %p %p", pc, foreach_cb);
5838 return CAMERA_ERROR_INVALID_PARAMETER;
5843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5846 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5848 LOGD("ret : 0x%x", ret);
5854 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5856 int ret = CAMERA_ERROR_NONE;
5857 camera_cli_s *pc = (camera_cli_s *)camera;
5858 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5860 if (!pc || !pc->cb_info || !foreach_cb) {
5861 LOGE("NULL pointer %p %p", pc, foreach_cb);
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5867 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5868 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5870 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5872 LOGD("ret : 0x%x", ret);
5878 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5880 int ret = CAMERA_ERROR_NONE;
5881 camera_cli_s *pc = (camera_cli_s *)camera;
5882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5883 camera_msg_param param;
5884 int set_rotation = (int)rotation;
5886 if (!pc || !pc->cb_info) {
5887 LOGE("NULL handle");
5888 return CAMERA_ERROR_INVALID_PARAMETER;
5893 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5895 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5897 LOGD("ret : 0x%x", ret);
5903 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5905 int ret = CAMERA_ERROR_NONE;
5906 camera_cli_s *pc = (camera_cli_s *)camera;
5907 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5909 if (!pc || !pc->cb_info || !rotation) {
5910 LOGE("NULL pointer %p %p", pc, rotation);
5911 return CAMERA_ERROR_INVALID_PARAMETER;
5916 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5918 if (ret == CAMERA_ERROR_NONE)
5919 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5921 LOGD("ret : 0x%x", ret);
5927 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5932 camera_msg_param param;
5933 int set_flip = (int)flip;
5935 if (!pc || !pc->cb_info) {
5936 LOGE("NULL handle");
5937 return CAMERA_ERROR_INVALID_PARAMETER;
5942 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5944 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5946 LOGD("ret : 0x%x", ret);
5952 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5954 int ret = CAMERA_ERROR_NONE;
5955 camera_cli_s *pc = (camera_cli_s *)camera;
5956 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5958 if (!pc || !pc->cb_info || !flip) {
5959 LOGE("NULL pointer %p %p", pc, flip);
5960 return CAMERA_ERROR_INVALID_PARAMETER;
5965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5967 if (ret == CAMERA_ERROR_NONE)
5968 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5970 LOGD("ret : 0x%x", ret);
5975 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5977 int ret = CAMERA_ERROR_NONE;
5978 camera_cli_s *pc = (camera_cli_s *)camera;
5979 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5980 camera_msg_param param;
5981 int set_mode = (int)mode;
5983 if (!pc || !pc->cb_info) {
5984 LOGE("NULL handle");
5985 return CAMERA_ERROR_INVALID_PARAMETER;
5990 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5992 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5994 LOGD("ret : 0x%x", ret);
6000 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6002 int ret = CAMERA_ERROR_NONE;
6003 camera_cli_s *pc = (camera_cli_s *)camera;
6004 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6006 if (!pc || !pc->cb_info || !mode) {
6007 LOGE("NULL pointer %p %p", pc, mode);
6008 return CAMERA_ERROR_INVALID_PARAMETER;
6013 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6015 if (ret == CAMERA_ERROR_NONE)
6016 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6018 LOGD("ret : 0x%x", ret);
6024 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6026 int ret = CAMERA_ERROR_NONE;
6027 camera_cli_s *pc = (camera_cli_s *)camera;
6028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6030 if (!pc || !pc->cb_info) {
6031 LOGE("NULL handle");
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6037 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6040 LOGE("error is occurred 0x%x", ret);
6044 LOGD("ret : %d", ret);
6050 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6052 int ret = CAMERA_ERROR_NONE;
6053 camera_cli_s *pc = (camera_cli_s *)camera;
6054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6056 if (!pc || !pc->cb_info) {
6057 LOGE("NULL handle");
6058 return CAMERA_ERROR_INVALID_PARAMETER;
6063 if (!camera_attr_is_supported_hdr_capture(camera)) {
6064 LOGE("HDR not supported");
6065 return CAMERA_ERROR_NOT_SUPPORTED;
6069 LOGE("NULL callback");
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6073 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6075 if (ret == CAMERA_ERROR_NONE) {
6076 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6077 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6080 LOGD("ret : 0x%x", ret);
6086 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6088 int ret = CAMERA_ERROR_NONE;
6089 camera_cli_s *pc = (camera_cli_s *)camera;
6090 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6092 if (!pc || !pc->cb_info) {
6093 LOGE("NULL handle");
6094 return CAMERA_ERROR_INVALID_PARAMETER;
6099 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6101 if (ret == CAMERA_ERROR_NONE) {
6102 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6103 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6106 LOGD("ret : 0x%x", ret);
6112 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6114 int ret = CAMERA_ERROR_NONE;
6115 camera_cli_s *pc = (camera_cli_s *)camera;
6116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6117 camera_msg_param param;
6118 int set_enable = (int)enable;
6120 if (!pc || !pc->cb_info) {
6121 LOGE("NULL handle");
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6127 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6129 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6131 LOGD("ret : 0x%x", ret);
6137 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6139 int ret = CAMERA_ERROR_NONE;
6140 camera_cli_s *pc = (camera_cli_s *)camera;
6141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6143 if (!pc || !pc->cb_info || !enabled) {
6144 LOGE("NULL pointer %p %p", pc, enabled);
6145 return CAMERA_ERROR_INVALID_PARAMETER;
6150 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6152 if (ret == CAMERA_ERROR_NONE)
6153 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6155 LOGD("ret : 0x%x", ret);
6161 bool camera_attr_is_supported_anti_shake(camera_h camera)
6163 int ret = CAMERA_ERROR_NONE;
6164 camera_cli_s *pc = (camera_cli_s *)camera;
6165 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6167 if (!pc || !pc->cb_info) {
6168 LOGE("NULL handle");
6169 return CAMERA_ERROR_INVALID_PARAMETER;
6174 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6177 LOGE("error is occurred 0x%x", ret);
6181 LOGD("ret : %d", ret);
6187 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6189 int ret = CAMERA_ERROR_NONE;
6190 camera_cli_s *pc = (camera_cli_s *)camera;
6191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6192 camera_msg_param param;
6193 int set_enable = (int)enable;
6195 if (!pc || !pc->cb_info) {
6196 LOGE("NULL handle");
6197 return CAMERA_ERROR_INVALID_PARAMETER;
6202 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6204 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6206 LOGD("ret : 0x%x", ret);
6212 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6214 int ret = CAMERA_ERROR_NONE;
6215 camera_cli_s *pc = (camera_cli_s *)camera;
6216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6218 if (!pc || !pc->cb_info || !enabled) {
6219 LOGE("NULL pointer %p %p", pc, enabled);
6220 return CAMERA_ERROR_INVALID_PARAMETER;
6225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6227 if (ret == CAMERA_ERROR_NONE)
6228 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6230 LOGD("ret : 0x%x", ret);
6236 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6238 int ret = CAMERA_ERROR_NONE;
6239 camera_cli_s *pc = (camera_cli_s *)camera;
6240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6242 if (!pc || !pc->cb_info) {
6243 LOGE("NULL handle");
6244 return CAMERA_ERROR_INVALID_PARAMETER;
6249 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6252 LOGE("error is occurred 0x%x", ret);
6256 LOGD("ret : %d", ret);
6262 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_cli_s *pc = (camera_cli_s *)camera;
6266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6267 camera_msg_param param;
6268 int set_enable = (int)enable;
6270 if (!pc || !pc->cb_info) {
6271 LOGE("NULL handle");
6272 return CAMERA_ERROR_INVALID_PARAMETER;
6277 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6279 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6281 LOGD("ret : 0x%x", ret);
6287 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6289 int ret = CAMERA_ERROR_NONE;
6290 camera_cli_s *pc = (camera_cli_s *)camera;
6291 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6293 if (!pc || !pc->cb_info || !enabled) {
6294 LOGE("NULL pointer %p %p", pc, enabled);
6295 return CAMERA_ERROR_INVALID_PARAMETER;
6300 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6302 if (ret == CAMERA_ERROR_NONE)
6303 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6305 LOGD("ret : 0x%x", ret);
6311 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6313 int ret = CAMERA_ERROR_NONE;
6314 camera_cli_s *pc = (camera_cli_s *)camera;
6315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6317 if (!pc || !pc->cb_info) {
6318 LOGE("NULL handle");
6319 return CAMERA_ERROR_INVALID_PARAMETER;
6324 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6327 LOGE("error is occurred 0x%x", ret);
6331 LOGD("ret : %d", ret);
6337 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6339 int ret = CAMERA_ERROR_NONE;
6340 camera_cli_s *pc = (camera_cli_s *)camera;
6341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6342 camera_msg_param param;
6343 int set_disable = (int)disable;
6345 if (!pc || !pc->cb_info) {
6346 LOGE("NULL handle");
6347 return CAMERA_ERROR_INVALID_PARAMETER;
6352 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6354 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6356 LOGD("ret : 0x%x", ret);
6362 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6364 int ret = CAMERA_ERROR_NONE;
6365 camera_cli_s *pc = (camera_cli_s *)camera;
6366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6367 camera_msg_param param;
6368 int set_move_type = (int)move_type;
6371 if (!pc || !pc->cb_info) {
6372 LOGE("NULL handle");
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6378 value = (set_move_type << 16) | pan_step;
6379 CAMERA_MSG_PARAM_SET(param, INT, value);
6381 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6383 LOGD("ret : 0x%x", ret);
6389 int camera_attr_get_pan(camera_h camera, int *pan_step)
6391 int ret = CAMERA_ERROR_NONE;
6392 camera_cli_s *pc = (camera_cli_s *)camera;
6393 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6395 if (!pc || !pc->cb_info || !pan_step) {
6396 LOGE("NULL pointer %p %p", pc, pan_step);
6397 return CAMERA_ERROR_INVALID_PARAMETER;
6402 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6404 if (ret == CAMERA_ERROR_NONE)
6405 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6407 LOGD("ret : 0x%x", ret);
6413 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6415 int ret = CAMERA_ERROR_NONE;
6416 camera_cli_s *pc = (camera_cli_s *)camera;
6417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6419 if (!pc || !pc->cb_info || !min || !max) {
6420 LOGE("NULL pointer %p %p", pc, min, max);
6421 return CAMERA_ERROR_INVALID_PARAMETER;
6426 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6428 if (ret == CAMERA_ERROR_NONE) {
6429 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6430 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6433 LOGD("ret : 0x%x", ret);
6439 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6441 int ret = CAMERA_ERROR_NONE;
6442 camera_cli_s *pc = (camera_cli_s *)camera;
6443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6444 camera_msg_param param;
6445 int set_move_type = (int)move_type;
6448 if (!pc || !pc->cb_info) {
6449 LOGE("NULL handle");
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6455 value = (set_move_type << 16) | tilt_step;
6456 CAMERA_MSG_PARAM_SET(param, INT, value);
6458 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6460 LOGD("ret : 0x%x", ret);
6466 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6468 int ret = CAMERA_ERROR_NONE;
6469 camera_cli_s *pc = (camera_cli_s *)camera;
6470 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6472 if (!pc || !pc->cb_info || !tilt_step) {
6473 LOGE("NULL pointer %p %p", pc, tilt_step);
6474 return CAMERA_ERROR_INVALID_PARAMETER;
6479 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6481 if (ret == CAMERA_ERROR_NONE)
6482 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6484 LOGD("ret : 0x%x", ret);
6490 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6492 int ret = CAMERA_ERROR_NONE;
6493 camera_cli_s *pc = (camera_cli_s *)camera;
6494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6496 if (!pc || !pc->cb_info || !min || !max) {
6497 LOGE("NULL pointer %p %p %p", pc, min, max);
6498 return CAMERA_ERROR_INVALID_PARAMETER;
6503 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6505 if (ret == CAMERA_ERROR_NONE) {
6506 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6507 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6510 LOGD("ret : 0x%x", ret);
6516 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6518 int ret = CAMERA_ERROR_NONE;
6519 camera_cli_s *pc = (camera_cli_s *)camera;
6520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6521 camera_msg_param param;
6522 int set_ptz_type = (int)ptz_type;
6524 if (!pc || !pc->cb_info) {
6525 LOGE("NULL handle");
6526 return CAMERA_ERROR_INVALID_PARAMETER;
6531 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6533 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6535 LOGD("ret : 0x%x", ret);
6541 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6543 int ret = CAMERA_ERROR_NONE;
6544 camera_cli_s *pc = (camera_cli_s *)camera;
6545 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6547 if (!pc || !pc->cb_info || !foreach_cb) {
6548 LOGE("NULL pointer %p %p", pc, foreach_cb);
6549 return CAMERA_ERROR_INVALID_PARAMETER;
6554 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6555 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6557 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6559 LOGD("ret : 0x%x", ret);
6565 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6567 int ret = CAMERA_ERROR_NONE;
6568 camera_cli_s *pc = (camera_cli_s *)camera;
6569 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6570 int set_display_roi_area[4] = {x, y, width, height};
6575 if (!pc || !pc->cb_info) {
6576 LOGE("NULL handle");
6577 return CAMERA_ERROR_INVALID_PARAMETER;
6582 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6583 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6584 g_mutex_lock(&pc->cb_info->evas_mutex);
6586 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6588 g_mutex_unlock(&pc->cb_info->evas_mutex);
6590 if (ret != MM_ERROR_NONE) {
6591 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6592 return CAMERA_ERROR_INVALID_OPERATION;
6595 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6597 length = sizeof(set_display_roi_area) / sizeof(int) + \
6598 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6600 msg = muse_core_msg_json_factory_new(api,
6601 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6604 LOGE("msg creation failed: api %d", api);
6605 return CAMERA_ERROR_OUT_OF_MEMORY;
6608 if (pc->cb_info->is_server_connected) {
6609 __camera_update_api_waiting(pc->cb_info, api, 1);
6611 g_mutex_lock(&pc->cb_info->fd_lock);
6612 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6613 g_mutex_unlock(&pc->cb_info->fd_lock);
6617 LOGE("message send failed");
6618 ret = CAMERA_ERROR_INVALID_OPERATION;
6620 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6623 __camera_update_api_waiting(pc->cb_info, api, -1);
6625 muse_core_msg_json_factory_free(msg);
6627 LOGD("ret : 0x%x", ret);
6633 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6635 camera_cli_s *pc = (camera_cli_s *)camera;
6636 int ret = CAMERA_ERROR_NONE;
6637 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6639 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6640 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6641 return CAMERA_ERROR_INVALID_PARAMETER;
6646 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6648 if (ret == CAMERA_ERROR_NONE) {
6649 *x = pc->cb_info->get_display_roi_area[0];
6650 *y = pc->cb_info->get_display_roi_area[1];
6651 *width = pc->cb_info->get_display_roi_area[2];
6652 *height = pc->cb_info->get_display_roi_area[3];
6655 LOGD("ret : 0x%x", ret);
6661 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6663 int ret = CAMERA_ERROR_NONE;
6664 int get_device_state = 0;
6667 LOGE("NULL pointer");
6668 return CAMERA_ERROR_INVALID_PARAMETER;
6671 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6672 (int)device, "get_device_state", &get_device_state);
6674 if (ret == CAMERA_ERROR_NONE) {
6675 *state = (camera_device_state_e)get_device_state;
6676 LOGD("device state %d", *state);
6678 LOGE("failed 0x%x", ret);
6685 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6687 int ret = CAMERA_ERROR_NONE;
6688 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6689 camera_cb_info *info = NULL;
6691 if (!callback || !cb_id) {
6692 LOGE("invalid pointer %p %p", callback, cb_id);
6693 return CAMERA_ERROR_INVALID_PARAMETER;
6696 /* check camera support */
6697 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6698 if (ret != CAMERA_ERROR_NONE) {
6699 LOGE("get device state failed");
6703 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6705 info = g_new0(camera_cb_info, 1);
6707 LOGE("info failed");
6708 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6712 info->id = ++g_cam_dev_state_changed_cb_id;
6713 info->callback = (void *)callback;
6714 info->user_data = user_data;
6718 /* subscribe dbus signal for camera state change */
6719 if (!g_cam_dev_state_changed_cb_conn) {
6720 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6721 if (!g_cam_dev_state_changed_cb_conn) {
6722 LOGE("failed to get gdbus connection");
6723 ret = CAMERA_ERROR_INVALID_OPERATION;
6727 LOGD("subscribe signal %s - %s - %s",
6728 MM_CAMCORDER_DBUS_OBJECT,
6729 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6730 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6732 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6733 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6734 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6735 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6736 LOGE("failed to get gdbus connection");
6737 ret = CAMERA_ERROR_INVALID_OPERATION;
6741 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6744 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6746 LOGD("callback id %d", info->id);
6749 if (ret != CAMERA_ERROR_NONE) {
6755 if (g_cam_dev_state_changed_cb_conn) {
6756 g_object_unref(g_cam_dev_state_changed_cb_conn);
6757 g_cam_dev_state_changed_cb_conn = NULL;
6761 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6767 int camera_remove_device_state_changed_cb(int cb_id)
6769 int ret = CAMERA_ERROR_NONE;
6770 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6771 GList *tmp_list = NULL;
6772 camera_cb_info *info = NULL;
6774 /* check camera support */
6775 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6776 if (ret != CAMERA_ERROR_NONE) {
6777 LOGE("get device state failed");
6781 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6783 if (!g_cam_dev_state_changed_cb_list) {
6784 LOGE("there is no callback info");
6785 ret = CAMERA_ERROR_INVALID_OPERATION;
6789 tmp_list = g_cam_dev_state_changed_cb_list;
6792 info = tmp_list->data;
6793 tmp_list = tmp_list->next;
6800 if (info->id == cb_id) {
6801 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6806 if (!g_cam_dev_state_changed_cb_list) {
6807 /* no remained callback */
6808 if (g_cam_dev_state_changed_cb_conn) {
6809 /* unsubscribe signal */
6810 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6811 g_cam_dev_state_changed_cb_subscribe_id = 0;
6813 /* unref connection */
6814 g_object_unref(g_cam_dev_state_changed_cb_conn);
6815 g_cam_dev_state_changed_cb_conn = NULL;
6819 LOGD("id %d callback removed", cb_id);
6820 ret = CAMERA_ERROR_NONE;
6826 LOGE("id %d callback not found", cb_id);
6827 ret = CAMERA_ERROR_INVALID_PARAMETER;
6830 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);