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 LOGW("all preview callback from user are NULL");
1103 } else if (cb_info->user_cb[event] == NULL) {
1104 LOGW("user callback for event %d is not set", event);
1109 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1115 muse_camera_msg_get(previous, recv_msg);
1116 muse_camera_msg_get(current, recv_msg);
1117 muse_camera_msg_get(by_policy, recv_msg);
1119 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1120 previous, current, by_policy);
1122 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1123 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1126 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1130 muse_camera_msg_get(state, recv_msg);
1132 LOGD("FOCUS state - %d", state);
1134 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1137 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1138 LOGD("CAPTURE_COMPLETED");
1139 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1141 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1142 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1146 int num_buffer_key = 0;
1147 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1149 unsigned char *buf_pos = NULL;
1151 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1152 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1153 tbm_bo data_bo = NULL;
1154 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1156 camera_preview_data_s frame;
1157 camera_stream_data_s *stream = NULL;
1158 camera_media_packet_data *mp_data = NULL;
1159 media_packet_h pkt = NULL;
1160 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1161 media_packet_h pkt_evas = NULL;
1162 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1164 muse_camera_msg_get(tbm_key, recv_msg);
1165 muse_camera_msg_get(num_buffer_key, recv_msg);
1166 muse_camera_msg_get_array(buffer_key, recv_msg);
1167 muse_camera_msg_get(data_key, recv_msg);
1169 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1172 LOGE("invalid key %d", tbm_key);
1176 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1178 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1179 LOGE("invalid num buffer key %d", num_buffer_key);
1180 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1185 /* import tbm data_bo and get virtual address */
1186 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1187 LOGE("failed to import data key %d", data_key);
1188 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1193 /* import tbm bo and get virtual address */
1194 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1195 LOGE("failed to import key %d", tbm_key);
1196 _camera_release_imported_bo(&data_bo);
1197 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1201 buf_pos = (unsigned char *)bo_handle.ptr;
1203 /* get stream info */
1204 stream = (camera_stream_data_s *)buf_pos;
1206 for (i = 0 ; i < num_buffer_key ; i++) {
1207 /* import buffer bo and get virtual address */
1208 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1209 LOGE("failed to import buffer key %d", buffer_key[i]);
1211 /* release imported bo */
1212 _camera_release_imported_bo(&data_bo);
1213 _camera_release_imported_bo(&bo);
1215 for (i -= 1 ; i >= 0 ; i--)
1216 _camera_release_imported_bo(&buffer_bo[i]);
1218 /* send return buffer */
1219 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1225 /* call preview callback */
1226 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1227 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1229 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1230 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1233 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1234 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1235 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1237 if (ret == CAMERA_ERROR_NONE) {
1238 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1239 if (ret != CAMERA_ERROR_NONE) {
1240 LOGE("create pkt for evas failed");
1241 _camera_media_packet_data_release(mp_data, cb_info);
1245 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1246 LOGW("evas renderer is not supported");
1247 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1250 /* call media packet callback */
1251 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1252 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1254 if (ret == CAMERA_ERROR_NONE) {
1255 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1257 if (ret == CAMERA_ERROR_NONE) {
1258 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1259 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1261 _camera_media_packet_data_release(mp_data, cb_info);
1267 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1268 /* call evas renderer */
1270 g_mutex_lock(&cb_info->evas_mutex);
1271 if (cb_info->run_evas_render) {
1272 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1274 LOGW("evas renderer is stopped, skip this buffer...");
1275 media_packet_destroy(pkt_evas);
1278 g_mutex_unlock(&cb_info->evas_mutex);
1280 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1282 /* send message for preview callback return */
1283 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1284 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1286 if (mp_data == NULL) {
1287 /* release imported bo */
1288 for (i = 0 ; i < num_buffer_key ; i++)
1289 _camera_release_imported_bo(&buffer_bo[i]);
1291 /* unmap and unref tbm bo */
1292 _camera_release_imported_bo(&data_bo);
1293 _camera_release_imported_bo(&bo);
1296 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1298 /*LOGD("return buffer Done");*/
1302 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1306 muse_camera_msg_get(percent, recv_msg);
1308 LOGD("HDR progress - %d \%", percent);
1310 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1313 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1319 muse_camera_msg_get(policy, recv_msg);
1320 muse_camera_msg_get(previous, recv_msg);
1321 muse_camera_msg_get(current, recv_msg);
1323 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1324 policy, previous, current);
1326 if (policy == CAMERA_POLICY_SOUND)
1327 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1328 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1329 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1330 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1331 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1333 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1334 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1337 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1340 camera_detected_face_s *faces = NULL;
1342 muse_camera_msg_get(count, recv_msg);
1343 muse_camera_msg_get(tbm_key, recv_msg);
1346 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1350 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1352 faces = bo_handle.ptr;
1356 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1359 _camera_release_imported_bo(&bo);
1363 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1364 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1365 /*LOGD("return buffer done");*/
1368 LOGE("invalid message - count %d, key %d", count, tbm_key);
1372 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1375 int current_state = 0;
1377 muse_camera_msg_get(error, recv_msg);
1378 muse_camera_msg_get(current_state, recv_msg);
1380 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1382 if (error == CAMERA_ERROR_SOUND_POLICY)
1383 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1384 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1385 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1386 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1387 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1389 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1390 (camera_state_e)current_state, cb_info->user_data[event]);
1393 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1395 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1396 muse_camera_msg_get(param1, recv_msg);
1397 muse_camera_msg_get(param2, recv_msg);
1399 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1401 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1402 cb_info->user_cb[event] = NULL;
1403 cb_info->user_data[event] = NULL;
1404 LOGW("stop foreach callback for event %d", event);
1407 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1409 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1411 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1413 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1415 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1421 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1423 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1425 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1429 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1431 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1433 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1435 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1436 muse_camera_msg_get(param1, recv_msg);
1438 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1440 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1441 cb_info->user_cb[event] = NULL;
1442 cb_info->user_data[event] = NULL;
1443 LOGW("stop foreach callback for event %d", event);
1446 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1448 camera_image_data_s *rImage = NULL;
1449 camera_image_data_s *rPostview = NULL;
1450 camera_image_data_s *rThumbnail = NULL;
1451 unsigned char *buf_pos = NULL;
1452 int tbm_key_main = 0;
1453 int tbm_key_post = 0;
1454 int tbm_key_thumb = 0;
1455 tbm_bo bo_main = NULL;
1456 tbm_bo bo_post = NULL;
1457 tbm_bo bo_thumb = NULL;
1458 tbm_bo_handle bo_main_handle = {NULL, };
1459 tbm_bo_handle bo_post_handle = {NULL, };
1460 tbm_bo_handle bo_thumb_handle = {NULL, };
1462 muse_camera_msg_get(tbm_key_main, recv_msg);
1463 muse_camera_msg_get(tbm_key_post, recv_msg);
1464 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1467 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1468 tbm_key_main, tbm_key_post, tbm_key_thumb);
1471 if (tbm_key_main <= 0) {
1472 LOGE("invalid key %d", tbm_key_main);
1476 /* import tbm bo and get virtual address */
1477 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1480 buf_pos = (unsigned char *)bo_main_handle.ptr;
1481 rImage = (camera_image_data_s *)buf_pos;
1482 rImage->data = buf_pos + sizeof(camera_image_data_s);
1483 if (rImage->exif && rImage->exif_size > 0) {
1484 rImage->exif = rImage->data + rImage->size;
1486 rImage->exif = NULL;
1487 rImage->exif_size = 0;
1490 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1491 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1493 if (tbm_key_post > 0) {
1494 /* import tbm bo and get virtual address */
1495 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1498 buf_pos = (unsigned char *)bo_post_handle.ptr;
1499 rPostview = (camera_image_data_s *)buf_pos;
1500 LOGD("rPostview->size : %d", rPostview->size);
1501 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1504 if (tbm_key_thumb > 0) {
1505 /* import tbm bo and get virtual address */
1506 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1509 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1511 rThumbnail = (camera_image_data_s *)buf_pos;
1512 LOGD("rThumbnail->size : %d", rThumbnail->size);
1513 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1516 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1518 /* unmap and unref tbm bo */
1519 _camera_release_imported_bo(&bo_main);
1522 tbm_key = tbm_key_main;
1524 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1526 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1528 if (tbm_key_post > 0) {
1529 /* unmap and unref tbm bo */
1530 _camera_release_imported_bo(&bo_post);
1533 param.value.value_INT = tbm_key_post;
1534 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1537 if (tbm_key_thumb > 0) {
1538 /* unmap and unref tbm bo */
1539 _camera_release_imported_bo(&bo_thumb);
1542 param.value.value_INT = tbm_key_thumb;
1543 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1546 LOGD("return buffer done");
1549 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1550 LOGE("render error");
1557 static bool _camera_idle_event_callback(void *data)
1559 camera_cb_info_s *cb_info = NULL;
1560 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1562 if (cam_idle_event == NULL) {
1563 LOGE("cam_idle_event is NULL");
1568 g_mutex_lock(&cam_idle_event->event_mutex);
1570 cb_info = cam_idle_event->cb_info;
1571 if (cb_info == NULL) {
1572 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1573 goto IDLE_EVENT_CALLBACK_DONE;
1576 /* remove event from list */
1577 g_mutex_lock(&cb_info->idle_event_mutex);
1579 if (cb_info->idle_event_list)
1580 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1582 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1583 g_mutex_unlock(&cb_info->idle_event_mutex);
1586 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1588 /* send signal for waiting thread */
1589 g_cond_signal(&cb_info->idle_event_cond);
1591 IDLE_EVENT_CALLBACK_DONE:
1592 /* unlock and release event */
1593 g_mutex_unlock(&cam_idle_event->event_mutex);
1594 g_mutex_clear(&cam_idle_event->event_mutex);
1596 g_free(cam_idle_event);
1597 cam_idle_event = NULL;
1602 static void *_camera_msg_handler_func(gpointer data)
1606 camera_message_s *cam_msg = NULL;
1607 camera_idle_event_s *cam_idle_event = NULL;
1608 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1609 camera_cb_info_s *cb_info = NULL;
1611 if (!handler_info || !handler_info->cb_info) {
1612 LOGE("NULL handler %p", handler_info);
1616 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1617 type = handler_info->type;
1619 LOGD("t:%d start", type);
1621 g_mutex_lock(&handler_info->mutex);
1623 while (g_atomic_int_get(&handler_info->running)) {
1624 if (g_queue_is_empty(handler_info->queue)) {
1625 /*LOGD("t:%d signal wait...", type);*/
1626 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1627 /*LOGD("t:%d signal received", type);*/
1629 if (g_atomic_int_get(&handler_info->running) == 0) {
1630 LOGD("t:%d stop event thread", type);
1635 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1637 g_mutex_unlock(&handler_info->mutex);
1639 if (cam_msg == NULL) {
1640 LOGE("t:%d NULL message", type);
1641 g_mutex_lock(&handler_info->mutex);
1647 if (api < MUSE_CAMERA_API_MAX) {
1650 g_mutex_lock(&cb_info->api_mutex[api]);
1652 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1653 if (cb_info->api_waiting[api] > 0) {
1654 cb_info->api_ret[api] = ret;
1655 cb_info->api_activating[api] = 1;
1657 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1659 g_cond_signal(&cb_info->api_cond[api]);
1661 LOGW("no waiting for this api [%d]", api);
1664 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1667 g_mutex_unlock(&cb_info->api_mutex[api]);
1668 } else if (api == MUSE_CAMERA_CB_EVENT) {
1669 switch (cam_msg->event_class) {
1670 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1671 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1673 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1674 cam_idle_event = g_new0(camera_idle_event_s, 1);
1675 if (cam_idle_event == NULL) {
1676 LOGE("t:%d cam_idle_event alloc failed", type);
1680 cam_idle_event->event = cam_msg->event;
1681 cam_idle_event->cb_info = cb_info;
1682 g_mutex_init(&cam_idle_event->event_mutex);
1683 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1685 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1687 g_mutex_lock(&cb_info->idle_event_mutex);
1688 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1689 g_mutex_unlock(&cb_info->idle_event_mutex);
1691 g_idle_add_full(G_PRIORITY_DEFAULT,
1692 (GSourceFunc)_camera_idle_event_callback,
1693 (gpointer)cam_idle_event,
1697 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1701 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1707 g_mutex_lock(&handler_info->mutex);
1710 /* remove remained event */
1711 while (!g_queue_is_empty(handler_info->queue)) {
1712 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1714 LOGD("t:%d remove camera message %p", type, cam_msg);
1718 LOGW("t:%d NULL camera message", type);
1722 g_mutex_unlock(&handler_info->mutex);
1724 LOGD("t:%d return", type);
1730 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1732 camera_idle_event_s *cam_idle_event = NULL;
1733 gboolean ret = TRUE;
1735 gint64 end_time = 0;
1737 if (cb_info == NULL) {
1738 LOGE("cb_info is NULL");
1742 g_mutex_lock(&cb_info->idle_event_mutex);
1744 if (cb_info->idle_event_list == NULL) {
1745 LOGD("No remained idle event");
1746 g_mutex_unlock(&cb_info->idle_event_mutex);
1750 list = cb_info->idle_event_list;
1753 cam_idle_event = list->data;
1754 list = g_list_next(list);
1756 if (!cam_idle_event) {
1757 LOGW("Fail to remove idle event. The event is NULL");
1761 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1762 ret = g_idle_remove_by_data(cam_idle_event);
1764 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1767 cam_idle_event->cb_info = NULL;
1768 LOGW("idle event %p will be called later", cam_idle_event);
1771 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1773 g_mutex_unlock(&cam_idle_event->event_mutex);
1776 g_mutex_clear(&cam_idle_event->event_mutex);
1778 g_free(cam_idle_event);
1779 cam_idle_event = NULL;
1781 LOGD("remove idle event done");
1787 LOGW("event lock failed. it's being called...");
1789 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1791 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1792 LOGW("signal received");
1797 g_list_free(cb_info->idle_event_list);
1798 cb_info->idle_event_list = NULL;
1800 g_mutex_unlock(&cb_info->idle_event_mutex);
1806 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1808 camera_message_s *cam_msg = NULL;
1810 if (!cb_info || !msg) {
1811 LOGE("NULL pointer %p %p", cb_info, msg);
1815 cam_msg = g_new0(camera_message_s, 1);
1817 LOGE("failed to alloc cam_msg for [%s]", msg);
1822 cam_msg->event = event;
1823 cam_msg->event_class = event_class;
1825 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1827 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1829 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1830 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1831 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1832 g_cond_signal(&cb_info->preview_cb_info.cond);
1833 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1834 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1835 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1836 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1837 g_cond_signal(&cb_info->capture_cb_info.cond);
1838 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1840 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1841 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1842 g_cond_signal(&cb_info->msg_handler_info.cond);
1843 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1852 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1854 int ret = CAMERA_ERROR_NONE;
1858 int event_class = -1;
1862 if (!cb_info || !msg) {
1863 LOGE("invalid ptr %p %p", cb_info, msg);
1867 /*LOGD("msg [%s]", msg);*/
1869 if (!muse_camera_msg_get(api, msg)) {
1870 LOGE("failed to get camera api");
1874 if (api == MUSE_CAMERA_CB_EVENT) {
1875 if (!muse_camera_msg_get(event, msg) ||
1876 !muse_camera_msg_get(event_class, msg)) {
1877 LOGE("failed to get camera event or event_class [%s]", msg);
1881 if (!muse_camera_msg_get(api_class, msg)) {
1882 LOGE("failed to get camera api_class [%s]", msg);
1887 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1888 if (api >= MUSE_CAMERA_API_MAX) {
1889 LOGE("invalid api %d", api);
1893 if (!muse_camera_msg_get(ret, msg)) {
1894 LOGE("failed to get camera ret");
1898 g_mutex_lock(&cb_info->api_mutex[api]);
1901 case MUSE_CAMERA_API_CREATE:
1902 if (ret != CAMERA_ERROR_NONE) {
1903 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1904 LOGE("camera create error 0x%x. close client cb handler", ret);
1907 case MUSE_CAMERA_API_DESTROY:
1908 if (ret == CAMERA_ERROR_NONE) {
1909 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1910 LOGD("camera destroy done. close client cb handler");
1914 muse_camera_msg_get(get_type, msg);
1915 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1916 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1917 muse_camera_msg_get(get_index, msg);
1920 case MUSE_CAMERA_GET_TYPE_INT:
1921 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1923 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1924 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1925 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1927 case MUSE_CAMERA_GET_TYPE_ARRAY:
1928 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1929 muse_core_msg_json_deserialize("get_value",
1930 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1931 LOGD("get display roi %d,%d,%dx%d",
1932 cb_info->get_display_roi_area[0],
1933 cb_info->get_display_roi_area[1],
1934 cb_info->get_display_roi_area[2],
1935 cb_info->get_display_roi_area[3]);
1937 muse_core_msg_json_deserialize("get_value",
1938 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1939 LOGD("get geotag %lf, %lf, %lf",
1940 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1943 case MUSE_CAMERA_GET_TYPE_STRING:
1944 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1947 LOGW("unknown type %d", get_type);
1954 if (cb_info->api_waiting[api] > 0) {
1955 cb_info->api_ret[api] = ret;
1956 cb_info->api_activating[api] = 1;
1958 g_cond_signal(&cb_info->api_cond[api]);
1960 LOGW("no waiting for this api [%d]", api);
1963 g_mutex_unlock(&cb_info->api_mutex[api]);
1964 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1965 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1967 LOGW("unknown camera api %d, class %d", api, api_class);
1974 static void *_camera_msg_recv_func(gpointer data)
1976 int recv_length = 0;
1977 int single_length = 0;
1978 int remained_length = 0;
1979 char *recv_msg = NULL;
1980 char *single_msg = NULL;
1981 char *remained_msg = NULL;
1985 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1988 LOGE("cb_info NULL");
1994 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1996 LOGE("single_msg malloc failed");
2000 recv_msg = cb_info->recv_msg;
2002 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2003 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
2004 if (recv_length <= 0) {
2005 cb_info->is_server_connected = FALSE;
2006 LOGE("receive msg failed - server disconnected");
2014 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2016 /* Need to split the combined entering msgs */
2017 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2018 if (recv_msg[cur_pos] == '}') {
2019 single_length = cur_pos - prev_pos + 1;
2021 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2022 /* check remained msg */
2023 if (remained_length > 0) {
2025 strncpy(single_msg, remained_msg, remained_length);
2026 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2027 single_msg[remained_length + single_length] = '\0';
2030 remained_msg = NULL;
2032 strncpy(single_msg, recv_msg + prev_pos, single_length);
2033 single_msg[single_length] = '\0';
2034 LOGE("lost msg [%s], skip...", single_msg);
2037 remained_length = 0;
2039 strncpy(single_msg, recv_msg + prev_pos, single_length);
2040 single_msg[single_length] = '\0';
2043 if (single_msg[0] == '{') {
2045 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2046 /* process each message */
2047 __camera_process_msg(cb_info, single_msg);
2049 LOGE("invalid msg [%s]", single_msg);
2052 LOGE("too long message [len %d] skip...", single_length);
2055 prev_pos = cur_pos + 1;
2059 /* check incompleted message */
2060 if (recv_msg[recv_length - 1] != '}') {
2061 remained_length = recv_length - prev_pos;
2063 LOGW("incompleted message [len %d]", remained_length);
2065 remained_msg = (char *)malloc(remained_length + 1);
2067 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2068 remained_msg[remained_length] = '\0';
2070 LOGE("failed to alloc for remained msg");
2073 remained_length = 0;
2077 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2079 if (!cb_info->is_server_connected) {
2080 /* send error msg for server disconnection */
2081 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2082 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2083 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2087 LOGE("error_msg failed");
2088 goto CB_HANDLER_EXIT;
2091 __camera_add_msg_to_queue(cb_info,
2092 MUSE_CAMERA_CB_EVENT,
2093 MUSE_CAMERA_EVENT_TYPE_ERROR,
2094 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2097 muse_core_msg_json_factory_free(error_msg);
2100 LOGE("add error msg for service disconnection done");
2111 remained_msg = NULL;
2118 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2119 int type, const char *thread_name, camera_cb_info_s *cb_info)
2121 if (!handler_info || !thread_name || !cb_info) {
2122 LOGE("t:%d NULL %p %p %p",
2123 type, handler_info, thread_name, cb_info);
2129 handler_info->type = type;
2130 handler_info->queue = g_queue_new();
2131 if (handler_info->queue == NULL) {
2132 LOGE("t:%d queue failed", type);
2136 g_mutex_init(&handler_info->mutex);
2137 g_cond_init(&handler_info->cond);
2139 handler_info->cb_info = (void *)cb_info;
2140 g_atomic_int_set(&handler_info->running, 1);
2142 handler_info->thread = g_thread_try_new(thread_name,
2143 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2144 if (handler_info->thread == NULL) {
2145 LOGE("t:%d thread failed", type);
2147 g_mutex_clear(&handler_info->mutex);
2148 g_cond_clear(&handler_info->cond);
2149 g_queue_free(handler_info->queue);
2150 handler_info->queue = NULL;
2155 LOGD("t:%d done", type);
2161 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2165 if (!handler_info) {
2166 LOGE("NULL handler");
2170 if (!handler_info->thread) {
2171 LOGW("thread is not created");
2175 type = handler_info->type;
2177 LOGD("t:%d thread %p", type, handler_info->thread);
2179 g_mutex_lock(&handler_info->mutex);
2180 g_atomic_int_set(&handler_info->running, 0);
2181 g_cond_signal(&handler_info->cond);
2182 g_mutex_unlock(&handler_info->mutex);
2184 g_thread_join(handler_info->thread);
2185 handler_info->thread = NULL;
2187 g_mutex_clear(&handler_info->mutex);
2188 g_cond_clear(&handler_info->cond);
2189 g_queue_free(handler_info->queue);
2190 handler_info->queue = NULL;
2192 LOGD("t:%d done", type);
2198 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2200 camera_cb_info_s *cb_info = NULL;
2203 g_return_val_if_fail(sockfd > 0, NULL);
2205 cb_info = g_new0(camera_cb_info_s, 1);
2206 if (cb_info == NULL) {
2207 LOGE("cb_info failed");
2211 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2213 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2214 g_mutex_init(&cb_info->api_mutex[i]);
2215 g_cond_init(&cb_info->api_cond[i]);
2218 g_mutex_init(&cb_info->fd_lock);
2219 g_mutex_init(&cb_info->idle_event_mutex);
2220 g_cond_init(&cb_info->idle_event_cond);
2221 g_mutex_init(&cb_info->mp_data_mutex);
2222 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2223 g_mutex_init(&cb_info->evas_mutex);
2224 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2226 /* message handler thread */
2227 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2228 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2229 LOGE("msg_handler_info failed");
2233 /* message handler thread for preview callback */
2234 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2235 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2236 LOGE("preview_cb_info failed");
2240 /* message handler thread for capture callback */
2241 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2242 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2243 LOGE("capture_cb_info failed");
2247 cb_info->fd = sockfd;
2248 cb_info->preview_cb_flag = 0;
2249 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2250 cb_info->evas_info = NULL;
2251 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2253 /* message receive thread */
2254 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2255 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2256 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2257 if (cb_info->msg_recv_thread == NULL) {
2258 LOGE("message receive thread creation failed");
2262 cb_info->is_server_connected = TRUE;
2268 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2269 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2270 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2272 g_mutex_clear(&cb_info->fd_lock);
2273 g_mutex_clear(&cb_info->idle_event_mutex);
2274 g_cond_clear(&cb_info->idle_event_cond);
2275 g_mutex_clear(&cb_info->mp_data_mutex);
2276 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2277 g_mutex_clear(&cb_info->evas_mutex);
2278 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2280 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2281 g_mutex_clear(&cb_info->api_mutex[i]);
2282 g_cond_clear(&cb_info->api_cond[i]);
2292 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2296 g_return_if_fail(cb_info != NULL);
2298 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2300 g_thread_join(cb_info->msg_recv_thread);
2301 cb_info->msg_recv_thread = NULL;
2303 LOGD("msg_recv thread removed");
2305 /* destroy msg handler threads */
2306 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2307 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2308 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2310 g_mutex_clear(&cb_info->fd_lock);
2311 g_mutex_clear(&cb_info->idle_event_mutex);
2312 g_cond_clear(&cb_info->idle_event_cond);
2313 g_mutex_clear(&cb_info->mp_data_mutex);
2314 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2315 g_mutex_clear(&cb_info->evas_mutex);
2316 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2318 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2319 g_mutex_clear(&cb_info->api_mutex[i]);
2320 g_cond_clear(&cb_info->api_cond[i]);
2323 if (cb_info->fd > -1) {
2324 muse_core_connection_close(cb_info->fd);
2328 if (cb_info->bufmgr) {
2329 tbm_bufmgr_deinit(cb_info->bufmgr);
2330 cb_info->bufmgr = NULL;
2332 if (cb_info->pkt_fmt) {
2333 media_format_unref(cb_info->pkt_fmt);
2334 cb_info->pkt_fmt = NULL;
2337 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2338 if (cb_info->evas_info)
2339 mm_evas_renderer_destroy(&cb_info->evas_info);
2340 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2342 cb_info->preview_cb_flag = 0;
2351 int _camera_start_evas_rendering(camera_h camera)
2353 int ret = CAMERA_ERROR_NONE;
2354 camera_cli_s *pc = (camera_cli_s *)camera;
2356 if (!pc || !pc->cb_info) {
2357 LOGE("NULL handle");
2358 return CAMERA_ERROR_INVALID_PARAMETER;
2363 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2364 LOGE("EVAS surface is not set");
2365 return CAMERA_ERROR_NONE;
2368 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2369 g_mutex_lock(&pc->cb_info->evas_mutex);
2371 /* set evas render flag as RUN */
2372 pc->cb_info->run_evas_render = true;
2373 ret = CAMERA_ERROR_NONE;
2375 g_mutex_unlock(&pc->cb_info->evas_mutex);
2376 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2377 LOGW("evas renderer is not supported");
2378 ret = CAMERA_ERROR_NOT_SUPPORTED;
2379 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2385 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2387 int ret = CAMERA_ERROR_NONE;
2388 camera_cli_s *pc = (camera_cli_s *)camera;
2390 if (!pc || !pc->cb_info) {
2391 LOGE("NULL handle");
2392 return CAMERA_ERROR_INVALID_PARAMETER;
2395 LOGD("stop - keep screen %d", keep_screen);
2397 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2398 LOGE("EVAS surface is not set");
2399 return CAMERA_ERROR_NONE;
2402 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2403 g_mutex_lock(&pc->cb_info->evas_mutex);
2405 /* set evas render flag as STOP and release buffers */
2406 pc->cb_info->run_evas_render = false;
2408 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2409 if (ret != MM_ERROR_NONE) {
2410 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2411 ret = CAMERA_ERROR_INVALID_OPERATION;
2414 g_mutex_unlock(&pc->cb_info->evas_mutex);
2415 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2416 LOGW("evas renderer is not supported");
2417 ret = CAMERA_ERROR_NOT_SUPPORTED;
2418 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2424 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2426 int ret = CAMERA_ERROR_NONE;
2429 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2431 /* create muse connection */
2432 if (!key || !value) {
2433 LOGE("NULL pointer");
2434 return CAMERA_ERROR_INVALID_PARAMETER;
2437 sock_fd = muse_core_client_new();
2439 LOGE("muse_core_client_new failed");
2440 return CAMERA_ERROR_INVALID_OPERATION;
2443 msg = muse_core_msg_json_factory_new(api,
2444 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2445 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2449 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2453 ret = muse_core_ipc_send_msg(sock_fd, msg);
2455 muse_core_msg_json_factory_free(msg);
2459 LOGE("send msg failed");
2460 ret = CAMERA_ERROR_INVALID_OPERATION;
2464 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2466 LOGE("recv msg failed %d", errno);
2467 ret = CAMERA_ERROR_INVALID_OPERATION;
2471 if (!muse_camera_msg_get(ret, recv_msg)) {
2472 LOGE("failed to get return value from msg [%s]", recv_msg);
2473 ret = CAMERA_ERROR_INVALID_OPERATION;
2477 if (ret == CAMERA_ERROR_NONE)
2478 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2480 LOGD("api %d - value %d", api, *value);
2484 muse_core_connection_close(sock_fd);
2492 int camera_create(camera_device_e device, camera_h *camera)
2495 char *send_msg = NULL;
2497 int ret = CAMERA_ERROR_NONE;
2499 camera_cli_s *pc = NULL;
2500 tbm_bufmgr bufmgr = NULL;
2502 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2503 muse_core_api_module_e muse_module = MUSE_CAMERA;
2504 int device_type = (int)device;
2507 LOGE("NULL pointer");
2508 return CAMERA_ERROR_INVALID_PARAMETER;
2511 sock_fd = muse_core_client_new();
2513 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2514 ret = CAMERA_ERROR_INVALID_OPERATION;
2520 send_msg = muse_core_msg_json_factory_new(api,
2521 MUSE_TYPE_INT, "module", muse_module,
2522 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2523 MUSE_TYPE_INT, "pid", pid,
2528 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2532 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2534 muse_core_msg_json_factory_free(send_msg);
2538 LOGE("send msg failed %d", errno);
2539 ret = CAMERA_ERROR_INVALID_OPERATION;
2543 pc = g_new0(camera_cli_s, 1);
2545 LOGE("camera_cli_s alloc failed");
2546 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2550 bufmgr = tbm_bufmgr_init(-1);
2551 if (bufmgr == NULL) {
2552 LOGE("get tbm bufmgr failed");
2553 ret = CAMERA_ERROR_INVALID_OPERATION;
2557 pc->cb_info = _camera_client_callback_new(sock_fd);
2558 if (pc->cb_info == NULL) {
2559 LOGE("cb_info alloc failed");
2560 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2566 LOGD("cb info : %d", pc->cb_info->fd);
2568 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_NO_TIMEOUT);
2570 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2572 if (ret == CAMERA_ERROR_NONE) {
2573 intptr_t handle = 0;
2574 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2576 LOGE("Receiving Handle Failed!!");
2577 ret = CAMERA_ERROR_INVALID_OPERATION;
2581 pc->remote_handle = handle;
2582 pc->cb_info->bufmgr = bufmgr;
2584 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2585 if (ret != CAMERA_ERROR_NONE) {
2586 LOGE("init display failed 0x%x", ret);
2590 LOGD("camera create 0x%x", pc->remote_handle);
2591 *camera = (camera_h)pc;
2600 tbm_bufmgr_deinit(bufmgr);
2605 muse_core_connection_close(sock_fd);
2611 _camera_client_callback_destroy(pc->cb_info);
2618 LOGE("camera create error : 0x%x", ret);
2624 int camera_change_device(camera_h camera, camera_device_e device)
2627 int ret = CAMERA_ERROR_NONE;
2628 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2629 camera_cli_s *pc = (camera_cli_s *)camera;
2630 camera_msg_param param;
2632 if (!pc || !pc->cb_info) {
2633 LOGE("NULL handle");
2634 return CAMERA_ERROR_INVALID_PARAMETER;
2637 CAMERA_MSG_PARAM_SET(param, INT, device);
2639 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2641 if (ret == CAMERA_ERROR_NONE) {
2642 /* reset callback and user data */
2643 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2644 pc->cb_info->user_cb[i] = NULL;
2645 pc->cb_info->user_data[i] = NULL;
2647 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2654 int camera_destroy(camera_h camera)
2656 int ret = CAMERA_ERROR_NONE;
2657 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2658 camera_cli_s *pc = (camera_cli_s *)camera;
2660 if (!pc || !pc->cb_info) {
2661 LOGE("NULL handle");
2662 return CAMERA_ERROR_INVALID_PARAMETER;
2667 if (pc->cb_info->is_server_connected)
2668 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2670 LOGW("server disconnected. release resource without send message.");
2672 if (ret == CAMERA_ERROR_NONE) {
2673 _camera_remove_idle_event_all(pc->cb_info);
2674 _camera_client_callback_destroy(pc->cb_info);
2684 int camera_start_preview(camera_h camera)
2686 int ret = CAMERA_ERROR_NONE;
2687 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2688 camera_cli_s *pc = (camera_cli_s *)camera;
2690 if (!pc || !pc->cb_info) {
2691 LOGE("NULL handle");
2692 return CAMERA_ERROR_INVALID_PARAMETER;
2697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2698 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2699 ret = _camera_start_evas_rendering(camera);
2700 if (ret != CAMERA_ERROR_NONE) {
2701 LOGE("stop preview because of error");
2702 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2706 LOGD("ret : 0x%x", ret);
2712 int camera_stop_preview(camera_h camera)
2714 int ret = CAMERA_ERROR_NONE;
2715 camera_cli_s *pc = (camera_cli_s *)camera;
2716 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2717 camera_state_e current_state = CAMERA_STATE_NONE;
2719 if (!pc || !pc->cb_info) {
2720 LOGE("NULL handle");
2721 return CAMERA_ERROR_INVALID_PARAMETER;
2726 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2727 ret = camera_get_state(camera, ¤t_state);
2728 if (ret != CAMERA_ERROR_NONE) {
2729 LOGE("failed to get current state 0x%x", ret);
2733 if (current_state == CAMERA_STATE_PREVIEW) {
2734 ret = _camera_stop_evas_rendering(camera, false);
2735 if (ret != CAMERA_ERROR_NONE)
2740 /* send stop preview message */
2741 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2743 if (ret != CAMERA_ERROR_NONE &&
2744 current_state == CAMERA_STATE_PREVIEW) {
2745 LOGW("restart evas rendering");
2746 _camera_start_evas_rendering(camera);
2749 LOGD("ret : 0x%x", ret);
2755 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2757 int ret = CAMERA_ERROR_NONE;
2758 camera_cli_s *pc = (camera_cli_s *)camera;
2759 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2761 if (!pc || !pc->cb_info) {
2762 LOGE("NULL handle");
2763 return CAMERA_ERROR_INVALID_PARAMETER;
2768 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2769 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2771 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2772 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2774 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2776 LOGD("ret : 0x%x", ret);
2782 bool camera_is_supported_continuous_capture(camera_h camera)
2784 int ret = CAMERA_ERROR_NONE;
2785 camera_cli_s *pc = (camera_cli_s *)camera;
2786 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2788 if (!pc || !pc->cb_info) {
2789 LOGE("NULL handle");
2790 return CAMERA_ERROR_INVALID_PARAMETER;
2795 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2798 LOGE("error is occurred 0x%x", ret);
2802 LOGD("ret : %d", ret);
2808 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)
2810 int ret = CAMERA_ERROR_NONE;
2811 camera_cli_s *pc = (camera_cli_s *)camera;
2812 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2813 camera_msg_param param;
2816 if (!pc || !pc->cb_info) {
2817 LOGE("NULL handle");
2818 return CAMERA_ERROR_INVALID_PARAMETER;
2823 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2824 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2826 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2827 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2829 value = (count << 16) | interval;
2830 CAMERA_MSG_PARAM_SET(param, INT, value);
2832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2834 LOGD("ret : 0x%x", ret);
2840 int camera_stop_continuous_capture(camera_h camera)
2842 int ret = CAMERA_ERROR_NONE;
2843 camera_cli_s *pc = (camera_cli_s *)camera;
2844 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2846 if (!pc || !pc->cb_info) {
2847 LOGE("NULL handle");
2848 return CAMERA_ERROR_INVALID_PARAMETER;
2853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2855 LOGD("ret : 0x%x", ret);
2861 bool camera_is_supported_face_detection(camera_h camera)
2863 int ret = CAMERA_ERROR_NONE;
2864 camera_cli_s *pc = (camera_cli_s *)camera;
2865 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2867 if (!pc || !pc->cb_info) {
2868 LOGE("NULL handle");
2869 return CAMERA_ERROR_INVALID_PARAMETER;
2874 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2877 LOGE("error is occurred 0x%x", ret);
2881 LOGD("ret : %d", ret);
2887 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2889 int ret = CAMERA_ERROR_NONE;
2890 camera_cli_s *pc = (camera_cli_s *)camera;
2891 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2893 if (!pc || !pc->cb_info) {
2894 LOGE("NULL handle");
2895 return CAMERA_ERROR_INVALID_PARAMETER;
2900 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2903 LOGE("error is occurred 0x%x", ret);
2907 LOGD("ret : %d", ret);
2913 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2915 int ret = CAMERA_ERROR_NONE;
2916 camera_cli_s *pc = (camera_cli_s *)camera;
2917 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2919 if (!pc || !pc->cb_info) {
2920 LOGE("NULL handle");
2921 return CAMERA_ERROR_INVALID_PARAMETER;
2926 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2929 LOGE("error is occurred 0x%x", ret);
2933 LOGD("ret : %d", ret);
2938 int camera_get_device_count(camera_h camera, int *device_count)
2940 int ret = CAMERA_ERROR_NONE;
2941 camera_cli_s *pc = (camera_cli_s *)camera;
2942 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2944 if (!pc || !pc->cb_info) {
2945 LOGE("NULL handle");
2946 return CAMERA_ERROR_INVALID_PARAMETER;
2951 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2953 if (ret == CAMERA_ERROR_NONE)
2954 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2956 LOGD("ret : 0x%x", ret);
2961 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2963 int ret = CAMERA_ERROR_NONE;
2964 camera_cli_s *pc = (camera_cli_s *)camera;
2965 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2967 if (!pc || !pc->cb_info) {
2968 LOGE("NULL handle");
2969 return CAMERA_ERROR_INVALID_PARAMETER;
2974 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2975 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2977 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2979 LOGD("ret : 0x%x", ret);
2984 int camera_stop_face_detection(camera_h camera)
2986 int ret = CAMERA_ERROR_NONE;
2987 camera_cli_s *pc = (camera_cli_s *)camera;
2988 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2990 if (!pc || !pc->cb_info) {
2991 LOGE("NULL handle");
2992 return CAMERA_ERROR_INVALID_PARAMETER;
2997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2999 LOGD("ret : 0x%x", ret);
3004 int camera_get_state(camera_h camera, camera_state_e *state)
3006 int ret = CAMERA_ERROR_NONE;
3007 camera_cli_s *pc = (camera_cli_s *)camera;
3008 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3010 if (!pc || !pc->cb_info || !state) {
3011 LOGE("NULL pointer %p %p", pc, state);
3012 return CAMERA_ERROR_INVALID_PARAMETER;
3017 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3019 if (ret == CAMERA_ERROR_NONE)
3020 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3022 LOGD("ret : 0x%x", ret);
3027 int camera_start_focusing(camera_h camera, bool continuous)
3029 int ret = CAMERA_ERROR_NONE;
3030 camera_cli_s *pc = (camera_cli_s *)camera;
3031 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3032 camera_msg_param param;
3033 int is_continuous = (int)continuous;
3035 if (!pc || !pc->cb_info) {
3036 LOGE("NULL handle");
3037 return CAMERA_ERROR_INVALID_PARAMETER;
3042 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3044 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3046 LOGD("ret : 0x%x", ret);
3051 int camera_cancel_focusing(camera_h camera)
3053 int ret = CAMERA_ERROR_NONE;
3054 camera_cli_s *pc = (camera_cli_s *)camera;
3055 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3057 if (!pc || !pc->cb_info) {
3058 LOGE("NULL handle");
3059 return CAMERA_ERROR_INVALID_PARAMETER;
3062 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3064 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3066 LOGD("ret : 0x%x", ret);
3071 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3073 int ret = CAMERA_ERROR_NONE;
3074 void *set_display_handle = NULL;
3075 Evas_Object *obj = NULL;
3076 const char *object_type = NULL;
3077 camera_cli_s *pc = (camera_cli_s *)camera;
3078 camera_cb_info_s *cb_info = NULL;
3079 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3080 camera_state_e current_state = CAMERA_STATE_NONE;
3081 camera_msg_param param;
3085 if (!pc || !pc->cb_info) {
3086 LOGE("NULL handle");
3087 return CAMERA_ERROR_INVALID_PARAMETER;
3090 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3091 LOGE("invalid type %d", type);
3092 return CAMERA_ERROR_INVALID_PARAMETER;
3095 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3096 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3097 return CAMERA_ERROR_INVALID_PARAMETER;
3100 cb_info = (camera_cb_info_s *)pc->cb_info;
3102 ret = camera_get_state(camera, ¤t_state);
3103 if (ret != CAMERA_ERROR_NONE) {
3104 LOGE("failed to get current state 0x%x", ret);
3108 if (current_state != CAMERA_STATE_CREATED) {
3109 LOGE("INVALID_STATE : current %d", current_state);
3110 return CAMERA_ERROR_INVALID_STATE;
3113 LOGD("Enter - display : %p", display);
3115 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3116 set_display_handle = 0;
3117 LOGD("display type NONE");
3119 obj = (Evas_Object *)display;
3120 object_type = evas_object_type_get(obj);
3122 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3123 /* get wayland parent id */
3124 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3125 LOGE("failed to get wayland info");
3126 return CAMERA_ERROR_INVALID_OPERATION;
3129 set_display_handle = (void *)&pc->wl_info;
3130 LOGD("display type OVERLAY : handle %p", set_display_handle);
3131 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3132 /* evas object surface */
3133 set_display_handle = (void *)display;
3134 LOGD("display type EVAS : handle %p", set_display_handle);
3136 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3137 g_mutex_lock(&cb_info->evas_mutex);
3139 if (cb_info->evas_info) {
3140 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3141 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3142 if (ret != MM_ERROR_NONE) {
3143 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3144 g_mutex_unlock(&cb_info->evas_mutex);
3145 return CAMERA_ERROR_INVALID_OPERATION;
3149 /* create evas renderer */
3150 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3151 if (ret == MM_ERROR_NONE) {
3152 camera_flip_e flip = CAMERA_FLIP_NONE;
3153 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3154 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3161 camera_get_display_flip(camera, &flip);
3162 camera_get_display_mode(camera, &mode);
3163 camera_get_display_rotation(camera, &rotation);
3164 camera_is_display_visible(camera, &visible);
3165 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3167 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3168 flip, mode, rotation, visible, x, y, width, height);
3170 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3171 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3172 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3173 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3175 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3176 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3179 g_mutex_unlock(&cb_info->evas_mutex);
3181 if (ret != MM_ERROR_NONE) {
3182 LOGE("mm_evas_renderer error 0x%x", ret);
3183 return CAMERA_ERROR_INVALID_OPERATION;
3185 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3186 LOGE("EVAS surface is not supported");
3187 return CAMERA_ERROR_NOT_SUPPORTED;
3188 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3190 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3191 return CAMERA_ERROR_INVALID_PARAMETER;
3194 LOGE("failed to get evas object type from %p", obj);
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3199 pc->display_handle = (intptr_t)set_display_handle;
3201 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3204 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3205 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3207 msg = muse_core_msg_json_factory_new(api,
3208 MUSE_TYPE_INT, "type", type,
3209 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3212 LOGE("msg creation failed: api %d", api);
3213 return CAMERA_ERROR_OUT_OF_MEMORY;
3216 if (pc->cb_info->is_server_connected) {
3217 __camera_update_api_waiting(pc->cb_info, api, 1);
3219 g_mutex_lock(&pc->cb_info->fd_lock);
3220 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3221 g_mutex_unlock(&pc->cb_info->fd_lock);
3225 LOGE("message send failed");
3226 ret = CAMERA_ERROR_INVALID_OPERATION;
3228 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3231 __camera_update_api_waiting(pc->cb_info, api, -1);
3233 muse_core_msg_json_factory_free(msg);
3235 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3236 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3237 pc->wl_info.window_width, pc->wl_info.window_height);
3239 CAMERA_MSG_PARAM_SET(param, INT, type);
3241 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3244 if (ret != CAMERA_ERROR_NONE)
3245 LOGE("set display error 0x%x", ret);
3246 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3247 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3253 int camera_set_preview_resolution(camera_h camera, int width, int height)
3255 int ret = CAMERA_ERROR_NONE;
3256 camera_state_e current_state = CAMERA_STATE_NONE;
3257 camera_cli_s *pc = (camera_cli_s *)camera;
3258 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3259 camera_msg_param param;
3262 if (!pc || !pc->cb_info) {
3263 LOGE("NULL handle");
3264 return CAMERA_ERROR_INVALID_PARAMETER;
3267 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3268 ret = camera_get_state(camera, ¤t_state);
3269 if (ret != CAMERA_ERROR_NONE) {
3270 LOGE("failed to get current state 0x%x", ret);
3274 if (current_state == CAMERA_STATE_PREVIEW) {
3275 ret = _camera_stop_evas_rendering(camera, true);
3276 if (ret != CAMERA_ERROR_NONE)
3281 value = (width << 16) | height;
3282 CAMERA_MSG_PARAM_SET(param, INT, value);
3284 LOGD("%dx%d -> 0x%x", width, height, value);
3286 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3288 LOGD("ret : 0x%x", ret);
3290 if (current_state == CAMERA_STATE_PREVIEW) {
3291 LOGW("restart evas rendering");
3292 _camera_start_evas_rendering(camera);
3299 int camera_set_capture_resolution(camera_h camera, int width, int height)
3301 int ret = CAMERA_ERROR_NONE;
3302 camera_cli_s *pc = (camera_cli_s *)camera;
3303 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3304 camera_msg_param param;
3307 if (!pc || !pc->cb_info) {
3308 LOGE("NULL handle");
3309 return CAMERA_ERROR_INVALID_PARAMETER;
3314 value = (width << 16) | height;
3315 CAMERA_MSG_PARAM_SET(param, INT, value);
3317 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3319 LOGD("ret : 0x%x", ret);
3325 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3327 int ret = CAMERA_ERROR_NONE;
3328 int set_format = (int)format;
3329 camera_cli_s *pc = (camera_cli_s *)camera;
3330 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3331 camera_msg_param param;
3333 if (!pc || !pc->cb_info) {
3334 LOGE("NULL handle");
3335 return CAMERA_ERROR_INVALID_PARAMETER;
3338 LOGD("Enter - format %d", set_format);
3340 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3342 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3344 LOGD("ret : 0x%x", ret);
3350 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3352 int ret = CAMERA_ERROR_NONE;
3353 int set_format = (int)format;
3354 camera_msg_param param;
3355 camera_cli_s *pc = (camera_cli_s *)camera;
3356 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3358 if (!pc || !pc->cb_info) {
3359 LOGE("NULL handle");
3360 return CAMERA_ERROR_INVALID_PARAMETER;
3363 LOGD("Enter - capture_format %d", set_format);
3365 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3367 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3369 LOGD("ret : 0x%x", ret);
3375 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3377 int ret = CAMERA_ERROR_NONE;
3378 camera_cli_s *pc = (camera_cli_s *)camera;
3379 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3381 if (!pc || !pc->cb_info || !width || !height) {
3382 LOGE("NULL pointer %p %p %p", pc, width, height);
3383 return CAMERA_ERROR_INVALID_PARAMETER;
3388 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3390 if (ret == CAMERA_ERROR_NONE) {
3391 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3392 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3395 LOGD("ret : 0x%x", ret);
3401 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3403 int ret = CAMERA_ERROR_NONE;
3404 int set_rotation = (int)rotation;
3405 camera_cli_s *pc = (camera_cli_s *)camera;
3406 camera_msg_param param;
3408 if (!pc || !pc->cb_info) {
3409 LOGE("NULL handle");
3410 return CAMERA_ERROR_INVALID_PARAMETER;
3413 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3414 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3415 g_mutex_lock(&pc->cb_info->evas_mutex);
3417 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3419 g_mutex_unlock(&pc->cb_info->evas_mutex);
3421 if (ret != MM_ERROR_NONE) {
3422 LOGE("failed to set rotation for evas surface 0x%x", ret);
3423 return CAMERA_ERROR_INVALID_OPERATION;
3426 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3428 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3430 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3436 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3438 int ret = CAMERA_ERROR_NONE;
3439 camera_cli_s *pc = (camera_cli_s *)camera;
3441 if (!pc || !pc->cb_info || !rotation) {
3442 LOGE("NULL pointer %p %p", pc, rotation);
3443 return CAMERA_ERROR_INVALID_PARAMETER;
3446 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3448 if (ret == CAMERA_ERROR_NONE)
3449 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3455 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3457 int ret = CAMERA_ERROR_NONE;
3458 int set_flip = (int)flip;
3459 camera_cli_s *pc = (camera_cli_s *)camera;
3460 camera_msg_param param;
3462 if (!pc || !pc->cb_info) {
3463 LOGE("NULL handle");
3464 return CAMERA_ERROR_INVALID_PARAMETER;
3467 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3468 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3469 g_mutex_lock(&pc->cb_info->evas_mutex);
3471 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3473 g_mutex_unlock(&pc->cb_info->evas_mutex);
3475 if (ret != MM_ERROR_NONE) {
3476 LOGE("failed to set flip for evas surface 0x%x", ret);
3477 return CAMERA_ERROR_INVALID_OPERATION;
3480 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3482 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3484 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3490 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3492 int ret = CAMERA_ERROR_NONE;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3495 if (!pc || !pc->cb_info || !flip) {
3496 LOGE("NULL pointer %p %p", pc, flip);
3497 return CAMERA_ERROR_INVALID_PARAMETER;
3500 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3502 if (ret == CAMERA_ERROR_NONE)
3503 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3509 int camera_set_display_visible(camera_h camera, bool visible)
3511 int ret = CAMERA_ERROR_NONE;
3512 int set_visible = (int)visible;
3513 camera_cli_s *pc = (camera_cli_s *)camera;
3514 camera_msg_param param;
3516 if (!pc || !pc->cb_info) {
3517 LOGE("NULL handle");
3518 return CAMERA_ERROR_INVALID_PARAMETER;
3521 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3522 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3523 g_mutex_lock(&pc->cb_info->evas_mutex);
3525 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3527 g_mutex_unlock(&pc->cb_info->evas_mutex);
3529 if (ret != MM_ERROR_NONE) {
3530 LOGE("failed to set visible for evas surface 0x%x", ret);
3531 return CAMERA_ERROR_INVALID_OPERATION;
3534 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3536 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3538 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3544 int camera_is_display_visible(camera_h camera, bool *visible)
3546 int ret = CAMERA_ERROR_NONE;
3547 camera_cli_s *pc = (camera_cli_s *)camera;
3549 if (!pc || !pc->cb_info || !visible) {
3550 LOGE("NULL pointer %p %p", pc, visible);
3551 return CAMERA_ERROR_INVALID_PARAMETER;
3554 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3556 if (ret == CAMERA_ERROR_NONE)
3557 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3563 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3565 int ret = CAMERA_ERROR_NONE;
3566 int set_mode = (int)mode;
3567 camera_cli_s *pc = (camera_cli_s *)camera;
3568 camera_msg_param param;
3570 if (!pc || !pc->cb_info) {
3571 LOGE("NULL handle");
3572 return CAMERA_ERROR_INVALID_PARAMETER;
3575 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3576 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3577 g_mutex_lock(&pc->cb_info->evas_mutex);
3579 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3581 g_mutex_unlock(&pc->cb_info->evas_mutex);
3583 if (ret != MM_ERROR_NONE) {
3584 LOGE("failed to set geometry for evas surface 0x%x", ret);
3585 return CAMERA_ERROR_INVALID_OPERATION;
3588 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3590 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3592 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3598 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3600 int ret = CAMERA_ERROR_NONE;
3601 camera_cli_s *pc = (camera_cli_s *)camera;
3603 if (!pc || !pc->cb_info || !mode) {
3604 LOGE("NULL pointer %p %p", pc, mode);
3605 return CAMERA_ERROR_INVALID_PARAMETER;
3608 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3610 if (ret == CAMERA_ERROR_NONE)
3611 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3617 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3619 int ret = CAMERA_ERROR_NONE;
3620 int set_hint = (int)hint;
3621 camera_cli_s *pc = (camera_cli_s *)camera;
3622 camera_msg_param param;
3624 if (!pc || !pc->cb_info) {
3625 LOGE("NULL handle");
3626 return CAMERA_ERROR_INVALID_PARAMETER;
3629 LOGD("Enter - hint %d", set_hint);
3631 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3633 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3639 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3641 int ret = CAMERA_ERROR_NONE;
3642 camera_cli_s *pc = (camera_cli_s *)camera;
3643 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3645 if (!pc || !pc->cb_info || !hint) {
3646 LOGE("NULL pointer %p %p", pc, hint);
3647 return CAMERA_ERROR_INVALID_PARAMETER;
3650 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3652 if (ret == CAMERA_ERROR_NONE) {
3653 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3654 LOGD("display reuse hint %d", *hint);
3661 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3663 int ret = CAMERA_ERROR_NONE;
3664 camera_cli_s *pc = (camera_cli_s *)camera;
3665 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3667 if (!pc || !pc->cb_info || !width || !height) {
3668 LOGE("NULL pointer %p %p %p", pc, width, height);
3669 return CAMERA_ERROR_INVALID_PARAMETER;
3674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3676 if (ret == CAMERA_ERROR_NONE) {
3677 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3678 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3681 LOGD("ret : 0x%x", ret);
3687 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3689 int ret = CAMERA_ERROR_NONE;
3690 camera_cli_s *pc = (camera_cli_s *)camera;
3691 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3693 if (!pc || !pc->cb_info || !format) {
3694 LOGE("NULL pointer %p %p", pc, format);
3695 return CAMERA_ERROR_INVALID_PARAMETER;
3700 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3702 if (ret == CAMERA_ERROR_NONE)
3703 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3705 LOGD("ret : 0x%x", ret);
3711 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3713 int ret = CAMERA_ERROR_NONE;
3714 camera_cli_s *pc = (camera_cli_s *)camera;
3715 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3717 if (!pc || !pc->cb_info || !format) {
3718 LOGE("NULL pointer %p %p", pc, format);
3719 return CAMERA_ERROR_INVALID_PARAMETER;
3724 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3726 if (ret == CAMERA_ERROR_NONE)
3727 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3729 LOGD("ret : 0x%x", ret);
3735 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3737 int ret = CAMERA_ERROR_NONE;
3738 camera_cli_s *pc = (camera_cli_s *)camera;
3739 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3741 if (!pc || !pc->cb_info || !facing_direction) {
3742 LOGE("NULL pointer %p %p", pc, facing_direction);
3743 return CAMERA_ERROR_INVALID_PARAMETER;
3748 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3750 if (ret == CAMERA_ERROR_NONE)
3751 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3753 LOGD("ret : 0x%x", ret);
3759 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3761 int ret = CAMERA_ERROR_NONE;
3762 camera_cli_s *pc = (camera_cli_s *)camera;
3763 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3765 if (!pc || !pc->cb_info || !callback) {
3766 LOGE("NULL pointer %p %p", pc, callback);
3767 return CAMERA_ERROR_INVALID_PARAMETER;
3772 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3774 if (ret == CAMERA_ERROR_NONE) {
3775 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3776 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3777 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3780 LOGD("ret : 0x%x", ret);
3786 int camera_unset_preview_cb(camera_h camera)
3788 int ret = CAMERA_ERROR_NONE;
3789 camera_cli_s *pc = (camera_cli_s *)camera;
3790 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3792 if (!pc || !pc->cb_info) {
3793 LOGE("NULL handle");
3794 return CAMERA_ERROR_INVALID_PARAMETER;
3799 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3800 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3802 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3804 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3806 LOGD("ret : 0x%x", ret);
3812 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3814 int ret = CAMERA_ERROR_NONE;
3815 camera_cli_s *pc = (camera_cli_s *)camera;
3816 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3818 if (!pc || !pc->cb_info) {
3819 LOGE("NULL handle");
3820 return CAMERA_ERROR_INVALID_PARAMETER;
3823 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3824 LOGE("NOT SUPPORTED");
3825 return CAMERA_ERROR_NOT_SUPPORTED;
3828 if (callback == NULL) {
3829 LOGE("NULL callback");
3830 return CAMERA_ERROR_INVALID_PARAMETER;
3835 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3837 if (ret == CAMERA_ERROR_NONE) {
3838 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3839 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3842 LOGD("ret : 0x%x", ret);
3848 int camera_unset_media_packet_preview_cb(camera_h camera)
3850 int ret = CAMERA_ERROR_NONE;
3851 camera_cli_s *pc = (camera_cli_s *)camera;
3852 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3854 if (!pc || !pc->cb_info) {
3855 LOGE("NULL handle");
3856 return CAMERA_ERROR_INVALID_PARAMETER;
3861 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3862 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3864 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3866 LOGD("ret : 0x%x", ret);
3872 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3874 int ret = CAMERA_ERROR_NONE;
3875 camera_cli_s *pc = (camera_cli_s *)camera;
3876 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3878 if (!pc || !pc->cb_info || !callback) {
3879 LOGE("NULL pointer %p %p", pc, callback);
3880 return CAMERA_ERROR_INVALID_PARAMETER;
3885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3887 if (ret == CAMERA_ERROR_NONE) {
3888 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3889 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3892 LOGD("ret : 0x%x", ret);
3898 int camera_unset_state_changed_cb(camera_h camera)
3900 int ret = CAMERA_ERROR_NONE;
3901 camera_cli_s *pc = (camera_cli_s *)camera;
3902 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3904 if (!pc || !pc->cb_info) {
3905 LOGE("NULL handle");
3906 return CAMERA_ERROR_INVALID_PARAMETER;
3911 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3912 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3914 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3916 LOGD("ret : 0x%x", ret);
3922 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3928 if (!pc || !pc->cb_info || !callback) {
3929 LOGE("NULL pointer %p %p", pc, callback);
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3937 if (ret == CAMERA_ERROR_NONE) {
3938 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3939 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3942 LOGD("ret : 0x%x", ret);
3948 int camera_unset_interrupted_cb(camera_h camera)
3950 int ret = CAMERA_ERROR_NONE;
3951 camera_cli_s *pc = (camera_cli_s *)camera;
3952 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3954 if (!pc || !pc->cb_info) {
3955 LOGE("NULL handle");
3956 return CAMERA_ERROR_INVALID_PARAMETER;
3961 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3962 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3964 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3966 LOGD("ret : 0x%x", ret);
3972 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3974 int ret = CAMERA_ERROR_NONE;
3975 camera_cli_s *pc = (camera_cli_s *)camera;
3976 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3978 if (!pc || !pc->cb_info || !callback) {
3979 LOGE("NULL pointer %p %p", pc, callback);
3980 return CAMERA_ERROR_INVALID_PARAMETER;
3985 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3987 if (ret == CAMERA_ERROR_NONE) {
3988 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3989 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3992 LOGD("ret : 0x%x", ret);
3998 int camera_unset_focus_changed_cb(camera_h camera)
4000 int ret = CAMERA_ERROR_NONE;
4001 camera_cli_s *pc = (camera_cli_s *)camera;
4002 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4004 if (!pc || !pc->cb_info) {
4005 LOGE("NULL handle");
4006 return CAMERA_ERROR_INVALID_PARAMETER;
4011 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4012 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4014 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4016 LOGD("ret : 0x%x", ret);
4022 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4024 int ret = CAMERA_ERROR_NONE;
4025 camera_cli_s *pc = (camera_cli_s *)camera;
4026 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4028 if (!pc || !pc->cb_info || !callback) {
4029 LOGE("NULL pointer %p %p", pc, callback);
4030 return CAMERA_ERROR_INVALID_PARAMETER;
4035 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4037 if (ret == CAMERA_ERROR_NONE) {
4038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4042 LOGD("ret : 0x%x", ret);
4048 int camera_unset_error_cb(camera_h camera)
4050 int ret = CAMERA_ERROR_NONE;
4051 camera_cli_s *pc = (camera_cli_s *)camera;
4052 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4054 if (!pc || !pc->cb_info) {
4055 LOGE("NULL handle");
4056 return CAMERA_ERROR_INVALID_PARAMETER;
4061 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4062 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4064 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4066 LOGD("ret : 0x%x", ret);
4072 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4074 int ret = CAMERA_ERROR_NONE;
4075 camera_cli_s *pc = (camera_cli_s *)camera;
4076 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4078 if (!pc || !pc->cb_info || !foreach_cb) {
4079 LOGE("NULL pointer %p %p", pc, foreach_cb);
4080 return CAMERA_ERROR_INVALID_PARAMETER;
4085 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4086 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4088 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4090 LOGD("ret : 0x%x", ret);
4096 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4098 int ret = CAMERA_ERROR_NONE;
4099 camera_cli_s *pc = (camera_cli_s *)camera;
4100 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4102 if (!pc || !pc->cb_info || !foreach_cb) {
4103 LOGE("NULL pointer %p %p", pc, foreach_cb);
4104 return CAMERA_ERROR_INVALID_PARAMETER;
4109 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4110 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4112 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4114 LOGD("ret : 0x%x", ret);
4120 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4122 int ret = CAMERA_ERROR_NONE;
4123 camera_cli_s *pc = (camera_cli_s *)camera;
4124 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4126 if (!pc || !pc->cb_info || !foreach_cb) {
4127 LOGE("NULL pointer %p %p", pc, foreach_cb);
4128 return CAMERA_ERROR_INVALID_PARAMETER;
4133 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4134 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4136 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4138 LOGD("ret : 0x%x", ret);
4144 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4146 int ret = CAMERA_ERROR_NONE;
4147 camera_cli_s *pc = (camera_cli_s *)camera;
4148 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4150 if (!pc || !pc->cb_info || !foreach_cb) {
4151 LOGE("NULL pointer %p %p", pc, foreach_cb);
4152 return CAMERA_ERROR_INVALID_PARAMETER;
4157 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4158 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4160 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4162 LOGD("ret : 0x%x", ret);
4168 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4170 int ret = CAMERA_ERROR_NONE;
4171 camera_cli_s *pc = (camera_cli_s *)camera;
4172 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4174 if (!pc || !pc->cb_info || !width || !height) {
4175 LOGE("NULL pointer %p %p %p", pc, width, height);
4176 return CAMERA_ERROR_INVALID_PARAMETER;
4180 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4182 if (ret == CAMERA_ERROR_NONE) {
4183 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4184 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4187 LOGD("ret : 0x%x", ret);
4193 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4195 int ret = CAMERA_ERROR_NONE;
4196 camera_cli_s *pc = (camera_cli_s *)camera;
4197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4199 if (!pc || !pc->cb_info || !angle) {
4200 LOGE("NULL pointer %p %p", pc, angle);
4201 return CAMERA_ERROR_INVALID_PARAMETER;
4206 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4208 if (ret == CAMERA_ERROR_NONE)
4209 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4211 LOGD("ret : 0x%x", ret);
4217 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4219 int ret = CAMERA_ERROR_NONE;
4220 camera_cli_s *pc = (camera_cli_s *)camera;
4221 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4222 camera_msg_param param;
4223 int set_mode = (int)mode;
4225 if (!pc || !pc->cb_info) {
4226 LOGE("NULL handle");
4227 return CAMERA_ERROR_INVALID_PARAMETER;
4232 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4234 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4236 LOGD("ret : 0x%x", ret);
4242 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4244 int ret = CAMERA_ERROR_NONE;
4245 camera_cli_s *pc = (camera_cli_s *)camera;
4246 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4248 if (!pc || !pc->cb_info || !mode) {
4249 LOGE("NULL pointer %p %p", pc, mode);
4250 return CAMERA_ERROR_INVALID_PARAMETER;
4255 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4257 if (ret == CAMERA_ERROR_NONE)
4258 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4260 LOGD("ret : 0x%x", ret);
4266 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4268 int ret = CAMERA_ERROR_NONE;
4269 camera_cli_s *pc = (camera_cli_s *)camera;
4270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4272 if (!pc || !pc->cb_info || !foreach_cb) {
4273 LOGE("NULL pointer %p %p", pc, foreach_cb);
4274 return CAMERA_ERROR_INVALID_PARAMETER;
4279 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4280 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4282 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4284 LOGD("Finish, return :%x", ret);
4290 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4292 int ret = CAMERA_ERROR_NONE;
4293 camera_cli_s *pc = (camera_cli_s *)camera;
4294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4295 camera_msg_param param;
4296 int set_fps = (int)fps;
4298 if (!pc || !pc->cb_info) {
4299 LOGE("NULL handle");
4300 return CAMERA_ERROR_INVALID_PARAMETER;
4305 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4307 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4309 LOGD("ret : 0x%x", ret);
4315 int camera_attr_set_image_quality(camera_h camera, int quality)
4317 int ret = CAMERA_ERROR_NONE;
4318 camera_cli_s *pc = (camera_cli_s *)camera;
4319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4320 camera_msg_param param;
4322 if (!pc || !pc->cb_info) {
4323 LOGE("NULL handle");
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4329 CAMERA_MSG_PARAM_SET(param, INT, quality);
4331 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4333 LOGD("ret : 0x%x", ret);
4339 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4341 int ret = CAMERA_ERROR_NONE;
4342 camera_cli_s *pc = (camera_cli_s *)camera;
4343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4345 if (!pc || !pc->cb_info || !fps) {
4346 LOGE("NULL pointer %p %p", pc, fps);
4347 return CAMERA_ERROR_INVALID_PARAMETER;
4352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4354 if (ret == CAMERA_ERROR_NONE)
4355 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4357 LOGD("ret : 0x%x", ret);
4363 int camera_attr_get_image_quality(camera_h camera, int *quality)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4369 if (!pc || !pc->cb_info || !quality) {
4370 LOGE("NULL pointer %p %p", pc, quality);
4371 return CAMERA_ERROR_INVALID_PARAMETER;
4376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4378 if (ret == CAMERA_ERROR_NONE)
4379 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4381 LOGD("ret : 0x%x", ret);
4387 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4389 int ret = CAMERA_ERROR_NONE;
4390 camera_cli_s *pc = (camera_cli_s *)camera;
4391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4393 if (!pc || !pc->cb_info || !bitrate) {
4394 LOGE("NULL pointer %p %p", pc, bitrate);
4395 return CAMERA_ERROR_INVALID_PARAMETER;
4400 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4402 if (ret == CAMERA_ERROR_NONE)
4403 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4405 LOGD("ret : 0x%x", ret);
4411 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4416 camera_msg_param param;
4417 int set_bitrate = bitrate;
4419 if (!pc || !pc->cb_info) {
4420 LOGE("NULL handle");
4421 return CAMERA_ERROR_INVALID_PARAMETER;
4426 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4428 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4430 LOGD("ret : 0x%x", ret);
4436 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4438 int ret = CAMERA_ERROR_NONE;
4439 camera_cli_s *pc = (camera_cli_s *)camera;
4440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4442 if (!pc || !pc->cb_info || !interval) {
4443 LOGE("NULL pointer %p %p", pc, interval);
4444 return CAMERA_ERROR_INVALID_PARAMETER;
4449 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4451 if (ret == CAMERA_ERROR_NONE)
4452 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4454 LOGD("ret : 0x%x", ret);
4460 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4465 camera_msg_param param;
4466 int set_gop_interval = interval;
4468 if (!pc || !pc->cb_info) {
4469 LOGE("NULL handle");
4470 return CAMERA_ERROR_INVALID_PARAMETER;
4475 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4477 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4479 LOGD("ret : 0x%x", ret);
4485 int camera_attr_set_zoom(camera_h camera, int zoom)
4487 int ret = CAMERA_ERROR_NONE;
4488 camera_cli_s *pc = (camera_cli_s *)camera;
4489 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4490 camera_msg_param param;
4492 if (!pc || !pc->cb_info) {
4493 LOGE("NULL handle");
4494 return CAMERA_ERROR_INVALID_PARAMETER;
4497 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4499 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4501 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4503 LOGD("ret : 0x%x", ret);
4509 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4511 int ret = CAMERA_ERROR_NONE;
4512 camera_cli_s *pc = (camera_cli_s *)camera;
4513 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4514 camera_msg_param param;
4515 int set_mode = (int)mode;
4517 if (!pc || !pc->cb_info) {
4518 LOGE("NULL handle");
4519 return CAMERA_ERROR_INVALID_PARAMETER;
4522 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4524 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4526 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4532 int camera_attr_set_af_area(camera_h camera, int x, int y)
4534 int ret = CAMERA_ERROR_NONE;
4535 camera_cli_s *pc = (camera_cli_s *)camera;
4536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4537 camera_msg_param param;
4540 if (!pc || !pc->cb_info) {
4541 LOGE("NULL handle");
4542 return CAMERA_ERROR_INVALID_PARAMETER;
4545 LOGD("Enter - %d,%d", x, y);
4547 value = (x << 16) | y;
4548 CAMERA_MSG_PARAM_SET(param, INT, value);
4550 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4552 LOGD("ret : 0x%x", ret);
4558 int camera_attr_clear_af_area(camera_h camera)
4560 int ret = CAMERA_ERROR_NONE;
4561 camera_cli_s *pc = (camera_cli_s *)camera;
4562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4564 if (!pc || !pc->cb_info) {
4565 LOGE("NULL handle");
4566 return CAMERA_ERROR_INVALID_PARAMETER;
4571 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4573 LOGD("ret : 0x%x", ret);
4579 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4581 int ret = CAMERA_ERROR_NONE;
4582 camera_cli_s *pc = (camera_cli_s *)camera;
4583 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4584 camera_msg_param param;
4585 int set_mode = (int)mode;
4587 if (!pc || !pc->cb_info) {
4588 LOGE("NULL handle");
4589 return CAMERA_ERROR_INVALID_PARAMETER;
4594 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4596 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4598 LOGD("ret : 0x%x", ret);
4604 int camera_attr_set_exposure(camera_h camera, int value)
4606 int ret = CAMERA_ERROR_NONE;
4607 camera_cli_s *pc = (camera_cli_s *)camera;
4608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4609 camera_msg_param param;
4611 if (!pc || !pc->cb_info) {
4612 LOGE("NULL handle");
4613 return CAMERA_ERROR_INVALID_PARAMETER;
4618 CAMERA_MSG_PARAM_SET(param, INT, value);
4620 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4622 LOGD("ret : 0x%x", ret);
4628 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4630 int ret = CAMERA_ERROR_NONE;
4631 camera_cli_s *pc = (camera_cli_s *)camera;
4632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4633 camera_msg_param param;
4634 int set_iso = (int)iso;
4636 if (!pc || !pc->cb_info) {
4637 LOGE("NULL handle");
4638 return CAMERA_ERROR_INVALID_PARAMETER;
4643 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4645 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4647 LOGD("ret : 0x%x", ret);
4653 int camera_attr_set_brightness(camera_h camera, int level)
4655 int ret = CAMERA_ERROR_NONE;
4656 camera_cli_s *pc = (camera_cli_s *)camera;
4657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4658 camera_msg_param param;
4660 if (!pc || !pc->cb_info) {
4661 LOGE("NULL handle");
4662 return CAMERA_ERROR_INVALID_PARAMETER;
4667 CAMERA_MSG_PARAM_SET(param, INT, level);
4669 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4671 LOGD("ret : 0x%x", ret);
4677 int camera_attr_set_contrast(camera_h camera, int level)
4679 int ret = CAMERA_ERROR_NONE;
4680 camera_cli_s *pc = (camera_cli_s *)camera;
4681 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4682 camera_msg_param param;
4684 if (!pc || !pc->cb_info) {
4685 LOGE("NULL handle");
4686 return CAMERA_ERROR_INVALID_PARAMETER;
4691 CAMERA_MSG_PARAM_SET(param, INT, level);
4693 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4695 LOGD("ret : 0x%x", ret);
4701 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4703 int ret = CAMERA_ERROR_NONE;
4704 camera_cli_s *pc = (camera_cli_s *)camera;
4705 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4706 camera_msg_param param;
4707 int set_whitebalance = (int)wb;
4709 if (!pc || !pc->cb_info) {
4710 LOGE("NULL handle");
4711 return CAMERA_ERROR_INVALID_PARAMETER;
4716 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4718 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4720 LOGD("ret : 0x%x", ret);
4726 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4728 int ret = CAMERA_ERROR_NONE;
4729 camera_cli_s *pc = (camera_cli_s *)camera;
4730 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4731 camera_msg_param param;
4732 int set_effect = (int)effect;
4734 if (!pc || !pc->cb_info) {
4735 LOGE("NULL handle");
4736 return CAMERA_ERROR_INVALID_PARAMETER;
4741 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4743 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4745 LOGD("ret : 0x%x", ret);
4751 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4753 int ret = CAMERA_ERROR_NONE;
4754 camera_cli_s *pc = (camera_cli_s *)camera;
4755 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4756 camera_msg_param param;
4757 int set_mode = (int)mode;
4759 if (!pc || !pc->cb_info) {
4760 LOGE("NULL handle");
4761 return CAMERA_ERROR_INVALID_PARAMETER;
4766 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4768 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4770 LOGD("ret : 0x%x", ret);
4776 int camera_attr_enable_tag(camera_h camera, bool enable)
4778 int ret = CAMERA_ERROR_NONE;
4779 camera_cli_s *pc = (camera_cli_s *)camera;
4780 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4781 camera_msg_param param;
4782 int set_enable = (int)enable;
4784 if (!pc || !pc->cb_info) {
4785 LOGE("NULL handle");
4786 return CAMERA_ERROR_INVALID_PARAMETER;
4791 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4793 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4795 LOGD("ret : 0x%x", ret);
4801 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4803 int ret = CAMERA_ERROR_NONE;
4804 camera_cli_s *pc = (camera_cli_s *)camera;
4805 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4806 camera_msg_param param;
4808 if (!pc || !pc->cb_info || !description) {
4809 LOGE("NULL pointer %p %p", pc, description);
4810 return CAMERA_ERROR_INVALID_PARAMETER;
4815 CAMERA_MSG_PARAM_SET(param, STRING, description);
4817 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4819 LOGD("ret : 0x%x", ret);
4825 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4827 int ret = CAMERA_ERROR_NONE;
4828 camera_cli_s *pc = (camera_cli_s *)camera;
4829 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4830 camera_msg_param param;
4831 int set_orientation = (int)orientation;
4833 if (!pc || !pc->cb_info) {
4834 LOGE("NULL handle");
4835 return CAMERA_ERROR_INVALID_PARAMETER;
4840 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4842 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4844 LOGD("ret : 0x%x", ret);
4850 int camera_attr_set_tag_software(camera_h camera, const char *software)
4852 int ret = CAMERA_ERROR_NONE;
4853 camera_cli_s *pc = (camera_cli_s *)camera;
4854 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4855 camera_msg_param param;
4857 if (!pc || !pc->cb_info || !software) {
4858 LOGE("NULL pointer %p %p", pc, software);
4859 return CAMERA_ERROR_INVALID_PARAMETER;
4862 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4864 CAMERA_MSG_PARAM_SET(param, STRING, software);
4866 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4868 LOGD("ret : 0x%x", ret);
4874 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4876 int ret = CAMERA_ERROR_NONE;
4877 camera_cli_s *pc = (camera_cli_s *)camera;
4878 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4879 double set_geotag[3] = {latitude, longitude, altitude};
4884 if (!pc || !pc->cb_info) {
4885 LOGE("NULL handle");
4886 return CAMERA_ERROR_INVALID_PARAMETER;
4891 length = sizeof(set_geotag) / sizeof(int) + \
4892 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4894 msg = muse_core_msg_json_factory_new(api,
4895 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4898 LOGE("msg creation failed: api %d", api);
4899 return CAMERA_ERROR_OUT_OF_MEMORY;
4902 if (pc->cb_info->is_server_connected) {
4903 __camera_update_api_waiting(pc->cb_info, api, 1);
4905 g_mutex_lock(&pc->cb_info->fd_lock);
4906 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4907 g_mutex_unlock(&pc->cb_info->fd_lock);
4911 LOGE("message send failed");
4912 ret = CAMERA_ERROR_INVALID_OPERATION;
4914 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4917 __camera_update_api_waiting(pc->cb_info, api, -1);
4919 muse_core_msg_json_factory_free(msg);
4921 LOGD("ret : 0x%x", ret);
4927 int camera_attr_remove_geotag(camera_h camera)
4929 int ret = CAMERA_ERROR_NONE;
4930 camera_cli_s *pc = (camera_cli_s *)camera;
4931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4933 if (!pc || !pc->cb_info) {
4934 LOGE("NULL handle");
4935 return CAMERA_ERROR_INVALID_PARAMETER;
4940 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4942 LOGD("ret : 0x%x", ret);
4948 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4950 int ret = CAMERA_ERROR_NONE;
4951 camera_cli_s *pc = (camera_cli_s *)camera;
4952 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4953 camera_msg_param param;
4954 int set_mode = (int)mode;
4956 if (!pc || !pc->cb_info) {
4957 LOGE("NULL handle");
4958 return CAMERA_ERROR_INVALID_PARAMETER;
4963 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4965 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4967 LOGD("ret : 0x%x", ret);
4973 int camera_attr_get_zoom(camera_h camera, int *zoom)
4975 int ret = CAMERA_ERROR_NONE;
4976 camera_cli_s *pc = (camera_cli_s *)camera;
4977 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4979 if (!pc || !pc->cb_info || !zoom) {
4980 LOGE("NULL pointer %p %p", pc, zoom);
4981 return CAMERA_ERROR_INVALID_PARAMETER;
4986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4988 if (ret == CAMERA_ERROR_NONE)
4989 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4991 LOGD("ret : 0x%x", ret);
4997 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4999 int ret = CAMERA_ERROR_NONE;
5000 camera_cli_s *pc = (camera_cli_s *)camera;
5001 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5003 if (!pc || !pc->cb_info || !min || !max) {
5004 LOGE("NULL pointer %p %p %p", pc, min, max);
5005 return CAMERA_ERROR_INVALID_PARAMETER;
5010 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5012 if (ret == CAMERA_ERROR_NONE) {
5013 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5014 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5017 LOGD("ret : 0x%x", ret);
5023 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5025 int ret = CAMERA_ERROR_NONE;
5026 camera_cli_s *pc = (camera_cli_s *)camera;
5027 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5029 if (!pc || !pc->cb_info || !mode) {
5030 LOGE("NULL pointer %p %p", pc, mode);
5031 return CAMERA_ERROR_INVALID_PARAMETER;
5036 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5038 if (ret == CAMERA_ERROR_NONE)
5039 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5041 LOGD("ret : 0x%x", ret);
5047 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5049 int ret = CAMERA_ERROR_NONE;
5050 camera_cli_s *pc = (camera_cli_s *)camera;
5051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5053 if (!pc || !pc->cb_info || !mode) {
5054 LOGE("NULL pointer %p %p", pc, mode);
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5060 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5062 if (ret == CAMERA_ERROR_NONE)
5063 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5065 LOGD("ret : 0x%x", ret);
5071 int camera_attr_get_exposure(camera_h camera, int *value)
5073 int ret = CAMERA_ERROR_NONE;
5074 camera_cli_s *pc = (camera_cli_s *)camera;
5075 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5077 if (!pc || !pc->cb_info || !value) {
5078 LOGE("NULL pointer %p %p", pc, value);
5079 return CAMERA_ERROR_INVALID_PARAMETER;
5084 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5086 if (ret == CAMERA_ERROR_NONE)
5087 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5089 LOGD("ret : 0x%x", ret);
5095 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5097 int ret = CAMERA_ERROR_NONE;
5098 camera_cli_s *pc = (camera_cli_s *)camera;
5099 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5101 if (!pc || !pc->cb_info || !min || !max) {
5102 LOGE("NULL pointer %p %p %p", pc, min, max);
5103 return CAMERA_ERROR_INVALID_PARAMETER;
5108 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5110 if (ret == CAMERA_ERROR_NONE) {
5111 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5112 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5115 LOGD("ret : 0x%x", ret);
5121 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5123 int ret = CAMERA_ERROR_NONE;
5124 camera_cli_s *pc = (camera_cli_s *)camera;
5125 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5127 if (!pc || !pc->cb_info || !iso) {
5128 LOGE("NULL pointer %p %p", pc, iso);
5129 return CAMERA_ERROR_INVALID_PARAMETER;
5134 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5136 if (ret == CAMERA_ERROR_NONE)
5137 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5139 LOGD("ret : 0x%x", ret);
5145 int camera_attr_get_brightness(camera_h camera, int *level)
5147 int ret = CAMERA_ERROR_NONE;
5148 camera_cli_s *pc = (camera_cli_s *)camera;
5149 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5151 if (!pc || !pc->cb_info || !level) {
5152 LOGE("NULL pointer %p %p", pc, level);
5153 return CAMERA_ERROR_INVALID_PARAMETER;
5158 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5160 if (ret == CAMERA_ERROR_NONE)
5161 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5163 LOGD("ret : 0x%x", ret);
5169 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5171 int ret = CAMERA_ERROR_NONE;
5172 camera_cli_s *pc = (camera_cli_s *)camera;
5173 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5175 if (!pc || !pc->cb_info || !min || !max) {
5176 LOGE("NULL pointer %p %p %p", pc, min, max);
5177 return CAMERA_ERROR_INVALID_PARAMETER;
5182 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5184 if (ret == CAMERA_ERROR_NONE) {
5185 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5186 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5189 LOGD("ret : 0x%x", ret);
5195 int camera_attr_get_contrast(camera_h camera, int *level)
5197 int ret = CAMERA_ERROR_NONE;
5198 camera_cli_s *pc = (camera_cli_s *)camera;
5199 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5201 if (!pc || !pc->cb_info || !level) {
5202 LOGE("NULL pointer %p %p", pc, level);
5203 return CAMERA_ERROR_INVALID_PARAMETER;
5208 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5210 if (ret == CAMERA_ERROR_NONE)
5211 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5213 LOGD("ret : 0x%x", ret);
5219 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5221 int ret = CAMERA_ERROR_NONE;
5222 camera_cli_s *pc = (camera_cli_s *)camera;
5223 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5225 if (!pc || !pc->cb_info || !min || !max) {
5226 LOGE("NULL pointer %p %p %p", pc, min, max);
5227 return CAMERA_ERROR_INVALID_PARAMETER;
5232 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5234 if (ret == CAMERA_ERROR_NONE) {
5235 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5236 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5237 LOGD("min %d, max %d", *min, *max);
5240 LOGD("ret : 0x%x", ret);
5246 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5248 int ret = CAMERA_ERROR_NONE;
5249 camera_cli_s *pc = (camera_cli_s *)camera;
5250 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5252 if (!pc || !pc->cb_info || !wb) {
5253 LOGE("NULL pointer %p %p", pc, wb);
5254 return CAMERA_ERROR_INVALID_PARAMETER;
5259 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5261 if (ret == CAMERA_ERROR_NONE)
5262 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5264 LOGD("ret : 0x%x", ret);
5270 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5272 int ret = CAMERA_ERROR_NONE;
5273 camera_cli_s *pc = (camera_cli_s *)camera;
5274 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5276 if (!pc || !pc->cb_info || !effect) {
5277 LOGE("NULL pointer %p %p", pc, effect);
5278 return CAMERA_ERROR_INVALID_PARAMETER;
5283 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5285 if (ret == CAMERA_ERROR_NONE)
5286 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5288 LOGD("ret : 0x%x", ret);
5294 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5296 int ret = CAMERA_ERROR_NONE;
5297 camera_cli_s *pc = (camera_cli_s *)camera;
5298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5300 if (!pc || !pc->cb_info || !mode) {
5301 LOGE("NULL pointer %p %p", pc, mode);
5302 return CAMERA_ERROR_INVALID_PARAMETER;
5307 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5309 if (ret == CAMERA_ERROR_NONE)
5310 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5312 LOGD("ret : 0x%x", ret);
5318 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5320 int ret = CAMERA_ERROR_NONE;
5321 camera_cli_s *pc = (camera_cli_s *)camera;
5322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5324 if (!pc || !pc->cb_info || !enable) {
5325 LOGE("NULL pointer %p %p", pc, enable);
5326 return CAMERA_ERROR_INVALID_PARAMETER;
5331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5333 if (ret == CAMERA_ERROR_NONE)
5334 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5336 LOGD("ret : 0x%x", ret);
5342 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5344 int ret = CAMERA_ERROR_NONE;
5345 camera_cli_s *pc = (camera_cli_s *)camera;
5346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5348 if (!pc || !pc->cb_info || !description) {
5349 LOGE("NULL pointer %p %p", pc, description);
5350 return CAMERA_ERROR_INVALID_PARAMETER;
5355 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5357 if (ret == CAMERA_ERROR_NONE)
5358 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5360 LOGD("ret : 0x%x", ret);
5366 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5368 int ret = CAMERA_ERROR_NONE;
5369 camera_cli_s *pc = (camera_cli_s *)camera;
5370 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5372 if (!pc || !pc->cb_info || !orientation) {
5373 LOGE("NULL pointer %p %p", pc, orientation);
5374 return CAMERA_ERROR_INVALID_PARAMETER;
5379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5381 if (ret == CAMERA_ERROR_NONE)
5382 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5384 LOGD("ret : 0x%x", ret);
5390 int camera_attr_get_tag_software(camera_h camera, char **software)
5392 int ret = CAMERA_ERROR_NONE;
5393 camera_cli_s *pc = (camera_cli_s *)camera;
5394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5396 if (!pc || !pc->cb_info || !software) {
5397 LOGE("NULL pointer %p %p", pc, software);
5398 return CAMERA_ERROR_INVALID_PARAMETER;
5403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5405 if (ret == CAMERA_ERROR_NONE)
5406 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5408 LOGD("ret : 0x%x", ret);
5414 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5416 int ret = CAMERA_ERROR_NONE;
5417 camera_cli_s *pc = (camera_cli_s *)camera;
5418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5420 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5421 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5422 return CAMERA_ERROR_INVALID_PARAMETER;
5427 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5429 if (ret == CAMERA_ERROR_NONE) {
5430 *latitude = pc->cb_info->get_geotag[0];
5431 *longitude = pc->cb_info->get_geotag[1];
5432 *altitude = pc->cb_info->get_geotag[2];
5435 LOGD("ret : 0x%x", ret);
5441 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5443 int ret = CAMERA_ERROR_NONE;
5444 camera_cli_s *pc = (camera_cli_s *)camera;
5445 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5447 if (!pc || !pc->cb_info || !mode) {
5448 LOGE("NULL pointer %p %p", pc, mode);
5449 return CAMERA_ERROR_INVALID_PARAMETER;
5454 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5456 if (ret == CAMERA_ERROR_NONE)
5457 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5459 LOGD("ret : 0x%x", ret);
5465 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5467 int ret = CAMERA_ERROR_NONE;
5468 int get_flash_state = 0;
5471 LOGE("NULL pointer");
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5475 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5476 (int)device, "get_flash_state", &get_flash_state);
5478 if (ret == CAMERA_ERROR_NONE) {
5479 *state = (camera_flash_state_e)get_flash_state;
5480 LOGD("flash state %d", *state);
5482 LOGE("failed 0x%x", ret);
5489 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5491 int ret = CAMERA_ERROR_NONE;
5492 camera_cli_s *pc = (camera_cli_s *)camera;
5493 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5495 if (!pc || !pc->cb_info || !foreach_cb) {
5496 LOGE("NULL pointer %p %p", pc, foreach_cb);
5497 return CAMERA_ERROR_INVALID_PARAMETER;
5502 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5503 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5505 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5507 LOGD("ret : 0x%x", ret);
5513 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5515 int ret = CAMERA_ERROR_NONE;
5516 camera_cli_s *pc = (camera_cli_s *)camera;
5517 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5519 if (!pc || !pc->cb_info || !foreach_cb) {
5520 LOGE("NULL pointer %p %p", pc, foreach_cb);
5521 return CAMERA_ERROR_INVALID_PARAMETER;
5526 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5527 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5529 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5531 LOGD("ret : 0x%x", ret);
5537 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5539 int ret = CAMERA_ERROR_NONE;
5540 camera_cli_s *pc = (camera_cli_s *)camera;
5541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5543 if (!pc || !pc->cb_info || !foreach_cb) {
5544 LOGE("NULL pointer %p %p", pc, foreach_cb);
5545 return CAMERA_ERROR_INVALID_PARAMETER;
5550 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5551 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5553 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5555 LOGD("ret : 0x%x", ret);
5561 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5563 int ret = CAMERA_ERROR_NONE;
5564 camera_cli_s *pc = (camera_cli_s *)camera;
5565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5567 if (!pc || !pc->cb_info || !foreach_cb) {
5568 LOGE("NULL pointer %p %p", pc, foreach_cb);
5569 return CAMERA_ERROR_INVALID_PARAMETER;
5574 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5575 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5577 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5579 LOGD("ret : 0x%x", ret);
5585 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5587 int ret = CAMERA_ERROR_NONE;
5588 camera_cli_s *pc = (camera_cli_s *)camera;
5589 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5591 if (!pc || !pc->cb_info || !foreach_cb) {
5592 LOGE("NULL pointer %p %p", pc, foreach_cb);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5598 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5599 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5601 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5603 LOGD("ret : 0x%x", ret);
5609 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5611 int ret = CAMERA_ERROR_NONE;
5612 camera_cli_s *pc = (camera_cli_s *)camera;
5613 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5615 if (!pc || !pc->cb_info || !foreach_cb) {
5616 LOGE("NULL pointer %p %p", pc, foreach_cb);
5617 return CAMERA_ERROR_INVALID_PARAMETER;
5622 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5623 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5625 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5627 LOGD("ret : 0x%x", ret);
5633 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5635 int ret = CAMERA_ERROR_NONE;
5636 camera_cli_s *pc = (camera_cli_s *)camera;
5637 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5639 if (!pc || !pc->cb_info || !foreach_cb) {
5640 LOGE("NULL pointer %p %p", pc, foreach_cb);
5641 return CAMERA_ERROR_INVALID_PARAMETER;
5646 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5647 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5649 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5651 LOGD("ret : 0x%x", ret);
5657 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5659 int ret = CAMERA_ERROR_NONE;
5660 camera_cli_s *pc = (camera_cli_s *)camera;
5661 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5663 if (!pc || !pc->cb_info || !foreach_cb) {
5664 LOGE("NULL pointer %p %p", pc, foreach_cb);
5665 return CAMERA_ERROR_INVALID_PARAMETER;
5670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5673 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5675 LOGD("Enter, handle :%x", pc->remote_handle);
5681 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)
5683 int ret = CAMERA_ERROR_NONE;
5684 camera_cli_s *pc = (camera_cli_s *)camera;
5685 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5686 camera_msg_param param;
5689 if (!pc || !pc->cb_info || !foreach_cb) {
5690 LOGE("NULL pointer %p %p", pc, foreach_cb);
5691 return CAMERA_ERROR_INVALID_PARAMETER;
5696 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5697 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5699 value = (width << 16) | height;
5700 CAMERA_MSG_PARAM_SET(param, INT, value);
5702 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5704 LOGD("ret : 0x%x", ret);
5710 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5712 int ret = CAMERA_ERROR_NONE;
5713 camera_cli_s *pc = (camera_cli_s *)camera;
5714 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5716 if (!pc || !pc->cb_info || !foreach_cb) {
5717 LOGE("NULL pointer %p %p", pc, foreach_cb);
5718 return CAMERA_ERROR_INVALID_PARAMETER;
5723 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5724 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5726 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5728 LOGD("ret : 0x%x", ret);
5734 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5736 int ret = CAMERA_ERROR_NONE;
5737 camera_cli_s *pc = (camera_cli_s *)camera;
5738 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5740 if (!pc || !pc->cb_info || !foreach_cb) {
5741 LOGE("NULL pointer %p %p", pc, foreach_cb);
5742 return CAMERA_ERROR_INVALID_PARAMETER;
5747 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5748 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5750 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5752 LOGD("ret : 0x%x", ret);
5758 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5760 int ret = CAMERA_ERROR_NONE;
5761 camera_cli_s *pc = (camera_cli_s *)camera;
5762 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5763 camera_msg_param param;
5764 int set_rotation = (int)rotation;
5766 if (!pc || !pc->cb_info) {
5767 LOGE("NULL handle");
5768 return CAMERA_ERROR_INVALID_PARAMETER;
5773 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5775 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5777 LOGD("ret : 0x%x", ret);
5783 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5785 int ret = CAMERA_ERROR_NONE;
5786 camera_cli_s *pc = (camera_cli_s *)camera;
5787 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5789 if (!pc || !pc->cb_info || !rotation) {
5790 LOGE("NULL pointer %p %p", pc, rotation);
5791 return CAMERA_ERROR_INVALID_PARAMETER;
5796 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5798 if (ret == CAMERA_ERROR_NONE)
5799 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5801 LOGD("ret : 0x%x", ret);
5807 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5809 int ret = CAMERA_ERROR_NONE;
5810 camera_cli_s *pc = (camera_cli_s *)camera;
5811 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5812 camera_msg_param param;
5813 int set_flip = (int)flip;
5815 if (!pc || !pc->cb_info) {
5816 LOGE("NULL handle");
5817 return CAMERA_ERROR_INVALID_PARAMETER;
5822 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5824 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5826 LOGD("ret : 0x%x", ret);
5832 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5834 int ret = CAMERA_ERROR_NONE;
5835 camera_cli_s *pc = (camera_cli_s *)camera;
5836 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5838 if (!pc || !pc->cb_info || !flip) {
5839 LOGE("NULL pointer %p %p", pc, flip);
5840 return CAMERA_ERROR_INVALID_PARAMETER;
5845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5847 if (ret == CAMERA_ERROR_NONE)
5848 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5850 LOGD("ret : 0x%x", ret);
5855 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5857 int ret = CAMERA_ERROR_NONE;
5858 camera_cli_s *pc = (camera_cli_s *)camera;
5859 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5860 camera_msg_param param;
5861 int set_mode = (int)mode;
5863 if (!pc || !pc->cb_info) {
5864 LOGE("NULL handle");
5865 return CAMERA_ERROR_INVALID_PARAMETER;
5870 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5872 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5874 LOGD("ret : 0x%x", ret);
5880 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5882 int ret = CAMERA_ERROR_NONE;
5883 camera_cli_s *pc = (camera_cli_s *)camera;
5884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5886 if (!pc || !pc->cb_info || !mode) {
5887 LOGE("NULL pointer %p %p", pc, mode);
5888 return CAMERA_ERROR_INVALID_PARAMETER;
5893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5895 if (ret == CAMERA_ERROR_NONE)
5896 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5898 LOGD("ret : 0x%x", ret);
5904 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5906 int ret = CAMERA_ERROR_NONE;
5907 camera_cli_s *pc = (camera_cli_s *)camera;
5908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5910 if (!pc || !pc->cb_info) {
5911 LOGE("NULL handle");
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5917 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5920 LOGE("error is occurred 0x%x", ret);
5924 LOGD("ret : %d", ret);
5930 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5932 int ret = CAMERA_ERROR_NONE;
5933 camera_cli_s *pc = (camera_cli_s *)camera;
5934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5936 if (!pc || !pc->cb_info) {
5937 LOGE("NULL handle");
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5943 if (!camera_attr_is_supported_hdr_capture(camera)) {
5944 LOGE("HDR not supported");
5945 return CAMERA_ERROR_NOT_SUPPORTED;
5949 LOGE("NULL callback");
5950 return CAMERA_ERROR_INVALID_PARAMETER;
5953 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5954 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5956 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5958 LOGD("ret : 0x%x", ret);
5964 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5966 int ret = CAMERA_ERROR_NONE;
5967 camera_cli_s *pc = (camera_cli_s *)camera;
5968 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5970 if (!pc || !pc->cb_info) {
5971 LOGE("NULL handle");
5972 return CAMERA_ERROR_INVALID_PARAMETER;
5977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5980 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5982 LOGD("ret : 0x%x", ret);
5988 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5990 int ret = CAMERA_ERROR_NONE;
5991 camera_cli_s *pc = (camera_cli_s *)camera;
5992 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5993 camera_msg_param param;
5994 int set_enable = (int)enable;
5996 if (!pc || !pc->cb_info) {
5997 LOGE("NULL handle");
5998 return CAMERA_ERROR_INVALID_PARAMETER;
6003 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6005 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6007 LOGD("ret : 0x%x", ret);
6013 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6015 int ret = CAMERA_ERROR_NONE;
6016 camera_cli_s *pc = (camera_cli_s *)camera;
6017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6019 if (!pc || !pc->cb_info || !enabled) {
6020 LOGE("NULL pointer %p %p", pc, enabled);
6021 return CAMERA_ERROR_INVALID_PARAMETER;
6026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6028 if (ret == CAMERA_ERROR_NONE)
6029 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6031 LOGD("ret : 0x%x", ret);
6037 bool camera_attr_is_supported_anti_shake(camera_h camera)
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_SUPPORTED_ANTI_SHAKE;
6043 if (!pc || !pc->cb_info) {
6044 LOGE("NULL handle");
6045 return CAMERA_ERROR_INVALID_PARAMETER;
6050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6053 LOGE("error is occurred 0x%x", ret);
6057 LOGD("ret : %d", ret);
6063 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6065 int ret = CAMERA_ERROR_NONE;
6066 camera_cli_s *pc = (camera_cli_s *)camera;
6067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6068 camera_msg_param param;
6069 int set_enable = (int)enable;
6071 if (!pc || !pc->cb_info) {
6072 LOGE("NULL handle");
6073 return CAMERA_ERROR_INVALID_PARAMETER;
6078 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6080 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6082 LOGD("ret : 0x%x", ret);
6088 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6094 if (!pc || !pc->cb_info || !enabled) {
6095 LOGE("NULL pointer %p %p", pc, enabled);
6096 return CAMERA_ERROR_INVALID_PARAMETER;
6101 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6103 if (ret == CAMERA_ERROR_NONE)
6104 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6106 LOGD("ret : 0x%x", ret);
6112 bool camera_attr_is_supported_video_stabilization(camera_h camera)
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_SUPPORTED_VIDEO_STABILIZATION;
6118 if (!pc || !pc->cb_info) {
6119 LOGE("NULL handle");
6120 return CAMERA_ERROR_INVALID_PARAMETER;
6125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6128 LOGE("error is occurred 0x%x", ret);
6132 LOGD("ret : %d", ret);
6138 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6140 int ret = CAMERA_ERROR_NONE;
6141 camera_cli_s *pc = (camera_cli_s *)camera;
6142 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6143 camera_msg_param param;
6144 int set_enable = (int)enable;
6146 if (!pc || !pc->cb_info) {
6147 LOGE("NULL handle");
6148 return CAMERA_ERROR_INVALID_PARAMETER;
6153 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6155 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6157 LOGD("ret : 0x%x", ret);
6163 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6169 if (!pc || !pc->cb_info || !enabled) {
6170 LOGE("NULL pointer %p %p", pc, enabled);
6171 return CAMERA_ERROR_INVALID_PARAMETER;
6176 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6178 if (ret == CAMERA_ERROR_NONE)
6179 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6181 LOGD("ret : 0x%x", ret);
6187 bool camera_attr_is_supported_auto_contrast(camera_h camera)
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_SUPPORTED_AUTO_CONTRAST;
6193 if (!pc || !pc->cb_info) {
6194 LOGE("NULL handle");
6195 return CAMERA_ERROR_INVALID_PARAMETER;
6200 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6203 LOGE("error is occurred 0x%x", ret);
6207 LOGD("ret : %d", ret);
6213 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6215 int ret = CAMERA_ERROR_NONE;
6216 camera_cli_s *pc = (camera_cli_s *)camera;
6217 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6218 camera_msg_param param;
6219 int set_disable = (int)disable;
6221 if (!pc || !pc->cb_info) {
6222 LOGE("NULL handle");
6223 return CAMERA_ERROR_INVALID_PARAMETER;
6228 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6230 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6232 LOGD("ret : 0x%x", ret);
6238 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6240 int ret = CAMERA_ERROR_NONE;
6241 camera_cli_s *pc = (camera_cli_s *)camera;
6242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6243 camera_msg_param param;
6244 int set_move_type = (int)move_type;
6247 if (!pc || !pc->cb_info) {
6248 LOGE("NULL handle");
6249 return CAMERA_ERROR_INVALID_PARAMETER;
6254 value = (set_move_type << 16) | pan_step;
6255 CAMERA_MSG_PARAM_SET(param, INT, value);
6257 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6259 LOGD("ret : 0x%x", ret);
6265 int camera_attr_get_pan(camera_h camera, int *pan_step)
6267 int ret = CAMERA_ERROR_NONE;
6268 camera_cli_s *pc = (camera_cli_s *)camera;
6269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6271 if (!pc || !pc->cb_info || !pan_step) {
6272 LOGE("NULL pointer %p %p", pc, pan_step);
6273 return CAMERA_ERROR_INVALID_PARAMETER;
6278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6280 if (ret == CAMERA_ERROR_NONE)
6281 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6283 LOGD("ret : 0x%x", ret);
6289 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
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_RANGE;
6295 if (!pc || !pc->cb_info || !min || !max) {
6296 LOGE("NULL pointer %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6306 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6309 LOGD("ret : 0x%x", ret);
6315 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6317 int ret = CAMERA_ERROR_NONE;
6318 camera_cli_s *pc = (camera_cli_s *)camera;
6319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6320 camera_msg_param param;
6321 int set_move_type = (int)move_type;
6324 if (!pc || !pc->cb_info) {
6325 LOGE("NULL handle");
6326 return CAMERA_ERROR_INVALID_PARAMETER;
6331 value = (set_move_type << 16) | tilt_step;
6332 CAMERA_MSG_PARAM_SET(param, INT, value);
6334 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6336 LOGD("ret : 0x%x", ret);
6342 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6348 if (!pc || !pc->cb_info || !tilt_step) {
6349 LOGE("NULL pointer %p %p", pc, tilt_step);
6350 return CAMERA_ERROR_INVALID_PARAMETER;
6355 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6357 if (ret == CAMERA_ERROR_NONE)
6358 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6360 LOGD("ret : 0x%x", ret);
6366 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
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_RANGE;
6372 if (!pc || !pc->cb_info || !min || !max) {
6373 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6383 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6386 LOGD("ret : 0x%x", ret);
6392 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6394 int ret = CAMERA_ERROR_NONE;
6395 camera_cli_s *pc = (camera_cli_s *)camera;
6396 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6397 camera_msg_param param;
6398 int set_ptz_type = (int)ptz_type;
6400 if (!pc || !pc->cb_info) {
6401 LOGE("NULL handle");
6402 return CAMERA_ERROR_INVALID_PARAMETER;
6407 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6409 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6411 LOGD("ret : 0x%x", ret);
6417 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6419 int ret = CAMERA_ERROR_NONE;
6420 camera_cli_s *pc = (camera_cli_s *)camera;
6421 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6423 if (!pc || !pc->cb_info || !foreach_cb) {
6424 LOGE("NULL pointer %p %p", pc, foreach_cb);
6425 return CAMERA_ERROR_INVALID_PARAMETER;
6430 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6431 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6433 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6435 LOGD("ret : 0x%x", ret);
6441 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6443 int ret = CAMERA_ERROR_NONE;
6444 camera_cli_s *pc = (camera_cli_s *)camera;
6445 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6446 int set_display_roi_area[4] = {x, y, width, height};
6451 if (!pc || !pc->cb_info) {
6452 LOGE("NULL handle");
6453 return CAMERA_ERROR_INVALID_PARAMETER;
6458 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6459 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6460 g_mutex_lock(&pc->cb_info->evas_mutex);
6462 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6464 g_mutex_unlock(&pc->cb_info->evas_mutex);
6466 if (ret != MM_ERROR_NONE) {
6467 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6468 return CAMERA_ERROR_INVALID_OPERATION;
6471 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6473 length = sizeof(set_display_roi_area) / sizeof(int) + \
6474 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6476 msg = muse_core_msg_json_factory_new(api,
6477 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6480 LOGE("msg creation failed: api %d", api);
6481 return CAMERA_ERROR_OUT_OF_MEMORY;
6484 if (pc->cb_info->is_server_connected) {
6485 __camera_update_api_waiting(pc->cb_info, api, 1);
6487 g_mutex_lock(&pc->cb_info->fd_lock);
6488 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6489 g_mutex_unlock(&pc->cb_info->fd_lock);
6493 LOGE("message send failed");
6494 ret = CAMERA_ERROR_INVALID_OPERATION;
6496 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6499 __camera_update_api_waiting(pc->cb_info, api, -1);
6501 muse_core_msg_json_factory_free(msg);
6503 LOGD("ret : 0x%x", ret);
6509 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6511 camera_cli_s *pc = (camera_cli_s *)camera;
6512 int ret = CAMERA_ERROR_NONE;
6513 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6515 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6516 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6517 return CAMERA_ERROR_INVALID_PARAMETER;
6522 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6524 if (ret == CAMERA_ERROR_NONE) {
6525 *x = pc->cb_info->get_display_roi_area[0];
6526 *y = pc->cb_info->get_display_roi_area[1];
6527 *width = pc->cb_info->get_display_roi_area[2];
6528 *height = pc->cb_info->get_display_roi_area[3];
6531 LOGD("ret : 0x%x", ret);
6537 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6539 int ret = CAMERA_ERROR_NONE;
6540 int get_device_state = 0;
6543 LOGE("NULL pointer");
6544 return CAMERA_ERROR_INVALID_PARAMETER;
6547 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6548 (int)device, "get_device_state", &get_device_state);
6550 if (ret == CAMERA_ERROR_NONE) {
6551 *state = (camera_device_state_e)get_device_state;
6552 LOGD("device state %d", *state);
6554 LOGE("failed 0x%x", ret);
6561 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6563 int ret = CAMERA_ERROR_NONE;
6564 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6565 camera_cb_info *info = NULL;
6567 if (!callback || !cb_id) {
6568 LOGE("invalid pointer %p %p", callback, cb_id);
6569 return CAMERA_ERROR_INVALID_PARAMETER;
6572 /* check camera support */
6573 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6574 if (ret != CAMERA_ERROR_NONE) {
6575 LOGE("get device state failed");
6579 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6581 info = g_new0(camera_cb_info, 1);
6583 LOGE("info failed");
6584 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6588 info->id = ++g_cam_dev_state_changed_cb_id;
6589 info->callback = (void *)callback;
6590 info->user_data = user_data;
6594 /* subscribe dbus signal for camera state change */
6595 if (!g_cam_dev_state_changed_cb_conn) {
6596 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6597 if (!g_cam_dev_state_changed_cb_conn) {
6598 LOGE("failed to get gdbus connection");
6599 ret = CAMERA_ERROR_INVALID_OPERATION;
6603 LOGD("subscribe signal %s - %s - %s",
6604 MM_CAMCORDER_DBUS_OBJECT,
6605 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6606 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6608 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6609 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6610 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6611 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6612 LOGE("failed to get gdbus connection");
6613 ret = CAMERA_ERROR_INVALID_OPERATION;
6617 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6620 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6622 LOGD("callback id %d", info->id);
6625 if (ret != CAMERA_ERROR_NONE) {
6631 if (g_cam_dev_state_changed_cb_conn) {
6632 g_object_unref(g_cam_dev_state_changed_cb_conn);
6633 g_cam_dev_state_changed_cb_conn = NULL;
6637 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6643 int camera_remove_device_state_changed_cb(int cb_id)
6645 int ret = CAMERA_ERROR_NONE;
6646 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6647 GList *tmp_list = NULL;
6648 camera_cb_info *info = NULL;
6650 /* check camera support */
6651 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6652 if (ret != CAMERA_ERROR_NONE) {
6653 LOGE("get device state failed");
6657 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6659 if (!g_cam_dev_state_changed_cb_list) {
6660 LOGE("there is no callback info");
6661 ret = CAMERA_ERROR_INVALID_OPERATION;
6665 tmp_list = g_cam_dev_state_changed_cb_list;
6668 info = tmp_list->data;
6669 tmp_list = tmp_list->next;
6676 if (info->id == cb_id) {
6677 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6682 if (!g_cam_dev_state_changed_cb_list) {
6683 /* no remained callback */
6684 if (g_cam_dev_state_changed_cb_conn) {
6685 /* unsubscribe signal */
6686 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6687 g_cam_dev_state_changed_cb_subscribe_id = 0;
6689 /* unref connection */
6690 g_object_unref(g_cam_dev_state_changed_cb_conn);
6691 g_cam_dev_state_changed_cb_conn = NULL;
6695 LOGD("id %d callback removed", cb_id);
6696 ret = CAMERA_ERROR_NONE;
6702 LOGE("id %d callback not found", cb_id);
6703 ret = CAMERA_ERROR_INVALID_PARAMETER;
6706 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);