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;
55 static void __global(void *data, struct wl_registry *registry,
56 uint32_t name, const char *interface, uint32_t version)
58 struct tizen_surface **tz_surface = NULL;
65 tz_surface = (struct tizen_surface **)data;
68 LOGW("NULL interface");
72 /*LOGI("interface %s", interface);*/
74 if (strcmp(interface, "tizen_surface") == 0) {
75 LOGD("binding tizen surface for wayland");
77 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
78 if (*tz_surface == NULL)
79 LOGE("failed to bind");
87 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
93 static const struct wl_registry_listener _camera_wl_registry_listener = {
98 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
105 *((unsigned int *)data) = id;
107 LOGD("[CLIENT] got parent_id [%u] from server", id);
112 static const struct tizen_resource_listener _camera_tz_resource_listener = {
116 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
118 int ret = CAMERA_ERROR_NONE;
119 Ecore_Wl_Window *window = NULL;
120 struct wl_display *display = NULL;
121 struct wl_display *display_wrapper = NULL;
122 struct wl_surface *surface = NULL;
123 struct wl_registry *registry = NULL;
124 struct wl_event_queue *queue = NULL;
125 struct tizen_surface *tz_surface = NULL;
126 struct tizen_resource *tz_resource = NULL;
128 if (!obj || !wl_info) {
129 LOGE("NULL parameter %p %p", obj, wl_info);
130 return CAMERA_ERROR_INVALID_OPERATION;
133 window = elm_win_wl_window_get(obj);
135 LOGE("failed to get wayland window");
136 ret = CAMERA_ERROR_INVALID_OPERATION;
140 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
142 LOGE("failed to get wayland surface");
143 ret = CAMERA_ERROR_INVALID_OPERATION;
147 display = (struct wl_display *)ecore_wl_display_get();
149 LOGE("failed to get wayland display");
150 ret = CAMERA_ERROR_INVALID_OPERATION;
154 display_wrapper = wl_proxy_create_wrapper(display);
155 if (!display_wrapper) {
156 LOGE("failed to create wl display wrapper");
157 ret = CAMERA_ERROR_INVALID_OPERATION;
161 queue = wl_display_create_queue(display);
163 LOGE("failed to create wl display queue");
164 ret = CAMERA_ERROR_INVALID_OPERATION;
168 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
170 registry = wl_display_get_registry(display_wrapper);
172 LOGE("failed to get wayland registry");
173 ret = CAMERA_ERROR_INVALID_OPERATION;
177 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
179 wl_display_dispatch_queue(display, queue);
180 wl_display_roundtrip_queue(display, queue);
183 LOGE("failed to get tizen surface");
184 ret = CAMERA_ERROR_INVALID_OPERATION;
188 /* Get parent_id which is unique in a entire systemw. */
189 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
191 LOGE("failed to get tizen resurce");
192 ret = CAMERA_ERROR_INVALID_OPERATION;
196 wl_info->parent_id = 0;
198 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
200 wl_display_roundtrip_queue(display, queue);
202 if (wl_info->parent_id > 0) {
204 Ecore_Evas *ecore_evas = NULL;
205 ret = CAMERA_ERROR_NONE;
207 wl_info->evas_obj = obj;
209 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
210 &wl_info->window_width, &wl_info->window_height);
212 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
214 rotation = ecore_evas_rotation_get(ecore_evas);
215 if (rotation == 90 || rotation == 270) {
216 int temp = wl_info->window_width;
218 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
220 wl_info->window_width = wl_info->window_height;
221 wl_info->window_height = temp;
224 LOGW("failed to get ecore_evas.. skip rotation check");
227 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
228 wl_info->evas_obj, rotation, wl_info->parent_id,
229 wl_info->window_x, wl_info->window_y,
230 wl_info->window_width, wl_info->window_height);
232 ret = CAMERA_ERROR_INVALID_OPERATION;
233 LOGE("failed to get parent id");
238 tizen_surface_destroy(tz_surface);
243 tizen_resource_destroy(tz_resource);
248 wl_registry_destroy(registry);
253 wl_event_queue_destroy(queue);
257 if (display_wrapper) {
258 wl_proxy_wrapper_destroy(display_wrapper);
259 display_wrapper = NULL;
266 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
269 api < 0 || api >= MUSE_CAMERA_API_MAX) {
270 LOGE("invalid param %p %d", cb_info, api);
274 g_mutex_lock(&(cb_info->api_mutex[api]));
275 cb_info->api_waiting[api] += value;
276 g_mutex_unlock(&(cb_info->api_mutex[api]));
278 /*LOGD("api %d, value %d, waiting %d",
279 api, value, cb_info->api_waiting[api]);*/
285 static void __camera_device_state_changed_cb(GDBusConnection *connection,
286 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
287 const gchar *signal_name, GVariant *param, gpointer user_data)
290 camera_device_e device = CAMERA_DEVICE_CAMERA0;
291 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
292 GList *tmp_list = NULL;
293 camera_cb_info *info = NULL;
295 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
297 if (!g_cam_dev_state_changed_cb_list || !param) {
298 LOGW("no callback or NULL param %p", param);
302 /* get device and state */
303 g_variant_get(param, "(i)", &value);
305 device = value >> 16;
306 state = 0x0000ffff & value;
308 LOGD("device %d, state %d", device, state);
310 tmp_list = g_cam_dev_state_changed_cb_list;
313 info = (camera_cb_info *)tmp_list->data;
316 if (info->callback) {
317 LOGD("start id[%d] callback", info->id);
318 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
319 LOGD("returned id[%d] callback", info->id);
321 LOGW("NULL callback for id %d", info->id);
325 tmp_list = tmp_list->next;
329 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
335 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
337 tbm_bo tmp_bo = NULL;
338 tbm_bo_handle tmp_bo_handle = {NULL, };
340 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
341 LOGE("invalid parameter - %p %p %p, key %d",
342 bufmgr, bo, bo_handle, tbm_key);
346 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
347 if (tmp_bo == NULL) {
348 LOGE("import failed - key %d", tbm_key);
352 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
353 if (tmp_bo_handle.ptr == NULL) {
354 LOGE("map failed %p", tmp_bo);
355 tbm_bo_unref(tmp_bo);
360 tbm_bo_unmap(tmp_bo);
362 /* set bo and bo_handle */
364 *bo_handle = tmp_bo_handle;
369 static void _camera_release_imported_bo(tbm_bo *bo)
382 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
384 int ret = CAMERA_ERROR_NONE;
387 /*LOGD("Enter api : %d", api);*/
389 if (!cb_info->is_server_connected) {
390 LOGE("server is disconnected");
391 return CAMERA_ERROR_SERVICE_DISCONNECTED;
394 g_mutex_lock(&(cb_info->api_mutex[api]));
396 if (cb_info->api_activating[api] == 0) {
397 if (time_out == CAMERA_CB_NO_TIMEOUT) {
398 LOGW("wait for api %d", api);
399 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
400 ret = cb_info->api_ret[api];
401 cb_info->api_activating[api] = 0;
402 LOGW("api %d returned 0x%x", api, ret);
404 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
405 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
406 ret = cb_info->api_ret[api];
407 cb_info->api_activating[api] = 0;
408 /*LOGD("return value : 0x%x", ret);*/
410 ret = CAMERA_ERROR_INVALID_OPERATION;
411 LOGE("api %d was TIMED OUT!", api);
415 ret = cb_info->api_ret[api];
416 cb_info->api_activating[api] = 0;
418 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
421 g_mutex_unlock(&(cb_info->api_mutex[api]));
423 if (ret != CAMERA_ERROR_NONE) {
424 LOGE("api %d : error 0x%x", api, ret);
426 if (ret == CAMERA_ERROR_SOUND_POLICY)
427 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
428 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
429 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
430 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
431 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
438 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
439 int *ret, int timeout)
445 LOGE("NULL info - api %d", api);
448 *ret = CAMERA_ERROR_INVALID_PARAMETER;
453 msg = muse_core_msg_json_factory_new(api, NULL);
455 LOGE("msg failed: api %d", api);
458 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
463 /*LOGD("send msg %s", msg);*/
465 if (cb_info->is_server_connected) {
466 __camera_update_api_waiting(cb_info, api, 1);
468 g_mutex_lock(&cb_info->fd_lock);
469 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
470 g_mutex_unlock(&cb_info->fd_lock);
474 LOGE("msg send failed");
476 *ret = CAMERA_ERROR_INVALID_OPERATION;
479 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
482 __camera_update_api_waiting(cb_info, api, -1);
484 muse_core_msg_json_factory_free(msg);
490 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
491 int *ret, camera_msg_param *param, int timeout)
496 if (!cb_info || !param) {
497 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
500 *ret = CAMERA_ERROR_INVALID_PARAMETER;
505 /*LOGD("type %d, name %s", param->type, param->name);*/
507 switch (param->type) {
509 msg = muse_core_msg_json_factory_new(api,
510 param->type, param->name, param->value.value_INT,
513 case MUSE_TYPE_STRING:
514 msg = muse_core_msg_json_factory_new(api,
515 param->type, param->name, param->value.value_STRING,
519 LOGE("unknown type %d", param->type);
524 LOGE("msg failed: api %d", api);
527 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
532 /*LOGD("send msg %s", msg);*/
534 if (cb_info->is_server_connected) {
535 __camera_update_api_waiting(cb_info, api, 1);
537 g_mutex_lock(&cb_info->fd_lock);
538 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
539 g_mutex_unlock(&cb_info->fd_lock);
543 LOGE("msg send failed");
546 *ret = CAMERA_ERROR_INVALID_OPERATION;
549 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
552 __camera_update_api_waiting(cb_info, api, -1);
554 muse_core_msg_json_factory_free(msg);
560 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
562 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
563 in_format >= MM_PIXEL_FORMAT_NUM ||
564 out_format == NULL) {
565 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
566 return CAMERA_ERROR_INVALID_PARAMETER;
570 case MM_PIXEL_FORMAT_NV12:
571 case MM_PIXEL_FORMAT_NV12T:
572 *out_format = TBM_FORMAT_NV12;
574 case MM_PIXEL_FORMAT_NV16:
575 *out_format = TBM_FORMAT_NV16;
577 case MM_PIXEL_FORMAT_NV21:
578 *out_format = TBM_FORMAT_NV21;
580 case MM_PIXEL_FORMAT_YUYV:
581 *out_format = TBM_FORMAT_YUYV;
583 case MM_PIXEL_FORMAT_UYVY:
584 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
585 *out_format = TBM_FORMAT_UYVY;
587 case MM_PIXEL_FORMAT_422P:
588 *out_format = TBM_FORMAT_YUV422;
590 case MM_PIXEL_FORMAT_I420:
591 *out_format = TBM_FORMAT_YUV420;
593 case MM_PIXEL_FORMAT_YV12:
594 *out_format = TBM_FORMAT_YVU420;
596 case MM_PIXEL_FORMAT_RGB565:
597 *out_format = TBM_FORMAT_RGB565;
599 case MM_PIXEL_FORMAT_RGB888:
600 *out_format = TBM_FORMAT_RGB888;
602 case MM_PIXEL_FORMAT_RGBA:
603 *out_format = TBM_FORMAT_RGBA8888;
605 case MM_PIXEL_FORMAT_ARGB:
606 *out_format = TBM_FORMAT_ARGB8888;
609 LOGE("invalid in_format %d", in_format);
610 return CAMERA_ERROR_INVALID_PARAMETER;
613 return CAMERA_ERROR_NONE;
617 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
619 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
620 in_format >= MM_PIXEL_FORMAT_NUM ||
622 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
623 return CAMERA_ERROR_INVALID_PARAMETER;
627 case MM_PIXEL_FORMAT_NV12:
628 case MM_PIXEL_FORMAT_NV12T:
629 *mimetype = MEDIA_FORMAT_NV12;
631 case MM_PIXEL_FORMAT_NV16:
632 *mimetype = MEDIA_FORMAT_NV16;
634 case MM_PIXEL_FORMAT_NV21:
635 *mimetype = MEDIA_FORMAT_NV21;
637 case MM_PIXEL_FORMAT_YUYV:
638 *mimetype = MEDIA_FORMAT_YUYV;
640 case MM_PIXEL_FORMAT_UYVY:
641 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
642 *mimetype = MEDIA_FORMAT_UYVY;
644 case MM_PIXEL_FORMAT_422P:
645 *mimetype = MEDIA_FORMAT_422P;
647 case MM_PIXEL_FORMAT_I420:
648 *mimetype = MEDIA_FORMAT_I420;
650 case MM_PIXEL_FORMAT_YV12:
651 *mimetype = MEDIA_FORMAT_YV12;
653 case MM_PIXEL_FORMAT_RGB565:
654 *mimetype = MEDIA_FORMAT_RGB565;
656 case MM_PIXEL_FORMAT_RGB888:
657 *mimetype = MEDIA_FORMAT_RGB888;
659 case MM_PIXEL_FORMAT_RGBA:
660 *mimetype = MEDIA_FORMAT_RGBA;
662 case MM_PIXEL_FORMAT_ARGB:
663 *mimetype = MEDIA_FORMAT_ARGB;
666 LOGE("invalid in_format %d", in_format);
667 return CAMERA_ERROR_INVALID_PARAMETER;
670 return CAMERA_ERROR_NONE;
673 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
674 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
677 unsigned char *buf_pos = NULL;
679 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
680 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
685 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
686 frame->format = MM_PIXEL_FORMAT_UYVY;
688 frame->format = stream->format;
690 frame->width = stream->width;
691 frame->height = stream->height;
692 frame->timestamp = stream->timestamp;
693 frame->num_of_planes = stream->num_planes;
695 if (num_buffer_key == 0) {
697 if (!data_bo_handle || !data_bo_handle->ptr) {
698 LOGE("NULL pointer");
702 buf_pos = data_bo_handle->ptr;
704 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
705 frame->data.encoded_plane.data = buf_pos;
706 frame->data.encoded_plane.size = stream->data.encoded.length_data;
707 total_size = stream->data.encoded.length_data;
709 switch (stream->num_planes) {
711 frame->data.single_plane.yuv = buf_pos;
712 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
713 total_size = stream->data.yuv420.length_yuv;
716 frame->data.double_plane.y = buf_pos;
717 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
718 buf_pos += stream->data.yuv420sp.length_y;
719 frame->data.double_plane.uv = buf_pos;
720 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
721 total_size = stream->data.yuv420sp.length_y + \
722 stream->data.yuv420sp.length_uv;
725 frame->data.triple_plane.y = buf_pos;
726 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
727 buf_pos += stream->data.yuv420p.length_y;
728 frame->data.triple_plane.u = buf_pos;
729 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
730 buf_pos += stream->data.yuv420p.length_u;
731 frame->data.triple_plane.v = buf_pos;
732 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
733 total_size = stream->data.yuv420p.length_y + \
734 stream->data.yuv420p.length_u + \
735 stream->data.yuv420p.length_v;
743 switch (stream->num_planes) {
745 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
746 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
747 total_size = stream->data.yuv420.length_yuv;
750 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
751 if (stream->num_planes == (unsigned int)num_buffer_key)
752 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
754 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
755 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
756 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
757 total_size = stream->data.yuv420sp.length_y + \
758 stream->data.yuv420sp.length_uv;
761 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
762 if (stream->num_planes == (unsigned int)num_buffer_key) {
763 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
764 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
766 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
767 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
769 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
770 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
771 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
772 total_size = stream->data.yuv420p.length_y + \
773 stream->data.yuv420p.length_u + \
774 stream->data.yuv420p.length_v;
782 LOGD("format %d, %dx%d, size %d plane num %d",
783 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
789 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
790 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
793 int ret = CAMERA_ERROR_NONE;
794 camera_media_packet_data *tmp_mp_data = NULL;
796 if (*mp_data == NULL) {
797 tmp_mp_data = g_new0(camera_media_packet_data, 1);
799 tmp_mp_data->tbm_key = tbm_key;
800 tmp_mp_data->num_buffer_key = num_buffer_key;
801 tmp_mp_data->bo = bo;
802 tmp_mp_data->data_bo = data_bo;
803 tmp_mp_data->ref_cnt++;
805 for (i = 0 ; i < num_buffer_key ; i++)
806 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
808 *mp_data = tmp_mp_data;
809 /*LOGD("mp_data %p", tmp_mp_data);*/
811 ret = CAMERA_ERROR_OUT_OF_MEMORY;
812 LOGE("failed to alloc media packet data");
815 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
821 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
825 camera_msg_param param;
827 if (!mp_data || !cb_info) {
828 LOGE("NULL pointer %p %p", mp_data, cb_info);
832 if (mp_data->ref_cnt > 1) {
834 LOGD("ref count %d", mp_data->ref_cnt);
836 /* release imported bo */
837 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
838 tbm_bo_unref(mp_data->buffer_bo[i]);
839 mp_data->buffer_bo[i] = NULL;
843 _camera_release_imported_bo(&mp_data->bo);
844 _camera_release_imported_bo(&mp_data->data_bo);
847 tbm_key = mp_data->tbm_key;
849 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
851 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
860 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
861 camera_media_packet_data *mp_data, media_packet_h *packet)
863 media_packet_h pkt = NULL;
864 bool make_pkt_fmt = false;
865 tbm_surface_h tsurf = NULL;
866 tbm_surface_info_s tsurf_info;
867 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
868 uint32_t bo_format = 0;
871 int num_buffer_key = 0;
872 tbm_bo *buffer_bo = NULL;
874 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
875 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
876 cb_info, stream, mp_data, packet);
877 return CAMERA_ERROR_INVALID_PARAMETER;
880 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
881 buffer_bo = mp_data->buffer_bo;
882 num_buffer_key = mp_data->num_buffer_key;
884 /* create tbm surface */
885 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
886 tsurf_info.planes[i].stride = stream->stride[i];
888 /* get tbm surface format */
889 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
890 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
892 if (ret == CAMERA_ERROR_NONE) {
893 tsurf_info.width = stream->width;
894 tsurf_info.height = stream->height;
895 tsurf_info.format = bo_format;
896 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
897 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
899 if (num_buffer_key > 0) {
901 case TBM_FORMAT_NV12:
902 case TBM_FORMAT_NV21:
903 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
904 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
905 tsurf_info.planes[0].offset = 0;
906 if (num_buffer_key == 1)
907 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
908 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
910 case TBM_FORMAT_YUV420:
911 case TBM_FORMAT_YVU420:
912 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
913 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
914 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
915 tsurf_info.planes[0].offset = 0;
916 if (num_buffer_key == 1) {
917 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
918 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
920 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
922 case TBM_FORMAT_UYVY:
923 case TBM_FORMAT_YUYV:
924 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
925 tsurf_info.planes[0].offset = 0;
926 tsurf_info.size = tsurf_info.planes[0].size;
932 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
933 } else if (mp_data->data_bo) {
935 case TBM_FORMAT_NV12:
936 case TBM_FORMAT_NV21:
937 tsurf_info.planes[0].size = stream->width * stream->height;
938 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
939 tsurf_info.planes[0].offset = 0;
940 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
941 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
943 case TBM_FORMAT_YUV420:
944 case TBM_FORMAT_YVU420:
945 tsurf_info.planes[0].size = stream->width * stream->height;
946 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
947 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
948 tsurf_info.planes[0].offset = 0;
949 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
950 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
951 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
953 case TBM_FORMAT_UYVY:
954 case TBM_FORMAT_YUYV:
955 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
956 tsurf_info.planes[0].offset = 0;
957 tsurf_info.size = tsurf_info.planes[0].size;
963 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
965 /*LOGD("tbm surface %p", tsurf);*/
969 /* check media packet format */
970 if (cb_info->pkt_fmt) {
971 int pkt_fmt_width = 0;
972 int pkt_fmt_height = 0;
973 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
975 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
976 if (pkt_fmt_mimetype != mimetype ||
977 pkt_fmt_width != stream->width ||
978 pkt_fmt_height != stream->height) {
979 LOGW("change fmt: current 0x%x, %dx%d",
980 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
981 media_format_unref(cb_info->pkt_fmt);
982 cb_info->pkt_fmt = NULL;
989 /* create packet format */
991 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
992 ret = media_format_create(&cb_info->pkt_fmt);
993 if (ret == MEDIA_FORMAT_ERROR_NONE) {
994 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
995 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
996 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
997 LOGW("media_format_set : 0x%x", ret);
999 LOGW("media_format_create failed 0x%x", ret);
1003 /* create media packet */
1004 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1005 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1006 (void *)cb_info, &pkt);
1007 if (ret != MEDIA_PACKET_ERROR_NONE) {
1008 LOGE("media_packet_create failed 0x%x", ret);
1009 tbm_surface_destroy(tsurf);
1013 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1014 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1018 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1019 /* set media packet data */
1020 ret = media_packet_set_extra(pkt, (void *)mp_data);
1021 if (ret != MEDIA_PACKET_ERROR_NONE) {
1022 LOGE("media_packet_set_extra failed");
1024 _camera_media_packet_data_release(mp_data, cb_info);
1027 media_packet_destroy(pkt);
1030 /* set timestamp : msec -> nsec */
1031 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1032 LOGW("media_packet_set_pts failed");
1041 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1044 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1045 camera_media_packet_data *mp_data = NULL;
1046 tbm_surface_h tsurf = NULL;
1048 if (!pkt || !cb_info) {
1049 LOGE("NULL pointer %p %p", pkt, cb_info);
1050 return MEDIA_PACKET_FINALIZE;
1053 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1054 if (ret != MEDIA_PACKET_ERROR_NONE) {
1055 LOGE("media_packet_get_extra failed 0x%x", ret);
1056 return MEDIA_PACKET_FINALIZE;
1059 /*LOGD("mp_data %p", mp_data);*/
1061 g_mutex_lock(&cb_info->mp_data_mutex);
1063 _camera_media_packet_data_release(mp_data, cb_info);
1066 g_mutex_unlock(&cb_info->mp_data_mutex);
1068 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1069 if (ret != MEDIA_PACKET_ERROR_NONE)
1070 LOGE("get tbm_surface failed 0x%x", ret);
1073 tbm_surface_destroy(tsurf);
1077 return MEDIA_PACKET_FINALIZE;
1080 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1086 tbm_bo_handle bo_handle = {NULL, };
1087 camera_msg_param param;
1089 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1090 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1094 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1096 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1097 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1098 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1099 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1100 /* return preview callback */
1101 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1104 muse_camera_msg_get(tbm_key, recv_msg);
1105 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1107 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1108 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1112 } else if (cb_info->user_cb[event] == NULL) {
1113 LOGW("user callback for event %d is not set", event);
1118 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1124 muse_camera_msg_get(previous, recv_msg);
1125 muse_camera_msg_get(current, recv_msg);
1126 muse_camera_msg_get(by_policy, recv_msg);
1128 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1129 previous, current, by_policy);
1131 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1132 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1135 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1139 muse_camera_msg_get(state, recv_msg);
1141 LOGD("FOCUS state - %d", state);
1143 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1146 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1147 LOGD("CAPTURE_COMPLETED");
1148 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1150 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1151 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1155 int num_buffer_key = 0;
1156 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1158 unsigned char *buf_pos = NULL;
1160 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1161 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1162 tbm_bo data_bo = NULL;
1163 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1165 camera_preview_data_s frame;
1166 camera_stream_data_s *stream = NULL;
1167 camera_media_packet_data *mp_data = NULL;
1168 media_packet_h pkt = NULL;
1169 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1170 media_packet_h pkt_evas = NULL;
1171 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1173 muse_camera_msg_get(tbm_key, recv_msg);
1174 muse_camera_msg_get(num_buffer_key, recv_msg);
1175 muse_camera_msg_get_array(buffer_key, recv_msg);
1176 muse_camera_msg_get(data_key, recv_msg);
1178 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1181 LOGE("invalid key %d", tbm_key);
1185 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1187 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1188 LOGE("invalid num buffer key %d", num_buffer_key);
1189 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1194 /* import tbm data_bo and get virtual address */
1195 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1196 LOGE("failed to import data key %d", data_key);
1197 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1202 /* import tbm bo and get virtual address */
1203 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1204 LOGE("failed to import key %d", tbm_key);
1205 _camera_release_imported_bo(&data_bo);
1206 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1210 buf_pos = (unsigned char *)bo_handle.ptr;
1212 /* get stream info */
1213 stream = (camera_stream_data_s *)buf_pos;
1215 for (i = 0 ; i < num_buffer_key ; i++) {
1216 /* import buffer bo and get virtual address */
1217 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1218 LOGE("failed to import buffer key %d", buffer_key[i]);
1220 /* release imported bo */
1221 _camera_release_imported_bo(&data_bo);
1222 _camera_release_imported_bo(&bo);
1224 for (i -= 1 ; i >= 0 ; i--)
1225 _camera_release_imported_bo(&buffer_bo[i]);
1227 /* send return buffer */
1228 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1234 /* call preview callback */
1235 g_mutex_lock(&cb_info->preview_cb_mutex);
1237 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1238 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1240 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1241 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1244 g_mutex_unlock(&cb_info->preview_cb_mutex);
1246 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1247 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1248 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1250 if (ret == CAMERA_ERROR_NONE) {
1251 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1252 if (ret != CAMERA_ERROR_NONE) {
1253 LOGE("create pkt for evas failed");
1254 _camera_media_packet_data_release(mp_data, cb_info);
1258 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1259 LOGW("evas renderer is not supported");
1260 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1263 /* call media packet callback */
1264 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1265 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1267 if (ret == CAMERA_ERROR_NONE) {
1268 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1270 if (ret == CAMERA_ERROR_NONE) {
1271 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1272 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1274 _camera_media_packet_data_release(mp_data, cb_info);
1280 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1281 /* call evas renderer */
1283 g_mutex_lock(&cb_info->evas_mutex);
1284 if (cb_info->run_evas_render) {
1285 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1287 LOGW("evas renderer is stopped, skip this buffer...");
1288 media_packet_destroy(pkt_evas);
1291 g_mutex_unlock(&cb_info->evas_mutex);
1293 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1295 /* send message for preview callback return */
1296 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1297 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1299 if (mp_data == NULL) {
1300 /* release imported bo */
1301 for (i = 0 ; i < num_buffer_key ; i++)
1302 _camera_release_imported_bo(&buffer_bo[i]);
1304 /* unmap and unref tbm bo */
1305 _camera_release_imported_bo(&data_bo);
1306 _camera_release_imported_bo(&bo);
1309 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1311 /*LOGD("return buffer Done");*/
1315 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1319 muse_camera_msg_get(percent, recv_msg);
1321 LOGD("HDR progress - %d \%", percent);
1323 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1326 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1332 muse_camera_msg_get(policy, recv_msg);
1333 muse_camera_msg_get(previous, recv_msg);
1334 muse_camera_msg_get(current, recv_msg);
1336 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1337 policy, previous, current);
1339 if (policy == CAMERA_POLICY_SOUND)
1340 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1341 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1342 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1343 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1344 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1346 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1347 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1350 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1355 muse_camera_msg_get(policy, recv_msg);
1356 muse_camera_msg_get(state, recv_msg);
1358 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1360 if (policy == CAMERA_POLICY_SOUND)
1361 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1362 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1363 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1364 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1365 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1367 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1368 (camera_state_e)state, cb_info->user_data[event]);
1371 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1374 camera_detected_face_s *faces = NULL;
1376 muse_camera_msg_get(count, recv_msg);
1377 muse_camera_msg_get(tbm_key, recv_msg);
1380 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1384 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1386 faces = bo_handle.ptr;
1390 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1393 _camera_release_imported_bo(&bo);
1397 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1398 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1399 /*LOGD("return buffer done");*/
1402 LOGE("invalid message - count %d, key %d", count, tbm_key);
1406 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1409 int current_state = 0;
1411 muse_camera_msg_get(error, recv_msg);
1412 muse_camera_msg_get(current_state, recv_msg);
1414 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1416 if (error == CAMERA_ERROR_SOUND_POLICY)
1417 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1418 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1419 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1420 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1421 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1423 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1424 (camera_state_e)current_state, cb_info->user_data[event]);
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1429 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1430 muse_camera_msg_get(param1, recv_msg);
1431 muse_camera_msg_get(param2, recv_msg);
1433 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1435 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1436 cb_info->user_cb[event] = NULL;
1437 cb_info->user_data[event] = NULL;
1438 LOGW("stop foreach callback for event %d", event);
1441 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1443 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1445 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1447 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1449 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1451 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1453 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1455 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1457 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1459 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1461 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1463 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1465 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1467 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1469 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1470 muse_camera_msg_get(param1, recv_msg);
1472 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1474 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1475 cb_info->user_cb[event] = NULL;
1476 cb_info->user_data[event] = NULL;
1477 LOGW("stop foreach callback for event %d", event);
1480 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1482 camera_image_data_s *rImage = NULL;
1483 camera_image_data_s *rPostview = NULL;
1484 camera_image_data_s *rThumbnail = NULL;
1485 unsigned char *buf_pos = NULL;
1486 int tbm_key_main = 0;
1487 int tbm_key_post = 0;
1488 int tbm_key_thumb = 0;
1489 tbm_bo bo_main = NULL;
1490 tbm_bo bo_post = NULL;
1491 tbm_bo bo_thumb = NULL;
1492 tbm_bo_handle bo_main_handle = {NULL, };
1493 tbm_bo_handle bo_post_handle = {NULL, };
1494 tbm_bo_handle bo_thumb_handle = {NULL, };
1496 muse_camera_msg_get(tbm_key_main, recv_msg);
1497 muse_camera_msg_get(tbm_key_post, recv_msg);
1498 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1501 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1502 tbm_key_main, tbm_key_post, tbm_key_thumb);
1505 if (tbm_key_main <= 0) {
1506 LOGE("invalid key %d", tbm_key_main);
1510 /* import tbm bo and get virtual address */
1511 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1514 buf_pos = (unsigned char *)bo_main_handle.ptr;
1515 rImage = (camera_image_data_s *)buf_pos;
1516 rImage->data = buf_pos + sizeof(camera_image_data_s);
1517 if (rImage->exif && rImage->exif_size > 0) {
1518 rImage->exif = rImage->data + rImage->size;
1520 rImage->exif = NULL;
1521 rImage->exif_size = 0;
1524 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1525 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1527 if (tbm_key_post > 0) {
1528 /* import tbm bo and get virtual address */
1529 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1532 buf_pos = (unsigned char *)bo_post_handle.ptr;
1533 rPostview = (camera_image_data_s *)buf_pos;
1534 LOGD("rPostview->size : %d", rPostview->size);
1535 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1538 if (tbm_key_thumb > 0) {
1539 /* import tbm bo and get virtual address */
1540 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1543 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1545 rThumbnail = (camera_image_data_s *)buf_pos;
1546 LOGD("rThumbnail->size : %d", rThumbnail->size);
1547 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1550 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1552 /* unmap and unref tbm bo */
1553 _camera_release_imported_bo(&bo_main);
1556 tbm_key = tbm_key_main;
1558 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1560 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1562 if (tbm_key_post > 0) {
1563 /* unmap and unref tbm bo */
1564 _camera_release_imported_bo(&bo_post);
1567 param.value.value_INT = tbm_key_post;
1568 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1571 if (tbm_key_thumb > 0) {
1572 /* unmap and unref tbm bo */
1573 _camera_release_imported_bo(&bo_thumb);
1576 param.value.value_INT = tbm_key_thumb;
1577 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1580 LOGD("return buffer done");
1584 LOGW("unhandled event %d", event);
1591 static bool _camera_idle_event_callback(void *data)
1593 camera_cb_info_s *cb_info = NULL;
1594 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1596 if (cam_idle_event == NULL) {
1597 LOGE("cam_idle_event is NULL");
1602 g_mutex_lock(&cam_idle_event->event_mutex);
1604 cb_info = cam_idle_event->cb_info;
1605 if (cb_info == NULL) {
1606 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1607 goto IDLE_EVENT_CALLBACK_DONE;
1610 /* remove event from list */
1611 g_mutex_lock(&cb_info->idle_event_mutex);
1613 if (cb_info->idle_event_list)
1614 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1616 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1617 g_mutex_unlock(&cb_info->idle_event_mutex);
1620 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1622 /* send signal for waiting thread */
1623 g_cond_signal(&cb_info->idle_event_cond);
1625 IDLE_EVENT_CALLBACK_DONE:
1626 /* unlock and release event */
1627 g_mutex_unlock(&cam_idle_event->event_mutex);
1628 g_mutex_clear(&cam_idle_event->event_mutex);
1630 g_free(cam_idle_event);
1631 cam_idle_event = NULL;
1636 static void *_camera_msg_handler_func(gpointer data)
1640 camera_message_s *cam_msg = NULL;
1641 camera_idle_event_s *cam_idle_event = NULL;
1642 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1643 camera_cb_info_s *cb_info = NULL;
1645 if (!handler_info || !handler_info->cb_info) {
1646 LOGE("NULL handler %p", handler_info);
1650 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1651 type = handler_info->type;
1653 LOGD("t:%d start", type);
1655 g_mutex_lock(&handler_info->mutex);
1657 while (g_atomic_int_get(&handler_info->running)) {
1658 if (g_queue_is_empty(handler_info->queue)) {
1659 /*LOGD("t:%d signal wait...", type);*/
1660 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1661 /*LOGD("t:%d signal received", type);*/
1663 if (g_atomic_int_get(&handler_info->running) == 0) {
1664 LOGD("t:%d stop event thread", type);
1669 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1671 g_mutex_unlock(&handler_info->mutex);
1673 if (cam_msg == NULL) {
1674 LOGE("t:%d NULL message", type);
1675 g_mutex_lock(&handler_info->mutex);
1681 if (api < MUSE_CAMERA_API_MAX) {
1684 g_mutex_lock(&cb_info->api_mutex[api]);
1686 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1687 if (cb_info->api_waiting[api] > 0) {
1688 cb_info->api_ret[api] = ret;
1689 cb_info->api_activating[api] = 1;
1691 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1693 g_cond_signal(&cb_info->api_cond[api]);
1695 LOGW("no waiting for this api [%d]", api);
1698 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1701 g_mutex_unlock(&cb_info->api_mutex[api]);
1702 } else if (api == MUSE_CAMERA_CB_EVENT) {
1703 switch (cam_msg->event_class) {
1704 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1705 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1707 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1708 cam_idle_event = g_new0(camera_idle_event_s, 1);
1709 if (cam_idle_event == NULL) {
1710 LOGE("t:%d cam_idle_event alloc failed", type);
1714 cam_idle_event->event = cam_msg->event;
1715 cam_idle_event->cb_info = cb_info;
1716 g_mutex_init(&cam_idle_event->event_mutex);
1717 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1719 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1721 g_mutex_lock(&cb_info->idle_event_mutex);
1722 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1723 g_mutex_unlock(&cb_info->idle_event_mutex);
1725 g_idle_add_full(G_PRIORITY_DEFAULT,
1726 (GSourceFunc)_camera_idle_event_callback,
1727 (gpointer)cam_idle_event,
1731 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1735 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1741 g_mutex_lock(&handler_info->mutex);
1744 /* remove remained event */
1745 while (!g_queue_is_empty(handler_info->queue)) {
1746 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1748 LOGD("t:%d remove camera message %p", type, cam_msg);
1752 LOGW("t:%d NULL camera message", type);
1756 g_mutex_unlock(&handler_info->mutex);
1758 LOGD("t:%d return", type);
1764 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1766 camera_idle_event_s *cam_idle_event = NULL;
1768 gint64 end_time = 0;
1770 if (cb_info == NULL) {
1771 LOGE("cb_info is NULL");
1775 g_mutex_lock(&cb_info->idle_event_mutex);
1777 if (cb_info->idle_event_list == NULL) {
1778 LOGD("No remained idle event");
1779 g_mutex_unlock(&cb_info->idle_event_mutex);
1783 list = cb_info->idle_event_list;
1786 cam_idle_event = list->data;
1787 list = g_list_next(list);
1789 if (!cam_idle_event) {
1790 LOGW("Fail to remove idle event. The event is NULL");
1794 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1795 LOGW("lock failed, %p event is calling now", cam_idle_event);
1797 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1799 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1800 LOGW("signal received");
1807 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1808 cam_idle_event, cam_idle_event->event);
1810 cam_idle_event->cb_info = NULL;
1812 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1814 g_mutex_unlock(&cam_idle_event->event_mutex);
1817 g_list_free(cb_info->idle_event_list);
1818 cb_info->idle_event_list = NULL;
1820 g_mutex_unlock(&cb_info->idle_event_mutex);
1826 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1828 camera_message_s *cam_msg = NULL;
1830 if (!cb_info || !msg) {
1831 LOGE("NULL pointer %p %p", cb_info, msg);
1835 cam_msg = g_new0(camera_message_s, 1);
1837 LOGE("failed to alloc cam_msg for [%s]", msg);
1842 cam_msg->event = event;
1843 cam_msg->event_class = event_class;
1845 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1847 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1849 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1850 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1851 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1852 g_cond_signal(&cb_info->preview_cb_info.cond);
1853 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1854 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1855 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1856 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1857 g_cond_signal(&cb_info->capture_cb_info.cond);
1858 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1860 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1861 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1862 g_cond_signal(&cb_info->msg_handler_info.cond);
1863 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1872 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1874 int ret = CAMERA_ERROR_NONE;
1878 int event_class = -1;
1882 if (!cb_info || !msg) {
1883 LOGE("invalid ptr %p %p", cb_info, msg);
1887 /*LOGD("msg [%s]", msg);*/
1889 if (!muse_camera_msg_get(api, msg)) {
1890 LOGE("failed to get camera api");
1894 if (api == MUSE_CAMERA_CB_EVENT) {
1895 if (!muse_camera_msg_get(event, msg) ||
1896 !muse_camera_msg_get(event_class, msg)) {
1897 LOGE("failed to get camera event or event_class [%s]", msg);
1901 if (!muse_camera_msg_get(api_class, msg)) {
1902 LOGE("failed to get camera api_class [%s]", msg);
1907 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1908 if (api >= MUSE_CAMERA_API_MAX) {
1909 LOGE("invalid api %d", api);
1913 if (!muse_camera_msg_get(ret, msg)) {
1914 LOGE("failed to get camera ret");
1918 g_mutex_lock(&cb_info->api_mutex[api]);
1921 case MUSE_CAMERA_API_CREATE:
1922 if (ret != CAMERA_ERROR_NONE) {
1923 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1924 LOGE("camera create error 0x%x. close client cb handler", ret);
1927 case MUSE_CAMERA_API_DESTROY:
1928 if (ret == CAMERA_ERROR_NONE) {
1929 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1930 LOGD("camera destroy done. close client cb handler");
1934 muse_camera_msg_get(get_type, msg);
1935 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1936 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1937 muse_camera_msg_get(get_index, msg);
1940 case MUSE_CAMERA_GET_TYPE_INT:
1941 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1943 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1944 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1945 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1947 case MUSE_CAMERA_GET_TYPE_ARRAY:
1948 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1949 muse_core_msg_json_deserialize("get_value",
1950 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1951 LOGD("get display roi %d,%d,%dx%d",
1952 cb_info->get_display_roi_area[0],
1953 cb_info->get_display_roi_area[1],
1954 cb_info->get_display_roi_area[2],
1955 cb_info->get_display_roi_area[3]);
1957 muse_core_msg_json_deserialize("get_value",
1958 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1959 LOGD("get geotag %lf, %lf, %lf",
1960 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1963 case MUSE_CAMERA_GET_TYPE_STRING:
1964 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1967 LOGW("unknown type %d", get_type);
1974 if (cb_info->api_waiting[api] > 0) {
1975 cb_info->api_ret[api] = ret;
1976 cb_info->api_activating[api] = 1;
1978 g_cond_signal(&cb_info->api_cond[api]);
1980 LOGW("no waiting for this api [%d]", api);
1983 g_mutex_unlock(&cb_info->api_mutex[api]);
1984 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1985 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1987 LOGW("unknown camera api %d, class %d", api, api_class);
1994 static void *_camera_msg_recv_func(gpointer data)
1996 int recv_length = 0;
1997 int single_length = 0;
1998 int remained_length = 0;
1999 char *recv_msg = NULL;
2000 char *single_msg = NULL;
2001 char *remained_msg = NULL;
2005 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2008 LOGE("cb_info NULL");
2014 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2016 LOGE("single_msg malloc failed");
2020 recv_msg = cb_info->recv_msg;
2022 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2023 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
2024 if (recv_length <= 0) {
2025 cb_info->is_server_connected = FALSE;
2026 LOGE("receive msg failed - server disconnected");
2034 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2036 /* Need to split the combined entering msgs */
2037 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2038 if (recv_msg[cur_pos] == '}') {
2039 single_length = cur_pos - prev_pos + 1;
2041 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2042 /* check remained msg */
2043 if (remained_length > 0) {
2045 strncpy(single_msg, remained_msg, remained_length);
2046 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2047 single_msg[remained_length + single_length] = '\0';
2050 remained_msg = NULL;
2052 strncpy(single_msg, recv_msg + prev_pos, single_length);
2053 single_msg[single_length] = '\0';
2054 LOGE("lost msg [%s], skip...", single_msg);
2057 remained_length = 0;
2059 strncpy(single_msg, recv_msg + prev_pos, single_length);
2060 single_msg[single_length] = '\0';
2063 if (single_msg[0] == '{') {
2065 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2066 /* process each message */
2067 __camera_process_msg(cb_info, single_msg);
2069 LOGE("invalid msg [%s]", single_msg);
2072 LOGE("too long message [len %d] skip...", single_length);
2075 prev_pos = cur_pos + 1;
2079 /* check incompleted message */
2080 if (recv_msg[recv_length - 1] != '}') {
2081 remained_length = recv_length - prev_pos;
2083 LOGW("incompleted message [len %d]", remained_length);
2085 remained_msg = (char *)malloc(remained_length + 1);
2087 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2088 remained_msg[remained_length] = '\0';
2090 LOGE("failed to alloc for remained msg");
2093 remained_length = 0;
2097 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2099 if (!cb_info->is_server_connected) {
2100 /* send error msg for server disconnection */
2101 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2102 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2103 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2107 LOGE("error_msg failed");
2108 goto CB_HANDLER_EXIT;
2111 __camera_add_msg_to_queue(cb_info,
2112 MUSE_CAMERA_CB_EVENT,
2113 MUSE_CAMERA_EVENT_TYPE_ERROR,
2114 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2117 muse_core_msg_json_factory_free(error_msg);
2120 LOGE("add error msg for service disconnection done");
2131 remained_msg = NULL;
2138 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2139 int type, const char *thread_name, camera_cb_info_s *cb_info)
2141 if (!handler_info || !thread_name || !cb_info) {
2142 LOGE("t:%d NULL %p %p %p",
2143 type, handler_info, thread_name, cb_info);
2149 handler_info->type = type;
2150 handler_info->queue = g_queue_new();
2151 if (handler_info->queue == NULL) {
2152 LOGE("t:%d queue failed", type);
2156 g_mutex_init(&handler_info->mutex);
2157 g_cond_init(&handler_info->cond);
2159 handler_info->cb_info = (void *)cb_info;
2160 g_atomic_int_set(&handler_info->running, 1);
2162 handler_info->thread = g_thread_try_new(thread_name,
2163 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2164 if (handler_info->thread == NULL) {
2165 LOGE("t:%d thread failed", type);
2167 g_mutex_clear(&handler_info->mutex);
2168 g_cond_clear(&handler_info->cond);
2169 g_queue_free(handler_info->queue);
2170 handler_info->queue = NULL;
2175 LOGD("t:%d done", type);
2181 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2185 if (!handler_info) {
2186 LOGE("NULL handler");
2190 if (!handler_info->thread) {
2191 LOGW("thread is not created");
2195 type = handler_info->type;
2197 LOGD("t:%d thread %p", type, handler_info->thread);
2199 g_mutex_lock(&handler_info->mutex);
2200 g_atomic_int_set(&handler_info->running, 0);
2201 g_cond_signal(&handler_info->cond);
2202 g_mutex_unlock(&handler_info->mutex);
2204 g_thread_join(handler_info->thread);
2205 handler_info->thread = NULL;
2207 g_mutex_clear(&handler_info->mutex);
2208 g_cond_clear(&handler_info->cond);
2209 g_queue_free(handler_info->queue);
2210 handler_info->queue = NULL;
2212 LOGD("t:%d done", type);
2218 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2220 camera_cb_info_s *cb_info = NULL;
2223 g_return_val_if_fail(sockfd > 0, NULL);
2225 cb_info = g_new0(camera_cb_info_s, 1);
2226 if (cb_info == NULL) {
2227 LOGE("cb_info failed");
2231 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2233 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2234 g_mutex_init(&cb_info->api_mutex[i]);
2235 g_cond_init(&cb_info->api_cond[i]);
2238 g_mutex_init(&cb_info->fd_lock);
2239 g_mutex_init(&cb_info->idle_event_mutex);
2240 g_cond_init(&cb_info->idle_event_cond);
2241 g_mutex_init(&cb_info->mp_data_mutex);
2242 g_mutex_init(&cb_info->preview_cb_mutex);
2243 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2244 g_mutex_init(&cb_info->evas_mutex);
2245 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2247 /* message handler thread */
2248 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2249 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2250 LOGE("msg_handler_info failed");
2254 /* message handler thread for preview callback */
2255 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2256 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2257 LOGE("preview_cb_info failed");
2261 /* message handler thread for capture callback */
2262 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2263 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2264 LOGE("capture_cb_info failed");
2268 cb_info->fd = sockfd;
2269 cb_info->preview_cb_flag = 0;
2270 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2271 cb_info->evas_info = NULL;
2272 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2274 /* message receive thread */
2275 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2276 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2277 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2278 if (cb_info->msg_recv_thread == NULL) {
2279 LOGE("message receive thread creation failed");
2283 cb_info->is_server_connected = TRUE;
2289 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2290 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2291 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2293 g_mutex_clear(&cb_info->fd_lock);
2294 g_mutex_clear(&cb_info->idle_event_mutex);
2295 g_cond_clear(&cb_info->idle_event_cond);
2296 g_mutex_clear(&cb_info->mp_data_mutex);
2297 g_mutex_clear(&cb_info->preview_cb_mutex);
2298 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2299 g_mutex_clear(&cb_info->evas_mutex);
2300 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2302 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2303 g_mutex_clear(&cb_info->api_mutex[i]);
2304 g_cond_clear(&cb_info->api_cond[i]);
2314 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2318 g_return_if_fail(cb_info != NULL);
2320 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2322 g_thread_join(cb_info->msg_recv_thread);
2323 cb_info->msg_recv_thread = NULL;
2325 LOGD("msg_recv thread removed");
2327 /* destroy msg handler threads */
2328 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2329 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2330 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2332 g_mutex_clear(&cb_info->fd_lock);
2333 g_mutex_clear(&cb_info->idle_event_mutex);
2334 g_cond_clear(&cb_info->idle_event_cond);
2335 g_mutex_clear(&cb_info->mp_data_mutex);
2336 g_mutex_clear(&cb_info->preview_cb_mutex);
2337 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2338 g_mutex_clear(&cb_info->evas_mutex);
2339 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2341 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2342 g_mutex_clear(&cb_info->api_mutex[i]);
2343 g_cond_clear(&cb_info->api_cond[i]);
2346 if (cb_info->fd > -1) {
2347 muse_core_connection_close(cb_info->fd);
2351 if (cb_info->bufmgr) {
2352 tbm_bufmgr_deinit(cb_info->bufmgr);
2353 cb_info->bufmgr = NULL;
2355 if (cb_info->pkt_fmt) {
2356 media_format_unref(cb_info->pkt_fmt);
2357 cb_info->pkt_fmt = NULL;
2360 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2361 if (cb_info->evas_info)
2362 mm_evas_renderer_destroy(&cb_info->evas_info);
2363 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2365 cb_info->preview_cb_flag = 0;
2374 int _camera_start_evas_rendering(camera_h camera)
2376 int ret = CAMERA_ERROR_NONE;
2377 camera_cli_s *pc = (camera_cli_s *)camera;
2379 if (!pc || !pc->cb_info) {
2380 LOGE("NULL handle");
2381 return CAMERA_ERROR_INVALID_PARAMETER;
2386 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2387 LOGE("EVAS surface is not set");
2388 return CAMERA_ERROR_NONE;
2391 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2392 g_mutex_lock(&pc->cb_info->evas_mutex);
2394 /* set evas render flag as RUN */
2395 pc->cb_info->run_evas_render = true;
2396 ret = CAMERA_ERROR_NONE;
2398 g_mutex_unlock(&pc->cb_info->evas_mutex);
2399 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2400 LOGW("evas renderer is not supported");
2401 ret = CAMERA_ERROR_NOT_SUPPORTED;
2402 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2408 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2410 int ret = CAMERA_ERROR_NONE;
2411 camera_cli_s *pc = (camera_cli_s *)camera;
2413 if (!pc || !pc->cb_info) {
2414 LOGE("NULL handle");
2415 return CAMERA_ERROR_INVALID_PARAMETER;
2418 LOGD("stop - keep screen %d", keep_screen);
2420 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2421 LOGE("EVAS surface is not set");
2422 return CAMERA_ERROR_NONE;
2425 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2426 g_mutex_lock(&pc->cb_info->evas_mutex);
2428 /* set evas render flag as STOP and release buffers */
2429 pc->cb_info->run_evas_render = false;
2431 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2432 if (ret != MM_ERROR_NONE) {
2433 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2434 ret = CAMERA_ERROR_INVALID_OPERATION;
2437 g_mutex_unlock(&pc->cb_info->evas_mutex);
2438 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2439 LOGW("evas renderer is not supported");
2440 ret = CAMERA_ERROR_NOT_SUPPORTED;
2441 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2447 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2449 int ret = CAMERA_ERROR_NONE;
2452 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2454 /* create muse connection */
2455 if (!key || !value) {
2456 LOGE("NULL pointer");
2457 return CAMERA_ERROR_INVALID_PARAMETER;
2460 sock_fd = muse_core_client_new();
2462 LOGE("muse_core_client_new failed");
2463 return CAMERA_ERROR_INVALID_OPERATION;
2466 msg = muse_core_msg_json_factory_new(api,
2467 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2468 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2472 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2476 ret = muse_core_ipc_send_msg(sock_fd, msg);
2478 muse_core_msg_json_factory_free(msg);
2482 LOGE("send msg failed");
2483 ret = CAMERA_ERROR_INVALID_OPERATION;
2487 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2489 LOGE("recv msg failed %d", errno);
2490 ret = CAMERA_ERROR_INVALID_OPERATION;
2494 if (!muse_camera_msg_get(ret, recv_msg)) {
2495 LOGE("failed to get return value from msg [%s]", recv_msg);
2496 ret = CAMERA_ERROR_INVALID_OPERATION;
2500 if (ret == CAMERA_ERROR_NONE)
2501 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2503 LOGD("api %d - value %d", api, *value);
2507 muse_core_connection_close(sock_fd);
2515 int camera_create(camera_device_e device, camera_h *camera)
2518 char *send_msg = NULL;
2520 int ret = CAMERA_ERROR_NONE;
2522 camera_cli_s *pc = NULL;
2523 tbm_bufmgr bufmgr = NULL;
2525 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2526 muse_core_api_module_e muse_module = MUSE_CAMERA;
2527 int device_type = (int)device;
2530 LOGE("NULL pointer");
2531 return CAMERA_ERROR_INVALID_PARAMETER;
2534 sock_fd = muse_core_client_new();
2536 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2537 ret = CAMERA_ERROR_INVALID_OPERATION;
2543 send_msg = muse_core_msg_json_factory_new(api,
2544 MUSE_TYPE_INT, "module", muse_module,
2545 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2546 MUSE_TYPE_INT, "pid", pid,
2551 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2555 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2557 muse_core_msg_json_factory_free(send_msg);
2561 LOGE("send msg failed %d", errno);
2562 ret = CAMERA_ERROR_INVALID_OPERATION;
2566 pc = g_new0(camera_cli_s, 1);
2568 LOGE("camera_cli_s alloc failed");
2569 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2573 bufmgr = tbm_bufmgr_init(-1);
2574 if (bufmgr == NULL) {
2575 LOGE("get tbm bufmgr failed");
2576 ret = CAMERA_ERROR_INVALID_OPERATION;
2580 pc->cb_info = _camera_client_callback_new(sock_fd);
2581 if (pc->cb_info == NULL) {
2582 LOGE("cb_info alloc failed");
2583 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2589 LOGD("cb info : %d", pc->cb_info->fd);
2591 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2593 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2595 if (ret == CAMERA_ERROR_NONE) {
2596 intptr_t handle = 0;
2597 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2599 LOGE("Receiving Handle Failed!!");
2600 ret = CAMERA_ERROR_INVALID_OPERATION;
2604 pc->remote_handle = handle;
2605 pc->cb_info->bufmgr = bufmgr;
2607 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2608 if (ret != CAMERA_ERROR_NONE) {
2609 LOGE("init display failed 0x%x", ret);
2613 LOGD("camera create 0x%x", pc->remote_handle);
2614 *camera = (camera_h)pc;
2623 tbm_bufmgr_deinit(bufmgr);
2628 muse_core_connection_close(sock_fd);
2634 _camera_client_callback_destroy(pc->cb_info);
2641 LOGE("camera create error : 0x%x", ret);
2647 int camera_change_device(camera_h camera, camera_device_e device)
2650 int ret = CAMERA_ERROR_NONE;
2651 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2652 camera_cli_s *pc = (camera_cli_s *)camera;
2653 camera_msg_param param;
2655 if (!pc || !pc->cb_info) {
2656 LOGE("NULL handle");
2657 return CAMERA_ERROR_INVALID_PARAMETER;
2660 CAMERA_MSG_PARAM_SET(param, INT, device);
2662 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2664 if (ret == CAMERA_ERROR_NONE) {
2665 /* reset callback and user data */
2666 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2667 pc->cb_info->user_cb[i] = NULL;
2668 pc->cb_info->user_data[i] = NULL;
2670 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2677 int camera_destroy(camera_h camera)
2679 int ret = CAMERA_ERROR_NONE;
2680 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2681 camera_cli_s *pc = (camera_cli_s *)camera;
2683 if (!pc || !pc->cb_info) {
2684 LOGE("NULL handle");
2685 return CAMERA_ERROR_INVALID_PARAMETER;
2690 if (pc->cb_info->is_server_connected)
2691 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2693 LOGW("server disconnected. release resource without send message.");
2695 if (ret == CAMERA_ERROR_NONE) {
2696 _camera_deactivate_idle_event_all(pc->cb_info);
2697 _camera_client_callback_destroy(pc->cb_info);
2707 int camera_start_preview(camera_h camera)
2709 int ret = CAMERA_ERROR_NONE;
2710 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2711 camera_cli_s *pc = (camera_cli_s *)camera;
2713 if (!pc || !pc->cb_info) {
2714 LOGE("NULL handle");
2715 return CAMERA_ERROR_INVALID_PARAMETER;
2720 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2721 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2722 ret = _camera_start_evas_rendering(camera);
2723 if (ret != CAMERA_ERROR_NONE) {
2724 LOGE("stop preview because of error");
2725 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2729 LOGD("ret : 0x%x", ret);
2735 int camera_stop_preview(camera_h camera)
2737 int ret = CAMERA_ERROR_NONE;
2738 camera_cli_s *pc = (camera_cli_s *)camera;
2739 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2740 camera_state_e current_state = CAMERA_STATE_NONE;
2742 if (!pc || !pc->cb_info) {
2743 LOGE("NULL handle");
2744 return CAMERA_ERROR_INVALID_PARAMETER;
2749 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2750 ret = camera_get_state(camera, ¤t_state);
2751 if (ret != CAMERA_ERROR_NONE) {
2752 LOGE("failed to get current state 0x%x", ret);
2756 if (current_state == CAMERA_STATE_PREVIEW) {
2757 ret = _camera_stop_evas_rendering(camera, false);
2758 if (ret != CAMERA_ERROR_NONE)
2763 /* send stop preview message */
2764 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2766 if (ret != CAMERA_ERROR_NONE &&
2767 current_state == CAMERA_STATE_PREVIEW) {
2768 LOGW("restart evas rendering");
2769 _camera_start_evas_rendering(camera);
2772 LOGD("ret : 0x%x", ret);
2778 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2780 int ret = CAMERA_ERROR_NONE;
2781 camera_cli_s *pc = (camera_cli_s *)camera;
2782 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2784 if (!pc || !pc->cb_info) {
2785 LOGE("NULL handle");
2786 return CAMERA_ERROR_INVALID_PARAMETER;
2791 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2792 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2799 LOGD("ret : 0x%x", ret);
2805 bool camera_is_supported_continuous_capture(camera_h camera)
2807 int ret = CAMERA_ERROR_NONE;
2808 camera_cli_s *pc = (camera_cli_s *)camera;
2809 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2811 if (!pc || !pc->cb_info) {
2812 LOGE("NULL handle");
2813 return CAMERA_ERROR_INVALID_PARAMETER;
2818 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2821 LOGE("error is occurred 0x%x", ret);
2825 LOGD("ret : %d", ret);
2831 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)
2833 int ret = CAMERA_ERROR_NONE;
2834 camera_cli_s *pc = (camera_cli_s *)camera;
2835 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2836 camera_msg_param param;
2839 if (!pc || !pc->cb_info) {
2840 LOGE("NULL handle");
2841 return CAMERA_ERROR_INVALID_PARAMETER;
2846 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2847 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2849 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2850 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2852 value = (count << 16) | interval;
2853 CAMERA_MSG_PARAM_SET(param, INT, value);
2855 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2857 LOGD("ret : 0x%x", ret);
2863 int camera_stop_continuous_capture(camera_h camera)
2865 int ret = CAMERA_ERROR_NONE;
2866 camera_cli_s *pc = (camera_cli_s *)camera;
2867 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2869 if (!pc || !pc->cb_info) {
2870 LOGE("NULL handle");
2871 return CAMERA_ERROR_INVALID_PARAMETER;
2876 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2878 LOGD("ret : 0x%x", ret);
2884 bool camera_is_supported_face_detection(camera_h camera)
2886 int ret = CAMERA_ERROR_NONE;
2887 camera_cli_s *pc = (camera_cli_s *)camera;
2888 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2890 if (!pc || !pc->cb_info) {
2891 LOGE("NULL handle");
2892 return CAMERA_ERROR_INVALID_PARAMETER;
2897 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2900 LOGE("error is occurred 0x%x", ret);
2904 LOGD("ret : %d", ret);
2910 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2912 int ret = CAMERA_ERROR_NONE;
2913 camera_cli_s *pc = (camera_cli_s *)camera;
2914 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2916 if (!pc || !pc->cb_info) {
2917 LOGE("NULL handle");
2918 return CAMERA_ERROR_INVALID_PARAMETER;
2923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2926 LOGE("error is occurred 0x%x", ret);
2930 LOGD("ret : %d", ret);
2936 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2938 int ret = CAMERA_ERROR_NONE;
2939 camera_cli_s *pc = (camera_cli_s *)camera;
2940 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2942 if (!pc || !pc->cb_info) {
2943 LOGE("NULL handle");
2944 return CAMERA_ERROR_INVALID_PARAMETER;
2949 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2952 LOGE("error is occurred 0x%x", ret);
2956 LOGD("ret : %d", ret);
2961 int camera_get_device_count(camera_h camera, int *device_count)
2963 int ret = CAMERA_ERROR_NONE;
2964 camera_cli_s *pc = (camera_cli_s *)camera;
2965 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2967 if (!pc || !pc->cb_info) {
2968 LOGE("NULL handle");
2969 return CAMERA_ERROR_INVALID_PARAMETER;
2974 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2976 if (ret == CAMERA_ERROR_NONE)
2977 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2979 LOGD("ret : 0x%x", ret);
2984 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2986 int ret = CAMERA_ERROR_NONE;
2987 camera_cli_s *pc = (camera_cli_s *)camera;
2988 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2990 if (!pc || !pc->cb_info) {
2991 LOGE("NULL handle");
2992 return CAMERA_ERROR_INVALID_PARAMETER;
2997 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2998 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3002 LOGD("ret : 0x%x", ret);
3007 int camera_stop_face_detection(camera_h camera)
3009 int ret = CAMERA_ERROR_NONE;
3010 camera_cli_s *pc = (camera_cli_s *)camera;
3011 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3013 if (!pc || !pc->cb_info) {
3014 LOGE("NULL handle");
3015 return CAMERA_ERROR_INVALID_PARAMETER;
3020 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3022 LOGD("ret : 0x%x", ret);
3027 int camera_get_state(camera_h camera, camera_state_e *state)
3029 int ret = CAMERA_ERROR_NONE;
3030 camera_cli_s *pc = (camera_cli_s *)camera;
3031 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3033 if (!pc || !pc->cb_info || !state) {
3034 LOGE("NULL pointer %p %p", pc, state);
3035 return CAMERA_ERROR_INVALID_PARAMETER;
3040 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3042 if (ret == CAMERA_ERROR_NONE)
3043 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3045 LOGD("ret : 0x%x", ret);
3050 int camera_start_focusing(camera_h camera, bool continuous)
3052 int ret = CAMERA_ERROR_NONE;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3055 camera_msg_param param;
3056 int is_continuous = (int)continuous;
3058 if (!pc || !pc->cb_info) {
3059 LOGE("NULL handle");
3060 return CAMERA_ERROR_INVALID_PARAMETER;
3065 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3067 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3069 LOGD("ret : 0x%x", ret);
3074 int camera_cancel_focusing(camera_h camera)
3076 int ret = CAMERA_ERROR_NONE;
3077 camera_cli_s *pc = (camera_cli_s *)camera;
3078 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3080 if (!pc || !pc->cb_info) {
3081 LOGE("NULL handle");
3082 return CAMERA_ERROR_INVALID_PARAMETER;
3085 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3087 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3089 LOGD("ret : 0x%x", ret);
3094 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3096 int ret = CAMERA_ERROR_NONE;
3097 void *set_display_handle = NULL;
3098 Evas_Object *obj = NULL;
3099 const char *object_type = NULL;
3100 camera_cli_s *pc = (camera_cli_s *)camera;
3101 camera_cb_info_s *cb_info = NULL;
3102 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3103 camera_state_e current_state = CAMERA_STATE_NONE;
3104 camera_msg_param param;
3108 if (!pc || !pc->cb_info) {
3109 LOGE("NULL handle");
3110 return CAMERA_ERROR_INVALID_PARAMETER;
3113 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3114 LOGE("invalid type %d", type);
3115 return CAMERA_ERROR_INVALID_PARAMETER;
3118 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3119 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3120 return CAMERA_ERROR_INVALID_PARAMETER;
3123 cb_info = (camera_cb_info_s *)pc->cb_info;
3125 ret = camera_get_state(camera, ¤t_state);
3126 if (ret != CAMERA_ERROR_NONE) {
3127 LOGE("failed to get current state 0x%x", ret);
3131 if (current_state != CAMERA_STATE_CREATED) {
3132 LOGE("INVALID_STATE : current %d", current_state);
3133 return CAMERA_ERROR_INVALID_STATE;
3136 LOGD("Enter - display : %p", display);
3138 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3139 set_display_handle = 0;
3140 LOGD("display type NONE");
3142 obj = (Evas_Object *)display;
3143 object_type = evas_object_type_get(obj);
3145 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3146 /* get wayland parent id */
3147 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3148 LOGE("failed to get wayland info");
3149 return CAMERA_ERROR_INVALID_OPERATION;
3152 set_display_handle = (void *)&pc->wl_info;
3153 LOGD("display type OVERLAY : handle %p", set_display_handle);
3154 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3155 /* evas object surface */
3156 set_display_handle = (void *)display;
3157 LOGD("display type EVAS : handle %p", set_display_handle);
3159 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3160 g_mutex_lock(&cb_info->evas_mutex);
3162 if (cb_info->evas_info) {
3163 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3164 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3165 if (ret != MM_ERROR_NONE) {
3166 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3167 g_mutex_unlock(&cb_info->evas_mutex);
3168 return CAMERA_ERROR_INVALID_OPERATION;
3172 /* create evas renderer */
3173 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3174 if (ret == MM_ERROR_NONE) {
3175 camera_flip_e flip = CAMERA_FLIP_NONE;
3176 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3177 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3184 camera_get_display_flip(camera, &flip);
3185 camera_get_display_mode(camera, &mode);
3186 camera_get_display_rotation(camera, &rotation);
3187 camera_is_display_visible(camera, &visible);
3188 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3190 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3191 flip, mode, rotation, visible, x, y, width, height);
3193 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3194 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3195 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3196 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3198 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3199 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3202 g_mutex_unlock(&cb_info->evas_mutex);
3204 if (ret != MM_ERROR_NONE) {
3205 LOGE("mm_evas_renderer error 0x%x", ret);
3206 return CAMERA_ERROR_INVALID_OPERATION;
3208 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3209 LOGE("EVAS surface is not supported");
3210 return CAMERA_ERROR_NOT_SUPPORTED;
3211 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3213 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3214 return CAMERA_ERROR_INVALID_PARAMETER;
3217 LOGE("failed to get evas object type from %p", obj);
3218 return CAMERA_ERROR_INVALID_PARAMETER;
3222 pc->display_handle = (intptr_t)set_display_handle;
3224 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3227 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3228 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3230 msg = muse_core_msg_json_factory_new(api,
3231 MUSE_TYPE_INT, "type", type,
3232 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3235 LOGE("msg creation failed: api %d", api);
3236 return CAMERA_ERROR_OUT_OF_MEMORY;
3239 if (pc->cb_info->is_server_connected) {
3240 __camera_update_api_waiting(pc->cb_info, api, 1);
3242 g_mutex_lock(&pc->cb_info->fd_lock);
3243 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3244 g_mutex_unlock(&pc->cb_info->fd_lock);
3248 LOGE("message send failed");
3249 ret = CAMERA_ERROR_INVALID_OPERATION;
3251 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3254 __camera_update_api_waiting(pc->cb_info, api, -1);
3256 muse_core_msg_json_factory_free(msg);
3258 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3259 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3260 pc->wl_info.window_width, pc->wl_info.window_height);
3262 CAMERA_MSG_PARAM_SET(param, INT, type);
3264 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3267 if (ret != CAMERA_ERROR_NONE)
3268 LOGE("set display error 0x%x", ret);
3269 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3270 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3276 int camera_set_preview_resolution(camera_h camera, int width, int height)
3278 int ret = CAMERA_ERROR_NONE;
3279 camera_state_e current_state = CAMERA_STATE_NONE;
3280 camera_cli_s *pc = (camera_cli_s *)camera;
3281 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3282 camera_msg_param param;
3285 if (!pc || !pc->cb_info) {
3286 LOGE("NULL handle");
3287 return CAMERA_ERROR_INVALID_PARAMETER;
3290 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3291 ret = camera_get_state(camera, ¤t_state);
3292 if (ret != CAMERA_ERROR_NONE) {
3293 LOGE("failed to get current state 0x%x", ret);
3297 if (current_state == CAMERA_STATE_PREVIEW) {
3298 ret = _camera_stop_evas_rendering(camera, true);
3299 if (ret != CAMERA_ERROR_NONE)
3304 value = (width << 16) | height;
3305 CAMERA_MSG_PARAM_SET(param, INT, value);
3307 LOGD("%dx%d -> 0x%x", width, height, value);
3309 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3311 LOGD("ret : 0x%x", ret);
3313 if (current_state == CAMERA_STATE_PREVIEW) {
3314 LOGW("restart evas rendering");
3315 _camera_start_evas_rendering(camera);
3322 int camera_set_capture_resolution(camera_h camera, int width, int height)
3324 int ret = CAMERA_ERROR_NONE;
3325 camera_cli_s *pc = (camera_cli_s *)camera;
3326 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3327 camera_msg_param param;
3330 if (!pc || !pc->cb_info) {
3331 LOGE("NULL handle");
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3337 value = (width << 16) | height;
3338 CAMERA_MSG_PARAM_SET(param, INT, value);
3340 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3342 LOGD("ret : 0x%x", ret);
3348 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3350 int ret = CAMERA_ERROR_NONE;
3351 int set_format = (int)format;
3352 camera_cli_s *pc = (camera_cli_s *)camera;
3353 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3354 camera_msg_param param;
3356 if (!pc || !pc->cb_info) {
3357 LOGE("NULL handle");
3358 return CAMERA_ERROR_INVALID_PARAMETER;
3361 LOGD("Enter - format %d", set_format);
3363 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3365 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3367 LOGD("ret : 0x%x", ret);
3373 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3375 int ret = CAMERA_ERROR_NONE;
3376 int set_format = (int)format;
3377 camera_msg_param param;
3378 camera_cli_s *pc = (camera_cli_s *)camera;
3379 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3381 if (!pc || !pc->cb_info) {
3382 LOGE("NULL handle");
3383 return CAMERA_ERROR_INVALID_PARAMETER;
3386 LOGD("Enter - capture_format %d", set_format);
3388 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3390 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3392 LOGD("ret : 0x%x", ret);
3398 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3400 int ret = CAMERA_ERROR_NONE;
3401 camera_cli_s *pc = (camera_cli_s *)camera;
3402 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3404 if (!pc || !pc->cb_info || !width || !height) {
3405 LOGE("NULL pointer %p %p %p", pc, width, height);
3406 return CAMERA_ERROR_INVALID_PARAMETER;
3411 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3413 if (ret == CAMERA_ERROR_NONE) {
3414 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3415 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3418 LOGD("ret : 0x%x", ret);
3424 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3426 int ret = CAMERA_ERROR_NONE;
3427 int set_rotation = (int)rotation;
3428 camera_cli_s *pc = (camera_cli_s *)camera;
3429 camera_msg_param param;
3431 if (!pc || !pc->cb_info) {
3432 LOGE("NULL handle");
3433 return CAMERA_ERROR_INVALID_PARAMETER;
3436 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3437 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3438 g_mutex_lock(&pc->cb_info->evas_mutex);
3440 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3442 g_mutex_unlock(&pc->cb_info->evas_mutex);
3444 if (ret != MM_ERROR_NONE) {
3445 LOGE("failed to set rotation for evas surface 0x%x", ret);
3446 return CAMERA_ERROR_INVALID_OPERATION;
3449 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3451 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3453 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3459 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3461 int ret = CAMERA_ERROR_NONE;
3462 camera_cli_s *pc = (camera_cli_s *)camera;
3464 if (!pc || !pc->cb_info || !rotation) {
3465 LOGE("NULL pointer %p %p", pc, rotation);
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3469 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3471 if (ret == CAMERA_ERROR_NONE)
3472 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3478 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3480 int ret = CAMERA_ERROR_NONE;
3481 int set_flip = (int)flip;
3482 camera_cli_s *pc = (camera_cli_s *)camera;
3483 camera_msg_param param;
3485 if (!pc || !pc->cb_info) {
3486 LOGE("NULL handle");
3487 return CAMERA_ERROR_INVALID_PARAMETER;
3490 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3491 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3492 g_mutex_lock(&pc->cb_info->evas_mutex);
3494 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3496 g_mutex_unlock(&pc->cb_info->evas_mutex);
3498 if (ret != MM_ERROR_NONE) {
3499 LOGE("failed to set flip for evas surface 0x%x", ret);
3500 return CAMERA_ERROR_INVALID_OPERATION;
3503 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3505 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3507 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3513 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3515 int ret = CAMERA_ERROR_NONE;
3516 camera_cli_s *pc = (camera_cli_s *)camera;
3518 if (!pc || !pc->cb_info || !flip) {
3519 LOGE("NULL pointer %p %p", pc, flip);
3520 return CAMERA_ERROR_INVALID_PARAMETER;
3523 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3525 if (ret == CAMERA_ERROR_NONE)
3526 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3532 int camera_set_display_visible(camera_h camera, bool visible)
3534 int ret = CAMERA_ERROR_NONE;
3535 int set_visible = (int)visible;
3536 camera_cli_s *pc = (camera_cli_s *)camera;
3537 camera_msg_param param;
3539 if (!pc || !pc->cb_info) {
3540 LOGE("NULL handle");
3541 return CAMERA_ERROR_INVALID_PARAMETER;
3544 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3545 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3546 g_mutex_lock(&pc->cb_info->evas_mutex);
3548 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3550 g_mutex_unlock(&pc->cb_info->evas_mutex);
3552 if (ret != MM_ERROR_NONE) {
3553 LOGE("failed to set visible for evas surface 0x%x", ret);
3554 return CAMERA_ERROR_INVALID_OPERATION;
3557 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3559 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3561 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3567 int camera_is_display_visible(camera_h camera, bool *visible)
3569 int ret = CAMERA_ERROR_NONE;
3570 camera_cli_s *pc = (camera_cli_s *)camera;
3572 if (!pc || !pc->cb_info || !visible) {
3573 LOGE("NULL pointer %p %p", pc, visible);
3574 return CAMERA_ERROR_INVALID_PARAMETER;
3577 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3579 if (ret == CAMERA_ERROR_NONE)
3580 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3586 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3588 int ret = CAMERA_ERROR_NONE;
3589 int set_mode = (int)mode;
3590 camera_cli_s *pc = (camera_cli_s *)camera;
3591 camera_msg_param param;
3593 if (!pc || !pc->cb_info) {
3594 LOGE("NULL handle");
3595 return CAMERA_ERROR_INVALID_PARAMETER;
3598 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3599 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3600 g_mutex_lock(&pc->cb_info->evas_mutex);
3602 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3604 g_mutex_unlock(&pc->cb_info->evas_mutex);
3606 if (ret != MM_ERROR_NONE) {
3607 LOGE("failed to set geometry for evas surface 0x%x", ret);
3608 return CAMERA_ERROR_INVALID_OPERATION;
3611 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3613 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3615 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3621 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3623 int ret = CAMERA_ERROR_NONE;
3624 camera_cli_s *pc = (camera_cli_s *)camera;
3626 if (!pc || !pc->cb_info || !mode) {
3627 LOGE("NULL pointer %p %p", pc, mode);
3628 return CAMERA_ERROR_INVALID_PARAMETER;
3631 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3633 if (ret == CAMERA_ERROR_NONE)
3634 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3640 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3642 int ret = CAMERA_ERROR_NONE;
3643 int set_hint = (int)hint;
3644 camera_cli_s *pc = (camera_cli_s *)camera;
3645 camera_msg_param param;
3647 if (!pc || !pc->cb_info) {
3648 LOGE("NULL handle");
3649 return CAMERA_ERROR_INVALID_PARAMETER;
3652 LOGD("Enter - hint %d", set_hint);
3654 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3656 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3662 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3664 int ret = CAMERA_ERROR_NONE;
3665 camera_cli_s *pc = (camera_cli_s *)camera;
3666 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3668 if (!pc || !pc->cb_info || !hint) {
3669 LOGE("NULL pointer %p %p", pc, hint);
3670 return CAMERA_ERROR_INVALID_PARAMETER;
3673 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3675 if (ret == CAMERA_ERROR_NONE) {
3676 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3677 LOGD("display reuse hint %d", *hint);
3684 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3690 if (!pc || !pc->cb_info || !width || !height) {
3691 LOGE("NULL pointer %p %p %p", pc, width, height);
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE) {
3700 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3701 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3704 LOGD("ret : 0x%x", ret);
3710 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3712 int ret = CAMERA_ERROR_NONE;
3713 camera_cli_s *pc = (camera_cli_s *)camera;
3714 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3716 if (!pc || !pc->cb_info || !format) {
3717 LOGE("NULL pointer %p %p", pc, format);
3718 return CAMERA_ERROR_INVALID_PARAMETER;
3723 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3725 if (ret == CAMERA_ERROR_NONE)
3726 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3728 LOGD("ret : 0x%x", ret);
3734 int camera_get_preview_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_PREVIEW_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_PREVIEW_FORMAT];
3752 LOGD("ret : 0x%x", ret);
3758 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
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_FACING_DIRECTION;
3764 if (!pc || !pc->cb_info || !facing_direction) {
3765 LOGE("NULL pointer %p %p", pc, facing_direction);
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 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3776 LOGD("ret : 0x%x", ret);
3782 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3784 int ret = CAMERA_ERROR_NONE;
3785 camera_cli_s *pc = (camera_cli_s *)camera;
3786 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3788 if (!pc || !pc->cb_info || !callback) {
3789 LOGE("NULL pointer %p %p", pc, callback);
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 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3800 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3801 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3803 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3805 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3808 LOGD("ret : 0x%x", ret);
3814 int camera_unset_preview_cb(camera_h camera)
3816 int ret = CAMERA_ERROR_NONE;
3817 camera_cli_s *pc = (camera_cli_s *)camera;
3818 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3820 if (!pc || !pc->cb_info) {
3821 LOGE("NULL handle");
3822 return CAMERA_ERROR_INVALID_PARAMETER;
3827 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3829 if (ret == CAMERA_ERROR_NONE) {
3830 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3832 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3833 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3835 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3837 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3840 LOGD("ret : 0x%x", ret);
3846 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3848 int ret = CAMERA_ERROR_NONE;
3849 camera_cli_s *pc = (camera_cli_s *)camera;
3850 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3852 if (!pc || !pc->cb_info) {
3853 LOGE("NULL handle");
3854 return CAMERA_ERROR_INVALID_PARAMETER;
3857 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3858 LOGE("NOT SUPPORTED");
3859 return CAMERA_ERROR_NOT_SUPPORTED;
3862 if (callback == NULL) {
3863 LOGE("NULL callback");
3864 return CAMERA_ERROR_INVALID_PARAMETER;
3869 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3871 if (ret == CAMERA_ERROR_NONE) {
3872 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3873 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3876 LOGD("ret : 0x%x", ret);
3882 int camera_unset_media_packet_preview_cb(camera_h camera)
3884 int ret = CAMERA_ERROR_NONE;
3885 camera_cli_s *pc = (camera_cli_s *)camera;
3886 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3888 if (!pc || !pc->cb_info) {
3889 LOGE("NULL handle");
3890 return CAMERA_ERROR_INVALID_PARAMETER;
3895 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3897 if (ret == CAMERA_ERROR_NONE) {
3898 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3899 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3902 LOGD("ret : 0x%x", ret);
3908 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3910 int ret = CAMERA_ERROR_NONE;
3911 camera_cli_s *pc = (camera_cli_s *)camera;
3912 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3914 if (!pc || !pc->cb_info || !callback) {
3915 LOGE("NULL pointer %p %p", pc, callback);
3916 return CAMERA_ERROR_INVALID_PARAMETER;
3921 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3923 if (ret == CAMERA_ERROR_NONE) {
3924 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3925 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3928 LOGD("ret : 0x%x", ret);
3934 int camera_unset_state_changed_cb(camera_h camera)
3936 int ret = CAMERA_ERROR_NONE;
3937 camera_cli_s *pc = (camera_cli_s *)camera;
3938 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3940 if (!pc || !pc->cb_info) {
3941 LOGE("NULL handle");
3942 return CAMERA_ERROR_INVALID_PARAMETER;
3947 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3949 if (ret == CAMERA_ERROR_NONE) {
3950 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3951 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3954 LOGD("ret : 0x%x", ret);
3960 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3962 int ret = CAMERA_ERROR_NONE;
3963 camera_cli_s *pc = (camera_cli_s *)camera;
3964 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3966 if (!pc || !pc->cb_info || !callback) {
3967 LOGE("NULL pointer %p %p", pc, callback);
3968 return CAMERA_ERROR_INVALID_PARAMETER;
3973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3975 if (ret == CAMERA_ERROR_NONE) {
3976 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3977 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3980 LOGD("ret : 0x%x", ret);
3986 int camera_unset_interrupted_cb(camera_h camera)
3988 int ret = CAMERA_ERROR_NONE;
3989 camera_cli_s *pc = (camera_cli_s *)camera;
3990 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3992 if (!pc || !pc->cb_info) {
3993 LOGE("NULL handle");
3994 return CAMERA_ERROR_INVALID_PARAMETER;
3999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4001 if (ret == CAMERA_ERROR_NONE) {
4002 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4003 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4006 LOGD("ret : 0x%x", ret);
4012 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4014 int ret = CAMERA_ERROR_NONE;
4015 camera_cli_s *pc = (camera_cli_s *)camera;
4016 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4018 if (!pc || !pc->cb_info || !callback) {
4019 LOGE("NULL pointer %p %p", pc, callback);
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4027 if (ret == CAMERA_ERROR_NONE) {
4028 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4029 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4032 LOGD("ret : 0x%x", ret);
4038 int camera_unset_interrupt_started_cb(camera_h camera)
4040 int ret = CAMERA_ERROR_NONE;
4041 camera_cli_s *pc = (camera_cli_s *)camera;
4042 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4044 if (!pc || !pc->cb_info) {
4045 LOGE("NULL handle");
4046 return CAMERA_ERROR_INVALID_PARAMETER;
4051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 if (ret == CAMERA_ERROR_NONE) {
4054 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4055 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4058 LOGD("ret : 0x%x", ret);
4064 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4066 int ret = CAMERA_ERROR_NONE;
4067 camera_cli_s *pc = (camera_cli_s *)camera;
4068 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4070 if (!pc || !pc->cb_info || !callback) {
4071 LOGE("NULL pointer %p %p", pc, callback);
4072 return CAMERA_ERROR_INVALID_PARAMETER;
4077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4079 if (ret == CAMERA_ERROR_NONE) {
4080 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4081 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4084 LOGD("ret : 0x%x", ret);
4090 int camera_unset_focus_changed_cb(camera_h camera)
4092 int ret = CAMERA_ERROR_NONE;
4093 camera_cli_s *pc = (camera_cli_s *)camera;
4094 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4096 if (!pc || !pc->cb_info) {
4097 LOGE("NULL handle");
4098 return CAMERA_ERROR_INVALID_PARAMETER;
4103 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4105 if (ret == CAMERA_ERROR_NONE) {
4106 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4107 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4110 LOGD("ret : 0x%x", ret);
4116 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4118 int ret = CAMERA_ERROR_NONE;
4119 camera_cli_s *pc = (camera_cli_s *)camera;
4120 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4122 if (!pc || !pc->cb_info || !callback) {
4123 LOGE("NULL pointer %p %p", pc, callback);
4124 return CAMERA_ERROR_INVALID_PARAMETER;
4129 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4131 if (ret == CAMERA_ERROR_NONE) {
4132 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4133 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4136 LOGD("ret : 0x%x", ret);
4142 int camera_unset_error_cb(camera_h camera)
4144 int ret = CAMERA_ERROR_NONE;
4145 camera_cli_s *pc = (camera_cli_s *)camera;
4146 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4148 if (!pc || !pc->cb_info) {
4149 LOGE("NULL handle");
4150 return CAMERA_ERROR_INVALID_PARAMETER;
4155 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4157 if (ret == CAMERA_ERROR_NONE) {
4158 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4159 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4162 LOGD("ret : 0x%x", ret);
4168 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4170 int ret = CAMERA_ERROR_NONE;
4171 camera_cli_s *pc = (camera_cli_s *)camera;
4172 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4174 if (!pc || !pc->cb_info || !foreach_cb) {
4175 LOGE("NULL pointer %p %p", pc, foreach_cb);
4176 return CAMERA_ERROR_INVALID_PARAMETER;
4181 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4182 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4184 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4186 LOGD("ret : 0x%x", ret);
4192 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_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_CAPTURE_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_CAPTURE_RESOLUTION] = foreach_cb;
4206 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_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_format(camera_h camera, camera_supported_capture_format_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_FORMAT;
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_FORMAT] = foreach_cb;
4230 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = 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_preview_format(camera_h camera, camera_supported_preview_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_PREVIEW_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_PREVIEW_FORMAT] = foreach_cb;
4254 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4256 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4258 LOGD("ret : 0x%x", ret);
4264 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4266 int ret = CAMERA_ERROR_NONE;
4267 camera_cli_s *pc = (camera_cli_s *)camera;
4268 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4270 if (!pc || !pc->cb_info || !width || !height) {
4271 LOGE("NULL pointer %p %p %p", pc, width, height);
4272 return CAMERA_ERROR_INVALID_PARAMETER;
4276 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4278 if (ret == CAMERA_ERROR_NONE) {
4279 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4280 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4283 LOGD("ret : 0x%x", ret);
4289 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4291 int ret = CAMERA_ERROR_NONE;
4292 camera_cli_s *pc = (camera_cli_s *)camera;
4293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4295 if (!pc || !pc->cb_info || !angle) {
4296 LOGE("NULL pointer %p %p", pc, angle);
4297 return CAMERA_ERROR_INVALID_PARAMETER;
4302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4304 if (ret == CAMERA_ERROR_NONE)
4305 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4307 LOGD("ret : 0x%x", ret);
4313 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
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_SET_THEATER_MODE;
4318 camera_msg_param param;
4319 int set_mode = (int)mode;
4321 if (!pc || !pc->cb_info) {
4322 LOGE("NULL handle");
4323 return CAMERA_ERROR_INVALID_PARAMETER;
4328 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4330 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4332 LOGD("ret : 0x%x", ret);
4338 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4344 if (!pc || !pc->cb_info || !mode) {
4345 LOGE("NULL pointer %p %p", pc, mode);
4346 return CAMERA_ERROR_INVALID_PARAMETER;
4351 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4353 if (ret == CAMERA_ERROR_NONE)
4354 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4356 LOGD("ret : 0x%x", ret);
4362 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_THEATER_MODE;
4368 if (!pc || !pc->cb_info || !foreach_cb) {
4369 LOGE("NULL pointer %p %p", pc, foreach_cb);
4370 return CAMERA_ERROR_INVALID_PARAMETER;
4375 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4376 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4380 LOGD("Finish, return :%x", ret);
4386 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
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_SET_PREVIEW_FPS;
4391 camera_msg_param param;
4392 int set_fps = (int)fps;
4394 if (!pc || !pc->cb_info) {
4395 LOGE("NULL handle");
4396 return CAMERA_ERROR_INVALID_PARAMETER;
4401 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4403 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4405 LOGD("ret : 0x%x", ret);
4411 int camera_attr_set_image_quality(camera_h camera, int quality)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4416 camera_msg_param param;
4418 if (!pc || !pc->cb_info) {
4419 LOGE("NULL handle");
4420 return CAMERA_ERROR_INVALID_PARAMETER;
4425 CAMERA_MSG_PARAM_SET(param, INT, quality);
4427 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4429 LOGD("ret : 0x%x", ret);
4435 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
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_GET_PREVIEW_FPS;
4441 if (!pc || !pc->cb_info || !fps) {
4442 LOGE("NULL pointer %p %p", pc, fps);
4443 return CAMERA_ERROR_INVALID_PARAMETER;
4448 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4450 if (ret == CAMERA_ERROR_NONE)
4451 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4453 LOGD("ret : 0x%x", ret);
4459 int camera_attr_get_image_quality(camera_h camera, int *quality)
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_IMAGE_QUALITY;
4465 if (!pc || !pc->cb_info || !quality) {
4466 LOGE("NULL pointer %p %p", pc, quality);
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 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4477 LOGD("ret : 0x%x", ret);
4483 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
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_ENCODED_PREVIEW_BITRATE;
4489 if (!pc || !pc->cb_info || !bitrate) {
4490 LOGE("NULL pointer %p %p", pc, bitrate);
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 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4501 LOGD("ret : 0x%x", ret);
4507 int camera_attr_set_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_SET_ENCODED_PREVIEW_BITRATE;
4512 camera_msg_param param;
4513 int set_bitrate = bitrate;
4515 if (!pc || !pc->cb_info) {
4516 LOGE("NULL handle");
4517 return CAMERA_ERROR_INVALID_PARAMETER;
4522 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4524 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4526 LOGD("ret : 0x%x", ret);
4532 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4534 int ret = CAMERA_ERROR_NONE;
4535 camera_cli_s *pc = (camera_cli_s *)camera;
4536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4538 if (!pc || !pc->cb_info || !interval) {
4539 LOGE("NULL pointer %p %p", pc, interval);
4540 return CAMERA_ERROR_INVALID_PARAMETER;
4545 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4547 if (ret == CAMERA_ERROR_NONE)
4548 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4550 LOGD("ret : 0x%x", ret);
4556 int camera_attr_set_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_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4561 camera_msg_param param;
4562 int set_gop_interval = interval;
4564 if (!pc || !pc->cb_info) {
4565 LOGE("NULL handle");
4566 return CAMERA_ERROR_INVALID_PARAMETER;
4571 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4573 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4575 LOGD("ret : 0x%x", ret);
4581 int camera_attr_set_zoom(camera_h camera, int zoom)
4583 int ret = CAMERA_ERROR_NONE;
4584 camera_cli_s *pc = (camera_cli_s *)camera;
4585 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4586 camera_msg_param param;
4588 if (!pc || !pc->cb_info) {
4589 LOGE("NULL handle");
4590 return CAMERA_ERROR_INVALID_PARAMETER;
4593 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4595 CAMERA_MSG_PARAM_SET(param, INT, zoom);
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_af_mode(camera_h camera, camera_attr_af_mode_e mode)
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_AF_MODE;
4610 camera_msg_param param;
4611 int set_mode = (int)mode;
4613 if (!pc || !pc->cb_info) {
4614 LOGE("NULL handle");
4615 return CAMERA_ERROR_INVALID_PARAMETER;
4618 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4620 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4622 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4628 int camera_attr_set_af_area(camera_h camera, int x, int y)
4630 int ret = CAMERA_ERROR_NONE;
4631 camera_cli_s *pc = (camera_cli_s *)camera;
4632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4633 camera_msg_param param;
4636 if (!pc || !pc->cb_info) {
4637 LOGE("NULL handle");
4638 return CAMERA_ERROR_INVALID_PARAMETER;
4641 LOGD("Enter - %d,%d", x, y);
4643 value = (x << 16) | y;
4644 CAMERA_MSG_PARAM_SET(param, INT, value);
4646 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4648 LOGD("ret : 0x%x", ret);
4654 int camera_attr_clear_af_area(camera_h camera)
4656 int ret = CAMERA_ERROR_NONE;
4657 camera_cli_s *pc = (camera_cli_s *)camera;
4658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4660 if (!pc || !pc->cb_info) {
4661 LOGE("NULL handle");
4662 return CAMERA_ERROR_INVALID_PARAMETER;
4667 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4669 LOGD("ret : 0x%x", ret);
4675 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4677 int ret = CAMERA_ERROR_NONE;
4678 camera_cli_s *pc = (camera_cli_s *)camera;
4679 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4680 camera_msg_param param;
4681 int set_mode = (int)mode;
4683 if (!pc || !pc->cb_info) {
4684 LOGE("NULL handle");
4685 return CAMERA_ERROR_INVALID_PARAMETER;
4690 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4692 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4694 LOGD("ret : 0x%x", ret);
4700 int camera_attr_set_exposure(camera_h camera, int value)
4702 int ret = CAMERA_ERROR_NONE;
4703 camera_cli_s *pc = (camera_cli_s *)camera;
4704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4705 camera_msg_param param;
4707 if (!pc || !pc->cb_info) {
4708 LOGE("NULL handle");
4709 return CAMERA_ERROR_INVALID_PARAMETER;
4714 CAMERA_MSG_PARAM_SET(param, INT, value);
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_iso(camera_h camera, camera_attr_iso_e iso)
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_ISO;
4729 camera_msg_param param;
4730 int set_iso = (int)iso;
4732 if (!pc || !pc->cb_info) {
4733 LOGE("NULL handle");
4734 return CAMERA_ERROR_INVALID_PARAMETER;
4739 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4741 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4743 LOGD("ret : 0x%x", ret);
4749 int camera_attr_set_brightness(camera_h camera, int level)
4751 int ret = CAMERA_ERROR_NONE;
4752 camera_cli_s *pc = (camera_cli_s *)camera;
4753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4754 camera_msg_param param;
4756 if (!pc || !pc->cb_info) {
4757 LOGE("NULL handle");
4758 return CAMERA_ERROR_INVALID_PARAMETER;
4763 CAMERA_MSG_PARAM_SET(param, INT, level);
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_contrast(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_CONTRAST;
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_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
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_WHITEBALANCE;
4802 camera_msg_param param;
4803 int set_whitebalance = (int)wb;
4805 if (!pc || !pc->cb_info) {
4806 LOGE("NULL handle");
4807 return CAMERA_ERROR_INVALID_PARAMETER;
4812 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4816 LOGD("ret : 0x%x", ret);
4822 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4824 int ret = CAMERA_ERROR_NONE;
4825 camera_cli_s *pc = (camera_cli_s *)camera;
4826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4827 camera_msg_param param;
4828 int set_effect = (int)effect;
4830 if (!pc || !pc->cb_info) {
4831 LOGE("NULL handle");
4832 return CAMERA_ERROR_INVALID_PARAMETER;
4837 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4841 LOGD("ret : 0x%x", ret);
4847 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4849 int ret = CAMERA_ERROR_NONE;
4850 camera_cli_s *pc = (camera_cli_s *)camera;
4851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4852 camera_msg_param param;
4853 int set_mode = (int)mode;
4855 if (!pc || !pc->cb_info) {
4856 LOGE("NULL handle");
4857 return CAMERA_ERROR_INVALID_PARAMETER;
4862 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4864 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4866 LOGD("ret : 0x%x", ret);
4872 int camera_attr_enable_tag(camera_h camera, bool enable)
4874 int ret = CAMERA_ERROR_NONE;
4875 camera_cli_s *pc = (camera_cli_s *)camera;
4876 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4877 camera_msg_param param;
4878 int set_enable = (int)enable;
4880 if (!pc || !pc->cb_info) {
4881 LOGE("NULL handle");
4882 return CAMERA_ERROR_INVALID_PARAMETER;
4887 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4891 LOGD("ret : 0x%x", ret);
4897 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4899 int ret = CAMERA_ERROR_NONE;
4900 camera_cli_s *pc = (camera_cli_s *)camera;
4901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4902 camera_msg_param param;
4904 if (!pc || !pc->cb_info || !description) {
4905 LOGE("NULL pointer %p %p", pc, description);
4906 return CAMERA_ERROR_INVALID_PARAMETER;
4911 CAMERA_MSG_PARAM_SET(param, STRING, description);
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_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
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_ORIENTATION;
4926 camera_msg_param param;
4927 int set_orientation = (int)orientation;
4929 if (!pc || !pc->cb_info) {
4930 LOGE("NULL handle");
4931 return CAMERA_ERROR_INVALID_PARAMETER;
4936 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4938 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4940 LOGD("ret : 0x%x", ret);
4946 int camera_attr_set_tag_software(camera_h camera, const char *software)
4948 int ret = CAMERA_ERROR_NONE;
4949 camera_cli_s *pc = (camera_cli_s *)camera;
4950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4951 camera_msg_param param;
4953 if (!pc || !pc->cb_info || !software) {
4954 LOGE("NULL pointer %p %p", pc, software);
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4958 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4960 CAMERA_MSG_PARAM_SET(param, STRING, software);
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_geotag(camera_h camera, double latitude, double longitude, double altitude)
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_GEOTAG;
4975 double set_geotag[3] = {latitude, longitude, altitude};
4980 if (!pc || !pc->cb_info) {
4981 LOGE("NULL handle");
4982 return CAMERA_ERROR_INVALID_PARAMETER;
4987 length = sizeof(set_geotag) / sizeof(int) + \
4988 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4990 msg = muse_core_msg_json_factory_new(api,
4991 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4994 LOGE("msg creation failed: api %d", api);
4995 return CAMERA_ERROR_OUT_OF_MEMORY;
4998 if (pc->cb_info->is_server_connected) {
4999 __camera_update_api_waiting(pc->cb_info, api, 1);
5001 g_mutex_lock(&pc->cb_info->fd_lock);
5002 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
5003 g_mutex_unlock(&pc->cb_info->fd_lock);
5007 LOGE("message send failed");
5008 ret = CAMERA_ERROR_INVALID_OPERATION;
5010 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5013 __camera_update_api_waiting(pc->cb_info, api, -1);
5015 muse_core_msg_json_factory_free(msg);
5017 LOGD("ret : 0x%x", ret);
5023 int camera_attr_remove_geotag(camera_h camera)
5025 int ret = CAMERA_ERROR_NONE;
5026 camera_cli_s *pc = (camera_cli_s *)camera;
5027 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5029 if (!pc || !pc->cb_info) {
5030 LOGE("NULL handle");
5031 return CAMERA_ERROR_INVALID_PARAMETER;
5036 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5038 LOGD("ret : 0x%x", ret);
5044 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5046 int ret = CAMERA_ERROR_NONE;
5047 camera_cli_s *pc = (camera_cli_s *)camera;
5048 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5049 camera_msg_param param;
5050 int set_mode = (int)mode;
5052 if (!pc || !pc->cb_info) {
5053 LOGE("NULL handle");
5054 return CAMERA_ERROR_INVALID_PARAMETER;
5059 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5061 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5063 LOGD("ret : 0x%x", ret);
5069 int camera_attr_get_zoom(camera_h camera, int *zoom)
5071 int ret = CAMERA_ERROR_NONE;
5072 camera_cli_s *pc = (camera_cli_s *)camera;
5073 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5075 if (!pc || !pc->cb_info || !zoom) {
5076 LOGE("NULL pointer %p %p", pc, zoom);
5077 return CAMERA_ERROR_INVALID_PARAMETER;
5082 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5084 if (ret == CAMERA_ERROR_NONE)
5085 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5087 LOGD("ret : 0x%x", ret);
5093 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
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_RANGE;
5099 if (!pc || !pc->cb_info || !min || !max) {
5100 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5110 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5113 LOGD("ret : 0x%x", ret);
5119 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5121 int ret = CAMERA_ERROR_NONE;
5122 camera_cli_s *pc = (camera_cli_s *)camera;
5123 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5125 if (!pc || !pc->cb_info || !mode) {
5126 LOGE("NULL pointer %p %p", pc, mode);
5127 return CAMERA_ERROR_INVALID_PARAMETER;
5132 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5134 if (ret == CAMERA_ERROR_NONE)
5135 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5137 LOGD("ret : 0x%x", ret);
5143 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_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_EXPOSURE_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_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5161 LOGD("ret : 0x%x", ret);
5167 int camera_attr_get_exposure(camera_h camera, int *value)
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;
5173 if (!pc || !pc->cb_info || !value) {
5174 LOGE("NULL pointer %p %p", pc, value);
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 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5185 LOGD("ret : 0x%x", ret);
5191 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
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_RANGE;
5197 if (!pc || !pc->cb_info || !min || !max) {
5198 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5208 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5211 LOGD("ret : 0x%x", ret);
5217 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5219 int ret = CAMERA_ERROR_NONE;
5220 camera_cli_s *pc = (camera_cli_s *)camera;
5221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5223 if (!pc || !pc->cb_info || !iso) {
5224 LOGE("NULL pointer %p %p", pc, iso);
5225 return CAMERA_ERROR_INVALID_PARAMETER;
5230 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5232 if (ret == CAMERA_ERROR_NONE)
5233 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5235 LOGD("ret : 0x%x", ret);
5241 int camera_attr_get_brightness(camera_h camera, int *level)
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_BRIGHTNESS;
5247 if (!pc || !pc->cb_info || !level) {
5248 LOGE("NULL pointer %p %p", pc, level);
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 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5259 LOGD("ret : 0x%x", ret);
5265 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
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_RANGE;
5271 if (!pc || !pc->cb_info || !min || !max) {
5272 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5282 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5285 LOGD("ret : 0x%x", ret);
5291 int camera_attr_get_contrast(camera_h camera, int *level)
5293 int ret = CAMERA_ERROR_NONE;
5294 camera_cli_s *pc = (camera_cli_s *)camera;
5295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5297 if (!pc || !pc->cb_info || !level) {
5298 LOGE("NULL pointer %p %p", pc, level);
5299 return CAMERA_ERROR_INVALID_PARAMETER;
5304 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5306 if (ret == CAMERA_ERROR_NONE)
5307 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
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_RANGE;
5321 if (!pc || !pc->cb_info || !min || !max) {
5322 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5332 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5333 LOGD("min %d, max %d", *min, *max);
5336 LOGD("ret : 0x%x", ret);
5342 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5344 int ret = CAMERA_ERROR_NONE;
5345 camera_cli_s *pc = (camera_cli_s *)camera;
5346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5348 if (!pc || !pc->cb_info || !wb) {
5349 LOGE("NULL pointer %p %p", pc, wb);
5350 return CAMERA_ERROR_INVALID_PARAMETER;
5355 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5357 if (ret == CAMERA_ERROR_NONE)
5358 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5360 LOGD("ret : 0x%x", ret);
5366 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
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_EFFECT;
5372 if (!pc || !pc->cb_info || !effect) {
5373 LOGE("NULL pointer %p %p", pc, effect);
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 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5384 LOGD("ret : 0x%x", ret);
5390 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
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_SCENE_MODE;
5396 if (!pc || !pc->cb_info || !mode) {
5397 LOGE("NULL pointer %p %p", pc, mode);
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 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5408 LOGD("ret : 0x%x", ret);
5414 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
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_IS_ENABLED_TAG;
5420 if (!pc || !pc->cb_info || !enable) {
5421 LOGE("NULL pointer %p %p", pc, enable);
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 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5432 LOGD("ret : 0x%x", ret);
5438 int camera_attr_get_tag_image_description(camera_h camera, char **description)
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_GET_TAG_IMAGE_DESCRIPTION;
5444 if (!pc || !pc->cb_info || !description) {
5445 LOGE("NULL pointer %p %p", pc, description);
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 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5456 LOGD("ret : 0x%x", ret);
5462 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
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_ORIENTATION;
5468 if (!pc || !pc->cb_info || !orientation) {
5469 LOGE("NULL pointer %p %p", pc, orientation);
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 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5480 LOGD("ret : 0x%x", ret);
5486 int camera_attr_get_tag_software(camera_h camera, char **software)
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_SOFTWARE;
5492 if (!pc || !pc->cb_info || !software) {
5493 LOGE("NULL pointer %p %p", pc, software);
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 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5504 LOGD("ret : 0x%x", ret);
5510 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
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_GEOTAG;
5516 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5517 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
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 *latitude = pc->cb_info->get_geotag[0];
5527 *longitude = pc->cb_info->get_geotag[1];
5528 *altitude = pc->cb_info->get_geotag[2];
5531 LOGD("ret : 0x%x", ret);
5537 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5539 int ret = CAMERA_ERROR_NONE;
5540 camera_cli_s *pc = (camera_cli_s *)camera;
5541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5543 if (!pc || !pc->cb_info || !mode) {
5544 LOGE("NULL pointer %p %p", pc, mode);
5545 return CAMERA_ERROR_INVALID_PARAMETER;
5550 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5552 if (ret == CAMERA_ERROR_NONE)
5553 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5555 LOGD("ret : 0x%x", ret);
5561 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5563 int ret = CAMERA_ERROR_NONE;
5564 int get_flash_state = 0;
5567 LOGE("NULL pointer");
5568 return CAMERA_ERROR_INVALID_PARAMETER;
5571 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5572 (int)device, "get_flash_state", &get_flash_state);
5574 if (ret == CAMERA_ERROR_NONE) {
5575 *state = (camera_flash_state_e)get_flash_state;
5576 LOGD("flash state %d", *state);
5578 LOGE("failed 0x%x", ret);
5585 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5587 int ret = CAMERA_ERROR_NONE;
5588 camera_cli_s *pc = (camera_cli_s *)camera;
5589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5591 if (!pc || !pc->cb_info || !foreach_cb) {
5592 LOGE("NULL pointer %p %p", pc, foreach_cb);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5598 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5599 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5601 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5603 LOGD("ret : 0x%x", ret);
5609 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_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_EXPOSURE_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_EXPOSURE_MODE] = foreach_cb;
5623 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_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_iso(camera_h camera, camera_attr_supported_iso_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_ISO;
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_ISO] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = 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_whitebalance(camera_h camera, camera_attr_supported_whitebalance_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_WHITEBALANCE;
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_WHITEBALANCE] = foreach_cb;
5671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = 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_effect(camera_h camera, camera_attr_supported_effect_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_EFFECT;
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_EFFECT] = foreach_cb;
5695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = 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_scene_mode(camera_h camera, camera_attr_supported_scene_mode_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_SCENE_MODE;
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_SCENE_MODE] = foreach_cb;
5719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = 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_flash_mode(camera_h camera, camera_attr_supported_flash_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_FLASH_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_FLASH_MODE] = foreach_cb;
5743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_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_fps(camera_h camera, camera_attr_supported_fps_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_FPS;
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_FPS] = foreach_cb;
5767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5769 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5771 LOGD("Enter, handle :%x", pc->remote_handle);
5777 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)
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_BY_RESOLUTION;
5782 camera_msg_param param;
5785 if (!pc || !pc->cb_info || !foreach_cb) {
5786 LOGE("NULL pointer %p %p", pc, foreach_cb);
5787 return CAMERA_ERROR_INVALID_PARAMETER;
5792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5795 value = (width << 16) | height;
5796 CAMERA_MSG_PARAM_SET(param, INT, value);
5798 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5800 LOGD("ret : 0x%x", ret);
5806 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5808 int ret = CAMERA_ERROR_NONE;
5809 camera_cli_s *pc = (camera_cli_s *)camera;
5810 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5812 if (!pc || !pc->cb_info || !foreach_cb) {
5813 LOGE("NULL pointer %p %p", pc, foreach_cb);
5814 return CAMERA_ERROR_INVALID_PARAMETER;
5819 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5820 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5822 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5824 LOGD("ret : 0x%x", ret);
5830 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_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_ROTATION;
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_ROTATION] = foreach_cb;
5844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5846 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5848 LOGD("ret : 0x%x", ret);
5854 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
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_SET_STREAM_ROTATION;
5859 camera_msg_param param;
5860 int set_rotation = (int)rotation;
5862 if (!pc || !pc->cb_info) {
5863 LOGE("NULL handle");
5864 return CAMERA_ERROR_INVALID_PARAMETER;
5869 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5871 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5873 LOGD("ret : 0x%x", ret);
5879 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5881 int ret = CAMERA_ERROR_NONE;
5882 camera_cli_s *pc = (camera_cli_s *)camera;
5883 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5885 if (!pc || !pc->cb_info || !rotation) {
5886 LOGE("NULL pointer %p %p", pc, rotation);
5887 return CAMERA_ERROR_INVALID_PARAMETER;
5892 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5894 if (ret == CAMERA_ERROR_NONE)
5895 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5897 LOGD("ret : 0x%x", ret);
5903 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
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_SET_STREAM_FLIP;
5908 camera_msg_param param;
5909 int set_flip = (int)flip;
5911 if (!pc || !pc->cb_info) {
5912 LOGE("NULL handle");
5913 return CAMERA_ERROR_INVALID_PARAMETER;
5918 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5920 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5922 LOGD("ret : 0x%x", ret);
5928 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5930 int ret = CAMERA_ERROR_NONE;
5931 camera_cli_s *pc = (camera_cli_s *)camera;
5932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5934 if (!pc || !pc->cb_info || !flip) {
5935 LOGE("NULL pointer %p %p", pc, flip);
5936 return CAMERA_ERROR_INVALID_PARAMETER;
5941 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5943 if (ret == CAMERA_ERROR_NONE)
5944 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5946 LOGD("ret : 0x%x", ret);
5951 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5953 int ret = CAMERA_ERROR_NONE;
5954 camera_cli_s *pc = (camera_cli_s *)camera;
5955 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5956 camera_msg_param param;
5957 int set_mode = (int)mode;
5959 if (!pc || !pc->cb_info) {
5960 LOGE("NULL handle");
5961 return CAMERA_ERROR_INVALID_PARAMETER;
5966 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5968 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5970 LOGD("ret : 0x%x", ret);
5976 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5982 if (!pc || !pc->cb_info || !mode) {
5983 LOGE("NULL pointer %p %p", pc, mode);
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5991 if (ret == CAMERA_ERROR_NONE)
5992 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5994 LOGD("ret : 0x%x", ret);
6000 bool camera_attr_is_supported_hdr_capture(camera_h camera)
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_IS_SUPPORTED_HDR_CAPTURE;
6006 if (!pc || !pc->cb_info) {
6007 LOGE("NULL handle");
6008 return CAMERA_ERROR_INVALID_PARAMETER;
6013 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6016 LOGE("error is occurred 0x%x", ret);
6020 LOGD("ret : %d", ret);
6026 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6028 int ret = CAMERA_ERROR_NONE;
6029 camera_cli_s *pc = (camera_cli_s *)camera;
6030 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6032 if (!pc || !pc->cb_info) {
6033 LOGE("NULL handle");
6034 return CAMERA_ERROR_INVALID_PARAMETER;
6039 if (!camera_attr_is_supported_hdr_capture(camera)) {
6040 LOGE("HDR not supported");
6041 return CAMERA_ERROR_NOT_SUPPORTED;
6045 LOGE("NULL callback");
6046 return CAMERA_ERROR_INVALID_PARAMETER;
6049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6051 if (ret == CAMERA_ERROR_NONE) {
6052 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6053 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6056 LOGD("ret : 0x%x", ret);
6062 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6064 int ret = CAMERA_ERROR_NONE;
6065 camera_cli_s *pc = (camera_cli_s *)camera;
6066 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6068 if (!pc || !pc->cb_info) {
6069 LOGE("NULL handle");
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6077 if (ret == CAMERA_ERROR_NONE) {
6078 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6079 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6082 LOGD("ret : 0x%x", ret);
6088 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6093 camera_msg_param param;
6094 int set_enable = (int)enable;
6096 if (!pc || !pc->cb_info) {
6097 LOGE("NULL handle");
6098 return CAMERA_ERROR_INVALID_PARAMETER;
6103 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6105 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6107 LOGD("ret : 0x%x", ret);
6113 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6115 int ret = CAMERA_ERROR_NONE;
6116 camera_cli_s *pc = (camera_cli_s *)camera;
6117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6119 if (!pc || !pc->cb_info || !enabled) {
6120 LOGE("NULL pointer %p %p", pc, enabled);
6121 return CAMERA_ERROR_INVALID_PARAMETER;
6126 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6128 if (ret == CAMERA_ERROR_NONE)
6129 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6131 LOGD("ret : 0x%x", ret);
6137 bool camera_attr_is_supported_anti_shake(camera_h camera)
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_SUPPORTED_ANTI_SHAKE;
6143 if (!pc || !pc->cb_info) {
6144 LOGE("NULL handle");
6145 return CAMERA_ERROR_INVALID_PARAMETER;
6150 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6153 LOGE("error is occurred 0x%x", ret);
6157 LOGD("ret : %d", ret);
6163 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6168 camera_msg_param param;
6169 int set_enable = (int)enable;
6171 if (!pc || !pc->cb_info) {
6172 LOGE("NULL handle");
6173 return CAMERA_ERROR_INVALID_PARAMETER;
6178 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6180 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6182 LOGD("ret : 0x%x", ret);
6188 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6194 if (!pc || !pc->cb_info || !enabled) {
6195 LOGE("NULL pointer %p %p", pc, enabled);
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6203 if (ret == CAMERA_ERROR_NONE)
6204 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6206 LOGD("ret : 0x%x", ret);
6212 bool camera_attr_is_supported_video_stabilization(camera_h camera)
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_SUPPORTED_VIDEO_STABILIZATION;
6218 if (!pc || !pc->cb_info) {
6219 LOGE("NULL handle");
6220 return CAMERA_ERROR_INVALID_PARAMETER;
6225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6228 LOGE("error is occurred 0x%x", ret);
6232 LOGD("ret : %d", ret);
6238 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6240 int ret = CAMERA_ERROR_NONE;
6241 camera_cli_s *pc = (camera_cli_s *)camera;
6242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6243 camera_msg_param param;
6244 int set_enable = (int)enable;
6246 if (!pc || !pc->cb_info) {
6247 LOGE("NULL handle");
6248 return CAMERA_ERROR_INVALID_PARAMETER;
6253 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6255 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6257 LOGD("ret : 0x%x", ret);
6263 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6265 int ret = CAMERA_ERROR_NONE;
6266 camera_cli_s *pc = (camera_cli_s *)camera;
6267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6269 if (!pc || !pc->cb_info || !enabled) {
6270 LOGE("NULL pointer %p %p", pc, enabled);
6271 return CAMERA_ERROR_INVALID_PARAMETER;
6276 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6278 if (ret == CAMERA_ERROR_NONE)
6279 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6281 LOGD("ret : 0x%x", ret);
6287 bool camera_attr_is_supported_auto_contrast(camera_h camera)
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_SUPPORTED_AUTO_CONTRAST;
6293 if (!pc || !pc->cb_info) {
6294 LOGE("NULL handle");
6295 return CAMERA_ERROR_INVALID_PARAMETER;
6300 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6303 LOGE("error is occurred 0x%x", ret);
6307 LOGD("ret : %d", ret);
6313 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6315 int ret = CAMERA_ERROR_NONE;
6316 camera_cli_s *pc = (camera_cli_s *)camera;
6317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6318 camera_msg_param param;
6319 int set_disable = (int)disable;
6321 if (!pc || !pc->cb_info) {
6322 LOGE("NULL handle");
6323 return CAMERA_ERROR_INVALID_PARAMETER;
6328 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6330 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6332 LOGD("ret : 0x%x", ret);
6338 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6340 int ret = CAMERA_ERROR_NONE;
6341 camera_cli_s *pc = (camera_cli_s *)camera;
6342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6343 camera_msg_param param;
6344 int set_move_type = (int)move_type;
6347 if (!pc || !pc->cb_info) {
6348 LOGE("NULL handle");
6349 return CAMERA_ERROR_INVALID_PARAMETER;
6354 value = (set_move_type << 16) | pan_step;
6355 CAMERA_MSG_PARAM_SET(param, INT, value);
6357 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6359 LOGD("ret : 0x%x", ret);
6365 int camera_attr_get_pan(camera_h camera, int *pan_step)
6367 int ret = CAMERA_ERROR_NONE;
6368 camera_cli_s *pc = (camera_cli_s *)camera;
6369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6371 if (!pc || !pc->cb_info || !pan_step) {
6372 LOGE("NULL pointer %p %p", pc, pan_step);
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6380 if (ret == CAMERA_ERROR_NONE)
6381 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6383 LOGD("ret : 0x%x", ret);
6389 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
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_RANGE;
6395 if (!pc || !pc->cb_info || !min || !max) {
6396 LOGE("NULL pointer %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6406 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6409 LOGD("ret : 0x%x", ret);
6415 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6417 int ret = CAMERA_ERROR_NONE;
6418 camera_cli_s *pc = (camera_cli_s *)camera;
6419 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6420 camera_msg_param param;
6421 int set_move_type = (int)move_type;
6424 if (!pc || !pc->cb_info) {
6425 LOGE("NULL handle");
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 value = (set_move_type << 16) | tilt_step;
6432 CAMERA_MSG_PARAM_SET(param, INT, value);
6434 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6436 LOGD("ret : 0x%x", ret);
6442 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6444 int ret = CAMERA_ERROR_NONE;
6445 camera_cli_s *pc = (camera_cli_s *)camera;
6446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6448 if (!pc || !pc->cb_info || !tilt_step) {
6449 LOGE("NULL pointer %p %p", pc, tilt_step);
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6455 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6457 if (ret == CAMERA_ERROR_NONE)
6458 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6460 LOGD("ret : 0x%x", ret);
6466 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
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_RANGE;
6472 if (!pc || !pc->cb_info || !min || !max) {
6473 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6483 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6486 LOGD("ret : 0x%x", ret);
6492 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6494 int ret = CAMERA_ERROR_NONE;
6495 camera_cli_s *pc = (camera_cli_s *)camera;
6496 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6497 camera_msg_param param;
6498 int set_ptz_type = (int)ptz_type;
6500 if (!pc || !pc->cb_info) {
6501 LOGE("NULL handle");
6502 return CAMERA_ERROR_INVALID_PARAMETER;
6507 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6509 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6511 LOGD("ret : 0x%x", ret);
6517 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6519 int ret = CAMERA_ERROR_NONE;
6520 camera_cli_s *pc = (camera_cli_s *)camera;
6521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6523 if (!pc || !pc->cb_info || !foreach_cb) {
6524 LOGE("NULL pointer %p %p", pc, foreach_cb);
6525 return CAMERA_ERROR_INVALID_PARAMETER;
6530 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6531 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6533 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6535 LOGD("ret : 0x%x", ret);
6541 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6543 int ret = CAMERA_ERROR_NONE;
6544 camera_cli_s *pc = (camera_cli_s *)camera;
6545 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6546 int set_display_roi_area[4] = {x, y, width, height};
6551 if (!pc || !pc->cb_info) {
6552 LOGE("NULL handle");
6553 return CAMERA_ERROR_INVALID_PARAMETER;
6558 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6559 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6560 g_mutex_lock(&pc->cb_info->evas_mutex);
6562 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6564 g_mutex_unlock(&pc->cb_info->evas_mutex);
6566 if (ret != MM_ERROR_NONE) {
6567 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6568 return CAMERA_ERROR_INVALID_OPERATION;
6571 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6573 length = sizeof(set_display_roi_area) / sizeof(int) + \
6574 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6576 msg = muse_core_msg_json_factory_new(api,
6577 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6580 LOGE("msg creation failed: api %d", api);
6581 return CAMERA_ERROR_OUT_OF_MEMORY;
6584 if (pc->cb_info->is_server_connected) {
6585 __camera_update_api_waiting(pc->cb_info, api, 1);
6587 g_mutex_lock(&pc->cb_info->fd_lock);
6588 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6589 g_mutex_unlock(&pc->cb_info->fd_lock);
6593 LOGE("message send failed");
6594 ret = CAMERA_ERROR_INVALID_OPERATION;
6596 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6599 __camera_update_api_waiting(pc->cb_info, api, -1);
6601 muse_core_msg_json_factory_free(msg);
6603 LOGD("ret : 0x%x", ret);
6609 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6611 camera_cli_s *pc = (camera_cli_s *)camera;
6612 int ret = CAMERA_ERROR_NONE;
6613 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6615 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6616 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6617 return CAMERA_ERROR_INVALID_PARAMETER;
6622 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6624 if (ret == CAMERA_ERROR_NONE) {
6625 *x = pc->cb_info->get_display_roi_area[0];
6626 *y = pc->cb_info->get_display_roi_area[1];
6627 *width = pc->cb_info->get_display_roi_area[2];
6628 *height = pc->cb_info->get_display_roi_area[3];
6631 LOGD("ret : 0x%x", ret);
6637 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6639 int ret = CAMERA_ERROR_NONE;
6640 int get_device_state = 0;
6643 LOGE("NULL pointer");
6644 return CAMERA_ERROR_INVALID_PARAMETER;
6647 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6648 (int)device, "get_device_state", &get_device_state);
6650 if (ret == CAMERA_ERROR_NONE) {
6651 *state = (camera_device_state_e)get_device_state;
6652 LOGD("device state %d", *state);
6654 LOGE("failed 0x%x", ret);
6661 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6663 int ret = CAMERA_ERROR_NONE;
6664 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6665 camera_cb_info *info = NULL;
6667 if (!callback || !cb_id) {
6668 LOGE("invalid pointer %p %p", callback, cb_id);
6669 return CAMERA_ERROR_INVALID_PARAMETER;
6672 /* check camera support */
6673 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6674 if (ret != CAMERA_ERROR_NONE) {
6675 LOGE("get device state failed");
6679 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6681 info = g_new0(camera_cb_info, 1);
6683 LOGE("info failed");
6684 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6688 info->id = ++g_cam_dev_state_changed_cb_id;
6689 info->callback = (void *)callback;
6690 info->user_data = user_data;
6694 /* subscribe dbus signal for camera state change */
6695 if (!g_cam_dev_state_changed_cb_conn) {
6696 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6697 if (!g_cam_dev_state_changed_cb_conn) {
6698 LOGE("failed to get gdbus connection");
6699 ret = CAMERA_ERROR_INVALID_OPERATION;
6703 LOGD("subscribe signal %s - %s - %s",
6704 MM_CAMCORDER_DBUS_OBJECT,
6705 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6706 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6708 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6709 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6710 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6711 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6712 LOGE("failed to get gdbus connection");
6713 ret = CAMERA_ERROR_INVALID_OPERATION;
6717 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6720 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6722 LOGD("callback id %d", info->id);
6725 if (ret != CAMERA_ERROR_NONE) {
6731 if (g_cam_dev_state_changed_cb_conn) {
6732 g_object_unref(g_cam_dev_state_changed_cb_conn);
6733 g_cam_dev_state_changed_cb_conn = NULL;
6737 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6743 int camera_remove_device_state_changed_cb(int cb_id)
6745 int ret = CAMERA_ERROR_NONE;
6746 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6747 GList *tmp_list = NULL;
6748 camera_cb_info *info = NULL;
6750 /* check camera support */
6751 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6752 if (ret != CAMERA_ERROR_NONE) {
6753 LOGE("get device state failed");
6757 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6759 if (!g_cam_dev_state_changed_cb_list) {
6760 LOGE("there is no callback info");
6761 ret = CAMERA_ERROR_INVALID_OPERATION;
6765 tmp_list = g_cam_dev_state_changed_cb_list;
6768 info = tmp_list->data;
6769 tmp_list = tmp_list->next;
6776 if (info->id == cb_id) {
6777 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6782 if (!g_cam_dev_state_changed_cb_list) {
6783 /* no remained callback */
6784 if (g_cam_dev_state_changed_cb_conn) {
6785 /* unsubscribe signal */
6786 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6787 g_cam_dev_state_changed_cb_subscribe_id = 0;
6789 /* unref connection */
6790 g_object_unref(g_cam_dev_state_changed_cb_conn);
6791 g_cam_dev_state_changed_cb_conn = NULL;
6795 LOGD("id %d callback removed", cb_id);
6796 ret = CAMERA_ERROR_NONE;
6802 LOGE("id %d callback not found", cb_id);
6803 ret = CAMERA_ERROR_INVALID_PARAMETER;
6806 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);