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 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1236 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1238 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1239 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1242 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1243 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1244 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1246 if (ret == CAMERA_ERROR_NONE) {
1247 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1248 if (ret != CAMERA_ERROR_NONE) {
1249 LOGE("create pkt for evas failed");
1250 _camera_media_packet_data_release(mp_data, cb_info);
1254 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1255 LOGW("evas renderer is not supported");
1256 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1259 /* call media packet callback */
1260 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1261 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1263 if (ret == CAMERA_ERROR_NONE) {
1264 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1266 if (ret == CAMERA_ERROR_NONE) {
1267 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1268 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1270 _camera_media_packet_data_release(mp_data, cb_info);
1276 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1277 /* call evas renderer */
1279 g_mutex_lock(&cb_info->evas_mutex);
1280 if (cb_info->run_evas_render) {
1281 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1283 LOGW("evas renderer is stopped, skip this buffer...");
1284 media_packet_destroy(pkt_evas);
1287 g_mutex_unlock(&cb_info->evas_mutex);
1289 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1291 /* send message for preview callback return */
1292 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1293 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1295 if (mp_data == NULL) {
1296 /* release imported bo */
1297 for (i = 0 ; i < num_buffer_key ; i++)
1298 _camera_release_imported_bo(&buffer_bo[i]);
1300 /* unmap and unref tbm bo */
1301 _camera_release_imported_bo(&data_bo);
1302 _camera_release_imported_bo(&bo);
1305 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1307 /*LOGD("return buffer Done");*/
1311 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1315 muse_camera_msg_get(percent, recv_msg);
1317 LOGD("HDR progress - %d \%", percent);
1319 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1322 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1328 muse_camera_msg_get(policy, recv_msg);
1329 muse_camera_msg_get(previous, recv_msg);
1330 muse_camera_msg_get(current, recv_msg);
1332 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1333 policy, previous, current);
1335 if (policy == CAMERA_POLICY_SOUND)
1336 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1337 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1338 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1339 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1340 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1342 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1343 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1346 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1349 camera_detected_face_s *faces = NULL;
1351 muse_camera_msg_get(count, recv_msg);
1352 muse_camera_msg_get(tbm_key, recv_msg);
1355 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1359 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1361 faces = bo_handle.ptr;
1365 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1368 _camera_release_imported_bo(&bo);
1372 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1373 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1374 /*LOGD("return buffer done");*/
1377 LOGE("invalid message - count %d, key %d", count, tbm_key);
1381 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1384 int current_state = 0;
1386 muse_camera_msg_get(error, recv_msg);
1387 muse_camera_msg_get(current_state, recv_msg);
1389 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1391 if (error == CAMERA_ERROR_SOUND_POLICY)
1392 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1393 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1394 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1395 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1396 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1398 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1399 (camera_state_e)current_state, cb_info->user_data[event]);
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1405 muse_camera_msg_get(param1, recv_msg);
1406 muse_camera_msg_get(param2, recv_msg);
1408 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1410 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1411 cb_info->user_cb[event] = NULL;
1412 cb_info->user_data[event] = NULL;
1413 LOGW("stop foreach callback for event %d", event);
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1424 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1432 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1434 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1436 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1438 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1442 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1445 muse_camera_msg_get(param1, recv_msg);
1447 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1449 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1450 cb_info->user_cb[event] = NULL;
1451 cb_info->user_data[event] = NULL;
1452 LOGW("stop foreach callback for event %d", event);
1455 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1457 camera_image_data_s *rImage = NULL;
1458 camera_image_data_s *rPostview = NULL;
1459 camera_image_data_s *rThumbnail = NULL;
1460 unsigned char *buf_pos = NULL;
1461 int tbm_key_main = 0;
1462 int tbm_key_post = 0;
1463 int tbm_key_thumb = 0;
1464 tbm_bo bo_main = NULL;
1465 tbm_bo bo_post = NULL;
1466 tbm_bo bo_thumb = NULL;
1467 tbm_bo_handle bo_main_handle = {NULL, };
1468 tbm_bo_handle bo_post_handle = {NULL, };
1469 tbm_bo_handle bo_thumb_handle = {NULL, };
1471 muse_camera_msg_get(tbm_key_main, recv_msg);
1472 muse_camera_msg_get(tbm_key_post, recv_msg);
1473 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1476 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1477 tbm_key_main, tbm_key_post, tbm_key_thumb);
1480 if (tbm_key_main <= 0) {
1481 LOGE("invalid key %d", tbm_key_main);
1485 /* import tbm bo and get virtual address */
1486 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1489 buf_pos = (unsigned char *)bo_main_handle.ptr;
1490 rImage = (camera_image_data_s *)buf_pos;
1491 rImage->data = buf_pos + sizeof(camera_image_data_s);
1492 if (rImage->exif && rImage->exif_size > 0) {
1493 rImage->exif = rImage->data + rImage->size;
1495 rImage->exif = NULL;
1496 rImage->exif_size = 0;
1499 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1500 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1502 if (tbm_key_post > 0) {
1503 /* import tbm bo and get virtual address */
1504 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1507 buf_pos = (unsigned char *)bo_post_handle.ptr;
1508 rPostview = (camera_image_data_s *)buf_pos;
1509 LOGD("rPostview->size : %d", rPostview->size);
1510 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1513 if (tbm_key_thumb > 0) {
1514 /* import tbm bo and get virtual address */
1515 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1518 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1520 rThumbnail = (camera_image_data_s *)buf_pos;
1521 LOGD("rThumbnail->size : %d", rThumbnail->size);
1522 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1525 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1527 /* unmap and unref tbm bo */
1528 _camera_release_imported_bo(&bo_main);
1531 tbm_key = tbm_key_main;
1533 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1535 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1537 if (tbm_key_post > 0) {
1538 /* unmap and unref tbm bo */
1539 _camera_release_imported_bo(&bo_post);
1542 param.value.value_INT = tbm_key_post;
1543 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1546 if (tbm_key_thumb > 0) {
1547 /* unmap and unref tbm bo */
1548 _camera_release_imported_bo(&bo_thumb);
1551 param.value.value_INT = tbm_key_thumb;
1552 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1555 LOGD("return buffer done");
1558 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1559 LOGE("render error");
1566 static bool _camera_idle_event_callback(void *data)
1568 camera_cb_info_s *cb_info = NULL;
1569 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1571 if (cam_idle_event == NULL) {
1572 LOGE("cam_idle_event is NULL");
1577 g_mutex_lock(&cam_idle_event->event_mutex);
1579 cb_info = cam_idle_event->cb_info;
1580 if (cb_info == NULL) {
1581 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1582 goto IDLE_EVENT_CALLBACK_DONE;
1585 /* remove event from list */
1586 g_mutex_lock(&cb_info->idle_event_mutex);
1588 if (cb_info->idle_event_list)
1589 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1591 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1592 g_mutex_unlock(&cb_info->idle_event_mutex);
1595 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1597 /* send signal for waiting thread */
1598 g_cond_signal(&cb_info->idle_event_cond);
1600 IDLE_EVENT_CALLBACK_DONE:
1601 /* unlock and release event */
1602 g_mutex_unlock(&cam_idle_event->event_mutex);
1603 g_mutex_clear(&cam_idle_event->event_mutex);
1605 g_free(cam_idle_event);
1606 cam_idle_event = NULL;
1611 static void *_camera_msg_handler_func(gpointer data)
1615 camera_message_s *cam_msg = NULL;
1616 camera_idle_event_s *cam_idle_event = NULL;
1617 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1618 camera_cb_info_s *cb_info = NULL;
1620 if (!handler_info || !handler_info->cb_info) {
1621 LOGE("NULL handler %p", handler_info);
1625 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1626 type = handler_info->type;
1628 LOGD("t:%d start", type);
1630 g_mutex_lock(&handler_info->mutex);
1632 while (g_atomic_int_get(&handler_info->running)) {
1633 if (g_queue_is_empty(handler_info->queue)) {
1634 /*LOGD("t:%d signal wait...", type);*/
1635 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1636 /*LOGD("t:%d signal received", type);*/
1638 if (g_atomic_int_get(&handler_info->running) == 0) {
1639 LOGD("t:%d stop event thread", type);
1644 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1646 g_mutex_unlock(&handler_info->mutex);
1648 if (cam_msg == NULL) {
1649 LOGE("t:%d NULL message", type);
1650 g_mutex_lock(&handler_info->mutex);
1656 if (api < MUSE_CAMERA_API_MAX) {
1659 g_mutex_lock(&cb_info->api_mutex[api]);
1661 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1662 if (cb_info->api_waiting[api] > 0) {
1663 cb_info->api_ret[api] = ret;
1664 cb_info->api_activating[api] = 1;
1666 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1668 g_cond_signal(&cb_info->api_cond[api]);
1670 LOGW("no waiting for this api [%d]", api);
1673 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1676 g_mutex_unlock(&cb_info->api_mutex[api]);
1677 } else if (api == MUSE_CAMERA_CB_EVENT) {
1678 switch (cam_msg->event_class) {
1679 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1680 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1682 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1683 cam_idle_event = g_new0(camera_idle_event_s, 1);
1684 if (cam_idle_event == NULL) {
1685 LOGE("t:%d cam_idle_event alloc failed", type);
1689 cam_idle_event->event = cam_msg->event;
1690 cam_idle_event->cb_info = cb_info;
1691 g_mutex_init(&cam_idle_event->event_mutex);
1692 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1694 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1696 g_mutex_lock(&cb_info->idle_event_mutex);
1697 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1698 g_mutex_unlock(&cb_info->idle_event_mutex);
1700 g_idle_add_full(G_PRIORITY_DEFAULT,
1701 (GSourceFunc)_camera_idle_event_callback,
1702 (gpointer)cam_idle_event,
1706 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1710 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1716 g_mutex_lock(&handler_info->mutex);
1719 /* remove remained event */
1720 while (!g_queue_is_empty(handler_info->queue)) {
1721 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1723 LOGD("t:%d remove camera message %p", type, cam_msg);
1727 LOGW("t:%d NULL camera message", type);
1731 g_mutex_unlock(&handler_info->mutex);
1733 LOGD("t:%d return", type);
1739 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1741 camera_idle_event_s *cam_idle_event = NULL;
1742 gboolean ret = TRUE;
1744 gint64 end_time = 0;
1746 if (cb_info == NULL) {
1747 LOGE("cb_info is NULL");
1751 g_mutex_lock(&cb_info->idle_event_mutex);
1753 if (cb_info->idle_event_list == NULL) {
1754 LOGD("No remained idle event");
1755 g_mutex_unlock(&cb_info->idle_event_mutex);
1759 list = cb_info->idle_event_list;
1762 cam_idle_event = list->data;
1763 list = g_list_next(list);
1765 if (!cam_idle_event) {
1766 LOGW("Fail to remove idle event. The event is NULL");
1770 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1771 ret = g_idle_remove_by_data(cam_idle_event);
1773 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1776 cam_idle_event->cb_info = NULL;
1777 LOGW("idle event %p will be called later", cam_idle_event);
1780 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1782 g_mutex_unlock(&cam_idle_event->event_mutex);
1785 g_mutex_clear(&cam_idle_event->event_mutex);
1787 g_free(cam_idle_event);
1788 cam_idle_event = NULL;
1790 LOGD("remove idle event done");
1796 LOGW("event lock failed. it's being called...");
1798 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1800 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1801 LOGW("signal received");
1806 g_list_free(cb_info->idle_event_list);
1807 cb_info->idle_event_list = NULL;
1809 g_mutex_unlock(&cb_info->idle_event_mutex);
1815 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1817 camera_message_s *cam_msg = NULL;
1819 if (!cb_info || !msg) {
1820 LOGE("NULL pointer %p %p", cb_info, msg);
1824 cam_msg = g_new0(camera_message_s, 1);
1826 LOGE("failed to alloc cam_msg for [%s]", msg);
1831 cam_msg->event = event;
1832 cam_msg->event_class = event_class;
1834 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1836 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1838 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1839 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1840 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1841 g_cond_signal(&cb_info->preview_cb_info.cond);
1842 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1843 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1844 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1845 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1846 g_cond_signal(&cb_info->capture_cb_info.cond);
1847 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1849 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1850 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1851 g_cond_signal(&cb_info->msg_handler_info.cond);
1852 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1861 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1863 int ret = CAMERA_ERROR_NONE;
1867 int event_class = -1;
1871 if (!cb_info || !msg) {
1872 LOGE("invalid ptr %p %p", cb_info, msg);
1876 /*LOGD("msg [%s]", msg);*/
1878 if (!muse_camera_msg_get(api, msg)) {
1879 LOGE("failed to get camera api");
1883 if (api == MUSE_CAMERA_CB_EVENT) {
1884 if (!muse_camera_msg_get(event, msg) ||
1885 !muse_camera_msg_get(event_class, msg)) {
1886 LOGE("failed to get camera event or event_class [%s]", msg);
1890 if (!muse_camera_msg_get(api_class, msg)) {
1891 LOGE("failed to get camera api_class [%s]", msg);
1896 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1897 if (api >= MUSE_CAMERA_API_MAX) {
1898 LOGE("invalid api %d", api);
1902 if (!muse_camera_msg_get(ret, msg)) {
1903 LOGE("failed to get camera ret");
1907 g_mutex_lock(&cb_info->api_mutex[api]);
1910 case MUSE_CAMERA_API_CREATE:
1911 if (ret != CAMERA_ERROR_NONE) {
1912 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1913 LOGE("camera create error 0x%x. close client cb handler", ret);
1916 case MUSE_CAMERA_API_DESTROY:
1917 if (ret == CAMERA_ERROR_NONE) {
1918 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1919 LOGD("camera destroy done. close client cb handler");
1923 muse_camera_msg_get(get_type, msg);
1924 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1925 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1926 muse_camera_msg_get(get_index, msg);
1929 case MUSE_CAMERA_GET_TYPE_INT:
1930 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1932 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1933 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1934 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1936 case MUSE_CAMERA_GET_TYPE_ARRAY:
1937 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1938 muse_core_msg_json_deserialize("get_value",
1939 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1940 LOGD("get display roi %d,%d,%dx%d",
1941 cb_info->get_display_roi_area[0],
1942 cb_info->get_display_roi_area[1],
1943 cb_info->get_display_roi_area[2],
1944 cb_info->get_display_roi_area[3]);
1946 muse_core_msg_json_deserialize("get_value",
1947 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1948 LOGD("get geotag %lf, %lf, %lf",
1949 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1952 case MUSE_CAMERA_GET_TYPE_STRING:
1953 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1956 LOGW("unknown type %d", get_type);
1963 if (cb_info->api_waiting[api] > 0) {
1964 cb_info->api_ret[api] = ret;
1965 cb_info->api_activating[api] = 1;
1967 g_cond_signal(&cb_info->api_cond[api]);
1969 LOGW("no waiting for this api [%d]", api);
1972 g_mutex_unlock(&cb_info->api_mutex[api]);
1973 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1974 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1976 LOGW("unknown camera api %d, class %d", api, api_class);
1983 static void *_camera_msg_recv_func(gpointer data)
1985 int recv_length = 0;
1986 int single_length = 0;
1987 int remained_length = 0;
1988 char *recv_msg = NULL;
1989 char *single_msg = NULL;
1990 char *remained_msg = NULL;
1994 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1997 LOGE("cb_info NULL");
2003 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2005 LOGE("single_msg malloc failed");
2009 recv_msg = cb_info->recv_msg;
2011 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2012 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
2013 if (recv_length <= 0) {
2014 cb_info->is_server_connected = FALSE;
2015 LOGE("receive msg failed - server disconnected");
2023 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2025 /* Need to split the combined entering msgs */
2026 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2027 if (recv_msg[cur_pos] == '}') {
2028 single_length = cur_pos - prev_pos + 1;
2030 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2031 /* check remained msg */
2032 if (remained_length > 0) {
2034 strncpy(single_msg, remained_msg, remained_length);
2035 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2036 single_msg[remained_length + single_length] = '\0';
2039 remained_msg = NULL;
2041 strncpy(single_msg, recv_msg + prev_pos, single_length);
2042 single_msg[single_length] = '\0';
2043 LOGE("lost msg [%s], skip...", single_msg);
2046 remained_length = 0;
2048 strncpy(single_msg, recv_msg + prev_pos, single_length);
2049 single_msg[single_length] = '\0';
2052 if (single_msg[0] == '{') {
2054 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2055 /* process each message */
2056 __camera_process_msg(cb_info, single_msg);
2058 LOGE("invalid msg [%s]", single_msg);
2061 LOGE("too long message [len %d] skip...", single_length);
2064 prev_pos = cur_pos + 1;
2068 /* check incompleted message */
2069 if (recv_msg[recv_length - 1] != '}') {
2070 remained_length = recv_length - prev_pos;
2072 LOGW("incompleted message [len %d]", remained_length);
2074 remained_msg = (char *)malloc(remained_length + 1);
2076 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2077 remained_msg[remained_length] = '\0';
2079 LOGE("failed to alloc for remained msg");
2082 remained_length = 0;
2086 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2088 if (!cb_info->is_server_connected) {
2089 /* send error msg for server disconnection */
2090 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2091 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2092 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2096 LOGE("error_msg failed");
2097 goto CB_HANDLER_EXIT;
2100 __camera_add_msg_to_queue(cb_info,
2101 MUSE_CAMERA_CB_EVENT,
2102 MUSE_CAMERA_EVENT_TYPE_ERROR,
2103 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2106 muse_core_msg_json_factory_free(error_msg);
2109 LOGE("add error msg for service disconnection done");
2120 remained_msg = NULL;
2127 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2128 int type, const char *thread_name, camera_cb_info_s *cb_info)
2130 if (!handler_info || !thread_name || !cb_info) {
2131 LOGE("t:%d NULL %p %p %p",
2132 type, handler_info, thread_name, cb_info);
2138 handler_info->type = type;
2139 handler_info->queue = g_queue_new();
2140 if (handler_info->queue == NULL) {
2141 LOGE("t:%d queue failed", type);
2145 g_mutex_init(&handler_info->mutex);
2146 g_cond_init(&handler_info->cond);
2148 handler_info->cb_info = (void *)cb_info;
2149 g_atomic_int_set(&handler_info->running, 1);
2151 handler_info->thread = g_thread_try_new(thread_name,
2152 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2153 if (handler_info->thread == NULL) {
2154 LOGE("t:%d thread failed", type);
2156 g_mutex_clear(&handler_info->mutex);
2157 g_cond_clear(&handler_info->cond);
2158 g_queue_free(handler_info->queue);
2159 handler_info->queue = NULL;
2164 LOGD("t:%d done", type);
2170 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2174 if (!handler_info) {
2175 LOGE("NULL handler");
2179 if (!handler_info->thread) {
2180 LOGW("thread is not created");
2184 type = handler_info->type;
2186 LOGD("t:%d thread %p", type, handler_info->thread);
2188 g_mutex_lock(&handler_info->mutex);
2189 g_atomic_int_set(&handler_info->running, 0);
2190 g_cond_signal(&handler_info->cond);
2191 g_mutex_unlock(&handler_info->mutex);
2193 g_thread_join(handler_info->thread);
2194 handler_info->thread = NULL;
2196 g_mutex_clear(&handler_info->mutex);
2197 g_cond_clear(&handler_info->cond);
2198 g_queue_free(handler_info->queue);
2199 handler_info->queue = NULL;
2201 LOGD("t:%d done", type);
2207 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2209 camera_cb_info_s *cb_info = NULL;
2212 g_return_val_if_fail(sockfd > 0, NULL);
2214 cb_info = g_new0(camera_cb_info_s, 1);
2215 if (cb_info == NULL) {
2216 LOGE("cb_info failed");
2220 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2222 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2223 g_mutex_init(&cb_info->api_mutex[i]);
2224 g_cond_init(&cb_info->api_cond[i]);
2227 g_mutex_init(&cb_info->fd_lock);
2228 g_mutex_init(&cb_info->idle_event_mutex);
2229 g_cond_init(&cb_info->idle_event_cond);
2230 g_mutex_init(&cb_info->mp_data_mutex);
2231 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2232 g_mutex_init(&cb_info->evas_mutex);
2233 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2235 /* message handler thread */
2236 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2237 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2238 LOGE("msg_handler_info failed");
2242 /* message handler thread for preview callback */
2243 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2244 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2245 LOGE("preview_cb_info failed");
2249 /* message handler thread for capture callback */
2250 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2251 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2252 LOGE("capture_cb_info failed");
2256 cb_info->fd = sockfd;
2257 cb_info->preview_cb_flag = 0;
2258 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2259 cb_info->evas_info = NULL;
2260 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2262 /* message receive thread */
2263 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2264 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2265 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2266 if (cb_info->msg_recv_thread == NULL) {
2267 LOGE("message receive thread creation failed");
2271 cb_info->is_server_connected = TRUE;
2277 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2278 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2279 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2281 g_mutex_clear(&cb_info->fd_lock);
2282 g_mutex_clear(&cb_info->idle_event_mutex);
2283 g_cond_clear(&cb_info->idle_event_cond);
2284 g_mutex_clear(&cb_info->mp_data_mutex);
2285 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2286 g_mutex_clear(&cb_info->evas_mutex);
2287 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2289 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2290 g_mutex_clear(&cb_info->api_mutex[i]);
2291 g_cond_clear(&cb_info->api_cond[i]);
2301 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2305 g_return_if_fail(cb_info != NULL);
2307 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2309 g_thread_join(cb_info->msg_recv_thread);
2310 cb_info->msg_recv_thread = NULL;
2312 LOGD("msg_recv thread removed");
2314 /* destroy msg handler threads */
2315 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2316 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2317 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2319 g_mutex_clear(&cb_info->fd_lock);
2320 g_mutex_clear(&cb_info->idle_event_mutex);
2321 g_cond_clear(&cb_info->idle_event_cond);
2322 g_mutex_clear(&cb_info->mp_data_mutex);
2323 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2324 g_mutex_clear(&cb_info->evas_mutex);
2325 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2327 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2328 g_mutex_clear(&cb_info->api_mutex[i]);
2329 g_cond_clear(&cb_info->api_cond[i]);
2332 if (cb_info->fd > -1) {
2333 muse_core_connection_close(cb_info->fd);
2337 if (cb_info->bufmgr) {
2338 tbm_bufmgr_deinit(cb_info->bufmgr);
2339 cb_info->bufmgr = NULL;
2341 if (cb_info->pkt_fmt) {
2342 media_format_unref(cb_info->pkt_fmt);
2343 cb_info->pkt_fmt = NULL;
2346 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2347 if (cb_info->evas_info)
2348 mm_evas_renderer_destroy(&cb_info->evas_info);
2349 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2351 cb_info->preview_cb_flag = 0;
2360 int _camera_start_evas_rendering(camera_h camera)
2362 int ret = CAMERA_ERROR_NONE;
2363 camera_cli_s *pc = (camera_cli_s *)camera;
2365 if (!pc || !pc->cb_info) {
2366 LOGE("NULL handle");
2367 return CAMERA_ERROR_INVALID_PARAMETER;
2372 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2373 LOGE("EVAS surface is not set");
2374 return CAMERA_ERROR_NONE;
2377 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2378 g_mutex_lock(&pc->cb_info->evas_mutex);
2380 /* set evas render flag as RUN */
2381 pc->cb_info->run_evas_render = true;
2382 ret = CAMERA_ERROR_NONE;
2384 g_mutex_unlock(&pc->cb_info->evas_mutex);
2385 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2386 LOGW("evas renderer is not supported");
2387 ret = CAMERA_ERROR_NOT_SUPPORTED;
2388 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2394 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2396 int ret = CAMERA_ERROR_NONE;
2397 camera_cli_s *pc = (camera_cli_s *)camera;
2399 if (!pc || !pc->cb_info) {
2400 LOGE("NULL handle");
2401 return CAMERA_ERROR_INVALID_PARAMETER;
2404 LOGD("stop - keep screen %d", keep_screen);
2406 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2407 LOGE("EVAS surface is not set");
2408 return CAMERA_ERROR_NONE;
2411 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2412 g_mutex_lock(&pc->cb_info->evas_mutex);
2414 /* set evas render flag as STOP and release buffers */
2415 pc->cb_info->run_evas_render = false;
2417 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2418 if (ret != MM_ERROR_NONE) {
2419 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2420 ret = CAMERA_ERROR_INVALID_OPERATION;
2423 g_mutex_unlock(&pc->cb_info->evas_mutex);
2424 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2425 LOGW("evas renderer is not supported");
2426 ret = CAMERA_ERROR_NOT_SUPPORTED;
2427 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2433 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2435 int ret = CAMERA_ERROR_NONE;
2438 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2440 /* create muse connection */
2441 if (!key || !value) {
2442 LOGE("NULL pointer");
2443 return CAMERA_ERROR_INVALID_PARAMETER;
2446 sock_fd = muse_core_client_new();
2448 LOGE("muse_core_client_new failed");
2449 return CAMERA_ERROR_INVALID_OPERATION;
2452 msg = muse_core_msg_json_factory_new(api,
2453 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2454 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2458 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2462 ret = muse_core_ipc_send_msg(sock_fd, msg);
2464 muse_core_msg_json_factory_free(msg);
2468 LOGE("send msg failed");
2469 ret = CAMERA_ERROR_INVALID_OPERATION;
2473 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2475 LOGE("recv msg failed %d", errno);
2476 ret = CAMERA_ERROR_INVALID_OPERATION;
2480 if (!muse_camera_msg_get(ret, recv_msg)) {
2481 LOGE("failed to get return value from msg [%s]", recv_msg);
2482 ret = CAMERA_ERROR_INVALID_OPERATION;
2486 if (ret == CAMERA_ERROR_NONE)
2487 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2489 LOGD("api %d - value %d", api, *value);
2493 muse_core_connection_close(sock_fd);
2501 int camera_create(camera_device_e device, camera_h *camera)
2504 char *send_msg = NULL;
2506 int ret = CAMERA_ERROR_NONE;
2508 camera_cli_s *pc = NULL;
2509 tbm_bufmgr bufmgr = NULL;
2511 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2512 muse_core_api_module_e muse_module = MUSE_CAMERA;
2513 int device_type = (int)device;
2516 LOGE("NULL pointer");
2517 return CAMERA_ERROR_INVALID_PARAMETER;
2520 sock_fd = muse_core_client_new();
2522 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2523 ret = CAMERA_ERROR_INVALID_OPERATION;
2529 send_msg = muse_core_msg_json_factory_new(api,
2530 MUSE_TYPE_INT, "module", muse_module,
2531 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2532 MUSE_TYPE_INT, "pid", pid,
2537 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2541 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2543 muse_core_msg_json_factory_free(send_msg);
2547 LOGE("send msg failed %d", errno);
2548 ret = CAMERA_ERROR_INVALID_OPERATION;
2552 pc = g_new0(camera_cli_s, 1);
2554 LOGE("camera_cli_s alloc failed");
2555 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2559 bufmgr = tbm_bufmgr_init(-1);
2560 if (bufmgr == NULL) {
2561 LOGE("get tbm bufmgr failed");
2562 ret = CAMERA_ERROR_INVALID_OPERATION;
2566 pc->cb_info = _camera_client_callback_new(sock_fd);
2567 if (pc->cb_info == NULL) {
2568 LOGE("cb_info alloc failed");
2569 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2575 LOGD("cb info : %d", pc->cb_info->fd);
2577 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_NO_TIMEOUT);
2579 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2581 if (ret == CAMERA_ERROR_NONE) {
2582 intptr_t handle = 0;
2583 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2585 LOGE("Receiving Handle Failed!!");
2586 ret = CAMERA_ERROR_INVALID_OPERATION;
2590 pc->remote_handle = handle;
2591 pc->cb_info->bufmgr = bufmgr;
2593 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2594 if (ret != CAMERA_ERROR_NONE) {
2595 LOGE("init display failed 0x%x", ret);
2599 LOGD("camera create 0x%x", pc->remote_handle);
2600 *camera = (camera_h)pc;
2609 tbm_bufmgr_deinit(bufmgr);
2614 muse_core_connection_close(sock_fd);
2620 _camera_client_callback_destroy(pc->cb_info);
2627 LOGE("camera create error : 0x%x", ret);
2633 int camera_change_device(camera_h camera, camera_device_e device)
2636 int ret = CAMERA_ERROR_NONE;
2637 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2638 camera_cli_s *pc = (camera_cli_s *)camera;
2639 camera_msg_param param;
2641 if (!pc || !pc->cb_info) {
2642 LOGE("NULL handle");
2643 return CAMERA_ERROR_INVALID_PARAMETER;
2646 CAMERA_MSG_PARAM_SET(param, INT, device);
2648 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2650 if (ret == CAMERA_ERROR_NONE) {
2651 /* reset callback and user data */
2652 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2653 pc->cb_info->user_cb[i] = NULL;
2654 pc->cb_info->user_data[i] = NULL;
2656 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2663 int camera_destroy(camera_h camera)
2665 int ret = CAMERA_ERROR_NONE;
2666 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2667 camera_cli_s *pc = (camera_cli_s *)camera;
2669 if (!pc || !pc->cb_info) {
2670 LOGE("NULL handle");
2671 return CAMERA_ERROR_INVALID_PARAMETER;
2676 if (pc->cb_info->is_server_connected)
2677 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2679 LOGW("server disconnected. release resource without send message.");
2681 if (ret == CAMERA_ERROR_NONE) {
2682 _camera_remove_idle_event_all(pc->cb_info);
2683 _camera_client_callback_destroy(pc->cb_info);
2693 int camera_start_preview(camera_h camera)
2695 int ret = CAMERA_ERROR_NONE;
2696 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2697 camera_cli_s *pc = (camera_cli_s *)camera;
2699 if (!pc || !pc->cb_info) {
2700 LOGE("NULL handle");
2701 return CAMERA_ERROR_INVALID_PARAMETER;
2706 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2707 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2708 ret = _camera_start_evas_rendering(camera);
2709 if (ret != CAMERA_ERROR_NONE) {
2710 LOGE("stop preview because of error");
2711 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2715 LOGD("ret : 0x%x", ret);
2721 int camera_stop_preview(camera_h camera)
2723 int ret = CAMERA_ERROR_NONE;
2724 camera_cli_s *pc = (camera_cli_s *)camera;
2725 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2726 camera_state_e current_state = CAMERA_STATE_NONE;
2728 if (!pc || !pc->cb_info) {
2729 LOGE("NULL handle");
2730 return CAMERA_ERROR_INVALID_PARAMETER;
2735 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2736 ret = camera_get_state(camera, ¤t_state);
2737 if (ret != CAMERA_ERROR_NONE) {
2738 LOGE("failed to get current state 0x%x", ret);
2742 if (current_state == CAMERA_STATE_PREVIEW) {
2743 ret = _camera_stop_evas_rendering(camera, false);
2744 if (ret != CAMERA_ERROR_NONE)
2749 /* send stop preview message */
2750 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2752 if (ret != CAMERA_ERROR_NONE &&
2753 current_state == CAMERA_STATE_PREVIEW) {
2754 LOGW("restart evas rendering");
2755 _camera_start_evas_rendering(camera);
2758 LOGD("ret : 0x%x", ret);
2764 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2766 int ret = CAMERA_ERROR_NONE;
2767 camera_cli_s *pc = (camera_cli_s *)camera;
2768 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2770 if (!pc || !pc->cb_info) {
2771 LOGE("NULL handle");
2772 return CAMERA_ERROR_INVALID_PARAMETER;
2777 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2778 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2780 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2781 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2783 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2785 LOGD("ret : 0x%x", ret);
2791 bool camera_is_supported_continuous_capture(camera_h camera)
2793 int ret = CAMERA_ERROR_NONE;
2794 camera_cli_s *pc = (camera_cli_s *)camera;
2795 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2797 if (!pc || !pc->cb_info) {
2798 LOGE("NULL handle");
2799 return CAMERA_ERROR_INVALID_PARAMETER;
2804 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2807 LOGE("error is occurred 0x%x", ret);
2811 LOGD("ret : %d", ret);
2817 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)
2819 int ret = CAMERA_ERROR_NONE;
2820 camera_cli_s *pc = (camera_cli_s *)camera;
2821 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2822 camera_msg_param param;
2825 if (!pc || !pc->cb_info) {
2826 LOGE("NULL handle");
2827 return CAMERA_ERROR_INVALID_PARAMETER;
2832 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2833 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2835 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2836 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2838 value = (count << 16) | interval;
2839 CAMERA_MSG_PARAM_SET(param, INT, value);
2841 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2843 LOGD("ret : 0x%x", ret);
2849 int camera_stop_continuous_capture(camera_h camera)
2851 int ret = CAMERA_ERROR_NONE;
2852 camera_cli_s *pc = (camera_cli_s *)camera;
2853 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2855 if (!pc || !pc->cb_info) {
2856 LOGE("NULL handle");
2857 return CAMERA_ERROR_INVALID_PARAMETER;
2862 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2864 LOGD("ret : 0x%x", ret);
2870 bool camera_is_supported_face_detection(camera_h camera)
2872 int ret = CAMERA_ERROR_NONE;
2873 camera_cli_s *pc = (camera_cli_s *)camera;
2874 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2876 if (!pc || !pc->cb_info) {
2877 LOGE("NULL handle");
2878 return CAMERA_ERROR_INVALID_PARAMETER;
2883 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2886 LOGE("error is occurred 0x%x", ret);
2890 LOGD("ret : %d", ret);
2896 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2898 int ret = CAMERA_ERROR_NONE;
2899 camera_cli_s *pc = (camera_cli_s *)camera;
2900 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2902 if (!pc || !pc->cb_info) {
2903 LOGE("NULL handle");
2904 return CAMERA_ERROR_INVALID_PARAMETER;
2909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2912 LOGE("error is occurred 0x%x", ret);
2916 LOGD("ret : %d", ret);
2922 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2924 int ret = CAMERA_ERROR_NONE;
2925 camera_cli_s *pc = (camera_cli_s *)camera;
2926 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2928 if (!pc || !pc->cb_info) {
2929 LOGE("NULL handle");
2930 return CAMERA_ERROR_INVALID_PARAMETER;
2935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2938 LOGE("error is occurred 0x%x", ret);
2942 LOGD("ret : %d", ret);
2947 int camera_get_device_count(camera_h camera, int *device_count)
2949 int ret = CAMERA_ERROR_NONE;
2950 camera_cli_s *pc = (camera_cli_s *)camera;
2951 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2953 if (!pc || !pc->cb_info) {
2954 LOGE("NULL handle");
2955 return CAMERA_ERROR_INVALID_PARAMETER;
2960 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2962 if (ret == CAMERA_ERROR_NONE)
2963 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2965 LOGD("ret : 0x%x", ret);
2970 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2972 int ret = CAMERA_ERROR_NONE;
2973 camera_cli_s *pc = (camera_cli_s *)camera;
2974 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2976 if (!pc || !pc->cb_info) {
2977 LOGE("NULL handle");
2978 return CAMERA_ERROR_INVALID_PARAMETER;
2983 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2984 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2988 LOGD("ret : 0x%x", ret);
2993 int camera_stop_face_detection(camera_h camera)
2995 int ret = CAMERA_ERROR_NONE;
2996 camera_cli_s *pc = (camera_cli_s *)camera;
2997 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2999 if (!pc || !pc->cb_info) {
3000 LOGE("NULL handle");
3001 return CAMERA_ERROR_INVALID_PARAMETER;
3006 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3008 LOGD("ret : 0x%x", ret);
3013 int camera_get_state(camera_h camera, camera_state_e *state)
3015 int ret = CAMERA_ERROR_NONE;
3016 camera_cli_s *pc = (camera_cli_s *)camera;
3017 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3019 if (!pc || !pc->cb_info || !state) {
3020 LOGE("NULL pointer %p %p", pc, state);
3021 return CAMERA_ERROR_INVALID_PARAMETER;
3026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3028 if (ret == CAMERA_ERROR_NONE)
3029 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3031 LOGD("ret : 0x%x", ret);
3036 int camera_start_focusing(camera_h camera, bool continuous)
3038 int ret = CAMERA_ERROR_NONE;
3039 camera_cli_s *pc = (camera_cli_s *)camera;
3040 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3041 camera_msg_param param;
3042 int is_continuous = (int)continuous;
3044 if (!pc || !pc->cb_info) {
3045 LOGE("NULL handle");
3046 return CAMERA_ERROR_INVALID_PARAMETER;
3051 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3053 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3055 LOGD("ret : 0x%x", ret);
3060 int camera_cancel_focusing(camera_h camera)
3062 int ret = CAMERA_ERROR_NONE;
3063 camera_cli_s *pc = (camera_cli_s *)camera;
3064 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3066 if (!pc || !pc->cb_info) {
3067 LOGE("NULL handle");
3068 return CAMERA_ERROR_INVALID_PARAMETER;
3071 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3073 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3075 LOGD("ret : 0x%x", ret);
3080 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3082 int ret = CAMERA_ERROR_NONE;
3083 void *set_display_handle = NULL;
3084 Evas_Object *obj = NULL;
3085 const char *object_type = NULL;
3086 camera_cli_s *pc = (camera_cli_s *)camera;
3087 camera_cb_info_s *cb_info = NULL;
3088 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3089 camera_state_e current_state = CAMERA_STATE_NONE;
3090 camera_msg_param param;
3094 if (!pc || !pc->cb_info) {
3095 LOGE("NULL handle");
3096 return CAMERA_ERROR_INVALID_PARAMETER;
3099 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3100 LOGE("invalid type %d", type);
3101 return CAMERA_ERROR_INVALID_PARAMETER;
3104 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3105 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3106 return CAMERA_ERROR_INVALID_PARAMETER;
3109 cb_info = (camera_cb_info_s *)pc->cb_info;
3111 ret = camera_get_state(camera, ¤t_state);
3112 if (ret != CAMERA_ERROR_NONE) {
3113 LOGE("failed to get current state 0x%x", ret);
3117 if (current_state != CAMERA_STATE_CREATED) {
3118 LOGE("INVALID_STATE : current %d", current_state);
3119 return CAMERA_ERROR_INVALID_STATE;
3122 LOGD("Enter - display : %p", display);
3124 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3125 set_display_handle = 0;
3126 LOGD("display type NONE");
3128 obj = (Evas_Object *)display;
3129 object_type = evas_object_type_get(obj);
3131 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3132 /* get wayland parent id */
3133 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3134 LOGE("failed to get wayland info");
3135 return CAMERA_ERROR_INVALID_OPERATION;
3138 set_display_handle = (void *)&pc->wl_info;
3139 LOGD("display type OVERLAY : handle %p", set_display_handle);
3140 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3141 /* evas object surface */
3142 set_display_handle = (void *)display;
3143 LOGD("display type EVAS : handle %p", set_display_handle);
3145 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3146 g_mutex_lock(&cb_info->evas_mutex);
3148 if (cb_info->evas_info) {
3149 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3150 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3151 if (ret != MM_ERROR_NONE) {
3152 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3153 g_mutex_unlock(&cb_info->evas_mutex);
3154 return CAMERA_ERROR_INVALID_OPERATION;
3158 /* create evas renderer */
3159 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3160 if (ret == MM_ERROR_NONE) {
3161 camera_flip_e flip = CAMERA_FLIP_NONE;
3162 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3163 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3170 camera_get_display_flip(camera, &flip);
3171 camera_get_display_mode(camera, &mode);
3172 camera_get_display_rotation(camera, &rotation);
3173 camera_is_display_visible(camera, &visible);
3174 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3176 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3177 flip, mode, rotation, visible, x, y, width, height);
3179 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3180 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3181 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3182 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3184 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3185 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3188 g_mutex_unlock(&cb_info->evas_mutex);
3190 if (ret != MM_ERROR_NONE) {
3191 LOGE("mm_evas_renderer error 0x%x", ret);
3192 return CAMERA_ERROR_INVALID_OPERATION;
3194 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3195 LOGE("EVAS surface is not supported");
3196 return CAMERA_ERROR_NOT_SUPPORTED;
3197 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3199 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3200 return CAMERA_ERROR_INVALID_PARAMETER;
3203 LOGE("failed to get evas object type from %p", obj);
3204 return CAMERA_ERROR_INVALID_PARAMETER;
3208 pc->display_handle = (intptr_t)set_display_handle;
3210 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3213 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3214 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3216 msg = muse_core_msg_json_factory_new(api,
3217 MUSE_TYPE_INT, "type", type,
3218 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3221 LOGE("msg creation failed: api %d", api);
3222 return CAMERA_ERROR_OUT_OF_MEMORY;
3225 if (pc->cb_info->is_server_connected) {
3226 __camera_update_api_waiting(pc->cb_info, api, 1);
3228 g_mutex_lock(&pc->cb_info->fd_lock);
3229 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3230 g_mutex_unlock(&pc->cb_info->fd_lock);
3234 LOGE("message send failed");
3235 ret = CAMERA_ERROR_INVALID_OPERATION;
3237 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3240 __camera_update_api_waiting(pc->cb_info, api, -1);
3242 muse_core_msg_json_factory_free(msg);
3244 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3245 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3246 pc->wl_info.window_width, pc->wl_info.window_height);
3248 CAMERA_MSG_PARAM_SET(param, INT, type);
3250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3253 if (ret != CAMERA_ERROR_NONE)
3254 LOGE("set display error 0x%x", ret);
3255 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3256 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3262 int camera_set_preview_resolution(camera_h camera, int width, int height)
3264 int ret = CAMERA_ERROR_NONE;
3265 camera_state_e current_state = CAMERA_STATE_NONE;
3266 camera_cli_s *pc = (camera_cli_s *)camera;
3267 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3268 camera_msg_param param;
3271 if (!pc || !pc->cb_info) {
3272 LOGE("NULL handle");
3273 return CAMERA_ERROR_INVALID_PARAMETER;
3276 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3277 ret = camera_get_state(camera, ¤t_state);
3278 if (ret != CAMERA_ERROR_NONE) {
3279 LOGE("failed to get current state 0x%x", ret);
3283 if (current_state == CAMERA_STATE_PREVIEW) {
3284 ret = _camera_stop_evas_rendering(camera, true);
3285 if (ret != CAMERA_ERROR_NONE)
3290 value = (width << 16) | height;
3291 CAMERA_MSG_PARAM_SET(param, INT, value);
3293 LOGD("%dx%d -> 0x%x", width, height, value);
3295 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3297 LOGD("ret : 0x%x", ret);
3299 if (current_state == CAMERA_STATE_PREVIEW) {
3300 LOGW("restart evas rendering");
3301 _camera_start_evas_rendering(camera);
3308 int camera_set_capture_resolution(camera_h camera, int width, int height)
3310 int ret = CAMERA_ERROR_NONE;
3311 camera_cli_s *pc = (camera_cli_s *)camera;
3312 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3313 camera_msg_param param;
3316 if (!pc || !pc->cb_info) {
3317 LOGE("NULL handle");
3318 return CAMERA_ERROR_INVALID_PARAMETER;
3323 value = (width << 16) | height;
3324 CAMERA_MSG_PARAM_SET(param, INT, value);
3326 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3328 LOGD("ret : 0x%x", ret);
3334 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3336 int ret = CAMERA_ERROR_NONE;
3337 int set_format = (int)format;
3338 camera_cli_s *pc = (camera_cli_s *)camera;
3339 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3340 camera_msg_param param;
3342 if (!pc || !pc->cb_info) {
3343 LOGE("NULL handle");
3344 return CAMERA_ERROR_INVALID_PARAMETER;
3347 LOGD("Enter - format %d", set_format);
3349 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3351 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3353 LOGD("ret : 0x%x", ret);
3359 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3361 int ret = CAMERA_ERROR_NONE;
3362 int set_format = (int)format;
3363 camera_msg_param param;
3364 camera_cli_s *pc = (camera_cli_s *)camera;
3365 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3367 if (!pc || !pc->cb_info) {
3368 LOGE("NULL handle");
3369 return CAMERA_ERROR_INVALID_PARAMETER;
3372 LOGD("Enter - capture_format %d", set_format);
3374 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3376 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3378 LOGD("ret : 0x%x", ret);
3384 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3386 int ret = CAMERA_ERROR_NONE;
3387 camera_cli_s *pc = (camera_cli_s *)camera;
3388 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3390 if (!pc || !pc->cb_info || !width || !height) {
3391 LOGE("NULL pointer %p %p %p", pc, width, height);
3392 return CAMERA_ERROR_INVALID_PARAMETER;
3397 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3399 if (ret == CAMERA_ERROR_NONE) {
3400 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3401 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3404 LOGD("ret : 0x%x", ret);
3410 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3412 int ret = CAMERA_ERROR_NONE;
3413 int set_rotation = (int)rotation;
3414 camera_cli_s *pc = (camera_cli_s *)camera;
3415 camera_msg_param param;
3417 if (!pc || !pc->cb_info) {
3418 LOGE("NULL handle");
3419 return CAMERA_ERROR_INVALID_PARAMETER;
3422 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3423 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3424 g_mutex_lock(&pc->cb_info->evas_mutex);
3426 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3428 g_mutex_unlock(&pc->cb_info->evas_mutex);
3430 if (ret != MM_ERROR_NONE) {
3431 LOGE("failed to set rotation for evas surface 0x%x", ret);
3432 return CAMERA_ERROR_INVALID_OPERATION;
3435 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3437 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3439 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3445 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3447 int ret = CAMERA_ERROR_NONE;
3448 camera_cli_s *pc = (camera_cli_s *)camera;
3450 if (!pc || !pc->cb_info || !rotation) {
3451 LOGE("NULL pointer %p %p", pc, rotation);
3452 return CAMERA_ERROR_INVALID_PARAMETER;
3455 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3457 if (ret == CAMERA_ERROR_NONE)
3458 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3464 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3466 int ret = CAMERA_ERROR_NONE;
3467 int set_flip = (int)flip;
3468 camera_cli_s *pc = (camera_cli_s *)camera;
3469 camera_msg_param param;
3471 if (!pc || !pc->cb_info) {
3472 LOGE("NULL handle");
3473 return CAMERA_ERROR_INVALID_PARAMETER;
3476 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3477 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3478 g_mutex_lock(&pc->cb_info->evas_mutex);
3480 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3482 g_mutex_unlock(&pc->cb_info->evas_mutex);
3484 if (ret != MM_ERROR_NONE) {
3485 LOGE("failed to set flip for evas surface 0x%x", ret);
3486 return CAMERA_ERROR_INVALID_OPERATION;
3489 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3491 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3493 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3499 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3501 int ret = CAMERA_ERROR_NONE;
3502 camera_cli_s *pc = (camera_cli_s *)camera;
3504 if (!pc || !pc->cb_info || !flip) {
3505 LOGE("NULL pointer %p %p", pc, flip);
3506 return CAMERA_ERROR_INVALID_PARAMETER;
3509 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3511 if (ret == CAMERA_ERROR_NONE)
3512 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3518 int camera_set_display_visible(camera_h camera, bool visible)
3520 int ret = CAMERA_ERROR_NONE;
3521 int set_visible = (int)visible;
3522 camera_cli_s *pc = (camera_cli_s *)camera;
3523 camera_msg_param param;
3525 if (!pc || !pc->cb_info) {
3526 LOGE("NULL handle");
3527 return CAMERA_ERROR_INVALID_PARAMETER;
3530 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3531 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3532 g_mutex_lock(&pc->cb_info->evas_mutex);
3534 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3536 g_mutex_unlock(&pc->cb_info->evas_mutex);
3538 if (ret != MM_ERROR_NONE) {
3539 LOGE("failed to set visible for evas surface 0x%x", ret);
3540 return CAMERA_ERROR_INVALID_OPERATION;
3543 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3545 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3547 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3553 int camera_is_display_visible(camera_h camera, bool *visible)
3555 int ret = CAMERA_ERROR_NONE;
3556 camera_cli_s *pc = (camera_cli_s *)camera;
3558 if (!pc || !pc->cb_info || !visible) {
3559 LOGE("NULL pointer %p %p", pc, visible);
3560 return CAMERA_ERROR_INVALID_PARAMETER;
3563 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3565 if (ret == CAMERA_ERROR_NONE)
3566 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3572 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3574 int ret = CAMERA_ERROR_NONE;
3575 int set_mode = (int)mode;
3576 camera_cli_s *pc = (camera_cli_s *)camera;
3577 camera_msg_param param;
3579 if (!pc || !pc->cb_info) {
3580 LOGE("NULL handle");
3581 return CAMERA_ERROR_INVALID_PARAMETER;
3584 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3585 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3586 g_mutex_lock(&pc->cb_info->evas_mutex);
3588 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3590 g_mutex_unlock(&pc->cb_info->evas_mutex);
3592 if (ret != MM_ERROR_NONE) {
3593 LOGE("failed to set geometry for evas surface 0x%x", ret);
3594 return CAMERA_ERROR_INVALID_OPERATION;
3597 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3599 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3601 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3607 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3609 int ret = CAMERA_ERROR_NONE;
3610 camera_cli_s *pc = (camera_cli_s *)camera;
3612 if (!pc || !pc->cb_info || !mode) {
3613 LOGE("NULL pointer %p %p", pc, mode);
3614 return CAMERA_ERROR_INVALID_PARAMETER;
3617 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3619 if (ret == CAMERA_ERROR_NONE)
3620 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3626 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3628 int ret = CAMERA_ERROR_NONE;
3629 int set_hint = (int)hint;
3630 camera_cli_s *pc = (camera_cli_s *)camera;
3631 camera_msg_param param;
3633 if (!pc || !pc->cb_info) {
3634 LOGE("NULL handle");
3635 return CAMERA_ERROR_INVALID_PARAMETER;
3638 LOGD("Enter - hint %d", set_hint);
3640 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3642 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3648 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3650 int ret = CAMERA_ERROR_NONE;
3651 camera_cli_s *pc = (camera_cli_s *)camera;
3652 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3654 if (!pc || !pc->cb_info || !hint) {
3655 LOGE("NULL pointer %p %p", pc, hint);
3656 return CAMERA_ERROR_INVALID_PARAMETER;
3659 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3661 if (ret == CAMERA_ERROR_NONE) {
3662 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3663 LOGD("display reuse hint %d", *hint);
3670 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3672 int ret = CAMERA_ERROR_NONE;
3673 camera_cli_s *pc = (camera_cli_s *)camera;
3674 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3676 if (!pc || !pc->cb_info || !width || !height) {
3677 LOGE("NULL pointer %p %p %p", pc, width, height);
3678 return CAMERA_ERROR_INVALID_PARAMETER;
3683 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3685 if (ret == CAMERA_ERROR_NONE) {
3686 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3687 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3690 LOGD("ret : 0x%x", ret);
3696 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3698 int ret = CAMERA_ERROR_NONE;
3699 camera_cli_s *pc = (camera_cli_s *)camera;
3700 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3702 if (!pc || !pc->cb_info || !format) {
3703 LOGE("NULL pointer %p %p", pc, format);
3704 return CAMERA_ERROR_INVALID_PARAMETER;
3709 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3711 if (ret == CAMERA_ERROR_NONE)
3712 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3714 LOGD("ret : 0x%x", ret);
3720 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3722 int ret = CAMERA_ERROR_NONE;
3723 camera_cli_s *pc = (camera_cli_s *)camera;
3724 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3726 if (!pc || !pc->cb_info || !format) {
3727 LOGE("NULL pointer %p %p", pc, format);
3728 return CAMERA_ERROR_INVALID_PARAMETER;
3733 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3735 if (ret == CAMERA_ERROR_NONE)
3736 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3738 LOGD("ret : 0x%x", ret);
3744 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3746 int ret = CAMERA_ERROR_NONE;
3747 camera_cli_s *pc = (camera_cli_s *)camera;
3748 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3750 if (!pc || !pc->cb_info || !facing_direction) {
3751 LOGE("NULL pointer %p %p", pc, facing_direction);
3752 return CAMERA_ERROR_INVALID_PARAMETER;
3757 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3759 if (ret == CAMERA_ERROR_NONE)
3760 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3762 LOGD("ret : 0x%x", ret);
3768 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3770 int ret = CAMERA_ERROR_NONE;
3771 camera_cli_s *pc = (camera_cli_s *)camera;
3772 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3774 if (!pc || !pc->cb_info || !callback) {
3775 LOGE("NULL pointer %p %p", pc, callback);
3776 return CAMERA_ERROR_INVALID_PARAMETER;
3781 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3783 if (ret == CAMERA_ERROR_NONE) {
3784 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3785 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3786 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3789 LOGD("ret : 0x%x", ret);
3795 int camera_unset_preview_cb(camera_h camera)
3797 int ret = CAMERA_ERROR_NONE;
3798 camera_cli_s *pc = (camera_cli_s *)camera;
3799 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3801 if (!pc || !pc->cb_info) {
3802 LOGE("NULL handle");
3803 return CAMERA_ERROR_INVALID_PARAMETER;
3808 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3810 if (ret == CAMERA_ERROR_NONE) {
3811 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3812 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3813 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3816 LOGD("ret : 0x%x", ret);
3822 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3824 int ret = CAMERA_ERROR_NONE;
3825 camera_cli_s *pc = (camera_cli_s *)camera;
3826 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3828 if (!pc || !pc->cb_info) {
3829 LOGE("NULL handle");
3830 return CAMERA_ERROR_INVALID_PARAMETER;
3833 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3834 LOGE("NOT SUPPORTED");
3835 return CAMERA_ERROR_NOT_SUPPORTED;
3838 if (callback == NULL) {
3839 LOGE("NULL callback");
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3847 if (ret == CAMERA_ERROR_NONE) {
3848 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3849 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3852 LOGD("ret : 0x%x", ret);
3858 int camera_unset_media_packet_preview_cb(camera_h camera)
3860 int ret = CAMERA_ERROR_NONE;
3861 camera_cli_s *pc = (camera_cli_s *)camera;
3862 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3864 if (!pc || !pc->cb_info) {
3865 LOGE("NULL handle");
3866 return CAMERA_ERROR_INVALID_PARAMETER;
3871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3873 if (ret == CAMERA_ERROR_NONE) {
3874 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3875 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3878 LOGD("ret : 0x%x", ret);
3884 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3886 int ret = CAMERA_ERROR_NONE;
3887 camera_cli_s *pc = (camera_cli_s *)camera;
3888 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3890 if (!pc || !pc->cb_info || !callback) {
3891 LOGE("NULL pointer %p %p", pc, callback);
3892 return CAMERA_ERROR_INVALID_PARAMETER;
3897 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3899 if (ret == CAMERA_ERROR_NONE) {
3900 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3901 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3904 LOGD("ret : 0x%x", ret);
3910 int camera_unset_state_changed_cb(camera_h camera)
3912 int ret = CAMERA_ERROR_NONE;
3913 camera_cli_s *pc = (camera_cli_s *)camera;
3914 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3916 if (!pc || !pc->cb_info) {
3917 LOGE("NULL handle");
3918 return CAMERA_ERROR_INVALID_PARAMETER;
3923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3925 if (ret == CAMERA_ERROR_NONE) {
3926 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3927 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3930 LOGD("ret : 0x%x", ret);
3936 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3938 int ret = CAMERA_ERROR_NONE;
3939 camera_cli_s *pc = (camera_cli_s *)camera;
3940 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3942 if (!pc || !pc->cb_info || !callback) {
3943 LOGE("NULL pointer %p %p", pc, callback);
3944 return CAMERA_ERROR_INVALID_PARAMETER;
3949 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3951 if (ret == CAMERA_ERROR_NONE) {
3952 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3953 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3956 LOGD("ret : 0x%x", ret);
3962 int camera_unset_interrupted_cb(camera_h camera)
3964 int ret = CAMERA_ERROR_NONE;
3965 camera_cli_s *pc = (camera_cli_s *)camera;
3966 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3968 if (!pc || !pc->cb_info) {
3969 LOGE("NULL handle");
3970 return CAMERA_ERROR_INVALID_PARAMETER;
3975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3977 if (ret == CAMERA_ERROR_NONE) {
3978 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3979 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3982 LOGD("ret : 0x%x", ret);
3988 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3990 int ret = CAMERA_ERROR_NONE;
3991 camera_cli_s *pc = (camera_cli_s *)camera;
3992 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3994 if (!pc || !pc->cb_info || !callback) {
3995 LOGE("NULL pointer %p %p", pc, callback);
3996 return CAMERA_ERROR_INVALID_PARAMETER;
4001 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4003 if (ret == CAMERA_ERROR_NONE) {
4004 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4005 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4008 LOGD("ret : 0x%x", ret);
4014 int camera_unset_focus_changed_cb(camera_h camera)
4016 int ret = CAMERA_ERROR_NONE;
4017 camera_cli_s *pc = (camera_cli_s *)camera;
4018 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4020 if (!pc || !pc->cb_info) {
4021 LOGE("NULL handle");
4022 return CAMERA_ERROR_INVALID_PARAMETER;
4027 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4029 if (ret == CAMERA_ERROR_NONE) {
4030 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4031 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4034 LOGD("ret : 0x%x", ret);
4040 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4042 int ret = CAMERA_ERROR_NONE;
4043 camera_cli_s *pc = (camera_cli_s *)camera;
4044 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4046 if (!pc || !pc->cb_info || !callback) {
4047 LOGE("NULL pointer %p %p", pc, callback);
4048 return CAMERA_ERROR_INVALID_PARAMETER;
4053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4055 if (ret == CAMERA_ERROR_NONE) {
4056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4060 LOGD("ret : 0x%x", ret);
4066 int camera_unset_error_cb(camera_h camera)
4068 int ret = CAMERA_ERROR_NONE;
4069 camera_cli_s *pc = (camera_cli_s *)camera;
4070 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4072 if (!pc || !pc->cb_info) {
4073 LOGE("NULL handle");
4074 return CAMERA_ERROR_INVALID_PARAMETER;
4079 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4081 if (ret == CAMERA_ERROR_NONE) {
4082 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4083 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4086 LOGD("ret : 0x%x", ret);
4092 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4094 int ret = CAMERA_ERROR_NONE;
4095 camera_cli_s *pc = (camera_cli_s *)camera;
4096 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4098 if (!pc || !pc->cb_info || !foreach_cb) {
4099 LOGE("NULL pointer %p %p", pc, foreach_cb);
4100 return CAMERA_ERROR_INVALID_PARAMETER;
4105 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4106 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4108 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4110 LOGD("ret : 0x%x", ret);
4116 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, 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_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4122 if (!pc || !pc->cb_info || !foreach_cb) {
4123 LOGE("NULL pointer %p %p", pc, foreach_cb);
4124 return CAMERA_ERROR_INVALID_PARAMETER;
4129 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4130 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4132 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4134 LOGD("ret : 0x%x", ret);
4140 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4142 int ret = CAMERA_ERROR_NONE;
4143 camera_cli_s *pc = (camera_cli_s *)camera;
4144 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4146 if (!pc || !pc->cb_info || !foreach_cb) {
4147 LOGE("NULL pointer %p %p", pc, foreach_cb);
4148 return CAMERA_ERROR_INVALID_PARAMETER;
4153 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4154 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4156 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4158 LOGD("ret : 0x%x", ret);
4164 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4166 int ret = CAMERA_ERROR_NONE;
4167 camera_cli_s *pc = (camera_cli_s *)camera;
4168 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4170 if (!pc || !pc->cb_info || !foreach_cb) {
4171 LOGE("NULL pointer %p %p", pc, foreach_cb);
4172 return CAMERA_ERROR_INVALID_PARAMETER;
4177 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4178 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4180 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4182 LOGD("ret : 0x%x", ret);
4188 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4190 int ret = CAMERA_ERROR_NONE;
4191 camera_cli_s *pc = (camera_cli_s *)camera;
4192 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4194 if (!pc || !pc->cb_info || !width || !height) {
4195 LOGE("NULL pointer %p %p %p", pc, width, height);
4196 return CAMERA_ERROR_INVALID_PARAMETER;
4200 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4202 if (ret == CAMERA_ERROR_NONE) {
4203 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4204 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4207 LOGD("ret : 0x%x", ret);
4213 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4215 int ret = CAMERA_ERROR_NONE;
4216 camera_cli_s *pc = (camera_cli_s *)camera;
4217 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4219 if (!pc || !pc->cb_info || !angle) {
4220 LOGE("NULL pointer %p %p", pc, angle);
4221 return CAMERA_ERROR_INVALID_PARAMETER;
4226 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4228 if (ret == CAMERA_ERROR_NONE)
4229 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4231 LOGD("ret : 0x%x", ret);
4237 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4239 int ret = CAMERA_ERROR_NONE;
4240 camera_cli_s *pc = (camera_cli_s *)camera;
4241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4242 camera_msg_param param;
4243 int set_mode = (int)mode;
4245 if (!pc || !pc->cb_info) {
4246 LOGE("NULL handle");
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4252 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4254 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4256 LOGD("ret : 0x%x", ret);
4262 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4264 int ret = CAMERA_ERROR_NONE;
4265 camera_cli_s *pc = (camera_cli_s *)camera;
4266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4268 if (!pc || !pc->cb_info || !mode) {
4269 LOGE("NULL pointer %p %p", pc, mode);
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4277 if (ret == CAMERA_ERROR_NONE)
4278 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4280 LOGD("ret : 0x%x", ret);
4286 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4288 int ret = CAMERA_ERROR_NONE;
4289 camera_cli_s *pc = (camera_cli_s *)camera;
4290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4292 if (!pc || !pc->cb_info || !foreach_cb) {
4293 LOGE("NULL pointer %p %p", pc, foreach_cb);
4294 return CAMERA_ERROR_INVALID_PARAMETER;
4299 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4300 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4304 LOGD("Finish, return :%x", ret);
4310 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4312 int ret = CAMERA_ERROR_NONE;
4313 camera_cli_s *pc = (camera_cli_s *)camera;
4314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4315 camera_msg_param param;
4316 int set_fps = (int)fps;
4318 if (!pc || !pc->cb_info) {
4319 LOGE("NULL handle");
4320 return CAMERA_ERROR_INVALID_PARAMETER;
4325 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4327 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4329 LOGD("ret : 0x%x", ret);
4335 int camera_attr_set_image_quality(camera_h camera, int quality)
4337 int ret = CAMERA_ERROR_NONE;
4338 camera_cli_s *pc = (camera_cli_s *)camera;
4339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4340 camera_msg_param param;
4342 if (!pc || !pc->cb_info) {
4343 LOGE("NULL handle");
4344 return CAMERA_ERROR_INVALID_PARAMETER;
4349 CAMERA_MSG_PARAM_SET(param, INT, quality);
4351 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4353 LOGD("ret : 0x%x", ret);
4359 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4361 int ret = CAMERA_ERROR_NONE;
4362 camera_cli_s *pc = (camera_cli_s *)camera;
4363 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4365 if (!pc || !pc->cb_info || !fps) {
4366 LOGE("NULL pointer %p %p", pc, fps);
4367 return CAMERA_ERROR_INVALID_PARAMETER;
4372 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4374 if (ret == CAMERA_ERROR_NONE)
4375 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4377 LOGD("ret : 0x%x", ret);
4383 int camera_attr_get_image_quality(camera_h camera, int *quality)
4385 int ret = CAMERA_ERROR_NONE;
4386 camera_cli_s *pc = (camera_cli_s *)camera;
4387 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4389 if (!pc || !pc->cb_info || !quality) {
4390 LOGE("NULL pointer %p %p", pc, quality);
4391 return CAMERA_ERROR_INVALID_PARAMETER;
4396 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4398 if (ret == CAMERA_ERROR_NONE)
4399 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4401 LOGD("ret : 0x%x", ret);
4407 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4409 int ret = CAMERA_ERROR_NONE;
4410 camera_cli_s *pc = (camera_cli_s *)camera;
4411 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4413 if (!pc || !pc->cb_info || !bitrate) {
4414 LOGE("NULL pointer %p %p", pc, bitrate);
4415 return CAMERA_ERROR_INVALID_PARAMETER;
4420 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4422 if (ret == CAMERA_ERROR_NONE)
4423 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4425 LOGD("ret : 0x%x", ret);
4431 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4433 int ret = CAMERA_ERROR_NONE;
4434 camera_cli_s *pc = (camera_cli_s *)camera;
4435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4436 camera_msg_param param;
4437 int set_bitrate = bitrate;
4439 if (!pc || !pc->cb_info) {
4440 LOGE("NULL handle");
4441 return CAMERA_ERROR_INVALID_PARAMETER;
4446 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4448 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4450 LOGD("ret : 0x%x", ret);
4456 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4458 int ret = CAMERA_ERROR_NONE;
4459 camera_cli_s *pc = (camera_cli_s *)camera;
4460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4462 if (!pc || !pc->cb_info || !interval) {
4463 LOGE("NULL pointer %p %p", pc, interval);
4464 return CAMERA_ERROR_INVALID_PARAMETER;
4469 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4471 if (ret == CAMERA_ERROR_NONE)
4472 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4474 LOGD("ret : 0x%x", ret);
4480 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4482 int ret = CAMERA_ERROR_NONE;
4483 camera_cli_s *pc = (camera_cli_s *)camera;
4484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4485 camera_msg_param param;
4486 int set_gop_interval = interval;
4488 if (!pc || !pc->cb_info) {
4489 LOGE("NULL handle");
4490 return CAMERA_ERROR_INVALID_PARAMETER;
4495 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4497 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4499 LOGD("ret : 0x%x", ret);
4505 int camera_attr_set_zoom(camera_h camera, int zoom)
4507 int ret = CAMERA_ERROR_NONE;
4508 camera_cli_s *pc = (camera_cli_s *)camera;
4509 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4510 camera_msg_param param;
4512 if (!pc || !pc->cb_info) {
4513 LOGE("NULL handle");
4514 return CAMERA_ERROR_INVALID_PARAMETER;
4517 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4519 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4521 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4523 LOGD("ret : 0x%x", ret);
4529 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4534 camera_msg_param param;
4535 int set_mode = (int)mode;
4537 if (!pc || !pc->cb_info) {
4538 LOGE("NULL handle");
4539 return CAMERA_ERROR_INVALID_PARAMETER;
4542 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4544 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4546 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4552 int camera_attr_set_af_area(camera_h camera, int x, int y)
4554 int ret = CAMERA_ERROR_NONE;
4555 camera_cli_s *pc = (camera_cli_s *)camera;
4556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4557 camera_msg_param param;
4560 if (!pc || !pc->cb_info) {
4561 LOGE("NULL handle");
4562 return CAMERA_ERROR_INVALID_PARAMETER;
4565 LOGD("Enter - %d,%d", x, y);
4567 value = (x << 16) | y;
4568 CAMERA_MSG_PARAM_SET(param, INT, value);
4570 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4572 LOGD("ret : 0x%x", ret);
4578 int camera_attr_clear_af_area(camera_h camera)
4580 int ret = CAMERA_ERROR_NONE;
4581 camera_cli_s *pc = (camera_cli_s *)camera;
4582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4584 if (!pc || !pc->cb_info) {
4585 LOGE("NULL handle");
4586 return CAMERA_ERROR_INVALID_PARAMETER;
4591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4593 LOGD("ret : 0x%x", ret);
4599 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4601 int ret = CAMERA_ERROR_NONE;
4602 camera_cli_s *pc = (camera_cli_s *)camera;
4603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4604 camera_msg_param param;
4605 int set_mode = (int)mode;
4607 if (!pc || !pc->cb_info) {
4608 LOGE("NULL handle");
4609 return CAMERA_ERROR_INVALID_PARAMETER;
4614 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4616 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4618 LOGD("ret : 0x%x", ret);
4624 int camera_attr_set_exposure(camera_h camera, int value)
4626 int ret = CAMERA_ERROR_NONE;
4627 camera_cli_s *pc = (camera_cli_s *)camera;
4628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4629 camera_msg_param param;
4631 if (!pc || !pc->cb_info) {
4632 LOGE("NULL handle");
4633 return CAMERA_ERROR_INVALID_PARAMETER;
4638 CAMERA_MSG_PARAM_SET(param, INT, value);
4640 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4642 LOGD("ret : 0x%x", ret);
4648 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4653 camera_msg_param param;
4654 int set_iso = (int)iso;
4656 if (!pc || !pc->cb_info) {
4657 LOGE("NULL handle");
4658 return CAMERA_ERROR_INVALID_PARAMETER;
4663 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4665 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4667 LOGD("ret : 0x%x", ret);
4673 int camera_attr_set_brightness(camera_h camera, int level)
4675 int ret = CAMERA_ERROR_NONE;
4676 camera_cli_s *pc = (camera_cli_s *)camera;
4677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4678 camera_msg_param param;
4680 if (!pc || !pc->cb_info) {
4681 LOGE("NULL handle");
4682 return CAMERA_ERROR_INVALID_PARAMETER;
4687 CAMERA_MSG_PARAM_SET(param, INT, level);
4689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4691 LOGD("ret : 0x%x", ret);
4697 int camera_attr_set_contrast(camera_h camera, int level)
4699 int ret = CAMERA_ERROR_NONE;
4700 camera_cli_s *pc = (camera_cli_s *)camera;
4701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4702 camera_msg_param param;
4704 if (!pc || !pc->cb_info) {
4705 LOGE("NULL handle");
4706 return CAMERA_ERROR_INVALID_PARAMETER;
4711 CAMERA_MSG_PARAM_SET(param, INT, level);
4713 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4715 LOGD("ret : 0x%x", ret);
4721 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4723 int ret = CAMERA_ERROR_NONE;
4724 camera_cli_s *pc = (camera_cli_s *)camera;
4725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4726 camera_msg_param param;
4727 int set_whitebalance = (int)wb;
4729 if (!pc || !pc->cb_info) {
4730 LOGE("NULL handle");
4731 return CAMERA_ERROR_INVALID_PARAMETER;
4736 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4740 LOGD("ret : 0x%x", ret);
4746 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4751 camera_msg_param param;
4752 int set_effect = (int)effect;
4754 if (!pc || !pc->cb_info) {
4755 LOGE("NULL handle");
4756 return CAMERA_ERROR_INVALID_PARAMETER;
4761 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4765 LOGD("ret : 0x%x", ret);
4771 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4773 int ret = CAMERA_ERROR_NONE;
4774 camera_cli_s *pc = (camera_cli_s *)camera;
4775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4776 camera_msg_param param;
4777 int set_mode = (int)mode;
4779 if (!pc || !pc->cb_info) {
4780 LOGE("NULL handle");
4781 return CAMERA_ERROR_INVALID_PARAMETER;
4786 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4790 LOGD("ret : 0x%x", ret);
4796 int camera_attr_enable_tag(camera_h camera, bool enable)
4798 int ret = CAMERA_ERROR_NONE;
4799 camera_cli_s *pc = (camera_cli_s *)camera;
4800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4801 camera_msg_param param;
4802 int set_enable = (int)enable;
4804 if (!pc || !pc->cb_info) {
4805 LOGE("NULL handle");
4806 return CAMERA_ERROR_INVALID_PARAMETER;
4811 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4815 LOGD("ret : 0x%x", ret);
4821 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4823 int ret = CAMERA_ERROR_NONE;
4824 camera_cli_s *pc = (camera_cli_s *)camera;
4825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4826 camera_msg_param param;
4828 if (!pc || !pc->cb_info || !description) {
4829 LOGE("NULL pointer %p %p", pc, description);
4830 return CAMERA_ERROR_INVALID_PARAMETER;
4835 CAMERA_MSG_PARAM_SET(param, STRING, description);
4837 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4839 LOGD("ret : 0x%x", ret);
4845 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4847 int ret = CAMERA_ERROR_NONE;
4848 camera_cli_s *pc = (camera_cli_s *)camera;
4849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4850 camera_msg_param param;
4851 int set_orientation = (int)orientation;
4853 if (!pc || !pc->cb_info) {
4854 LOGE("NULL handle");
4855 return CAMERA_ERROR_INVALID_PARAMETER;
4860 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4862 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4864 LOGD("ret : 0x%x", ret);
4870 int camera_attr_set_tag_software(camera_h camera, const char *software)
4872 int ret = CAMERA_ERROR_NONE;
4873 camera_cli_s *pc = (camera_cli_s *)camera;
4874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4875 camera_msg_param param;
4877 if (!pc || !pc->cb_info || !software) {
4878 LOGE("NULL pointer %p %p", pc, software);
4879 return CAMERA_ERROR_INVALID_PARAMETER;
4882 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4884 CAMERA_MSG_PARAM_SET(param, STRING, software);
4886 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4888 LOGD("ret : 0x%x", ret);
4894 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4896 int ret = CAMERA_ERROR_NONE;
4897 camera_cli_s *pc = (camera_cli_s *)camera;
4898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4899 double set_geotag[3] = {latitude, longitude, altitude};
4904 if (!pc || !pc->cb_info) {
4905 LOGE("NULL handle");
4906 return CAMERA_ERROR_INVALID_PARAMETER;
4911 length = sizeof(set_geotag) / sizeof(int) + \
4912 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4914 msg = muse_core_msg_json_factory_new(api,
4915 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4918 LOGE("msg creation failed: api %d", api);
4919 return CAMERA_ERROR_OUT_OF_MEMORY;
4922 if (pc->cb_info->is_server_connected) {
4923 __camera_update_api_waiting(pc->cb_info, api, 1);
4925 g_mutex_lock(&pc->cb_info->fd_lock);
4926 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4927 g_mutex_unlock(&pc->cb_info->fd_lock);
4931 LOGE("message send failed");
4932 ret = CAMERA_ERROR_INVALID_OPERATION;
4934 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4937 __camera_update_api_waiting(pc->cb_info, api, -1);
4939 muse_core_msg_json_factory_free(msg);
4941 LOGD("ret : 0x%x", ret);
4947 int camera_attr_remove_geotag(camera_h camera)
4949 int ret = CAMERA_ERROR_NONE;
4950 camera_cli_s *pc = (camera_cli_s *)camera;
4951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4953 if (!pc || !pc->cb_info) {
4954 LOGE("NULL handle");
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4960 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4962 LOGD("ret : 0x%x", ret);
4968 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4970 int ret = CAMERA_ERROR_NONE;
4971 camera_cli_s *pc = (camera_cli_s *)camera;
4972 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4973 camera_msg_param param;
4974 int set_mode = (int)mode;
4976 if (!pc || !pc->cb_info) {
4977 LOGE("NULL handle");
4978 return CAMERA_ERROR_INVALID_PARAMETER;
4983 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4985 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4987 LOGD("ret : 0x%x", ret);
4993 int camera_attr_get_zoom(camera_h camera, int *zoom)
4995 int ret = CAMERA_ERROR_NONE;
4996 camera_cli_s *pc = (camera_cli_s *)camera;
4997 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4999 if (!pc || !pc->cb_info || !zoom) {
5000 LOGE("NULL pointer %p %p", pc, zoom);
5001 return CAMERA_ERROR_INVALID_PARAMETER;
5006 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5008 if (ret == CAMERA_ERROR_NONE)
5009 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5011 LOGD("ret : 0x%x", ret);
5017 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5019 int ret = CAMERA_ERROR_NONE;
5020 camera_cli_s *pc = (camera_cli_s *)camera;
5021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5023 if (!pc || !pc->cb_info || !min || !max) {
5024 LOGE("NULL pointer %p %p %p", pc, min, max);
5025 return CAMERA_ERROR_INVALID_PARAMETER;
5030 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5032 if (ret == CAMERA_ERROR_NONE) {
5033 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5034 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5037 LOGD("ret : 0x%x", ret);
5043 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5049 if (!pc || !pc->cb_info || !mode) {
5050 LOGE("NULL pointer %p %p", pc, mode);
5051 return CAMERA_ERROR_INVALID_PARAMETER;
5056 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5058 if (ret == CAMERA_ERROR_NONE)
5059 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5061 LOGD("ret : 0x%x", ret);
5067 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5069 int ret = CAMERA_ERROR_NONE;
5070 camera_cli_s *pc = (camera_cli_s *)camera;
5071 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5073 if (!pc || !pc->cb_info || !mode) {
5074 LOGE("NULL pointer %p %p", pc, mode);
5075 return CAMERA_ERROR_INVALID_PARAMETER;
5080 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5082 if (ret == CAMERA_ERROR_NONE)
5083 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5085 LOGD("ret : 0x%x", ret);
5091 int camera_attr_get_exposure(camera_h camera, int *value)
5093 int ret = CAMERA_ERROR_NONE;
5094 camera_cli_s *pc = (camera_cli_s *)camera;
5095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5097 if (!pc || !pc->cb_info || !value) {
5098 LOGE("NULL pointer %p %p", pc, value);
5099 return CAMERA_ERROR_INVALID_PARAMETER;
5104 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5106 if (ret == CAMERA_ERROR_NONE)
5107 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5109 LOGD("ret : 0x%x", ret);
5115 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5117 int ret = CAMERA_ERROR_NONE;
5118 camera_cli_s *pc = (camera_cli_s *)camera;
5119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5121 if (!pc || !pc->cb_info || !min || !max) {
5122 LOGE("NULL pointer %p %p %p", pc, min, max);
5123 return CAMERA_ERROR_INVALID_PARAMETER;
5128 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5130 if (ret == CAMERA_ERROR_NONE) {
5131 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5132 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5135 LOGD("ret : 0x%x", ret);
5141 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5143 int ret = CAMERA_ERROR_NONE;
5144 camera_cli_s *pc = (camera_cli_s *)camera;
5145 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5147 if (!pc || !pc->cb_info || !iso) {
5148 LOGE("NULL pointer %p %p", pc, iso);
5149 return CAMERA_ERROR_INVALID_PARAMETER;
5154 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5156 if (ret == CAMERA_ERROR_NONE)
5157 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5159 LOGD("ret : 0x%x", ret);
5165 int camera_attr_get_brightness(camera_h camera, int *level)
5167 int ret = CAMERA_ERROR_NONE;
5168 camera_cli_s *pc = (camera_cli_s *)camera;
5169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5171 if (!pc || !pc->cb_info || !level) {
5172 LOGE("NULL pointer %p %p", pc, level);
5173 return CAMERA_ERROR_INVALID_PARAMETER;
5178 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5180 if (ret == CAMERA_ERROR_NONE)
5181 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5183 LOGD("ret : 0x%x", ret);
5189 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5191 int ret = CAMERA_ERROR_NONE;
5192 camera_cli_s *pc = (camera_cli_s *)camera;
5193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5195 if (!pc || !pc->cb_info || !min || !max) {
5196 LOGE("NULL pointer %p %p %p", pc, min, max);
5197 return CAMERA_ERROR_INVALID_PARAMETER;
5202 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5204 if (ret == CAMERA_ERROR_NONE) {
5205 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5206 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5209 LOGD("ret : 0x%x", ret);
5215 int camera_attr_get_contrast(camera_h camera, int *level)
5217 int ret = CAMERA_ERROR_NONE;
5218 camera_cli_s *pc = (camera_cli_s *)camera;
5219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5221 if (!pc || !pc->cb_info || !level) {
5222 LOGE("NULL pointer %p %p", pc, level);
5223 return CAMERA_ERROR_INVALID_PARAMETER;
5228 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5230 if (ret == CAMERA_ERROR_NONE)
5231 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5233 LOGD("ret : 0x%x", ret);
5239 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5241 int ret = CAMERA_ERROR_NONE;
5242 camera_cli_s *pc = (camera_cli_s *)camera;
5243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5245 if (!pc || !pc->cb_info || !min || !max) {
5246 LOGE("NULL pointer %p %p %p", pc, min, max);
5247 return CAMERA_ERROR_INVALID_PARAMETER;
5252 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5254 if (ret == CAMERA_ERROR_NONE) {
5255 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5256 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5257 LOGD("min %d, max %d", *min, *max);
5260 LOGD("ret : 0x%x", ret);
5266 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5268 int ret = CAMERA_ERROR_NONE;
5269 camera_cli_s *pc = (camera_cli_s *)camera;
5270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5272 if (!pc || !pc->cb_info || !wb) {
5273 LOGE("NULL pointer %p %p", pc, wb);
5274 return CAMERA_ERROR_INVALID_PARAMETER;
5279 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5281 if (ret == CAMERA_ERROR_NONE)
5282 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5284 LOGD("ret : 0x%x", ret);
5290 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5292 int ret = CAMERA_ERROR_NONE;
5293 camera_cli_s *pc = (camera_cli_s *)camera;
5294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5296 if (!pc || !pc->cb_info || !effect) {
5297 LOGE("NULL pointer %p %p", pc, effect);
5298 return CAMERA_ERROR_INVALID_PARAMETER;
5303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5305 if (ret == CAMERA_ERROR_NONE)
5306 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5308 LOGD("ret : 0x%x", ret);
5314 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5316 int ret = CAMERA_ERROR_NONE;
5317 camera_cli_s *pc = (camera_cli_s *)camera;
5318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5320 if (!pc || !pc->cb_info || !mode) {
5321 LOGE("NULL pointer %p %p", pc, mode);
5322 return CAMERA_ERROR_INVALID_PARAMETER;
5327 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5329 if (ret == CAMERA_ERROR_NONE)
5330 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5332 LOGD("ret : 0x%x", ret);
5338 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5340 int ret = CAMERA_ERROR_NONE;
5341 camera_cli_s *pc = (camera_cli_s *)camera;
5342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5344 if (!pc || !pc->cb_info || !enable) {
5345 LOGE("NULL pointer %p %p", pc, enable);
5346 return CAMERA_ERROR_INVALID_PARAMETER;
5351 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5353 if (ret == CAMERA_ERROR_NONE)
5354 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5356 LOGD("ret : 0x%x", ret);
5362 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5364 int ret = CAMERA_ERROR_NONE;
5365 camera_cli_s *pc = (camera_cli_s *)camera;
5366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5368 if (!pc || !pc->cb_info || !description) {
5369 LOGE("NULL pointer %p %p", pc, description);
5370 return CAMERA_ERROR_INVALID_PARAMETER;
5375 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5377 if (ret == CAMERA_ERROR_NONE)
5378 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5380 LOGD("ret : 0x%x", ret);
5386 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5388 int ret = CAMERA_ERROR_NONE;
5389 camera_cli_s *pc = (camera_cli_s *)camera;
5390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5392 if (!pc || !pc->cb_info || !orientation) {
5393 LOGE("NULL pointer %p %p", pc, orientation);
5394 return CAMERA_ERROR_INVALID_PARAMETER;
5399 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5401 if (ret == CAMERA_ERROR_NONE)
5402 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5404 LOGD("ret : 0x%x", ret);
5410 int camera_attr_get_tag_software(camera_h camera, char **software)
5412 int ret = CAMERA_ERROR_NONE;
5413 camera_cli_s *pc = (camera_cli_s *)camera;
5414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5416 if (!pc || !pc->cb_info || !software) {
5417 LOGE("NULL pointer %p %p", pc, software);
5418 return CAMERA_ERROR_INVALID_PARAMETER;
5423 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5425 if (ret == CAMERA_ERROR_NONE)
5426 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5428 LOGD("ret : 0x%x", ret);
5434 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5436 int ret = CAMERA_ERROR_NONE;
5437 camera_cli_s *pc = (camera_cli_s *)camera;
5438 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5440 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5441 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5442 return CAMERA_ERROR_INVALID_PARAMETER;
5447 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5449 if (ret == CAMERA_ERROR_NONE) {
5450 *latitude = pc->cb_info->get_geotag[0];
5451 *longitude = pc->cb_info->get_geotag[1];
5452 *altitude = pc->cb_info->get_geotag[2];
5455 LOGD("ret : 0x%x", ret);
5461 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5463 int ret = CAMERA_ERROR_NONE;
5464 camera_cli_s *pc = (camera_cli_s *)camera;
5465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5467 if (!pc || !pc->cb_info || !mode) {
5468 LOGE("NULL pointer %p %p", pc, mode);
5469 return CAMERA_ERROR_INVALID_PARAMETER;
5474 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5476 if (ret == CAMERA_ERROR_NONE)
5477 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5479 LOGD("ret : 0x%x", ret);
5485 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5487 int ret = CAMERA_ERROR_NONE;
5488 int get_flash_state = 0;
5491 LOGE("NULL pointer");
5492 return CAMERA_ERROR_INVALID_PARAMETER;
5495 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5496 (int)device, "get_flash_state", &get_flash_state);
5498 if (ret == CAMERA_ERROR_NONE) {
5499 *state = (camera_flash_state_e)get_flash_state;
5500 LOGD("flash state %d", *state);
5502 LOGE("failed 0x%x", ret);
5509 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5511 int ret = CAMERA_ERROR_NONE;
5512 camera_cli_s *pc = (camera_cli_s *)camera;
5513 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5515 if (!pc || !pc->cb_info || !foreach_cb) {
5516 LOGE("NULL pointer %p %p", pc, foreach_cb);
5517 return CAMERA_ERROR_INVALID_PARAMETER;
5522 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5523 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5525 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5527 LOGD("ret : 0x%x", ret);
5533 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5535 int ret = CAMERA_ERROR_NONE;
5536 camera_cli_s *pc = (camera_cli_s *)camera;
5537 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5539 if (!pc || !pc->cb_info || !foreach_cb) {
5540 LOGE("NULL pointer %p %p", pc, foreach_cb);
5541 return CAMERA_ERROR_INVALID_PARAMETER;
5546 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5547 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5549 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5551 LOGD("ret : 0x%x", ret);
5557 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5559 int ret = CAMERA_ERROR_NONE;
5560 camera_cli_s *pc = (camera_cli_s *)camera;
5561 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5563 if (!pc || !pc->cb_info || !foreach_cb) {
5564 LOGE("NULL pointer %p %p", pc, foreach_cb);
5565 return CAMERA_ERROR_INVALID_PARAMETER;
5570 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5571 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5573 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5575 LOGD("ret : 0x%x", ret);
5581 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5583 int ret = CAMERA_ERROR_NONE;
5584 camera_cli_s *pc = (camera_cli_s *)camera;
5585 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5587 if (!pc || !pc->cb_info || !foreach_cb) {
5588 LOGE("NULL pointer %p %p", pc, foreach_cb);
5589 return CAMERA_ERROR_INVALID_PARAMETER;
5594 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5595 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5597 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5599 LOGD("ret : 0x%x", ret);
5605 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5607 int ret = CAMERA_ERROR_NONE;
5608 camera_cli_s *pc = (camera_cli_s *)camera;
5609 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5611 if (!pc || !pc->cb_info || !foreach_cb) {
5612 LOGE("NULL pointer %p %p", pc, foreach_cb);
5613 return CAMERA_ERROR_INVALID_PARAMETER;
5618 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5619 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5623 LOGD("ret : 0x%x", ret);
5629 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5631 int ret = CAMERA_ERROR_NONE;
5632 camera_cli_s *pc = (camera_cli_s *)camera;
5633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5635 if (!pc || !pc->cb_info || !foreach_cb) {
5636 LOGE("NULL pointer %p %p", pc, foreach_cb);
5637 return CAMERA_ERROR_INVALID_PARAMETER;
5642 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5643 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5645 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5647 LOGD("ret : 0x%x", ret);
5653 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5655 int ret = CAMERA_ERROR_NONE;
5656 camera_cli_s *pc = (camera_cli_s *)camera;
5657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5659 if (!pc || !pc->cb_info || !foreach_cb) {
5660 LOGE("NULL pointer %p %p", pc, foreach_cb);
5661 return CAMERA_ERROR_INVALID_PARAMETER;
5666 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5667 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5671 LOGD("ret : 0x%x", ret);
5677 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5679 int ret = CAMERA_ERROR_NONE;
5680 camera_cli_s *pc = (camera_cli_s *)camera;
5681 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5683 if (!pc || !pc->cb_info || !foreach_cb) {
5684 LOGE("NULL pointer %p %p", pc, foreach_cb);
5685 return CAMERA_ERROR_INVALID_PARAMETER;
5690 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5691 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5693 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5695 LOGD("Enter, handle :%x", pc->remote_handle);
5701 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)
5703 int ret = CAMERA_ERROR_NONE;
5704 camera_cli_s *pc = (camera_cli_s *)camera;
5705 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5706 camera_msg_param param;
5709 if (!pc || !pc->cb_info || !foreach_cb) {
5710 LOGE("NULL pointer %p %p", pc, foreach_cb);
5711 return CAMERA_ERROR_INVALID_PARAMETER;
5716 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5717 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5719 value = (width << 16) | height;
5720 CAMERA_MSG_PARAM_SET(param, INT, value);
5722 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5724 LOGD("ret : 0x%x", ret);
5730 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5732 int ret = CAMERA_ERROR_NONE;
5733 camera_cli_s *pc = (camera_cli_s *)camera;
5734 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5736 if (!pc || !pc->cb_info || !foreach_cb) {
5737 LOGE("NULL pointer %p %p", pc, foreach_cb);
5738 return CAMERA_ERROR_INVALID_PARAMETER;
5743 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5744 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5746 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5748 LOGD("ret : 0x%x", ret);
5754 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5760 if (!pc || !pc->cb_info || !foreach_cb) {
5761 LOGE("NULL pointer %p %p", pc, foreach_cb);
5762 return CAMERA_ERROR_INVALID_PARAMETER;
5767 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5768 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5772 LOGD("ret : 0x%x", ret);
5778 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5780 int ret = CAMERA_ERROR_NONE;
5781 camera_cli_s *pc = (camera_cli_s *)camera;
5782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5783 camera_msg_param param;
5784 int set_rotation = (int)rotation;
5786 if (!pc || !pc->cb_info) {
5787 LOGE("NULL handle");
5788 return CAMERA_ERROR_INVALID_PARAMETER;
5793 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5795 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5797 LOGD("ret : 0x%x", ret);
5803 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5805 int ret = CAMERA_ERROR_NONE;
5806 camera_cli_s *pc = (camera_cli_s *)camera;
5807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5809 if (!pc || !pc->cb_info || !rotation) {
5810 LOGE("NULL pointer %p %p", pc, rotation);
5811 return CAMERA_ERROR_INVALID_PARAMETER;
5816 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5818 if (ret == CAMERA_ERROR_NONE)
5819 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5821 LOGD("ret : 0x%x", ret);
5827 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5829 int ret = CAMERA_ERROR_NONE;
5830 camera_cli_s *pc = (camera_cli_s *)camera;
5831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5832 camera_msg_param param;
5833 int set_flip = (int)flip;
5835 if (!pc || !pc->cb_info) {
5836 LOGE("NULL handle");
5837 return CAMERA_ERROR_INVALID_PARAMETER;
5842 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5844 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5846 LOGD("ret : 0x%x", ret);
5852 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5854 int ret = CAMERA_ERROR_NONE;
5855 camera_cli_s *pc = (camera_cli_s *)camera;
5856 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5858 if (!pc || !pc->cb_info || !flip) {
5859 LOGE("NULL pointer %p %p", pc, flip);
5860 return CAMERA_ERROR_INVALID_PARAMETER;
5865 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5867 if (ret == CAMERA_ERROR_NONE)
5868 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5870 LOGD("ret : 0x%x", ret);
5875 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5877 int ret = CAMERA_ERROR_NONE;
5878 camera_cli_s *pc = (camera_cli_s *)camera;
5879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5880 camera_msg_param param;
5881 int set_mode = (int)mode;
5883 if (!pc || !pc->cb_info) {
5884 LOGE("NULL handle");
5885 return CAMERA_ERROR_INVALID_PARAMETER;
5890 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5892 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5894 LOGD("ret : 0x%x", ret);
5900 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5902 int ret = CAMERA_ERROR_NONE;
5903 camera_cli_s *pc = (camera_cli_s *)camera;
5904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5906 if (!pc || !pc->cb_info || !mode) {
5907 LOGE("NULL pointer %p %p", pc, mode);
5908 return CAMERA_ERROR_INVALID_PARAMETER;
5913 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5915 if (ret == CAMERA_ERROR_NONE)
5916 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5918 LOGD("ret : 0x%x", ret);
5924 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5926 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5930 if (!pc || !pc->cb_info) {
5931 LOGE("NULL handle");
5932 return CAMERA_ERROR_INVALID_PARAMETER;
5937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5940 LOGE("error is occurred 0x%x", ret);
5944 LOGD("ret : %d", ret);
5950 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5952 int ret = CAMERA_ERROR_NONE;
5953 camera_cli_s *pc = (camera_cli_s *)camera;
5954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5956 if (!pc || !pc->cb_info) {
5957 LOGE("NULL handle");
5958 return CAMERA_ERROR_INVALID_PARAMETER;
5963 if (!camera_attr_is_supported_hdr_capture(camera)) {
5964 LOGE("HDR not supported");
5965 return CAMERA_ERROR_NOT_SUPPORTED;
5969 LOGE("NULL callback");
5970 return CAMERA_ERROR_INVALID_PARAMETER;
5973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5975 if (ret == CAMERA_ERROR_NONE) {
5976 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5977 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5980 LOGD("ret : 0x%x", ret);
5986 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5988 int ret = CAMERA_ERROR_NONE;
5989 camera_cli_s *pc = (camera_cli_s *)camera;
5990 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5992 if (!pc || !pc->cb_info) {
5993 LOGE("NULL handle");
5994 return CAMERA_ERROR_INVALID_PARAMETER;
5999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6001 if (ret == CAMERA_ERROR_NONE) {
6002 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6003 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6006 LOGD("ret : 0x%x", ret);
6012 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6014 int ret = CAMERA_ERROR_NONE;
6015 camera_cli_s *pc = (camera_cli_s *)camera;
6016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6017 camera_msg_param param;
6018 int set_enable = (int)enable;
6020 if (!pc || !pc->cb_info) {
6021 LOGE("NULL handle");
6022 return CAMERA_ERROR_INVALID_PARAMETER;
6027 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6029 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6031 LOGD("ret : 0x%x", ret);
6037 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6039 int ret = CAMERA_ERROR_NONE;
6040 camera_cli_s *pc = (camera_cli_s *)camera;
6041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6043 if (!pc || !pc->cb_info || !enabled) {
6044 LOGE("NULL pointer %p %p", pc, enabled);
6045 return CAMERA_ERROR_INVALID_PARAMETER;
6050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6052 if (ret == CAMERA_ERROR_NONE)
6053 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6055 LOGD("ret : 0x%x", ret);
6061 bool camera_attr_is_supported_anti_shake(camera_h camera)
6063 int ret = CAMERA_ERROR_NONE;
6064 camera_cli_s *pc = (camera_cli_s *)camera;
6065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6067 if (!pc || !pc->cb_info) {
6068 LOGE("NULL handle");
6069 return CAMERA_ERROR_INVALID_PARAMETER;
6074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6077 LOGE("error is occurred 0x%x", ret);
6081 LOGD("ret : %d", ret);
6087 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6089 int ret = CAMERA_ERROR_NONE;
6090 camera_cli_s *pc = (camera_cli_s *)camera;
6091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6092 camera_msg_param param;
6093 int set_enable = (int)enable;
6095 if (!pc || !pc->cb_info) {
6096 LOGE("NULL handle");
6097 return CAMERA_ERROR_INVALID_PARAMETER;
6102 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6104 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6106 LOGD("ret : 0x%x", ret);
6112 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6114 int ret = CAMERA_ERROR_NONE;
6115 camera_cli_s *pc = (camera_cli_s *)camera;
6116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6118 if (!pc || !pc->cb_info || !enabled) {
6119 LOGE("NULL pointer %p %p", pc, enabled);
6120 return CAMERA_ERROR_INVALID_PARAMETER;
6125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6127 if (ret == CAMERA_ERROR_NONE)
6128 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6130 LOGD("ret : 0x%x", ret);
6136 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6138 int ret = CAMERA_ERROR_NONE;
6139 camera_cli_s *pc = (camera_cli_s *)camera;
6140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6142 if (!pc || !pc->cb_info) {
6143 LOGE("NULL handle");
6144 return CAMERA_ERROR_INVALID_PARAMETER;
6149 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6152 LOGE("error is occurred 0x%x", ret);
6156 LOGD("ret : %d", ret);
6162 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6164 int ret = CAMERA_ERROR_NONE;
6165 camera_cli_s *pc = (camera_cli_s *)camera;
6166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6167 camera_msg_param param;
6168 int set_enable = (int)enable;
6170 if (!pc || !pc->cb_info) {
6171 LOGE("NULL handle");
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6177 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6179 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6181 LOGD("ret : 0x%x", ret);
6187 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6189 int ret = CAMERA_ERROR_NONE;
6190 camera_cli_s *pc = (camera_cli_s *)camera;
6191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6193 if (!pc || !pc->cb_info || !enabled) {
6194 LOGE("NULL pointer %p %p", pc, enabled);
6195 return CAMERA_ERROR_INVALID_PARAMETER;
6200 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6202 if (ret == CAMERA_ERROR_NONE)
6203 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6205 LOGD("ret : 0x%x", ret);
6211 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6213 int ret = CAMERA_ERROR_NONE;
6214 camera_cli_s *pc = (camera_cli_s *)camera;
6215 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6217 if (!pc || !pc->cb_info) {
6218 LOGE("NULL handle");
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6224 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6227 LOGE("error is occurred 0x%x", ret);
6231 LOGD("ret : %d", ret);
6237 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6239 int ret = CAMERA_ERROR_NONE;
6240 camera_cli_s *pc = (camera_cli_s *)camera;
6241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6242 camera_msg_param param;
6243 int set_disable = (int)disable;
6245 if (!pc || !pc->cb_info) {
6246 LOGE("NULL handle");
6247 return CAMERA_ERROR_INVALID_PARAMETER;
6252 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6254 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6256 LOGD("ret : 0x%x", ret);
6262 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_cli_s *pc = (camera_cli_s *)camera;
6266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6267 camera_msg_param param;
6268 int set_move_type = (int)move_type;
6271 if (!pc || !pc->cb_info) {
6272 LOGE("NULL handle");
6273 return CAMERA_ERROR_INVALID_PARAMETER;
6278 value = (set_move_type << 16) | pan_step;
6279 CAMERA_MSG_PARAM_SET(param, INT, value);
6281 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6283 LOGD("ret : 0x%x", ret);
6289 int camera_attr_get_pan(camera_h camera, int *pan_step)
6291 int ret = CAMERA_ERROR_NONE;
6292 camera_cli_s *pc = (camera_cli_s *)camera;
6293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6295 if (!pc || !pc->cb_info || !pan_step) {
6296 LOGE("NULL pointer %p %p", pc, pan_step);
6297 return CAMERA_ERROR_INVALID_PARAMETER;
6302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6304 if (ret == CAMERA_ERROR_NONE)
6305 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6307 LOGD("ret : 0x%x", ret);
6313 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
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_GET_PAN_RANGE;
6319 if (!pc || !pc->cb_info || !min || !max) {
6320 LOGE("NULL pointer %p %p", pc, min, max);
6321 return CAMERA_ERROR_INVALID_PARAMETER;
6326 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6328 if (ret == CAMERA_ERROR_NONE) {
6329 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6330 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6333 LOGD("ret : 0x%x", ret);
6339 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6341 int ret = CAMERA_ERROR_NONE;
6342 camera_cli_s *pc = (camera_cli_s *)camera;
6343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6344 camera_msg_param param;
6345 int set_move_type = (int)move_type;
6348 if (!pc || !pc->cb_info) {
6349 LOGE("NULL handle");
6350 return CAMERA_ERROR_INVALID_PARAMETER;
6355 value = (set_move_type << 16) | tilt_step;
6356 CAMERA_MSG_PARAM_SET(param, INT, value);
6358 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6360 LOGD("ret : 0x%x", ret);
6366 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6368 int ret = CAMERA_ERROR_NONE;
6369 camera_cli_s *pc = (camera_cli_s *)camera;
6370 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6372 if (!pc || !pc->cb_info || !tilt_step) {
6373 LOGE("NULL pointer %p %p", pc, tilt_step);
6374 return CAMERA_ERROR_INVALID_PARAMETER;
6379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6381 if (ret == CAMERA_ERROR_NONE)
6382 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6384 LOGD("ret : 0x%x", ret);
6390 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6392 int ret = CAMERA_ERROR_NONE;
6393 camera_cli_s *pc = (camera_cli_s *)camera;
6394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6396 if (!pc || !pc->cb_info || !min || !max) {
6397 LOGE("NULL pointer %p %p %p", pc, min, max);
6398 return CAMERA_ERROR_INVALID_PARAMETER;
6403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6405 if (ret == CAMERA_ERROR_NONE) {
6406 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6407 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6410 LOGD("ret : 0x%x", ret);
6416 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6418 int ret = CAMERA_ERROR_NONE;
6419 camera_cli_s *pc = (camera_cli_s *)camera;
6420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6421 camera_msg_param param;
6422 int set_ptz_type = (int)ptz_type;
6424 if (!pc || !pc->cb_info) {
6425 LOGE("NULL handle");
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6433 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6435 LOGD("ret : 0x%x", ret);
6441 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6443 int ret = CAMERA_ERROR_NONE;
6444 camera_cli_s *pc = (camera_cli_s *)camera;
6445 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6447 if (!pc || !pc->cb_info || !foreach_cb) {
6448 LOGE("NULL pointer %p %p", pc, foreach_cb);
6449 return CAMERA_ERROR_INVALID_PARAMETER;
6454 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6455 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6457 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6459 LOGD("ret : 0x%x", ret);
6465 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6467 int ret = CAMERA_ERROR_NONE;
6468 camera_cli_s *pc = (camera_cli_s *)camera;
6469 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6470 int set_display_roi_area[4] = {x, y, width, height};
6475 if (!pc || !pc->cb_info) {
6476 LOGE("NULL handle");
6477 return CAMERA_ERROR_INVALID_PARAMETER;
6482 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6483 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6484 g_mutex_lock(&pc->cb_info->evas_mutex);
6486 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6488 g_mutex_unlock(&pc->cb_info->evas_mutex);
6490 if (ret != MM_ERROR_NONE) {
6491 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6492 return CAMERA_ERROR_INVALID_OPERATION;
6495 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6497 length = sizeof(set_display_roi_area) / sizeof(int) + \
6498 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6500 msg = muse_core_msg_json_factory_new(api,
6501 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6504 LOGE("msg creation failed: api %d", api);
6505 return CAMERA_ERROR_OUT_OF_MEMORY;
6508 if (pc->cb_info->is_server_connected) {
6509 __camera_update_api_waiting(pc->cb_info, api, 1);
6511 g_mutex_lock(&pc->cb_info->fd_lock);
6512 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6513 g_mutex_unlock(&pc->cb_info->fd_lock);
6517 LOGE("message send failed");
6518 ret = CAMERA_ERROR_INVALID_OPERATION;
6520 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6523 __camera_update_api_waiting(pc->cb_info, api, -1);
6525 muse_core_msg_json_factory_free(msg);
6527 LOGD("ret : 0x%x", ret);
6533 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6535 camera_cli_s *pc = (camera_cli_s *)camera;
6536 int ret = CAMERA_ERROR_NONE;
6537 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6539 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6540 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6541 return CAMERA_ERROR_INVALID_PARAMETER;
6546 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6548 if (ret == CAMERA_ERROR_NONE) {
6549 *x = pc->cb_info->get_display_roi_area[0];
6550 *y = pc->cb_info->get_display_roi_area[1];
6551 *width = pc->cb_info->get_display_roi_area[2];
6552 *height = pc->cb_info->get_display_roi_area[3];
6555 LOGD("ret : 0x%x", ret);
6561 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6563 int ret = CAMERA_ERROR_NONE;
6564 int get_device_state = 0;
6567 LOGE("NULL pointer");
6568 return CAMERA_ERROR_INVALID_PARAMETER;
6571 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6572 (int)device, "get_device_state", &get_device_state);
6574 if (ret == CAMERA_ERROR_NONE) {
6575 *state = (camera_device_state_e)get_device_state;
6576 LOGD("device state %d", *state);
6578 LOGE("failed 0x%x", ret);
6585 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6587 int ret = CAMERA_ERROR_NONE;
6588 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6589 camera_cb_info *info = NULL;
6591 if (!callback || !cb_id) {
6592 LOGE("invalid pointer %p %p", callback, cb_id);
6593 return CAMERA_ERROR_INVALID_PARAMETER;
6596 /* check camera support */
6597 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6598 if (ret != CAMERA_ERROR_NONE) {
6599 LOGE("get device state failed");
6603 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6605 info = g_new0(camera_cb_info, 1);
6607 LOGE("info failed");
6608 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6612 info->id = ++g_cam_dev_state_changed_cb_id;
6613 info->callback = (void *)callback;
6614 info->user_data = user_data;
6618 /* subscribe dbus signal for camera state change */
6619 if (!g_cam_dev_state_changed_cb_conn) {
6620 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6621 if (!g_cam_dev_state_changed_cb_conn) {
6622 LOGE("failed to get gdbus connection");
6623 ret = CAMERA_ERROR_INVALID_OPERATION;
6627 LOGD("subscribe signal %s - %s - %s",
6628 MM_CAMCORDER_DBUS_OBJECT,
6629 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6630 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6632 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6633 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6634 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6635 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6636 LOGE("failed to get gdbus connection");
6637 ret = CAMERA_ERROR_INVALID_OPERATION;
6641 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6644 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6646 LOGD("callback id %d", info->id);
6649 if (ret != CAMERA_ERROR_NONE) {
6655 if (g_cam_dev_state_changed_cb_conn) {
6656 g_object_unref(g_cam_dev_state_changed_cb_conn);
6657 g_cam_dev_state_changed_cb_conn = NULL;
6661 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6667 int camera_remove_device_state_changed_cb(int cb_id)
6669 int ret = CAMERA_ERROR_NONE;
6670 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6671 GList *tmp_list = NULL;
6672 camera_cb_info *info = NULL;
6674 /* check camera support */
6675 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6676 if (ret != CAMERA_ERROR_NONE) {
6677 LOGE("get device state failed");
6681 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6683 if (!g_cam_dev_state_changed_cb_list) {
6684 LOGE("there is no callback info");
6685 ret = CAMERA_ERROR_INVALID_OPERATION;
6689 tmp_list = g_cam_dev_state_changed_cb_list;
6692 info = tmp_list->data;
6693 tmp_list = tmp_list->next;
6700 if (info->id == cb_id) {
6701 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6706 if (!g_cam_dev_state_changed_cb_list) {
6707 /* no remained callback */
6708 if (g_cam_dev_state_changed_cb_conn) {
6709 /* unsubscribe signal */
6710 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6711 g_cam_dev_state_changed_cb_subscribe_id = 0;
6713 /* unref connection */
6714 g_object_unref(g_cam_dev_state_changed_cb_conn);
6715 g_cam_dev_state_changed_cb_conn = NULL;
6719 LOGD("id %d callback removed", cb_id);
6720 ret = CAMERA_ERROR_NONE;
6726 LOGE("id %d callback not found", cb_id);
6727 ret = CAMERA_ERROR_INVALID_PARAMETER;
6730 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);