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 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
398 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
399 ret = cb_info->api_ret[api];
400 cb_info->api_activating[api] = 0;
402 /*LOGD("return value : 0x%x", ret);*/
404 ret = CAMERA_ERROR_INVALID_OPERATION;
405 LOGE("api %d was TIMED OUT!", api);
408 ret = cb_info->api_ret[api];
409 cb_info->api_activating[api] = 0;
411 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
414 g_mutex_unlock(&(cb_info->api_mutex[api]));
416 if (ret != CAMERA_ERROR_NONE) {
417 LOGE("api %d : error 0x%x", api, ret);
419 if (ret == CAMERA_ERROR_SOUND_POLICY)
420 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
421 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
422 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
423 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
424 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
431 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
432 int *ret, int timeout)
438 LOGE("NULL info - api %d", api);
441 *ret = CAMERA_ERROR_INVALID_PARAMETER;
446 msg = muse_core_msg_json_factory_new(api, NULL);
448 LOGE("msg failed: api %d", api);
451 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
456 /*LOGD("send msg %s", msg);*/
458 if (cb_info->is_server_connected) {
459 __camera_update_api_waiting(cb_info, api, 1);
461 g_mutex_lock(&cb_info->fd_lock);
462 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
463 g_mutex_unlock(&cb_info->fd_lock);
467 LOGE("msg send failed");
469 *ret = CAMERA_ERROR_INVALID_OPERATION;
472 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
475 __camera_update_api_waiting(cb_info, api, -1);
477 muse_core_msg_json_factory_free(msg);
483 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
484 int *ret, camera_msg_param *param, int timeout)
489 if (!cb_info || !param) {
490 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
493 *ret = CAMERA_ERROR_INVALID_PARAMETER;
498 /*LOGD("type %d, name %s", param->type, param->name);*/
500 switch (param->type) {
502 msg = muse_core_msg_json_factory_new(api,
503 param->type, param->name, param->value.value_INT,
506 case MUSE_TYPE_STRING:
507 msg = muse_core_msg_json_factory_new(api,
508 param->type, param->name, param->value.value_STRING,
512 LOGE("unknown type %d", param->type);
517 LOGE("msg failed: api %d", api);
520 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
525 /*LOGD("send msg %s", msg);*/
527 if (cb_info->is_server_connected) {
528 __camera_update_api_waiting(cb_info, api, 1);
530 g_mutex_lock(&cb_info->fd_lock);
531 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
532 g_mutex_unlock(&cb_info->fd_lock);
536 LOGE("msg send failed");
539 *ret = CAMERA_ERROR_INVALID_OPERATION;
542 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
545 __camera_update_api_waiting(cb_info, api, -1);
547 muse_core_msg_json_factory_free(msg);
553 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
555 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
556 in_format >= MM_PIXEL_FORMAT_NUM ||
557 out_format == NULL) {
558 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
559 return CAMERA_ERROR_INVALID_PARAMETER;
563 case MM_PIXEL_FORMAT_NV12:
564 case MM_PIXEL_FORMAT_NV12T:
565 *out_format = TBM_FORMAT_NV12;
567 case MM_PIXEL_FORMAT_NV16:
568 *out_format = TBM_FORMAT_NV16;
570 case MM_PIXEL_FORMAT_NV21:
571 *out_format = TBM_FORMAT_NV21;
573 case MM_PIXEL_FORMAT_YUYV:
574 *out_format = TBM_FORMAT_YUYV;
576 case MM_PIXEL_FORMAT_UYVY:
577 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
578 *out_format = TBM_FORMAT_UYVY;
580 case MM_PIXEL_FORMAT_422P:
581 *out_format = TBM_FORMAT_YUV422;
583 case MM_PIXEL_FORMAT_I420:
584 *out_format = TBM_FORMAT_YUV420;
586 case MM_PIXEL_FORMAT_YV12:
587 *out_format = TBM_FORMAT_YVU420;
589 case MM_PIXEL_FORMAT_RGB565:
590 *out_format = TBM_FORMAT_RGB565;
592 case MM_PIXEL_FORMAT_RGB888:
593 *out_format = TBM_FORMAT_RGB888;
595 case MM_PIXEL_FORMAT_RGBA:
596 *out_format = TBM_FORMAT_RGBA8888;
598 case MM_PIXEL_FORMAT_ARGB:
599 *out_format = TBM_FORMAT_ARGB8888;
602 LOGE("invalid in_format %d", in_format);
603 return CAMERA_ERROR_INVALID_PARAMETER;
606 return CAMERA_ERROR_NONE;
610 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
612 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
613 in_format >= MM_PIXEL_FORMAT_NUM ||
615 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
616 return CAMERA_ERROR_INVALID_PARAMETER;
620 case MM_PIXEL_FORMAT_NV12:
621 case MM_PIXEL_FORMAT_NV12T:
622 *mimetype = MEDIA_FORMAT_NV12;
624 case MM_PIXEL_FORMAT_NV16:
625 *mimetype = MEDIA_FORMAT_NV16;
627 case MM_PIXEL_FORMAT_NV21:
628 *mimetype = MEDIA_FORMAT_NV21;
630 case MM_PIXEL_FORMAT_YUYV:
631 *mimetype = MEDIA_FORMAT_YUYV;
633 case MM_PIXEL_FORMAT_UYVY:
634 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
635 *mimetype = MEDIA_FORMAT_UYVY;
637 case MM_PIXEL_FORMAT_422P:
638 *mimetype = MEDIA_FORMAT_422P;
640 case MM_PIXEL_FORMAT_I420:
641 *mimetype = MEDIA_FORMAT_I420;
643 case MM_PIXEL_FORMAT_YV12:
644 *mimetype = MEDIA_FORMAT_YV12;
646 case MM_PIXEL_FORMAT_RGB565:
647 *mimetype = MEDIA_FORMAT_RGB565;
649 case MM_PIXEL_FORMAT_RGB888:
650 *mimetype = MEDIA_FORMAT_RGB888;
652 case MM_PIXEL_FORMAT_RGBA:
653 *mimetype = MEDIA_FORMAT_RGBA;
655 case MM_PIXEL_FORMAT_ARGB:
656 *mimetype = MEDIA_FORMAT_ARGB;
659 LOGE("invalid in_format %d", in_format);
660 return CAMERA_ERROR_INVALID_PARAMETER;
663 return CAMERA_ERROR_NONE;
666 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
667 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
670 unsigned char *buf_pos = NULL;
672 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
673 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
678 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
679 frame->format = MM_PIXEL_FORMAT_UYVY;
681 frame->format = stream->format;
683 frame->width = stream->width;
684 frame->height = stream->height;
685 frame->timestamp = stream->timestamp;
686 frame->num_of_planes = stream->num_planes;
688 if (num_buffer_key == 0) {
690 if (!data_bo_handle || !data_bo_handle->ptr) {
691 LOGE("NULL pointer");
695 buf_pos = data_bo_handle->ptr;
697 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
698 frame->data.encoded_plane.data = buf_pos;
699 frame->data.encoded_plane.size = stream->data.encoded.length_data;
700 total_size = stream->data.encoded.length_data;
702 switch (stream->num_planes) {
704 frame->data.single_plane.yuv = buf_pos;
705 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
706 total_size = stream->data.yuv420.length_yuv;
709 frame->data.double_plane.y = buf_pos;
710 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
711 buf_pos += stream->data.yuv420sp.length_y;
712 frame->data.double_plane.uv = buf_pos;
713 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
714 total_size = stream->data.yuv420sp.length_y + \
715 stream->data.yuv420sp.length_uv;
718 frame->data.triple_plane.y = buf_pos;
719 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
720 buf_pos += stream->data.yuv420p.length_y;
721 frame->data.triple_plane.u = buf_pos;
722 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
723 buf_pos += stream->data.yuv420p.length_u;
724 frame->data.triple_plane.v = buf_pos;
725 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
726 total_size = stream->data.yuv420p.length_y + \
727 stream->data.yuv420p.length_u + \
728 stream->data.yuv420p.length_v;
736 switch (stream->num_planes) {
738 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
739 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
740 total_size = stream->data.yuv420.length_yuv;
743 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
744 if (stream->num_planes == (unsigned int)num_buffer_key)
745 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
747 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
748 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
749 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
750 total_size = stream->data.yuv420sp.length_y + \
751 stream->data.yuv420sp.length_uv;
754 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
755 if (stream->num_planes == (unsigned int)num_buffer_key) {
756 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
757 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
759 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
760 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
762 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
763 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
764 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
765 total_size = stream->data.yuv420p.length_y + \
766 stream->data.yuv420p.length_u + \
767 stream->data.yuv420p.length_v;
775 LOGD("format %d, %dx%d, size %d plane num %d",
776 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
782 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
783 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
786 int ret = CAMERA_ERROR_NONE;
787 camera_media_packet_data *tmp_mp_data = NULL;
789 if (*mp_data == NULL) {
790 tmp_mp_data = g_new0(camera_media_packet_data, 1);
792 tmp_mp_data->tbm_key = tbm_key;
793 tmp_mp_data->num_buffer_key = num_buffer_key;
794 tmp_mp_data->bo = bo;
795 tmp_mp_data->data_bo = data_bo;
796 tmp_mp_data->ref_cnt++;
798 for (i = 0 ; i < num_buffer_key ; i++)
799 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
801 *mp_data = tmp_mp_data;
802 /*LOGD("mp_data %p", tmp_mp_data);*/
804 ret = CAMERA_ERROR_OUT_OF_MEMORY;
805 LOGE("failed to alloc media packet data");
808 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
814 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
818 camera_msg_param param;
820 if (!mp_data || !cb_info) {
821 LOGE("NULL pointer %p %p", mp_data, cb_info);
825 if (mp_data->ref_cnt > 1) {
827 LOGD("ref count %d", mp_data->ref_cnt);
829 /* release imported bo */
830 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
831 tbm_bo_unref(mp_data->buffer_bo[i]);
832 mp_data->buffer_bo[i] = NULL;
836 _camera_release_imported_bo(&mp_data->bo);
837 _camera_release_imported_bo(&mp_data->data_bo);
840 tbm_key = mp_data->tbm_key;
842 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
844 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
853 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
854 camera_media_packet_data *mp_data, media_packet_h *packet)
856 media_packet_h pkt = NULL;
857 bool make_pkt_fmt = false;
858 tbm_surface_h tsurf = NULL;
859 tbm_surface_info_s tsurf_info;
860 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
861 uint32_t bo_format = 0;
864 int num_buffer_key = 0;
865 tbm_bo *buffer_bo = NULL;
867 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
868 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
869 cb_info, stream, mp_data, packet);
870 return CAMERA_ERROR_INVALID_PARAMETER;
873 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
874 buffer_bo = mp_data->buffer_bo;
875 num_buffer_key = mp_data->num_buffer_key;
877 /* create tbm surface */
878 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
879 tsurf_info.planes[i].stride = stream->stride[i];
881 /* get tbm surface format */
882 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
883 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
885 if (ret == CAMERA_ERROR_NONE) {
886 tsurf_info.width = stream->width;
887 tsurf_info.height = stream->height;
888 tsurf_info.format = bo_format;
889 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
890 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
892 if (num_buffer_key > 0) {
894 case TBM_FORMAT_NV12:
895 case TBM_FORMAT_NV21:
896 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
897 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
898 tsurf_info.planes[0].offset = 0;
899 if (num_buffer_key == 1)
900 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
901 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
903 case TBM_FORMAT_YUV420:
904 case TBM_FORMAT_YVU420:
905 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
906 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
907 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
908 tsurf_info.planes[0].offset = 0;
909 if (num_buffer_key == 1) {
910 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
911 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
913 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
915 case TBM_FORMAT_UYVY:
916 case TBM_FORMAT_YUYV:
917 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
918 tsurf_info.planes[0].offset = 0;
919 tsurf_info.size = tsurf_info.planes[0].size;
925 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
926 } else if (mp_data->data_bo) {
928 case TBM_FORMAT_NV12:
929 case TBM_FORMAT_NV21:
930 tsurf_info.planes[0].size = stream->width * stream->height;
931 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
932 tsurf_info.planes[0].offset = 0;
933 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
934 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
936 case TBM_FORMAT_YUV420:
937 case TBM_FORMAT_YVU420:
938 tsurf_info.planes[0].size = stream->width * stream->height;
939 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
940 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
941 tsurf_info.planes[0].offset = 0;
942 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
943 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
944 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
946 case TBM_FORMAT_UYVY:
947 case TBM_FORMAT_YUYV:
948 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
949 tsurf_info.planes[0].offset = 0;
950 tsurf_info.size = tsurf_info.planes[0].size;
956 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
958 /*LOGD("tbm surface %p", tsurf);*/
962 /* check media packet format */
963 if (cb_info->pkt_fmt) {
964 int pkt_fmt_width = 0;
965 int pkt_fmt_height = 0;
966 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
968 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
969 if (pkt_fmt_mimetype != mimetype ||
970 pkt_fmt_width != stream->width ||
971 pkt_fmt_height != stream->height) {
972 LOGW("change fmt: current 0x%x, %dx%d",
973 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
974 media_format_unref(cb_info->pkt_fmt);
975 cb_info->pkt_fmt = NULL;
982 /* create packet format */
984 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
985 ret = media_format_create(&cb_info->pkt_fmt);
986 if (ret == MEDIA_FORMAT_ERROR_NONE) {
987 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
988 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
989 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
990 LOGW("media_format_set : 0x%x", ret);
992 LOGW("media_format_create failed 0x%x", ret);
996 /* create media packet */
997 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
998 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
999 (void *)cb_info, &pkt);
1000 if (ret != MEDIA_PACKET_ERROR_NONE) {
1001 LOGE("media_packet_create failed 0x%x", ret);
1002 tbm_surface_destroy(tsurf);
1006 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1007 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1011 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1012 /* set media packet data */
1013 ret = media_packet_set_extra(pkt, (void *)mp_data);
1014 if (ret != MEDIA_PACKET_ERROR_NONE) {
1015 LOGE("media_packet_set_extra failed");
1017 _camera_media_packet_data_release(mp_data, cb_info);
1020 media_packet_destroy(pkt);
1023 /* set timestamp : msec -> nsec */
1024 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1025 LOGW("media_packet_set_pts failed");
1034 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1037 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1038 camera_media_packet_data *mp_data = NULL;
1039 tbm_surface_h tsurf = NULL;
1041 if (!pkt || !cb_info) {
1042 LOGE("NULL pointer %p %p", pkt, cb_info);
1043 return MEDIA_PACKET_FINALIZE;
1046 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1047 if (ret != MEDIA_PACKET_ERROR_NONE) {
1048 LOGE("media_packet_get_extra failed 0x%x", ret);
1049 return MEDIA_PACKET_FINALIZE;
1052 /*LOGD("mp_data %p", mp_data);*/
1054 g_mutex_lock(&cb_info->mp_data_mutex);
1056 _camera_media_packet_data_release(mp_data, cb_info);
1059 g_mutex_unlock(&cb_info->mp_data_mutex);
1061 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1062 if (ret != MEDIA_PACKET_ERROR_NONE)
1063 LOGE("get tbm_surface failed 0x%x", ret);
1066 tbm_surface_destroy(tsurf);
1070 return MEDIA_PACKET_FINALIZE;
1073 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1079 tbm_bo_handle bo_handle = {NULL, };
1080 camera_msg_param param;
1082 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1083 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1087 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1089 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1090 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1091 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1092 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1093 LOGW("all preview callback from user are NULL");
1096 } else if (cb_info->user_cb[event] == NULL) {
1097 LOGW("user callback for event %d is not set", event);
1102 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1108 muse_camera_msg_get(previous, recv_msg);
1109 muse_camera_msg_get(current, recv_msg);
1110 muse_camera_msg_get(by_policy, recv_msg);
1112 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1113 previous, current, by_policy);
1115 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1116 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1119 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1123 muse_camera_msg_get(state, recv_msg);
1125 LOGD("FOCUS state - %d", state);
1127 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1130 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1131 LOGD("CAPTURE_COMPLETED");
1132 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1134 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1135 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1139 int num_buffer_key = 0;
1140 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1142 unsigned char *buf_pos = NULL;
1144 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1145 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1146 tbm_bo data_bo = NULL;
1147 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1149 camera_preview_data_s frame;
1150 camera_stream_data_s *stream = NULL;
1151 camera_media_packet_data *mp_data = NULL;
1152 media_packet_h pkt = NULL;
1153 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1154 media_packet_h pkt_evas = NULL;
1155 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1157 muse_camera_msg_get(tbm_key, recv_msg);
1158 muse_camera_msg_get(num_buffer_key, recv_msg);
1159 muse_camera_msg_get_array(buffer_key, recv_msg);
1160 muse_camera_msg_get(data_key, recv_msg);
1162 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1165 LOGE("invalid key %d", tbm_key);
1169 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1172 /* import tbm data_bo and get virtual address */
1173 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1174 LOGE("failed to import data key %d", data_key);
1175 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1180 /* import tbm bo and get virtual address */
1181 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1182 LOGE("failed to import key %d", tbm_key);
1183 _camera_release_imported_bo(&data_bo);
1184 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1188 buf_pos = (unsigned char *)bo_handle.ptr;
1190 /* get stream info */
1191 stream = (camera_stream_data_s *)buf_pos;
1193 for (i = 0 ; i < num_buffer_key ; i++) {
1194 /* import buffer bo and get virtual address */
1195 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1196 LOGE("failed to import buffer key %d", buffer_key[i]);
1198 /* release imported bo */
1199 _camera_release_imported_bo(&data_bo);
1200 _camera_release_imported_bo(&bo);
1202 for (i -= 1 ; i >= 0 ; i--)
1203 _camera_release_imported_bo(&buffer_bo[i]);
1205 /* send return buffer */
1206 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1212 /* call preview callback */
1213 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1214 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1216 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1217 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1220 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1221 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1222 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1224 if (ret == CAMERA_ERROR_NONE) {
1225 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1226 if (ret != CAMERA_ERROR_NONE) {
1227 LOGE("create pkt for evas failed");
1228 _camera_media_packet_data_release(mp_data, cb_info);
1232 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1233 LOGW("evas renderer is not supported");
1234 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1237 /* call media packet callback */
1238 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1239 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1241 if (ret == CAMERA_ERROR_NONE) {
1242 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1244 if (ret == CAMERA_ERROR_NONE) {
1245 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1246 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1248 _camera_media_packet_data_release(mp_data, cb_info);
1254 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1255 /* call evas renderer */
1257 g_mutex_lock(&cb_info->evas_mutex);
1258 if (cb_info->run_evas_render) {
1259 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1261 LOGW("evas renderer is stopped, skip this buffer...");
1262 media_packet_destroy(pkt_evas);
1265 g_mutex_unlock(&cb_info->evas_mutex);
1267 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1269 /* send message for preview callback return */
1270 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1271 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1273 if (mp_data == NULL) {
1274 /* release imported bo */
1275 for (i = 0 ; i < num_buffer_key ; i++)
1276 _camera_release_imported_bo(&buffer_bo[i]);
1278 /* unmap and unref tbm bo */
1279 _camera_release_imported_bo(&data_bo);
1280 _camera_release_imported_bo(&bo);
1283 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1285 /*LOGD("return buffer Done");*/
1289 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1293 muse_camera_msg_get(percent, recv_msg);
1295 LOGD("HDR progress - %d \%", percent);
1297 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1300 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1306 muse_camera_msg_get(policy, recv_msg);
1307 muse_camera_msg_get(previous, recv_msg);
1308 muse_camera_msg_get(current, recv_msg);
1310 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1311 policy, previous, current);
1313 if (policy == CAMERA_POLICY_SOUND)
1314 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1315 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1316 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1317 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1318 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1320 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1321 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1324 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1327 camera_detected_face_s *faces = NULL;
1329 muse_camera_msg_get(count, recv_msg);
1330 muse_camera_msg_get(tbm_key, recv_msg);
1332 if (count > 0 && tbm_key > 0) {
1333 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1335 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1339 faces = bo_handle.ptr;
1341 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1347 for (i = 0 ; i < count ; i++) {
1348 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1349 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1355 _camera_release_imported_bo(&bo);
1358 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1359 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1361 /*LOGD("return buffer done");*/
1363 LOGE("invalid message - count %d, key %d", count, tbm_key);
1367 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1370 int current_state = 0;
1372 muse_camera_msg_get(error, recv_msg);
1373 muse_camera_msg_get(current_state, recv_msg);
1375 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1377 if (error == CAMERA_ERROR_SOUND_POLICY)
1378 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1379 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1380 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1381 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1382 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1384 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1385 (camera_state_e)current_state, cb_info->user_data[event]);
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1390 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1391 muse_camera_msg_get(param1, recv_msg);
1392 muse_camera_msg_get(param2, recv_msg);
1394 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1396 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1397 cb_info->user_cb[event] = NULL;
1398 cb_info->user_data[event] = NULL;
1399 LOGW("stop foreach callback for event %d", event);
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1406 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1408 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1410 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1412 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1414 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1424 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1431 muse_camera_msg_get(param1, recv_msg);
1433 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1435 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1436 cb_info->user_cb[event] = NULL;
1437 cb_info->user_data[event] = NULL;
1438 LOGW("stop foreach callback for event %d", event);
1441 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1443 camera_image_data_s *rImage = NULL;
1444 camera_image_data_s *rPostview = NULL;
1445 camera_image_data_s *rThumbnail = NULL;
1446 unsigned char *buf_pos = NULL;
1447 int tbm_key_main = 0;
1448 int tbm_key_post = 0;
1449 int tbm_key_thumb = 0;
1450 tbm_bo bo_main = NULL;
1451 tbm_bo bo_post = NULL;
1452 tbm_bo bo_thumb = NULL;
1453 tbm_bo_handle bo_main_handle = {NULL, };
1454 tbm_bo_handle bo_post_handle = {NULL, };
1455 tbm_bo_handle bo_thumb_handle = {NULL, };
1457 muse_camera_msg_get(tbm_key_main, recv_msg);
1458 muse_camera_msg_get(tbm_key_post, recv_msg);
1459 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1462 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1463 tbm_key_main, tbm_key_post, tbm_key_thumb);
1466 if (tbm_key_main <= 0) {
1467 LOGE("invalid key %d", tbm_key_main);
1471 /* import tbm bo and get virtual address */
1472 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1475 buf_pos = (unsigned char *)bo_main_handle.ptr;
1476 rImage = (camera_image_data_s *)buf_pos;
1477 rImage->data = buf_pos + sizeof(camera_image_data_s);
1478 if (rImage->exif && rImage->exif_size > 0) {
1479 rImage->exif = rImage->data + rImage->size;
1481 rImage->exif = NULL;
1482 rImage->exif_size = 0;
1485 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1486 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1488 if (tbm_key_post > 0) {
1489 /* import tbm bo and get virtual address */
1490 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1493 buf_pos = (unsigned char *)bo_post_handle.ptr;
1494 rPostview = (camera_image_data_s *)buf_pos;
1495 LOGD("rPostview->size : %d", rPostview->size);
1496 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1499 if (tbm_key_thumb > 0) {
1500 /* import tbm bo and get virtual address */
1501 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1504 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1506 rThumbnail = (camera_image_data_s *)buf_pos;
1507 LOGD("rThumbnail->size : %d", rThumbnail->size);
1508 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1511 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1513 /* unmap and unref tbm bo */
1514 _camera_release_imported_bo(&bo_main);
1517 tbm_key = tbm_key_main;
1519 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1521 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1523 if (tbm_key_post > 0) {
1524 /* unmap and unref tbm bo */
1525 _camera_release_imported_bo(&bo_post);
1528 param.value.value_INT = tbm_key_post;
1529 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1532 if (tbm_key_thumb > 0) {
1533 /* unmap and unref tbm bo */
1534 _camera_release_imported_bo(&bo_thumb);
1537 param.value.value_INT = tbm_key_thumb;
1538 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1541 LOGD("return buffer done");
1544 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1545 LOGE("render error");
1552 static bool _camera_idle_event_callback(void *data)
1554 camera_cb_info_s *cb_info = NULL;
1555 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1557 if (cam_idle_event == NULL) {
1558 LOGE("cam_idle_event is NULL");
1563 g_mutex_lock(&cam_idle_event->event_mutex);
1565 cb_info = cam_idle_event->cb_info;
1566 if (cb_info == NULL) {
1567 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1568 goto IDLE_EVENT_CALLBACK_DONE;
1571 /* remove event from list */
1572 g_mutex_lock(&cb_info->idle_event_mutex);
1574 if (cb_info->idle_event_list)
1575 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1577 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1578 g_mutex_unlock(&cb_info->idle_event_mutex);
1581 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1583 /* send signal for waiting thread */
1584 g_cond_signal(&cb_info->idle_event_cond);
1586 IDLE_EVENT_CALLBACK_DONE:
1587 /* unlock and release event */
1588 g_mutex_unlock(&cam_idle_event->event_mutex);
1589 g_mutex_clear(&cam_idle_event->event_mutex);
1591 g_free(cam_idle_event);
1592 cam_idle_event = NULL;
1597 static void *_camera_msg_handler_func(gpointer data)
1601 camera_message_s *cam_msg = NULL;
1602 camera_idle_event_s *cam_idle_event = NULL;
1603 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1604 camera_cb_info_s *cb_info = NULL;
1606 if (!handler_info || !handler_info->cb_info) {
1607 LOGE("NULL handler %p", handler_info);
1611 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1612 type = handler_info->type;
1614 LOGD("t:%d start", type);
1616 g_mutex_lock(&handler_info->mutex);
1618 while (g_atomic_int_get(&handler_info->running)) {
1619 if (g_queue_is_empty(handler_info->queue)) {
1620 /*LOGD("t:%d signal wait...", type);*/
1621 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1622 /*LOGD("t:%d signal received", type);*/
1624 if (g_atomic_int_get(&handler_info->running) == 0) {
1625 LOGD("t:%d stop event thread", type);
1630 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1632 g_mutex_unlock(&handler_info->mutex);
1634 if (cam_msg == NULL) {
1635 LOGE("t:%d NULL message", type);
1636 g_mutex_lock(&handler_info->mutex);
1642 if (api < MUSE_CAMERA_API_MAX) {
1645 g_mutex_lock(&cb_info->api_mutex[api]);
1647 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1648 if (cb_info->api_waiting[api] > 0) {
1649 cb_info->api_ret[api] = ret;
1650 cb_info->api_activating[api] = 1;
1652 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1654 g_cond_signal(&cb_info->api_cond[api]);
1656 LOGW("no waiting for this api [%d]", api);
1659 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1662 g_mutex_unlock(&cb_info->api_mutex[api]);
1663 } else if (api == MUSE_CAMERA_CB_EVENT) {
1664 switch (cam_msg->event_class) {
1665 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1666 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1668 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1669 cam_idle_event = g_new0(camera_idle_event_s, 1);
1670 if (cam_idle_event == NULL) {
1671 LOGE("t:%d cam_idle_event alloc failed", type);
1675 cam_idle_event->event = cam_msg->event;
1676 cam_idle_event->cb_info = cb_info;
1677 g_mutex_init(&cam_idle_event->event_mutex);
1678 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1680 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1682 g_mutex_lock(&cb_info->idle_event_mutex);
1683 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1684 g_mutex_unlock(&cb_info->idle_event_mutex);
1686 g_idle_add_full(G_PRIORITY_DEFAULT,
1687 (GSourceFunc)_camera_idle_event_callback,
1688 (gpointer)cam_idle_event,
1692 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1696 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1702 g_mutex_lock(&handler_info->mutex);
1705 /* remove remained event */
1706 while (!g_queue_is_empty(handler_info->queue)) {
1707 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1709 LOGD("t:%d remove camera message %p", type, cam_msg);
1713 LOGW("t:%d NULL camera message", type);
1717 g_mutex_unlock(&handler_info->mutex);
1719 LOGD("t:%d return", type);
1725 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1727 camera_idle_event_s *cam_idle_event = NULL;
1728 gboolean ret = TRUE;
1730 gint64 end_time = 0;
1732 if (cb_info == NULL) {
1733 LOGE("cb_info is NULL");
1737 g_mutex_lock(&cb_info->idle_event_mutex);
1739 if (cb_info->idle_event_list == NULL) {
1740 LOGD("No remained idle event");
1741 g_mutex_unlock(&cb_info->idle_event_mutex);
1745 list = cb_info->idle_event_list;
1748 cam_idle_event = list->data;
1749 list = g_list_next(list);
1751 if (!cam_idle_event) {
1752 LOGW("Fail to remove idle event. The event is NULL");
1756 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1757 ret = g_idle_remove_by_data(cam_idle_event);
1759 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1762 cam_idle_event->cb_info = NULL;
1763 LOGW("idle event %p will be called later", cam_idle_event);
1766 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1768 g_mutex_unlock(&cam_idle_event->event_mutex);
1771 g_mutex_clear(&cam_idle_event->event_mutex);
1773 g_free(cam_idle_event);
1774 cam_idle_event = NULL;
1776 LOGD("remove idle event done");
1782 LOGW("event lock failed. it's being called...");
1784 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1786 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1787 LOGW("signal received");
1792 g_list_free(cb_info->idle_event_list);
1793 cb_info->idle_event_list = NULL;
1795 g_mutex_unlock(&cb_info->idle_event_mutex);
1801 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1803 camera_message_s *cam_msg = NULL;
1805 if (!cb_info || !msg) {
1806 LOGE("NULL pointer %p %p", cb_info, msg);
1810 cam_msg = g_new0(camera_message_s, 1);
1812 LOGE("failed to alloc cam_msg for [%s]", msg);
1817 cam_msg->event = event;
1818 cam_msg->event_class = event_class;
1820 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1822 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1824 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1825 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1826 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1827 g_cond_signal(&cb_info->preview_cb_info.cond);
1828 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1829 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1830 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1831 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1832 g_cond_signal(&cb_info->capture_cb_info.cond);
1833 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1835 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1836 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1837 g_cond_signal(&cb_info->msg_handler_info.cond);
1838 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1847 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1849 int ret = CAMERA_ERROR_NONE;
1853 int event_class = -1;
1857 if (!cb_info || !msg) {
1858 LOGE("invalid ptr %p %p", cb_info, msg);
1862 /*LOGD("msg [%s]", msg);*/
1864 if (!muse_camera_msg_get(api, msg)) {
1865 LOGE("failed to get camera api");
1869 if (api == MUSE_CAMERA_CB_EVENT) {
1870 if (!muse_camera_msg_get(event, msg) ||
1871 !muse_camera_msg_get(event_class, msg)) {
1872 LOGE("failed to get camera event or event_class [%s]", msg);
1876 if (!muse_camera_msg_get(api_class, msg)) {
1877 LOGE("failed to get camera api_class [%s]", msg);
1882 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1883 if (api >= MUSE_CAMERA_API_MAX) {
1884 LOGE("invalid api %d", api);
1888 if (!muse_camera_msg_get(ret, msg)) {
1889 LOGE("failed to get camera ret");
1893 g_mutex_lock(&cb_info->api_mutex[api]);
1896 case MUSE_CAMERA_API_CREATE:
1897 if (ret != CAMERA_ERROR_NONE) {
1898 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1899 LOGE("camera create error 0x%x. close client cb handler", ret);
1902 case MUSE_CAMERA_API_DESTROY:
1903 if (ret == CAMERA_ERROR_NONE) {
1904 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1905 LOGD("camera destroy done. close client cb handler");
1909 muse_camera_msg_get(get_type, msg);
1910 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1911 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1912 muse_camera_msg_get(get_index, msg);
1915 case MUSE_CAMERA_GET_TYPE_INT:
1916 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1918 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1919 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1920 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1922 case MUSE_CAMERA_GET_TYPE_ARRAY:
1923 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1924 muse_core_msg_json_deserialize("get_value",
1925 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1926 LOGD("get display roi %d,%d,%dx%d",
1927 cb_info->get_display_roi_area[0],
1928 cb_info->get_display_roi_area[1],
1929 cb_info->get_display_roi_area[2],
1930 cb_info->get_display_roi_area[3]);
1932 muse_core_msg_json_deserialize("get_value",
1933 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1934 LOGD("get geotag %lf, %lf, %lf",
1935 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1938 case MUSE_CAMERA_GET_TYPE_STRING:
1939 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1942 LOGW("unknown type %d", get_type);
1949 if (cb_info->api_waiting[api] > 0) {
1950 cb_info->api_ret[api] = ret;
1951 cb_info->api_activating[api] = 1;
1953 g_cond_signal(&cb_info->api_cond[api]);
1955 LOGW("no waiting for this api [%d]", api);
1958 g_mutex_unlock(&cb_info->api_mutex[api]);
1959 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1960 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1962 LOGW("unknown camera api %d, class %d", api, api_class);
1969 static void *_camera_msg_recv_func(gpointer data)
1971 int recv_length = 0;
1972 int single_length = 0;
1973 int remained_length = 0;
1974 char *recv_msg = NULL;
1975 char *single_msg = NULL;
1976 char *remained_msg = NULL;
1980 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1983 LOGE("cb_info NULL");
1989 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1991 LOGE("single_msg malloc failed");
1995 recv_msg = cb_info->recv_msg;
1997 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1998 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1999 if (recv_length <= 0) {
2000 cb_info->is_server_connected = FALSE;
2001 LOGE("receive msg failed - server disconnected");
2009 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2011 /* Need to split the combined entering msgs */
2012 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2013 if (recv_msg[cur_pos] == '}') {
2014 single_length = cur_pos - prev_pos + 1;
2016 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2017 /* check remained msg */
2018 if (remained_length > 0) {
2020 strncpy(single_msg, remained_msg, remained_length);
2021 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2022 single_msg[remained_length + single_length] = '\0';
2025 remained_msg = NULL;
2027 strncpy(single_msg, recv_msg + prev_pos, single_length);
2028 single_msg[single_length] = '\0';
2029 LOGE("lost msg [%s], skip...", single_msg);
2032 remained_length = 0;
2034 strncpy(single_msg, recv_msg + prev_pos, single_length);
2035 single_msg[single_length] = '\0';
2038 if (single_msg[0] == '{') {
2040 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2041 /* process each message */
2042 __camera_process_msg(cb_info, single_msg);
2044 LOGE("invalid msg [%s]", single_msg);
2047 LOGE("too long message [len %d] skip...", single_length);
2050 prev_pos = cur_pos + 1;
2054 /* check incompleted message */
2055 if (recv_msg[recv_length - 1] != '}') {
2056 remained_length = recv_length - prev_pos;
2058 LOGW("incompleted message [len %d]", remained_length);
2060 remained_msg = (char *)malloc(remained_length + 1);
2062 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2063 remained_msg[remained_length] = '\0';
2065 LOGE("failed to alloc for remained msg");
2068 remained_length = 0;
2072 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2074 if (!cb_info->is_server_connected) {
2075 /* send error msg for server disconnection */
2076 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2077 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2078 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2082 LOGE("error_msg failed");
2083 goto CB_HANDLER_EXIT;
2086 __camera_add_msg_to_queue(cb_info,
2087 MUSE_CAMERA_CB_EVENT,
2088 MUSE_CAMERA_EVENT_TYPE_ERROR,
2089 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2092 muse_core_msg_json_factory_free(error_msg);
2095 LOGE("add error msg for service disconnection done");
2106 remained_msg = NULL;
2113 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2114 int type, const char *thread_name, camera_cb_info_s *cb_info)
2116 if (!handler_info || !thread_name || !cb_info) {
2117 LOGE("t:%d NULL %p %p %p",
2118 type, handler_info, thread_name, cb_info);
2124 handler_info->type = type;
2125 handler_info->queue = g_queue_new();
2126 if (handler_info->queue == NULL) {
2127 LOGE("t:%d queue failed", type);
2131 g_mutex_init(&handler_info->mutex);
2132 g_cond_init(&handler_info->cond);
2134 handler_info->cb_info = (void *)cb_info;
2135 g_atomic_int_set(&handler_info->running, 1);
2137 handler_info->thread = g_thread_try_new(thread_name,
2138 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2139 if (handler_info->thread == NULL) {
2140 LOGE("t:%d thread failed", type);
2142 g_mutex_clear(&handler_info->mutex);
2143 g_cond_clear(&handler_info->cond);
2144 g_queue_free(handler_info->queue);
2145 handler_info->queue = NULL;
2150 LOGD("t:%d done", type);
2156 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2160 if (!handler_info) {
2161 LOGE("NULL handler");
2165 if (!handler_info->thread) {
2166 LOGW("thread is not created");
2170 type = handler_info->type;
2172 LOGD("t:%d thread %p", type, handler_info->thread);
2174 g_mutex_lock(&handler_info->mutex);
2175 g_atomic_int_set(&handler_info->running, 0);
2176 g_cond_signal(&handler_info->cond);
2177 g_mutex_unlock(&handler_info->mutex);
2179 g_thread_join(handler_info->thread);
2180 g_thread_unref(handler_info->thread);
2181 handler_info->thread = NULL;
2183 g_mutex_clear(&handler_info->mutex);
2184 g_cond_clear(&handler_info->cond);
2185 g_queue_free(handler_info->queue);
2186 handler_info->queue = NULL;
2188 LOGD("t:%d done", type);
2194 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2196 camera_cb_info_s *cb_info = NULL;
2199 g_return_val_if_fail(sockfd > 0, NULL);
2201 cb_info = g_new0(camera_cb_info_s, 1);
2202 if (cb_info == NULL) {
2203 LOGE("cb_info failed");
2207 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2209 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2210 g_mutex_init(&cb_info->api_mutex[i]);
2211 g_cond_init(&cb_info->api_cond[i]);
2214 g_mutex_init(&cb_info->fd_lock);
2215 g_mutex_init(&cb_info->idle_event_mutex);
2216 g_cond_init(&cb_info->idle_event_cond);
2217 g_mutex_init(&cb_info->mp_data_mutex);
2218 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2219 g_mutex_init(&cb_info->evas_mutex);
2220 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2222 /* message handler thread */
2223 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2224 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2225 LOGE("msg_handler_info failed");
2229 /* message handler thread for preview callback */
2230 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2231 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2232 LOGE("preview_cb_info failed");
2236 /* message handler thread for capture callback */
2237 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2238 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2239 LOGE("capture_cb_info failed");
2243 cb_info->fd = sockfd;
2244 cb_info->preview_cb_flag = 0;
2245 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2246 cb_info->evas_info = NULL;
2247 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2249 /* message receive thread */
2250 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2251 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2252 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2253 if (cb_info->msg_recv_thread == NULL) {
2254 LOGE("message receive thread creation failed");
2258 cb_info->is_server_connected = TRUE;
2264 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2265 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2266 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2268 g_mutex_clear(&cb_info->fd_lock);
2269 g_mutex_clear(&cb_info->idle_event_mutex);
2270 g_cond_clear(&cb_info->idle_event_cond);
2271 g_mutex_clear(&cb_info->mp_data_mutex);
2272 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2273 g_mutex_clear(&cb_info->evas_mutex);
2274 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2276 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2277 g_mutex_clear(&cb_info->api_mutex[i]);
2278 g_cond_clear(&cb_info->api_cond[i]);
2288 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2292 g_return_if_fail(cb_info != NULL);
2294 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2296 g_thread_join(cb_info->msg_recv_thread);
2297 g_thread_unref(cb_info->msg_recv_thread);
2298 cb_info->msg_recv_thread = NULL;
2300 LOGD("msg_recv thread removed");
2302 /* destroy msg handler threads */
2303 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2304 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2305 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2307 g_mutex_clear(&cb_info->fd_lock);
2308 g_mutex_clear(&cb_info->idle_event_mutex);
2309 g_cond_clear(&cb_info->idle_event_cond);
2310 g_mutex_clear(&cb_info->mp_data_mutex);
2311 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2312 g_mutex_clear(&cb_info->evas_mutex);
2313 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2315 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2316 g_mutex_clear(&cb_info->api_mutex[i]);
2317 g_cond_clear(&cb_info->api_cond[i]);
2320 if (cb_info->fd > -1) {
2321 muse_core_connection_close(cb_info->fd);
2325 if (cb_info->bufmgr) {
2326 tbm_bufmgr_deinit(cb_info->bufmgr);
2327 cb_info->bufmgr = NULL;
2329 if (cb_info->pkt_fmt) {
2330 media_format_unref(cb_info->pkt_fmt);
2331 cb_info->pkt_fmt = NULL;
2334 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2335 if (cb_info->evas_info)
2336 mm_evas_renderer_destroy(&cb_info->evas_info);
2337 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2339 cb_info->preview_cb_flag = 0;
2348 int _camera_start_evas_rendering(camera_h camera)
2350 int ret = CAMERA_ERROR_NONE;
2351 camera_cli_s *pc = (camera_cli_s *)camera;
2353 if (!pc || !pc->cb_info) {
2354 LOGE("NULL handle");
2355 return CAMERA_ERROR_INVALID_PARAMETER;
2360 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2361 LOGE("EVAS surface is not set");
2362 return CAMERA_ERROR_NONE;
2365 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2366 g_mutex_lock(&pc->cb_info->evas_mutex);
2368 /* set evas render flag as RUN */
2369 pc->cb_info->run_evas_render = true;
2370 ret = CAMERA_ERROR_NONE;
2372 g_mutex_unlock(&pc->cb_info->evas_mutex);
2373 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2374 LOGW("evas renderer is not supported");
2375 ret = CAMERA_ERROR_NOT_SUPPORTED;
2376 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2382 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2384 int ret = CAMERA_ERROR_NONE;
2385 camera_cli_s *pc = (camera_cli_s *)camera;
2387 if (!pc || !pc->cb_info) {
2388 LOGE("NULL handle");
2389 return CAMERA_ERROR_INVALID_PARAMETER;
2392 LOGD("stop - keep screen %d", keep_screen);
2394 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2395 LOGE("EVAS surface is not set");
2396 return CAMERA_ERROR_NONE;
2399 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2400 g_mutex_lock(&pc->cb_info->evas_mutex);
2402 /* set evas render flag as STOP and release buffers */
2403 pc->cb_info->run_evas_render = false;
2405 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2406 if (ret != MM_ERROR_NONE) {
2407 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2408 ret = CAMERA_ERROR_INVALID_OPERATION;
2411 g_mutex_unlock(&pc->cb_info->evas_mutex);
2412 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2413 LOGW("evas renderer is not supported");
2414 ret = CAMERA_ERROR_NOT_SUPPORTED;
2415 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2421 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2423 int ret = CAMERA_ERROR_NONE;
2426 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2428 /* create muse connection */
2429 if (!key || !value) {
2430 LOGE("NULL pointer");
2431 return CAMERA_ERROR_INVALID_PARAMETER;
2434 sock_fd = muse_core_client_new();
2436 LOGE("muse_core_client_new failed");
2437 return CAMERA_ERROR_INVALID_OPERATION;
2440 msg = muse_core_msg_json_factory_new(api,
2441 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2442 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2446 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2450 ret = muse_core_ipc_send_msg(sock_fd, msg);
2452 muse_core_msg_json_factory_free(msg);
2456 LOGE("send msg failed");
2457 ret = CAMERA_ERROR_INVALID_OPERATION;
2461 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2463 LOGE("recv msg failed %d", errno);
2464 ret = CAMERA_ERROR_INVALID_OPERATION;
2468 if (!muse_camera_msg_get(ret, recv_msg)) {
2469 LOGE("failed to get return value from msg [%s]", recv_msg);
2470 ret = CAMERA_ERROR_INVALID_OPERATION;
2474 if (ret == CAMERA_ERROR_NONE)
2475 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2477 LOGD("api %d - value %d", api, *value);
2481 muse_core_connection_close(sock_fd);
2489 int camera_create(camera_device_e device, camera_h *camera)
2492 char *send_msg = NULL;
2494 int ret = CAMERA_ERROR_NONE;
2496 camera_cli_s *pc = NULL;
2497 tbm_bufmgr bufmgr = NULL;
2499 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2500 muse_core_api_module_e muse_module = MUSE_CAMERA;
2501 int device_type = (int)device;
2504 LOGE("NULL pointer");
2505 return CAMERA_ERROR_INVALID_PARAMETER;
2508 sock_fd = muse_core_client_new();
2510 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2511 ret = CAMERA_ERROR_INVALID_OPERATION;
2517 send_msg = muse_core_msg_json_factory_new(api,
2518 MUSE_TYPE_INT, "module", muse_module,
2519 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2520 MUSE_TYPE_INT, "pid", pid,
2525 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2529 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2531 muse_core_msg_json_factory_free(send_msg);
2535 LOGE("send msg failed %d", errno);
2536 ret = CAMERA_ERROR_INVALID_OPERATION;
2540 pc = g_new0(camera_cli_s, 1);
2542 LOGE("camera_cli_s alloc failed");
2543 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2547 bufmgr = tbm_bufmgr_init(-1);
2548 if (bufmgr == NULL) {
2549 LOGE("get tbm bufmgr failed");
2550 ret = CAMERA_ERROR_INVALID_OPERATION;
2554 pc->cb_info = _camera_client_callback_new(sock_fd);
2555 if (pc->cb_info == NULL) {
2556 LOGE("cb_info alloc failed");
2557 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2563 LOGD("cb info : %d", pc->cb_info->fd);
2565 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2567 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2569 if (ret == CAMERA_ERROR_NONE) {
2570 intptr_t handle = 0;
2571 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2573 LOGE("Receiving Handle Failed!!");
2574 ret = CAMERA_ERROR_INVALID_OPERATION;
2578 pc->remote_handle = handle;
2579 pc->cb_info->bufmgr = bufmgr;
2581 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2582 if (ret != CAMERA_ERROR_NONE) {
2583 LOGE("init display failed 0x%x", ret);
2587 LOGD("camera create 0x%x", pc->remote_handle);
2588 *camera = (camera_h)pc;
2597 tbm_bufmgr_deinit(bufmgr);
2602 muse_core_connection_close(sock_fd);
2608 _camera_client_callback_destroy(pc->cb_info);
2615 LOGE("camera create error : 0x%x", ret);
2621 int camera_change_device(camera_h camera, camera_device_e device)
2624 int ret = CAMERA_ERROR_NONE;
2625 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2626 camera_cli_s *pc = (camera_cli_s *)camera;
2627 camera_msg_param param;
2629 if (!pc || !pc->cb_info) {
2630 LOGE("NULL handle");
2631 return CAMERA_ERROR_INVALID_PARAMETER;
2634 CAMERA_MSG_PARAM_SET(param, INT, device);
2636 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2638 if (ret == CAMERA_ERROR_NONE) {
2639 /* reset callback and user data */
2640 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2641 pc->cb_info->user_cb[i] = NULL;
2642 pc->cb_info->user_data[i] = NULL;
2644 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2651 int camera_destroy(camera_h camera)
2653 int ret = CAMERA_ERROR_NONE;
2654 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2655 camera_cli_s *pc = (camera_cli_s *)camera;
2657 if (!pc || !pc->cb_info) {
2658 LOGE("NULL handle");
2659 return CAMERA_ERROR_INVALID_PARAMETER;
2664 if (pc->cb_info->is_server_connected)
2665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2667 LOGW("server disconnected. release resource without send message.");
2669 if (ret == CAMERA_ERROR_NONE) {
2670 _camera_remove_idle_event_all(pc->cb_info);
2671 _camera_client_callback_destroy(pc->cb_info);
2681 int camera_start_preview(camera_h camera)
2683 int ret = CAMERA_ERROR_NONE;
2684 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2685 camera_cli_s *pc = (camera_cli_s *)camera;
2687 if (!pc || !pc->cb_info) {
2688 LOGE("NULL handle");
2689 return CAMERA_ERROR_INVALID_PARAMETER;
2694 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2695 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2696 ret = _camera_start_evas_rendering(camera);
2697 if (ret != CAMERA_ERROR_NONE) {
2698 LOGE("stop preview because of error");
2699 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2703 LOGD("ret : 0x%x", ret);
2709 int camera_stop_preview(camera_h camera)
2711 int ret = CAMERA_ERROR_NONE;
2712 camera_cli_s *pc = (camera_cli_s *)camera;
2713 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2714 camera_state_e current_state = CAMERA_STATE_NONE;
2716 if (!pc || !pc->cb_info) {
2717 LOGE("NULL handle");
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2723 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2724 ret = camera_get_state(camera, ¤t_state);
2725 if (ret != CAMERA_ERROR_NONE) {
2726 LOGE("failed to get current state 0x%x", ret);
2730 if (current_state == CAMERA_STATE_PREVIEW) {
2731 ret = _camera_stop_evas_rendering(camera, false);
2732 if (ret != CAMERA_ERROR_NONE)
2737 /* send stop preview message */
2738 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2740 if (ret != CAMERA_ERROR_NONE &&
2741 current_state == CAMERA_STATE_PREVIEW) {
2742 LOGW("restart evas rendering");
2743 _camera_start_evas_rendering(camera);
2746 LOGD("ret : 0x%x", ret);
2752 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2754 int ret = CAMERA_ERROR_NONE;
2755 camera_cli_s *pc = (camera_cli_s *)camera;
2756 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2758 if (!pc || !pc->cb_info) {
2759 LOGE("NULL handle");
2760 return CAMERA_ERROR_INVALID_PARAMETER;
2765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2768 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2769 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2773 LOGD("ret : 0x%x", ret);
2779 bool camera_is_supported_continuous_capture(camera_h camera)
2781 int ret = CAMERA_ERROR_NONE;
2782 camera_cli_s *pc = (camera_cli_s *)camera;
2783 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2785 if (!pc || !pc->cb_info) {
2786 LOGE("NULL handle");
2787 return CAMERA_ERROR_INVALID_PARAMETER;
2792 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2795 LOGE("error is occurred 0x%x", ret);
2799 LOGD("ret : %d", ret);
2805 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)
2807 int ret = CAMERA_ERROR_NONE;
2808 camera_cli_s *pc = (camera_cli_s *)camera;
2809 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2810 camera_msg_param param;
2813 if (!pc || !pc->cb_info) {
2814 LOGE("NULL handle");
2815 return CAMERA_ERROR_INVALID_PARAMETER;
2820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2823 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2824 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2826 value = (count << 16) | interval;
2827 CAMERA_MSG_PARAM_SET(param, INT, value);
2829 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2831 LOGD("ret : 0x%x", ret);
2837 int camera_stop_continuous_capture(camera_h camera)
2839 int ret = CAMERA_ERROR_NONE;
2840 camera_cli_s *pc = (camera_cli_s *)camera;
2841 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2843 if (!pc || !pc->cb_info) {
2844 LOGE("NULL handle");
2845 return CAMERA_ERROR_INVALID_PARAMETER;
2850 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2852 LOGD("ret : 0x%x", ret);
2858 bool camera_is_supported_face_detection(camera_h camera)
2860 int ret = CAMERA_ERROR_NONE;
2861 camera_cli_s *pc = (camera_cli_s *)camera;
2862 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2864 if (!pc || !pc->cb_info) {
2865 LOGE("NULL handle");
2866 return CAMERA_ERROR_INVALID_PARAMETER;
2871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2874 LOGE("error is occurred 0x%x", ret);
2878 LOGD("ret : %d", ret);
2884 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2886 int ret = CAMERA_ERROR_NONE;
2887 camera_cli_s *pc = (camera_cli_s *)camera;
2888 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2890 if (!pc || !pc->cb_info) {
2891 LOGE("NULL handle");
2892 return CAMERA_ERROR_INVALID_PARAMETER;
2897 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2900 LOGE("error is occurred 0x%x", ret);
2904 LOGD("ret : %d", ret);
2910 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2912 int ret = CAMERA_ERROR_NONE;
2913 camera_cli_s *pc = (camera_cli_s *)camera;
2914 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2916 if (!pc || !pc->cb_info) {
2917 LOGE("NULL handle");
2918 return CAMERA_ERROR_INVALID_PARAMETER;
2923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2926 LOGE("error is occurred 0x%x", ret);
2930 LOGD("ret : %d", ret);
2935 int camera_get_device_count(camera_h camera, int *device_count)
2937 int ret = CAMERA_ERROR_NONE;
2938 camera_cli_s *pc = (camera_cli_s *)camera;
2939 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2941 if (!pc || !pc->cb_info) {
2942 LOGE("NULL handle");
2943 return CAMERA_ERROR_INVALID_PARAMETER;
2948 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2950 if (ret == CAMERA_ERROR_NONE)
2951 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2953 LOGD("ret : 0x%x", ret);
2958 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2960 int ret = CAMERA_ERROR_NONE;
2961 camera_cli_s *pc = (camera_cli_s *)camera;
2962 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2964 if (!pc || !pc->cb_info) {
2965 LOGE("NULL handle");
2966 return CAMERA_ERROR_INVALID_PARAMETER;
2971 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2972 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2974 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2976 LOGD("ret : 0x%x", ret);
2981 int camera_stop_face_detection(camera_h camera)
2983 int ret = CAMERA_ERROR_NONE;
2984 camera_cli_s *pc = (camera_cli_s *)camera;
2985 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2987 if (!pc || !pc->cb_info) {
2988 LOGE("NULL handle");
2989 return CAMERA_ERROR_INVALID_PARAMETER;
2994 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2996 LOGD("ret : 0x%x", ret);
3001 int camera_get_state(camera_h camera, camera_state_e *state)
3003 int ret = CAMERA_ERROR_NONE;
3004 camera_cli_s *pc = (camera_cli_s *)camera;
3005 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3007 if (!pc || !pc->cb_info || !state) {
3008 LOGE("NULL pointer %p %p", pc, state);
3009 return CAMERA_ERROR_INVALID_PARAMETER;
3014 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3016 if (ret == CAMERA_ERROR_NONE)
3017 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3019 LOGD("ret : 0x%x", ret);
3024 int camera_start_focusing(camera_h camera, bool continuous)
3026 int ret = CAMERA_ERROR_NONE;
3027 camera_cli_s *pc = (camera_cli_s *)camera;
3028 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3029 camera_msg_param param;
3030 int is_continuous = (int)continuous;
3032 if (!pc || !pc->cb_info) {
3033 LOGE("NULL handle");
3034 return CAMERA_ERROR_INVALID_PARAMETER;
3039 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3041 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3043 LOGD("ret : 0x%x", ret);
3048 int camera_cancel_focusing(camera_h camera)
3050 int ret = CAMERA_ERROR_NONE;
3051 camera_cli_s *pc = (camera_cli_s *)camera;
3052 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3054 if (!pc || !pc->cb_info) {
3055 LOGE("NULL handle");
3056 return CAMERA_ERROR_INVALID_PARAMETER;
3059 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3061 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3063 LOGD("ret : 0x%x", ret);
3068 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3070 int ret = CAMERA_ERROR_NONE;
3071 void *set_display_handle = NULL;
3072 Evas_Object *obj = NULL;
3073 const char *object_type = NULL;
3074 camera_cli_s *pc = (camera_cli_s *)camera;
3075 camera_cb_info_s *cb_info = NULL;
3076 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3077 camera_state_e current_state = CAMERA_STATE_NONE;
3078 camera_msg_param param;
3082 if (!pc || !pc->cb_info) {
3083 LOGE("NULL handle");
3084 return CAMERA_ERROR_INVALID_PARAMETER;
3087 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3088 LOGE("invalid type %d", type);
3089 return CAMERA_ERROR_INVALID_PARAMETER;
3092 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3093 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3094 return CAMERA_ERROR_INVALID_PARAMETER;
3097 cb_info = (camera_cb_info_s *)pc->cb_info;
3099 ret = camera_get_state(camera, ¤t_state);
3100 if (ret != CAMERA_ERROR_NONE) {
3101 LOGE("failed to get current state 0x%x", ret);
3105 if (current_state != CAMERA_STATE_CREATED) {
3106 LOGE("INVALID_STATE : current %d", current_state);
3107 return CAMERA_ERROR_INVALID_STATE;
3110 LOGD("Enter - display : %p", display);
3112 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3113 set_display_handle = 0;
3114 LOGD("display type NONE");
3116 obj = (Evas_Object *)display;
3117 object_type = evas_object_type_get(obj);
3119 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3120 /* get wayland parent id */
3121 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3122 LOGE("failed to get wayland info");
3123 return CAMERA_ERROR_INVALID_OPERATION;
3126 set_display_handle = (void *)&pc->wl_info;
3127 LOGD("display type OVERLAY : handle %p", set_display_handle);
3128 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3129 /* evas object surface */
3130 set_display_handle = (void *)display;
3131 LOGD("display type EVAS : handle %p", set_display_handle);
3133 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3134 g_mutex_lock(&cb_info->evas_mutex);
3136 if (cb_info->evas_info) {
3137 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3138 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3139 if (ret != MM_ERROR_NONE) {
3140 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3141 g_mutex_unlock(&cb_info->evas_mutex);
3142 return CAMERA_ERROR_INVALID_OPERATION;
3146 /* create evas renderer */
3147 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3148 if (ret == MM_ERROR_NONE) {
3149 camera_flip_e flip = CAMERA_FLIP_NONE;
3150 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3151 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3158 camera_get_display_flip(camera, &flip);
3159 camera_get_display_mode(camera, &mode);
3160 camera_get_display_rotation(camera, &rotation);
3161 camera_is_display_visible(camera, &visible);
3162 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3164 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3165 flip, mode, rotation, visible, x, y, width, height);
3167 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3168 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3169 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3170 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3172 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3173 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3176 g_mutex_unlock(&cb_info->evas_mutex);
3178 if (ret != MM_ERROR_NONE) {
3179 LOGE("mm_evas_renderer error 0x%x", ret);
3180 return CAMERA_ERROR_INVALID_OPERATION;
3182 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3183 LOGE("EVAS surface is not supported");
3184 return CAMERA_ERROR_NOT_SUPPORTED;
3185 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3187 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3188 return CAMERA_ERROR_INVALID_PARAMETER;
3191 LOGE("failed to get evas object type from %p", obj);
3192 return CAMERA_ERROR_INVALID_PARAMETER;
3196 pc->display_handle = (intptr_t)set_display_handle;
3198 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3201 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3202 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3204 msg = muse_core_msg_json_factory_new(api,
3205 MUSE_TYPE_INT, "type", type,
3206 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3209 LOGE("msg creation failed: api %d", api);
3210 return CAMERA_ERROR_OUT_OF_MEMORY;
3213 if (pc->cb_info->is_server_connected) {
3214 __camera_update_api_waiting(pc->cb_info, api, 1);
3216 g_mutex_lock(&pc->cb_info->fd_lock);
3217 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3218 g_mutex_unlock(&pc->cb_info->fd_lock);
3222 LOGE("message send failed");
3223 ret = CAMERA_ERROR_INVALID_OPERATION;
3225 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3228 __camera_update_api_waiting(pc->cb_info, api, -1);
3230 muse_core_msg_json_factory_free(msg);
3232 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3233 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3234 pc->wl_info.window_width, pc->wl_info.window_height);
3236 CAMERA_MSG_PARAM_SET(param, INT, type);
3238 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3241 if (ret != CAMERA_ERROR_NONE)
3242 LOGE("set display error 0x%x", ret);
3243 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3244 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3250 int camera_set_preview_resolution(camera_h camera, int width, int height)
3252 int ret = CAMERA_ERROR_NONE;
3253 camera_state_e current_state = CAMERA_STATE_NONE;
3254 camera_cli_s *pc = (camera_cli_s *)camera;
3255 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3256 camera_msg_param param;
3259 if (!pc || !pc->cb_info) {
3260 LOGE("NULL handle");
3261 return CAMERA_ERROR_INVALID_PARAMETER;
3264 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3265 ret = camera_get_state(camera, ¤t_state);
3266 if (ret != CAMERA_ERROR_NONE) {
3267 LOGE("failed to get current state 0x%x", ret);
3271 if (current_state == CAMERA_STATE_PREVIEW) {
3272 ret = _camera_stop_evas_rendering(camera, true);
3273 if (ret != CAMERA_ERROR_NONE)
3278 value = (width << 16) | height;
3279 CAMERA_MSG_PARAM_SET(param, INT, value);
3281 LOGD("%dx%d -> 0x%x", width, height, value);
3283 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3285 LOGD("ret : 0x%x", ret);
3287 if (current_state == CAMERA_STATE_PREVIEW) {
3288 LOGW("restart evas rendering");
3289 _camera_start_evas_rendering(camera);
3296 int camera_set_capture_resolution(camera_h camera, int width, int height)
3298 int ret = CAMERA_ERROR_NONE;
3299 camera_cli_s *pc = (camera_cli_s *)camera;
3300 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3301 camera_msg_param param;
3304 if (!pc || !pc->cb_info) {
3305 LOGE("NULL handle");
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3311 value = (width << 16) | height;
3312 CAMERA_MSG_PARAM_SET(param, INT, value);
3314 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3316 LOGD("ret : 0x%x", ret);
3322 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3324 int ret = CAMERA_ERROR_NONE;
3325 int set_format = (int)format;
3326 camera_cli_s *pc = (camera_cli_s *)camera;
3327 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3328 camera_msg_param param;
3330 if (!pc || !pc->cb_info) {
3331 LOGE("NULL handle");
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3335 LOGD("Enter - format %d", set_format);
3337 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3339 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3341 LOGD("ret : 0x%x", ret);
3347 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3349 int ret = CAMERA_ERROR_NONE;
3350 int set_format = (int)format;
3351 camera_msg_param param;
3352 camera_cli_s *pc = (camera_cli_s *)camera;
3353 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3355 if (!pc || !pc->cb_info) {
3356 LOGE("NULL handle");
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3360 LOGD("Enter - capture_format %d", set_format);
3362 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3364 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3366 LOGD("ret : 0x%x", ret);
3372 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3374 int ret = CAMERA_ERROR_NONE;
3375 camera_cli_s *pc = (camera_cli_s *)camera;
3376 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3378 if (!pc || !pc->cb_info || !width || !height) {
3379 LOGE("NULL pointer %p %p %p", pc, width, height);
3380 return CAMERA_ERROR_INVALID_PARAMETER;
3385 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3387 if (ret == CAMERA_ERROR_NONE) {
3388 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3389 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3392 LOGD("ret : 0x%x", ret);
3398 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3400 int ret = CAMERA_ERROR_NONE;
3401 int set_rotation = (int)rotation;
3402 camera_cli_s *pc = (camera_cli_s *)camera;
3403 camera_msg_param param;
3405 if (!pc || !pc->cb_info) {
3406 LOGE("NULL handle");
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3410 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3411 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3412 g_mutex_lock(&pc->cb_info->evas_mutex);
3414 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3416 g_mutex_unlock(&pc->cb_info->evas_mutex);
3418 if (ret != MM_ERROR_NONE) {
3419 LOGE("failed to set rotation for evas surface 0x%x", ret);
3420 return CAMERA_ERROR_INVALID_OPERATION;
3423 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3425 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3427 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3433 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3435 int ret = CAMERA_ERROR_NONE;
3436 camera_cli_s *pc = (camera_cli_s *)camera;
3438 if (!pc || !pc->cb_info || !rotation) {
3439 LOGE("NULL pointer %p %p", pc, rotation);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3443 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3445 if (ret == CAMERA_ERROR_NONE)
3446 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3452 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3454 int ret = CAMERA_ERROR_NONE;
3455 int set_flip = (int)flip;
3456 camera_cli_s *pc = (camera_cli_s *)camera;
3457 camera_msg_param param;
3459 if (!pc || !pc->cb_info) {
3460 LOGE("NULL handle");
3461 return CAMERA_ERROR_INVALID_PARAMETER;
3464 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3465 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3466 g_mutex_lock(&pc->cb_info->evas_mutex);
3468 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3470 g_mutex_unlock(&pc->cb_info->evas_mutex);
3472 if (ret != MM_ERROR_NONE) {
3473 LOGE("failed to set flip for evas surface 0x%x", ret);
3474 return CAMERA_ERROR_INVALID_OPERATION;
3477 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3479 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3481 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3487 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3489 int ret = CAMERA_ERROR_NONE;
3490 camera_cli_s *pc = (camera_cli_s *)camera;
3492 if (!pc || !pc->cb_info || !flip) {
3493 LOGE("NULL pointer %p %p", pc, flip);
3494 return CAMERA_ERROR_INVALID_PARAMETER;
3497 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3499 if (ret == CAMERA_ERROR_NONE)
3500 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3506 int camera_set_display_visible(camera_h camera, bool visible)
3508 int ret = CAMERA_ERROR_NONE;
3509 int set_visible = (int)visible;
3510 camera_cli_s *pc = (camera_cli_s *)camera;
3511 camera_msg_param param;
3513 if (!pc || !pc->cb_info) {
3514 LOGE("NULL handle");
3515 return CAMERA_ERROR_INVALID_PARAMETER;
3518 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3519 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3520 g_mutex_lock(&pc->cb_info->evas_mutex);
3522 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3524 g_mutex_unlock(&pc->cb_info->evas_mutex);
3526 if (ret != MM_ERROR_NONE) {
3527 LOGE("failed to set visible for evas surface 0x%x", ret);
3528 return CAMERA_ERROR_INVALID_OPERATION;
3531 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3533 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3535 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3541 int camera_is_display_visible(camera_h camera, bool *visible)
3543 int ret = CAMERA_ERROR_NONE;
3544 camera_cli_s *pc = (camera_cli_s *)camera;
3546 if (!pc || !pc->cb_info || !visible) {
3547 LOGE("NULL pointer %p %p", pc, visible);
3548 return CAMERA_ERROR_INVALID_PARAMETER;
3551 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3553 if (ret == CAMERA_ERROR_NONE)
3554 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3560 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3562 int ret = CAMERA_ERROR_NONE;
3563 int set_mode = (int)mode;
3564 camera_cli_s *pc = (camera_cli_s *)camera;
3565 camera_msg_param param;
3567 if (!pc || !pc->cb_info) {
3568 LOGE("NULL handle");
3569 return CAMERA_ERROR_INVALID_PARAMETER;
3572 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3573 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3574 g_mutex_lock(&pc->cb_info->evas_mutex);
3576 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3578 g_mutex_unlock(&pc->cb_info->evas_mutex);
3580 if (ret != MM_ERROR_NONE) {
3581 LOGE("failed to set geometry for evas surface 0x%x", ret);
3582 return CAMERA_ERROR_INVALID_OPERATION;
3585 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3587 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3589 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3595 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3597 int ret = CAMERA_ERROR_NONE;
3598 camera_cli_s *pc = (camera_cli_s *)camera;
3600 if (!pc || !pc->cb_info || !mode) {
3601 LOGE("NULL pointer %p %p", pc, mode);
3602 return CAMERA_ERROR_INVALID_PARAMETER;
3605 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3607 if (ret == CAMERA_ERROR_NONE)
3608 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3614 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3616 int ret = CAMERA_ERROR_NONE;
3617 int set_hint = (int)hint;
3618 camera_cli_s *pc = (camera_cli_s *)camera;
3619 camera_msg_param param;
3621 if (!pc || !pc->cb_info) {
3622 LOGE("NULL handle");
3623 return CAMERA_ERROR_INVALID_PARAMETER;
3626 LOGD("Enter - hint %d", set_hint);
3628 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3630 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3636 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3638 int ret = CAMERA_ERROR_NONE;
3639 camera_cli_s *pc = (camera_cli_s *)camera;
3640 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3642 if (!pc || !pc->cb_info || !hint) {
3643 LOGE("NULL pointer %p %p", pc, hint);
3644 return CAMERA_ERROR_INVALID_PARAMETER;
3647 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3649 if (ret == CAMERA_ERROR_NONE) {
3650 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3651 LOGD("display reuse hint %d", *hint);
3658 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3660 int ret = CAMERA_ERROR_NONE;
3661 camera_cli_s *pc = (camera_cli_s *)camera;
3662 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3664 if (!pc || !pc->cb_info || !width || !height) {
3665 LOGE("NULL pointer %p %p %p", pc, width, height);
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3671 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3673 if (ret == CAMERA_ERROR_NONE) {
3674 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3675 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3678 LOGD("ret : 0x%x", ret);
3684 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3690 if (!pc || !pc->cb_info || !format) {
3691 LOGE("NULL pointer %p %p", pc, format);
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE)
3700 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3702 LOGD("ret : 0x%x", ret);
3708 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3710 int ret = CAMERA_ERROR_NONE;
3711 camera_cli_s *pc = (camera_cli_s *)camera;
3712 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3714 if (!pc || !pc->cb_info || !format) {
3715 LOGE("NULL pointer %p %p", pc, format);
3716 return CAMERA_ERROR_INVALID_PARAMETER;
3721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3723 if (ret == CAMERA_ERROR_NONE)
3724 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3726 LOGD("ret : 0x%x", ret);
3732 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3734 int ret = CAMERA_ERROR_NONE;
3735 camera_cli_s *pc = (camera_cli_s *)camera;
3736 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3738 if (!pc || !pc->cb_info || !facing_direction) {
3739 LOGE("NULL pointer %p %p", pc, facing_direction);
3740 return CAMERA_ERROR_INVALID_PARAMETER;
3745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3747 if (ret == CAMERA_ERROR_NONE)
3748 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3750 LOGD("ret : 0x%x", ret);
3756 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3758 int ret = CAMERA_ERROR_NONE;
3759 camera_cli_s *pc = (camera_cli_s *)camera;
3760 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3762 if (!pc || !pc->cb_info || !callback) {
3763 LOGE("NULL pointer %p %p", pc, callback);
3764 return CAMERA_ERROR_INVALID_PARAMETER;
3769 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3771 if (ret == CAMERA_ERROR_NONE) {
3772 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3773 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3774 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3777 LOGD("ret : 0x%x", ret);
3783 int camera_unset_preview_cb(camera_h camera)
3785 int ret = CAMERA_ERROR_NONE;
3786 camera_cli_s *pc = (camera_cli_s *)camera;
3787 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3789 if (!pc || !pc->cb_info) {
3790 LOGE("NULL handle");
3791 return CAMERA_ERROR_INVALID_PARAMETER;
3796 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3797 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3799 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3801 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3803 LOGD("ret : 0x%x", ret);
3809 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3811 int ret = CAMERA_ERROR_NONE;
3812 camera_cli_s *pc = (camera_cli_s *)camera;
3813 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3815 if (!pc || !pc->cb_info) {
3816 LOGE("NULL handle");
3817 return CAMERA_ERROR_INVALID_PARAMETER;
3820 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3821 LOGE("NOT SUPPORTED");
3822 return CAMERA_ERROR_NOT_SUPPORTED;
3825 if (callback == NULL) {
3826 LOGE("NULL callback");
3827 return CAMERA_ERROR_INVALID_PARAMETER;
3832 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3834 if (ret == CAMERA_ERROR_NONE) {
3835 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3836 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3839 LOGD("ret : 0x%x", ret);
3845 int camera_unset_media_packet_preview_cb(camera_h camera)
3847 int ret = CAMERA_ERROR_NONE;
3848 camera_cli_s *pc = (camera_cli_s *)camera;
3849 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3851 if (!pc || !pc->cb_info) {
3852 LOGE("NULL handle");
3853 return CAMERA_ERROR_INVALID_PARAMETER;
3858 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3859 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3861 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3863 LOGD("ret : 0x%x", ret);
3869 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3871 int ret = CAMERA_ERROR_NONE;
3872 camera_cli_s *pc = (camera_cli_s *)camera;
3873 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3875 if (!pc || !pc->cb_info || !callback) {
3876 LOGE("NULL pointer %p %p", pc, callback);
3877 return CAMERA_ERROR_INVALID_PARAMETER;
3882 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3884 if (ret == CAMERA_ERROR_NONE) {
3885 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3886 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3889 LOGD("ret : 0x%x", ret);
3895 int camera_unset_state_changed_cb(camera_h camera)
3897 int ret = CAMERA_ERROR_NONE;
3898 camera_cli_s *pc = (camera_cli_s *)camera;
3899 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3901 if (!pc || !pc->cb_info) {
3902 LOGE("NULL handle");
3903 return CAMERA_ERROR_INVALID_PARAMETER;
3908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3911 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3913 LOGD("ret : 0x%x", ret);
3919 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3921 int ret = CAMERA_ERROR_NONE;
3922 camera_cli_s *pc = (camera_cli_s *)camera;
3923 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3925 if (!pc || !pc->cb_info || !callback) {
3926 LOGE("NULL pointer %p %p", pc, callback);
3927 return CAMERA_ERROR_INVALID_PARAMETER;
3932 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3934 if (ret == CAMERA_ERROR_NONE) {
3935 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3936 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3939 LOGD("ret : 0x%x", ret);
3945 int camera_unset_interrupted_cb(camera_h camera)
3947 int ret = CAMERA_ERROR_NONE;
3948 camera_cli_s *pc = (camera_cli_s *)camera;
3949 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3951 if (!pc || !pc->cb_info) {
3952 LOGE("NULL handle");
3953 return CAMERA_ERROR_INVALID_PARAMETER;
3958 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3959 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3961 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3963 LOGD("ret : 0x%x", ret);
3969 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3971 int ret = CAMERA_ERROR_NONE;
3972 camera_cli_s *pc = (camera_cli_s *)camera;
3973 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3975 if (!pc || !pc->cb_info || !callback) {
3976 LOGE("NULL pointer %p %p", pc, callback);
3977 return CAMERA_ERROR_INVALID_PARAMETER;
3982 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3984 if (ret == CAMERA_ERROR_NONE) {
3985 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3986 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3989 LOGD("ret : 0x%x", ret);
3995 int camera_unset_focus_changed_cb(camera_h camera)
3997 int ret = CAMERA_ERROR_NONE;
3998 camera_cli_s *pc = (camera_cli_s *)camera;
3999 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4001 if (!pc || !pc->cb_info) {
4002 LOGE("NULL handle");
4003 return CAMERA_ERROR_INVALID_PARAMETER;
4008 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4009 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4011 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4013 LOGD("ret : 0x%x", ret);
4019 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4021 int ret = CAMERA_ERROR_NONE;
4022 camera_cli_s *pc = (camera_cli_s *)camera;
4023 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4025 if (!pc || !pc->cb_info || !callback) {
4026 LOGE("NULL pointer %p %p", pc, callback);
4027 return CAMERA_ERROR_INVALID_PARAMETER;
4032 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4034 if (ret == CAMERA_ERROR_NONE) {
4035 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4036 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4039 LOGD("ret : 0x%x", ret);
4045 int camera_unset_error_cb(camera_h camera)
4047 int ret = CAMERA_ERROR_NONE;
4048 camera_cli_s *pc = (camera_cli_s *)camera;
4049 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4051 if (!pc || !pc->cb_info) {
4052 LOGE("NULL handle");
4053 return CAMERA_ERROR_INVALID_PARAMETER;
4058 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4059 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4061 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4063 LOGD("ret : 0x%x", ret);
4069 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4071 int ret = CAMERA_ERROR_NONE;
4072 camera_cli_s *pc = (camera_cli_s *)camera;
4073 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4075 if (!pc || !pc->cb_info || !foreach_cb) {
4076 LOGE("NULL pointer %p %p", pc, foreach_cb);
4077 return CAMERA_ERROR_INVALID_PARAMETER;
4082 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4083 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4085 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4087 LOGD("ret : 0x%x", ret);
4093 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4095 int ret = CAMERA_ERROR_NONE;
4096 camera_cli_s *pc = (camera_cli_s *)camera;
4097 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4099 if (!pc || !pc->cb_info || !foreach_cb) {
4100 LOGE("NULL pointer %p %p", pc, foreach_cb);
4101 return CAMERA_ERROR_INVALID_PARAMETER;
4106 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4107 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4109 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4111 LOGD("ret : 0x%x", ret);
4117 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4119 int ret = CAMERA_ERROR_NONE;
4120 camera_cli_s *pc = (camera_cli_s *)camera;
4121 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4123 if (!pc || !pc->cb_info || !foreach_cb) {
4124 LOGE("NULL pointer %p %p", pc, foreach_cb);
4125 return CAMERA_ERROR_INVALID_PARAMETER;
4130 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4131 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4133 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4135 LOGD("ret : 0x%x", ret);
4141 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4143 int ret = CAMERA_ERROR_NONE;
4144 camera_cli_s *pc = (camera_cli_s *)camera;
4145 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4147 if (!pc || !pc->cb_info || !foreach_cb) {
4148 LOGE("NULL pointer %p %p", pc, foreach_cb);
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4154 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4155 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4157 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4159 LOGD("ret : 0x%x", ret);
4165 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4167 int ret = CAMERA_ERROR_NONE;
4168 camera_cli_s *pc = (camera_cli_s *)camera;
4169 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4171 if (!pc || !pc->cb_info || !width || !height) {
4172 LOGE("NULL pointer %p %p %p", pc, width, height);
4173 return CAMERA_ERROR_INVALID_PARAMETER;
4177 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4179 if (ret == CAMERA_ERROR_NONE) {
4180 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4181 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4184 LOGD("ret : 0x%x", ret);
4190 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4192 int ret = CAMERA_ERROR_NONE;
4193 camera_cli_s *pc = (camera_cli_s *)camera;
4194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4196 if (!pc || !pc->cb_info || !angle) {
4197 LOGE("NULL pointer %p %p", pc, angle);
4198 return CAMERA_ERROR_INVALID_PARAMETER;
4203 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4205 if (ret == CAMERA_ERROR_NONE)
4206 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4208 LOGD("ret : 0x%x", ret);
4214 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4216 int ret = CAMERA_ERROR_NONE;
4217 camera_cli_s *pc = (camera_cli_s *)camera;
4218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4219 camera_msg_param param;
4220 int set_mode = (int)mode;
4222 if (!pc || !pc->cb_info) {
4223 LOGE("NULL handle");
4224 return CAMERA_ERROR_INVALID_PARAMETER;
4229 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4231 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4233 LOGD("ret : 0x%x", ret);
4239 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4241 int ret = CAMERA_ERROR_NONE;
4242 camera_cli_s *pc = (camera_cli_s *)camera;
4243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4245 if (!pc || !pc->cb_info || !mode) {
4246 LOGE("NULL pointer %p %p", pc, mode);
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4252 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4254 if (ret == CAMERA_ERROR_NONE)
4255 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4257 LOGD("ret : 0x%x", ret);
4263 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4265 int ret = CAMERA_ERROR_NONE;
4266 camera_cli_s *pc = (camera_cli_s *)camera;
4267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4269 if (!pc || !pc->cb_info || !foreach_cb) {
4270 LOGE("NULL pointer %p %p", pc, foreach_cb);
4271 return CAMERA_ERROR_INVALID_PARAMETER;
4276 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4277 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4279 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4281 LOGD("Finish, return :%x", ret);
4287 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4289 int ret = CAMERA_ERROR_NONE;
4290 camera_cli_s *pc = (camera_cli_s *)camera;
4291 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4292 camera_msg_param param;
4293 int set_fps = (int)fps;
4295 if (!pc || !pc->cb_info) {
4296 LOGE("NULL handle");
4297 return CAMERA_ERROR_INVALID_PARAMETER;
4302 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4304 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4306 LOGD("ret : 0x%x", ret);
4312 int camera_attr_set_image_quality(camera_h camera, int quality)
4314 int ret = CAMERA_ERROR_NONE;
4315 camera_cli_s *pc = (camera_cli_s *)camera;
4316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4317 camera_msg_param param;
4319 if (!pc || !pc->cb_info) {
4320 LOGE("NULL handle");
4321 return CAMERA_ERROR_INVALID_PARAMETER;
4326 CAMERA_MSG_PARAM_SET(param, INT, quality);
4328 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4330 LOGD("ret : 0x%x", ret);
4336 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4338 int ret = CAMERA_ERROR_NONE;
4339 camera_cli_s *pc = (camera_cli_s *)camera;
4340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4342 if (!pc || !pc->cb_info || !fps) {
4343 LOGE("NULL pointer %p %p", pc, fps);
4344 return CAMERA_ERROR_INVALID_PARAMETER;
4349 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4351 if (ret == CAMERA_ERROR_NONE)
4352 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4354 LOGD("ret : 0x%x", ret);
4360 int camera_attr_get_image_quality(camera_h camera, int *quality)
4362 int ret = CAMERA_ERROR_NONE;
4363 camera_cli_s *pc = (camera_cli_s *)camera;
4364 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4366 if (!pc || !pc->cb_info || !quality) {
4367 LOGE("NULL pointer %p %p", pc, quality);
4368 return CAMERA_ERROR_INVALID_PARAMETER;
4373 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4375 if (ret == CAMERA_ERROR_NONE)
4376 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4378 LOGD("ret : 0x%x", ret);
4384 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4386 int ret = CAMERA_ERROR_NONE;
4387 camera_cli_s *pc = (camera_cli_s *)camera;
4388 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4390 if (!pc || !pc->cb_info || !bitrate) {
4391 LOGE("NULL pointer %p %p", pc, bitrate);
4392 return CAMERA_ERROR_INVALID_PARAMETER;
4397 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4399 if (ret == CAMERA_ERROR_NONE)
4400 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4402 LOGD("ret : 0x%x", ret);
4408 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4410 int ret = CAMERA_ERROR_NONE;
4411 camera_cli_s *pc = (camera_cli_s *)camera;
4412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4413 camera_msg_param param;
4414 int set_bitrate = bitrate;
4416 if (!pc || !pc->cb_info) {
4417 LOGE("NULL handle");
4418 return CAMERA_ERROR_INVALID_PARAMETER;
4423 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4425 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4427 LOGD("ret : 0x%x", ret);
4433 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4435 int ret = CAMERA_ERROR_NONE;
4436 camera_cli_s *pc = (camera_cli_s *)camera;
4437 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4439 if (!pc || !pc->cb_info || !interval) {
4440 LOGE("NULL pointer %p %p", pc, interval);
4441 return CAMERA_ERROR_INVALID_PARAMETER;
4446 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4448 if (ret == CAMERA_ERROR_NONE)
4449 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4451 LOGD("ret : 0x%x", ret);
4457 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4459 int ret = CAMERA_ERROR_NONE;
4460 camera_cli_s *pc = (camera_cli_s *)camera;
4461 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4462 camera_msg_param param;
4463 int set_gop_interval = interval;
4465 if (!pc || !pc->cb_info) {
4466 LOGE("NULL handle");
4467 return CAMERA_ERROR_INVALID_PARAMETER;
4472 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4474 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4476 LOGD("ret : 0x%x", ret);
4482 int camera_attr_set_zoom(camera_h camera, int zoom)
4484 int ret = CAMERA_ERROR_NONE;
4485 camera_cli_s *pc = (camera_cli_s *)camera;
4486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4487 camera_msg_param param;
4489 if (!pc || !pc->cb_info) {
4490 LOGE("NULL handle");
4491 return CAMERA_ERROR_INVALID_PARAMETER;
4494 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4496 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4498 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4500 LOGD("ret : 0x%x", ret);
4506 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4508 int ret = CAMERA_ERROR_NONE;
4509 camera_cli_s *pc = (camera_cli_s *)camera;
4510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4511 camera_msg_param param;
4512 int set_mode = (int)mode;
4514 if (!pc || !pc->cb_info) {
4515 LOGE("NULL handle");
4516 return CAMERA_ERROR_INVALID_PARAMETER;
4519 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4521 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4523 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4529 int camera_attr_set_af_area(camera_h camera, int x, int y)
4531 int ret = CAMERA_ERROR_NONE;
4532 camera_cli_s *pc = (camera_cli_s *)camera;
4533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4534 camera_msg_param param;
4537 if (!pc || !pc->cb_info) {
4538 LOGE("NULL handle");
4539 return CAMERA_ERROR_INVALID_PARAMETER;
4542 LOGD("Enter - %d,%d", x, y);
4544 value = (x << 16) | y;
4545 CAMERA_MSG_PARAM_SET(param, INT, value);
4547 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4549 LOGD("ret : 0x%x", ret);
4555 int camera_attr_clear_af_area(camera_h camera)
4557 int ret = CAMERA_ERROR_NONE;
4558 camera_cli_s *pc = (camera_cli_s *)camera;
4559 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4561 if (!pc || !pc->cb_info) {
4562 LOGE("NULL handle");
4563 return CAMERA_ERROR_INVALID_PARAMETER;
4568 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4570 LOGD("ret : 0x%x", ret);
4576 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4578 int ret = CAMERA_ERROR_NONE;
4579 camera_cli_s *pc = (camera_cli_s *)camera;
4580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4581 camera_msg_param param;
4582 int set_mode = (int)mode;
4584 if (!pc || !pc->cb_info) {
4585 LOGE("NULL handle");
4586 return CAMERA_ERROR_INVALID_PARAMETER;
4591 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4593 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4595 LOGD("ret : 0x%x", ret);
4601 int camera_attr_set_exposure(camera_h camera, int value)
4603 int ret = CAMERA_ERROR_NONE;
4604 camera_cli_s *pc = (camera_cli_s *)camera;
4605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4606 camera_msg_param param;
4608 if (!pc || !pc->cb_info) {
4609 LOGE("NULL handle");
4610 return CAMERA_ERROR_INVALID_PARAMETER;
4615 CAMERA_MSG_PARAM_SET(param, INT, value);
4617 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4619 LOGD("ret : 0x%x", ret);
4625 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4627 int ret = CAMERA_ERROR_NONE;
4628 camera_cli_s *pc = (camera_cli_s *)camera;
4629 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4630 camera_msg_param param;
4631 int set_iso = (int)iso;
4633 if (!pc || !pc->cb_info) {
4634 LOGE("NULL handle");
4635 return CAMERA_ERROR_INVALID_PARAMETER;
4640 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4642 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4644 LOGD("ret : 0x%x", ret);
4650 int camera_attr_set_brightness(camera_h camera, int level)
4652 int ret = CAMERA_ERROR_NONE;
4653 camera_cli_s *pc = (camera_cli_s *)camera;
4654 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4655 camera_msg_param param;
4657 if (!pc || !pc->cb_info) {
4658 LOGE("NULL handle");
4659 return CAMERA_ERROR_INVALID_PARAMETER;
4664 CAMERA_MSG_PARAM_SET(param, INT, level);
4666 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4668 LOGD("ret : 0x%x", ret);
4674 int camera_attr_set_contrast(camera_h camera, int level)
4676 int ret = CAMERA_ERROR_NONE;
4677 camera_cli_s *pc = (camera_cli_s *)camera;
4678 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4679 camera_msg_param param;
4681 if (!pc || !pc->cb_info) {
4682 LOGE("NULL handle");
4683 return CAMERA_ERROR_INVALID_PARAMETER;
4688 CAMERA_MSG_PARAM_SET(param, INT, level);
4690 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4692 LOGD("ret : 0x%x", ret);
4698 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4700 int ret = CAMERA_ERROR_NONE;
4701 camera_cli_s *pc = (camera_cli_s *)camera;
4702 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4703 camera_msg_param param;
4704 int set_whitebalance = (int)wb;
4706 if (!pc || !pc->cb_info) {
4707 LOGE("NULL handle");
4708 return CAMERA_ERROR_INVALID_PARAMETER;
4713 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4717 LOGD("ret : 0x%x", ret);
4723 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4725 int ret = CAMERA_ERROR_NONE;
4726 camera_cli_s *pc = (camera_cli_s *)camera;
4727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4728 camera_msg_param param;
4729 int set_effect = (int)effect;
4731 if (!pc || !pc->cb_info) {
4732 LOGE("NULL handle");
4733 return CAMERA_ERROR_INVALID_PARAMETER;
4738 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4740 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4742 LOGD("ret : 0x%x", ret);
4748 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4750 int ret = CAMERA_ERROR_NONE;
4751 camera_cli_s *pc = (camera_cli_s *)camera;
4752 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4753 camera_msg_param param;
4754 int set_mode = (int)mode;
4756 if (!pc || !pc->cb_info) {
4757 LOGE("NULL handle");
4758 return CAMERA_ERROR_INVALID_PARAMETER;
4763 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4765 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4767 LOGD("ret : 0x%x", ret);
4773 int camera_attr_enable_tag(camera_h camera, bool enable)
4775 int ret = CAMERA_ERROR_NONE;
4776 camera_cli_s *pc = (camera_cli_s *)camera;
4777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4778 camera_msg_param param;
4779 int set_enable = (int)enable;
4781 if (!pc || !pc->cb_info) {
4782 LOGE("NULL handle");
4783 return CAMERA_ERROR_INVALID_PARAMETER;
4788 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4790 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4792 LOGD("ret : 0x%x", ret);
4798 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4800 int ret = CAMERA_ERROR_NONE;
4801 camera_cli_s *pc = (camera_cli_s *)camera;
4802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4803 camera_msg_param param;
4805 if (!pc || !pc->cb_info || !description) {
4806 LOGE("NULL pointer %p %p", pc, description);
4807 return CAMERA_ERROR_INVALID_PARAMETER;
4812 CAMERA_MSG_PARAM_SET(param, STRING, description);
4814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4816 LOGD("ret : 0x%x", ret);
4822 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4824 int ret = CAMERA_ERROR_NONE;
4825 camera_cli_s *pc = (camera_cli_s *)camera;
4826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4827 camera_msg_param param;
4828 int set_orientation = (int)orientation;
4830 if (!pc || !pc->cb_info) {
4831 LOGE("NULL handle");
4832 return CAMERA_ERROR_INVALID_PARAMETER;
4837 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4841 LOGD("ret : 0x%x", ret);
4847 int camera_attr_set_tag_software(camera_h camera, const char *software)
4849 int ret = CAMERA_ERROR_NONE;
4850 camera_cli_s *pc = (camera_cli_s *)camera;
4851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4852 camera_msg_param param;
4854 if (!pc || !pc->cb_info || !software) {
4855 LOGE("NULL pointer %p %p", pc, software);
4856 return CAMERA_ERROR_INVALID_PARAMETER;
4859 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4861 CAMERA_MSG_PARAM_SET(param, STRING, software);
4863 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4876 double set_geotag[3] = {latitude, longitude, altitude};
4881 if (!pc || !pc->cb_info) {
4882 LOGE("NULL handle");
4883 return CAMERA_ERROR_INVALID_PARAMETER;
4888 length = sizeof(set_geotag) / sizeof(int) + \
4889 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4891 msg = muse_core_msg_json_factory_new(api,
4892 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4895 LOGE("msg creation failed: api %d", api);
4896 return CAMERA_ERROR_OUT_OF_MEMORY;
4899 if (pc->cb_info->is_server_connected) {
4900 __camera_update_api_waiting(pc->cb_info, api, 1);
4902 g_mutex_lock(&pc->cb_info->fd_lock);
4903 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4904 g_mutex_unlock(&pc->cb_info->fd_lock);
4908 LOGE("message send failed");
4909 ret = CAMERA_ERROR_INVALID_OPERATION;
4911 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4914 __camera_update_api_waiting(pc->cb_info, api, -1);
4916 muse_core_msg_json_factory_free(msg);
4918 LOGD("ret : 0x%x", ret);
4924 int camera_attr_remove_geotag(camera_h camera)
4926 int ret = CAMERA_ERROR_NONE;
4927 camera_cli_s *pc = (camera_cli_s *)camera;
4928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4930 if (!pc || !pc->cb_info) {
4931 LOGE("NULL handle");
4932 return CAMERA_ERROR_INVALID_PARAMETER;
4937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4939 LOGD("ret : 0x%x", ret);
4945 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4947 int ret = CAMERA_ERROR_NONE;
4948 camera_cli_s *pc = (camera_cli_s *)camera;
4949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4950 camera_msg_param param;
4951 int set_mode = (int)mode;
4953 if (!pc || !pc->cb_info) {
4954 LOGE("NULL handle");
4955 return CAMERA_ERROR_INVALID_PARAMETER;
4960 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4962 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4964 LOGD("ret : 0x%x", ret);
4970 int camera_attr_get_zoom(camera_h camera, int *zoom)
4972 int ret = CAMERA_ERROR_NONE;
4973 camera_cli_s *pc = (camera_cli_s *)camera;
4974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4976 if (!pc || !pc->cb_info || !zoom) {
4977 LOGE("NULL pointer %p %p", pc, zoom);
4978 return CAMERA_ERROR_INVALID_PARAMETER;
4983 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4985 if (ret == CAMERA_ERROR_NONE)
4986 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4988 LOGD("ret : 0x%x", ret);
4994 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4996 int ret = CAMERA_ERROR_NONE;
4997 camera_cli_s *pc = (camera_cli_s *)camera;
4998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5000 if (!pc || !pc->cb_info || !min || !max) {
5001 LOGE("NULL pointer %p %p %p", pc, min, max);
5002 return CAMERA_ERROR_INVALID_PARAMETER;
5007 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5009 if (ret == CAMERA_ERROR_NONE) {
5010 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5011 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5014 LOGD("ret : 0x%x", ret);
5020 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5022 int ret = CAMERA_ERROR_NONE;
5023 camera_cli_s *pc = (camera_cli_s *)camera;
5024 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5026 if (!pc || !pc->cb_info || !mode) {
5027 LOGE("NULL pointer %p %p", pc, mode);
5028 return CAMERA_ERROR_INVALID_PARAMETER;
5033 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5035 if (ret == CAMERA_ERROR_NONE)
5036 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5038 LOGD("ret : 0x%x", ret);
5044 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5046 int ret = CAMERA_ERROR_NONE;
5047 camera_cli_s *pc = (camera_cli_s *)camera;
5048 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5050 if (!pc || !pc->cb_info || !mode) {
5051 LOGE("NULL pointer %p %p", pc, mode);
5052 return CAMERA_ERROR_INVALID_PARAMETER;
5057 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5059 if (ret == CAMERA_ERROR_NONE)
5060 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5062 LOGD("ret : 0x%x", ret);
5068 int camera_attr_get_exposure(camera_h camera, int *value)
5070 int ret = CAMERA_ERROR_NONE;
5071 camera_cli_s *pc = (camera_cli_s *)camera;
5072 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5074 if (!pc || !pc->cb_info || !value) {
5075 LOGE("NULL pointer %p %p", pc, value);
5076 return CAMERA_ERROR_INVALID_PARAMETER;
5081 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5083 if (ret == CAMERA_ERROR_NONE)
5084 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5086 LOGD("ret : 0x%x", ret);
5092 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5094 int ret = CAMERA_ERROR_NONE;
5095 camera_cli_s *pc = (camera_cli_s *)camera;
5096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5098 if (!pc || !pc->cb_info || !min || !max) {
5099 LOGE("NULL pointer %p %p %p", pc, min, max);
5100 return CAMERA_ERROR_INVALID_PARAMETER;
5105 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5107 if (ret == CAMERA_ERROR_NONE) {
5108 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5109 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5112 LOGD("ret : 0x%x", ret);
5118 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5120 int ret = CAMERA_ERROR_NONE;
5121 camera_cli_s *pc = (camera_cli_s *)camera;
5122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5124 if (!pc || !pc->cb_info || !iso) {
5125 LOGE("NULL pointer %p %p", pc, iso);
5126 return CAMERA_ERROR_INVALID_PARAMETER;
5131 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5133 if (ret == CAMERA_ERROR_NONE)
5134 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5136 LOGD("ret : 0x%x", ret);
5142 int camera_attr_get_brightness(camera_h camera, int *level)
5144 int ret = CAMERA_ERROR_NONE;
5145 camera_cli_s *pc = (camera_cli_s *)camera;
5146 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5148 if (!pc || !pc->cb_info || !level) {
5149 LOGE("NULL pointer %p %p", pc, level);
5150 return CAMERA_ERROR_INVALID_PARAMETER;
5155 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5157 if (ret == CAMERA_ERROR_NONE)
5158 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5160 LOGD("ret : 0x%x", ret);
5166 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5168 int ret = CAMERA_ERROR_NONE;
5169 camera_cli_s *pc = (camera_cli_s *)camera;
5170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5172 if (!pc || !pc->cb_info || !min || !max) {
5173 LOGE("NULL pointer %p %p %p", pc, min, max);
5174 return CAMERA_ERROR_INVALID_PARAMETER;
5179 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5181 if (ret == CAMERA_ERROR_NONE) {
5182 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5183 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5186 LOGD("ret : 0x%x", ret);
5192 int camera_attr_get_contrast(camera_h camera, int *level)
5194 int ret = CAMERA_ERROR_NONE;
5195 camera_cli_s *pc = (camera_cli_s *)camera;
5196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5198 if (!pc || !pc->cb_info || !level) {
5199 LOGE("NULL pointer %p %p", pc, level);
5200 return CAMERA_ERROR_INVALID_PARAMETER;
5205 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5207 if (ret == CAMERA_ERROR_NONE)
5208 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5210 LOGD("ret : 0x%x", ret);
5216 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5218 int ret = CAMERA_ERROR_NONE;
5219 camera_cli_s *pc = (camera_cli_s *)camera;
5220 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5222 if (!pc || !pc->cb_info || !min || !max) {
5223 LOGE("NULL pointer %p %p %p", pc, min, max);
5224 return CAMERA_ERROR_INVALID_PARAMETER;
5229 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5231 if (ret == CAMERA_ERROR_NONE) {
5232 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5233 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5234 LOGD("min %d, max %d", *min, *max);
5237 LOGD("ret : 0x%x", ret);
5243 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5245 int ret = CAMERA_ERROR_NONE;
5246 camera_cli_s *pc = (camera_cli_s *)camera;
5247 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5249 if (!pc || !pc->cb_info || !wb) {
5250 LOGE("NULL pointer %p %p", pc, wb);
5251 return CAMERA_ERROR_INVALID_PARAMETER;
5256 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5258 if (ret == CAMERA_ERROR_NONE)
5259 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5261 LOGD("ret : 0x%x", ret);
5267 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5269 int ret = CAMERA_ERROR_NONE;
5270 camera_cli_s *pc = (camera_cli_s *)camera;
5271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5273 if (!pc || !pc->cb_info || !effect) {
5274 LOGE("NULL pointer %p %p", pc, effect);
5275 return CAMERA_ERROR_INVALID_PARAMETER;
5280 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5282 if (ret == CAMERA_ERROR_NONE)
5283 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5285 LOGD("ret : 0x%x", ret);
5291 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5293 int ret = CAMERA_ERROR_NONE;
5294 camera_cli_s *pc = (camera_cli_s *)camera;
5295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5297 if (!pc || !pc->cb_info || !mode) {
5298 LOGE("NULL pointer %p %p", pc, mode);
5299 return CAMERA_ERROR_INVALID_PARAMETER;
5304 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5306 if (ret == CAMERA_ERROR_NONE)
5307 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5317 int ret = CAMERA_ERROR_NONE;
5318 camera_cli_s *pc = (camera_cli_s *)camera;
5319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5321 if (!pc || !pc->cb_info || !enable) {
5322 LOGE("NULL pointer %p %p", pc, enable);
5323 return CAMERA_ERROR_INVALID_PARAMETER;
5328 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5330 if (ret == CAMERA_ERROR_NONE)
5331 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5333 LOGD("ret : 0x%x", ret);
5339 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5345 if (!pc || !pc->cb_info || !description) {
5346 LOGE("NULL pointer %p %p", pc, description);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE)
5355 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5357 LOGD("ret : 0x%x", ret);
5363 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5365 int ret = CAMERA_ERROR_NONE;
5366 camera_cli_s *pc = (camera_cli_s *)camera;
5367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5369 if (!pc || !pc->cb_info || !orientation) {
5370 LOGE("NULL pointer %p %p", pc, orientation);
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5378 if (ret == CAMERA_ERROR_NONE)
5379 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5381 LOGD("ret : 0x%x", ret);
5387 int camera_attr_get_tag_software(camera_h camera, char **software)
5389 int ret = CAMERA_ERROR_NONE;
5390 camera_cli_s *pc = (camera_cli_s *)camera;
5391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5393 if (!pc || !pc->cb_info || !software) {
5394 LOGE("NULL pointer %p %p", pc, software);
5395 return CAMERA_ERROR_INVALID_PARAMETER;
5400 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5402 if (ret == CAMERA_ERROR_NONE)
5403 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5405 LOGD("ret : 0x%x", ret);
5411 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5413 int ret = CAMERA_ERROR_NONE;
5414 camera_cli_s *pc = (camera_cli_s *)camera;
5415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5417 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5418 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5419 return CAMERA_ERROR_INVALID_PARAMETER;
5424 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5426 if (ret == CAMERA_ERROR_NONE) {
5427 *latitude = pc->cb_info->get_geotag[0];
5428 *longitude = pc->cb_info->get_geotag[1];
5429 *altitude = pc->cb_info->get_geotag[2];
5432 LOGD("ret : 0x%x", ret);
5438 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5440 int ret = CAMERA_ERROR_NONE;
5441 camera_cli_s *pc = (camera_cli_s *)camera;
5442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5444 if (!pc || !pc->cb_info || !mode) {
5445 LOGE("NULL pointer %p %p", pc, mode);
5446 return CAMERA_ERROR_INVALID_PARAMETER;
5451 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5453 if (ret == CAMERA_ERROR_NONE)
5454 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5456 LOGD("ret : 0x%x", ret);
5462 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5464 int ret = CAMERA_ERROR_NONE;
5465 int get_flash_state = 0;
5468 LOGE("NULL pointer");
5469 return CAMERA_ERROR_INVALID_PARAMETER;
5472 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5473 (int)device, "get_flash_state", &get_flash_state);
5475 if (ret == CAMERA_ERROR_NONE) {
5476 *state = (camera_flash_state_e)get_flash_state;
5477 LOGD("flash state %d", *state);
5479 LOGE("failed 0x%x", ret);
5486 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5488 int ret = CAMERA_ERROR_NONE;
5489 camera_cli_s *pc = (camera_cli_s *)camera;
5490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5492 if (!pc || !pc->cb_info || !foreach_cb) {
5493 LOGE("NULL pointer %p %p", pc, foreach_cb);
5494 return CAMERA_ERROR_INVALID_PARAMETER;
5499 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5500 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5502 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5504 LOGD("ret : 0x%x", ret);
5510 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5512 int ret = CAMERA_ERROR_NONE;
5513 camera_cli_s *pc = (camera_cli_s *)camera;
5514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5516 if (!pc || !pc->cb_info || !foreach_cb) {
5517 LOGE("NULL pointer %p %p", pc, foreach_cb);
5518 return CAMERA_ERROR_INVALID_PARAMETER;
5523 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5524 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5526 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5528 LOGD("ret : 0x%x", ret);
5534 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5540 if (!pc || !pc->cb_info || !foreach_cb) {
5541 LOGE("NULL pointer %p %p", pc, foreach_cb);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5547 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5548 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5550 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5552 LOGD("ret : 0x%x", ret);
5558 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5560 int ret = CAMERA_ERROR_NONE;
5561 camera_cli_s *pc = (camera_cli_s *)camera;
5562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5564 if (!pc || !pc->cb_info || !foreach_cb) {
5565 LOGE("NULL pointer %p %p", pc, foreach_cb);
5566 return CAMERA_ERROR_INVALID_PARAMETER;
5571 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5572 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5574 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5576 LOGD("ret : 0x%x", ret);
5582 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5584 int ret = CAMERA_ERROR_NONE;
5585 camera_cli_s *pc = (camera_cli_s *)camera;
5586 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5588 if (!pc || !pc->cb_info || !foreach_cb) {
5589 LOGE("NULL pointer %p %p", pc, foreach_cb);
5590 return CAMERA_ERROR_INVALID_PARAMETER;
5595 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5596 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5598 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 LOGD("ret : 0x%x", ret);
5606 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5608 int ret = CAMERA_ERROR_NONE;
5609 camera_cli_s *pc = (camera_cli_s *)camera;
5610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5612 if (!pc || !pc->cb_info || !foreach_cb) {
5613 LOGE("NULL pointer %p %p", pc, foreach_cb);
5614 return CAMERA_ERROR_INVALID_PARAMETER;
5619 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5620 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5622 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5624 LOGD("ret : 0x%x", ret);
5630 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5632 int ret = CAMERA_ERROR_NONE;
5633 camera_cli_s *pc = (camera_cli_s *)camera;
5634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5636 if (!pc || !pc->cb_info || !foreach_cb) {
5637 LOGE("NULL pointer %p %p", pc, foreach_cb);
5638 return CAMERA_ERROR_INVALID_PARAMETER;
5643 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5644 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5646 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5648 LOGD("ret : 0x%x", ret);
5654 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5656 int ret = CAMERA_ERROR_NONE;
5657 camera_cli_s *pc = (camera_cli_s *)camera;
5658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5660 if (!pc || !pc->cb_info || !foreach_cb) {
5661 LOGE("NULL pointer %p %p", pc, foreach_cb);
5662 return CAMERA_ERROR_INVALID_PARAMETER;
5667 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5668 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5670 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5672 LOGD("Enter, handle :%x", pc->remote_handle);
5678 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)
5680 int ret = CAMERA_ERROR_NONE;
5681 camera_cli_s *pc = (camera_cli_s *)camera;
5682 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5683 camera_msg_param param;
5686 if (!pc || !pc->cb_info || !foreach_cb) {
5687 LOGE("NULL pointer %p %p", pc, foreach_cb);
5688 return CAMERA_ERROR_INVALID_PARAMETER;
5693 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5694 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5696 value = (width << 16) | height;
5697 CAMERA_MSG_PARAM_SET(param, INT, value);
5699 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5701 LOGD("ret : 0x%x", ret);
5707 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5709 int ret = CAMERA_ERROR_NONE;
5710 camera_cli_s *pc = (camera_cli_s *)camera;
5711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5713 if (!pc || !pc->cb_info || !foreach_cb) {
5714 LOGE("NULL pointer %p %p", pc, foreach_cb);
5715 return CAMERA_ERROR_INVALID_PARAMETER;
5720 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5721 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5723 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5725 LOGD("ret : 0x%x", ret);
5731 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5733 int ret = CAMERA_ERROR_NONE;
5734 camera_cli_s *pc = (camera_cli_s *)camera;
5735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5737 if (!pc || !pc->cb_info || !foreach_cb) {
5738 LOGE("NULL pointer %p %p", pc, foreach_cb);
5739 return CAMERA_ERROR_INVALID_PARAMETER;
5744 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5745 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5749 LOGD("ret : 0x%x", ret);
5755 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5757 int ret = CAMERA_ERROR_NONE;
5758 camera_cli_s *pc = (camera_cli_s *)camera;
5759 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5760 camera_msg_param param;
5761 int set_rotation = (int)rotation;
5763 if (!pc || !pc->cb_info) {
5764 LOGE("NULL handle");
5765 return CAMERA_ERROR_INVALID_PARAMETER;
5770 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5772 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5774 LOGD("ret : 0x%x", ret);
5780 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5782 int ret = CAMERA_ERROR_NONE;
5783 camera_cli_s *pc = (camera_cli_s *)camera;
5784 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5786 if (!pc || !pc->cb_info || !rotation) {
5787 LOGE("NULL pointer %p %p", pc, rotation);
5788 return CAMERA_ERROR_INVALID_PARAMETER;
5793 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5795 if (ret == CAMERA_ERROR_NONE)
5796 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5798 LOGD("ret : 0x%x", ret);
5804 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5806 int ret = CAMERA_ERROR_NONE;
5807 camera_cli_s *pc = (camera_cli_s *)camera;
5808 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5809 camera_msg_param param;
5810 int set_flip = (int)flip;
5812 if (!pc || !pc->cb_info) {
5813 LOGE("NULL handle");
5814 return CAMERA_ERROR_INVALID_PARAMETER;
5819 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5821 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5823 LOGD("ret : 0x%x", ret);
5829 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5831 int ret = CAMERA_ERROR_NONE;
5832 camera_cli_s *pc = (camera_cli_s *)camera;
5833 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5835 if (!pc || !pc->cb_info || !flip) {
5836 LOGE("NULL pointer %p %p", pc, flip);
5837 return CAMERA_ERROR_INVALID_PARAMETER;
5842 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5844 if (ret == CAMERA_ERROR_NONE)
5845 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5847 LOGD("ret : 0x%x", ret);
5852 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5854 int ret = CAMERA_ERROR_NONE;
5855 camera_cli_s *pc = (camera_cli_s *)camera;
5856 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5857 camera_msg_param param;
5858 int set_mode = (int)mode;
5860 if (!pc || !pc->cb_info) {
5861 LOGE("NULL handle");
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5867 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5869 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5871 LOGD("ret : 0x%x", ret);
5877 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5879 int ret = CAMERA_ERROR_NONE;
5880 camera_cli_s *pc = (camera_cli_s *)camera;
5881 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5883 if (!pc || !pc->cb_info || !mode) {
5884 LOGE("NULL pointer %p %p", pc, mode);
5885 return CAMERA_ERROR_INVALID_PARAMETER;
5890 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5892 if (ret == CAMERA_ERROR_NONE)
5893 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5895 LOGD("ret : 0x%x", ret);
5901 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5903 int ret = CAMERA_ERROR_NONE;
5904 camera_cli_s *pc = (camera_cli_s *)camera;
5905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5907 if (!pc || !pc->cb_info) {
5908 LOGE("NULL handle");
5909 return CAMERA_ERROR_INVALID_PARAMETER;
5914 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5917 LOGE("error is occurred 0x%x", ret);
5921 LOGD("ret : %d", ret);
5927 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5933 if (!pc || !pc->cb_info) {
5934 LOGE("NULL handle");
5935 return CAMERA_ERROR_INVALID_PARAMETER;
5940 if (!camera_attr_is_supported_hdr_capture(camera)) {
5941 LOGE("HDR not supported");
5942 return CAMERA_ERROR_NOT_SUPPORTED;
5946 LOGE("NULL callback");
5947 return CAMERA_ERROR_INVALID_PARAMETER;
5950 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5951 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5953 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5955 LOGD("ret : 0x%x", ret);
5961 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5963 int ret = CAMERA_ERROR_NONE;
5964 camera_cli_s *pc = (camera_cli_s *)camera;
5965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5967 if (!pc || !pc->cb_info) {
5968 LOGE("NULL handle");
5969 return CAMERA_ERROR_INVALID_PARAMETER;
5974 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5975 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5977 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5979 LOGD("ret : 0x%x", ret);
5985 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5987 int ret = CAMERA_ERROR_NONE;
5988 camera_cli_s *pc = (camera_cli_s *)camera;
5989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5990 camera_msg_param param;
5991 int set_enable = (int)enable;
5993 if (!pc || !pc->cb_info) {
5994 LOGE("NULL handle");
5995 return CAMERA_ERROR_INVALID_PARAMETER;
6000 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6002 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6004 LOGD("ret : 0x%x", ret);
6010 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6012 int ret = CAMERA_ERROR_NONE;
6013 camera_cli_s *pc = (camera_cli_s *)camera;
6014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6016 if (!pc || !pc->cb_info || !enabled) {
6017 LOGE("NULL pointer %p %p", pc, enabled);
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6025 if (ret == CAMERA_ERROR_NONE)
6026 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6028 LOGD("ret : 0x%x", ret);
6034 bool camera_attr_is_supported_anti_shake(camera_h camera)
6036 int ret = CAMERA_ERROR_NONE;
6037 camera_cli_s *pc = (camera_cli_s *)camera;
6038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6040 if (!pc || !pc->cb_info) {
6041 LOGE("NULL handle");
6042 return CAMERA_ERROR_INVALID_PARAMETER;
6047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6050 LOGE("error is occurred 0x%x", ret);
6054 LOGD("ret : %d", ret);
6060 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6062 int ret = CAMERA_ERROR_NONE;
6063 camera_cli_s *pc = (camera_cli_s *)camera;
6064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6065 camera_msg_param param;
6066 int set_enable = (int)enable;
6068 if (!pc || !pc->cb_info) {
6069 LOGE("NULL handle");
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6075 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6077 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6079 LOGD("ret : 0x%x", ret);
6085 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6087 int ret = CAMERA_ERROR_NONE;
6088 camera_cli_s *pc = (camera_cli_s *)camera;
6089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6091 if (!pc || !pc->cb_info || !enabled) {
6092 LOGE("NULL pointer %p %p", pc, enabled);
6093 return CAMERA_ERROR_INVALID_PARAMETER;
6098 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6100 if (ret == CAMERA_ERROR_NONE)
6101 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6103 LOGD("ret : 0x%x", ret);
6109 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6111 int ret = CAMERA_ERROR_NONE;
6112 camera_cli_s *pc = (camera_cli_s *)camera;
6113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6115 if (!pc || !pc->cb_info) {
6116 LOGE("NULL handle");
6117 return CAMERA_ERROR_INVALID_PARAMETER;
6122 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6125 LOGE("error is occurred 0x%x", ret);
6129 LOGD("ret : %d", ret);
6135 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6137 int ret = CAMERA_ERROR_NONE;
6138 camera_cli_s *pc = (camera_cli_s *)camera;
6139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6140 camera_msg_param param;
6141 int set_enable = (int)enable;
6143 if (!pc || !pc->cb_info) {
6144 LOGE("NULL handle");
6145 return CAMERA_ERROR_INVALID_PARAMETER;
6150 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6152 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6154 LOGD("ret : 0x%x", ret);
6160 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6162 int ret = CAMERA_ERROR_NONE;
6163 camera_cli_s *pc = (camera_cli_s *)camera;
6164 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6166 if (!pc || !pc->cb_info || !enabled) {
6167 LOGE("NULL pointer %p %p", pc, enabled);
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6173 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6175 if (ret == CAMERA_ERROR_NONE)
6176 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6178 LOGD("ret : 0x%x", ret);
6184 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6186 int ret = CAMERA_ERROR_NONE;
6187 camera_cli_s *pc = (camera_cli_s *)camera;
6188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6190 if (!pc || !pc->cb_info) {
6191 LOGE("NULL handle");
6192 return CAMERA_ERROR_INVALID_PARAMETER;
6197 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6200 LOGE("error is occurred 0x%x", ret);
6204 LOGD("ret : %d", ret);
6210 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6212 int ret = CAMERA_ERROR_NONE;
6213 camera_cli_s *pc = (camera_cli_s *)camera;
6214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6215 camera_msg_param param;
6216 int set_disable = (int)disable;
6218 if (!pc || !pc->cb_info) {
6219 LOGE("NULL handle");
6220 return CAMERA_ERROR_INVALID_PARAMETER;
6225 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6227 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6229 LOGD("ret : 0x%x", ret);
6235 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6237 int ret = CAMERA_ERROR_NONE;
6238 camera_cli_s *pc = (camera_cli_s *)camera;
6239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6240 camera_msg_param param;
6241 int set_move_type = (int)move_type;
6244 if (!pc || !pc->cb_info) {
6245 LOGE("NULL handle");
6246 return CAMERA_ERROR_INVALID_PARAMETER;
6251 value = (set_move_type << 16) | pan_step;
6252 CAMERA_MSG_PARAM_SET(param, INT, value);
6254 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6256 LOGD("ret : 0x%x", ret);
6262 int camera_attr_get_pan(camera_h camera, int *pan_step)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_cli_s *pc = (camera_cli_s *)camera;
6266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6268 if (!pc || !pc->cb_info || !pan_step) {
6269 LOGE("NULL pointer %p %p", pc, pan_step);
6270 return CAMERA_ERROR_INVALID_PARAMETER;
6275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6277 if (ret == CAMERA_ERROR_NONE)
6278 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6280 LOGD("ret : 0x%x", ret);
6286 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6288 int ret = CAMERA_ERROR_NONE;
6289 camera_cli_s *pc = (camera_cli_s *)camera;
6290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6292 if (!pc || !pc->cb_info || !min || !max) {
6293 LOGE("NULL pointer %p %p", pc, min, max);
6294 return CAMERA_ERROR_INVALID_PARAMETER;
6299 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6301 if (ret == CAMERA_ERROR_NONE) {
6302 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6303 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6306 LOGD("ret : 0x%x", ret);
6312 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6314 int ret = CAMERA_ERROR_NONE;
6315 camera_cli_s *pc = (camera_cli_s *)camera;
6316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6317 camera_msg_param param;
6318 int set_move_type = (int)move_type;
6321 if (!pc || !pc->cb_info) {
6322 LOGE("NULL handle");
6323 return CAMERA_ERROR_INVALID_PARAMETER;
6328 value = (set_move_type << 16) | tilt_step;
6329 CAMERA_MSG_PARAM_SET(param, INT, value);
6331 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6333 LOGD("ret : 0x%x", ret);
6339 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6341 int ret = CAMERA_ERROR_NONE;
6342 camera_cli_s *pc = (camera_cli_s *)camera;
6343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6345 if (!pc || !pc->cb_info || !tilt_step) {
6346 LOGE("NULL pointer %p %p", pc, tilt_step);
6347 return CAMERA_ERROR_INVALID_PARAMETER;
6352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6354 if (ret == CAMERA_ERROR_NONE)
6355 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6357 LOGD("ret : 0x%x", ret);
6363 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6365 int ret = CAMERA_ERROR_NONE;
6366 camera_cli_s *pc = (camera_cli_s *)camera;
6367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6369 if (!pc || !pc->cb_info || !min || !max) {
6370 LOGE("NULL pointer %p %p %p", pc, min, max);
6371 return CAMERA_ERROR_INVALID_PARAMETER;
6376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6378 if (ret == CAMERA_ERROR_NONE) {
6379 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6380 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6383 LOGD("ret : 0x%x", ret);
6389 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6391 int ret = CAMERA_ERROR_NONE;
6392 camera_cli_s *pc = (camera_cli_s *)camera;
6393 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6394 camera_msg_param param;
6395 int set_ptz_type = (int)ptz_type;
6397 if (!pc || !pc->cb_info) {
6398 LOGE("NULL handle");
6399 return CAMERA_ERROR_INVALID_PARAMETER;
6404 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6406 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6408 LOGD("ret : 0x%x", ret);
6414 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_cli_s *pc = (camera_cli_s *)camera;
6418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6420 if (!pc || !pc->cb_info || !foreach_cb) {
6421 LOGE("NULL pointer %p %p", pc, foreach_cb);
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6427 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6428 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6430 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6432 LOGD("ret : 0x%x", ret);
6438 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6440 int ret = CAMERA_ERROR_NONE;
6441 camera_cli_s *pc = (camera_cli_s *)camera;
6442 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6443 int set_display_roi_area[4] = {x, y, width, height};
6448 if (!pc || !pc->cb_info) {
6449 LOGE("NULL handle");
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6455 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6456 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6457 g_mutex_lock(&pc->cb_info->evas_mutex);
6459 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6461 g_mutex_unlock(&pc->cb_info->evas_mutex);
6463 if (ret != MM_ERROR_NONE) {
6464 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6465 return CAMERA_ERROR_INVALID_OPERATION;
6468 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6470 length = sizeof(set_display_roi_area) / sizeof(int) + \
6471 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6473 msg = muse_core_msg_json_factory_new(api,
6474 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6477 LOGE("msg creation failed: api %d", api);
6478 return CAMERA_ERROR_OUT_OF_MEMORY;
6481 if (pc->cb_info->is_server_connected) {
6482 __camera_update_api_waiting(pc->cb_info, api, 1);
6484 g_mutex_lock(&pc->cb_info->fd_lock);
6485 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6486 g_mutex_unlock(&pc->cb_info->fd_lock);
6490 LOGE("message send failed");
6491 ret = CAMERA_ERROR_INVALID_OPERATION;
6493 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6496 __camera_update_api_waiting(pc->cb_info, api, -1);
6498 muse_core_msg_json_factory_free(msg);
6500 LOGD("ret : 0x%x", ret);
6506 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6508 camera_cli_s *pc = (camera_cli_s *)camera;
6509 int ret = CAMERA_ERROR_NONE;
6510 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6512 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6513 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6514 return CAMERA_ERROR_INVALID_PARAMETER;
6519 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6521 if (ret == CAMERA_ERROR_NONE) {
6522 *x = pc->cb_info->get_display_roi_area[0];
6523 *y = pc->cb_info->get_display_roi_area[1];
6524 *width = pc->cb_info->get_display_roi_area[2];
6525 *height = pc->cb_info->get_display_roi_area[3];
6528 LOGD("ret : 0x%x", ret);
6534 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6536 int ret = CAMERA_ERROR_NONE;
6537 int get_device_state = 0;
6540 LOGE("NULL pointer");
6541 return CAMERA_ERROR_INVALID_PARAMETER;
6544 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6545 (int)device, "get_device_state", &get_device_state);
6547 if (ret == CAMERA_ERROR_NONE) {
6548 *state = (camera_device_state_e)get_device_state;
6549 LOGD("device state %d", *state);
6551 LOGE("failed 0x%x", ret);
6558 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6560 int ret = CAMERA_ERROR_NONE;
6561 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6562 camera_cb_info *info = NULL;
6564 if (!callback || !cb_id) {
6565 LOGE("invalid pointer %p %p", callback, cb_id);
6566 return CAMERA_ERROR_INVALID_PARAMETER;
6569 /* check camera support */
6570 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6571 if (ret != CAMERA_ERROR_NONE) {
6572 LOGE("get device state failed");
6576 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6578 info = g_new0(camera_cb_info, 1);
6580 LOGE("info failed");
6581 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6585 info->id = ++g_cam_dev_state_changed_cb_id;
6586 info->callback = (void *)callback;
6587 info->user_data = user_data;
6591 /* subscribe dbus signal for camera state change */
6592 if (!g_cam_dev_state_changed_cb_conn) {
6593 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6594 if (!g_cam_dev_state_changed_cb_conn) {
6595 LOGE("failed to get gdbus connection");
6596 ret = CAMERA_ERROR_INVALID_OPERATION;
6600 LOGD("subscribe signal %s - %s - %s",
6601 MM_CAMCORDER_DBUS_OBJECT,
6602 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6603 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6605 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6606 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6607 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6608 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6609 LOGE("failed to get gdbus connection");
6610 ret = CAMERA_ERROR_INVALID_OPERATION;
6614 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6617 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6619 LOGD("callback id %d", info->id);
6622 if (ret != CAMERA_ERROR_NONE) {
6628 if (g_cam_dev_state_changed_cb_conn) {
6629 g_object_unref(g_cam_dev_state_changed_cb_conn);
6630 g_cam_dev_state_changed_cb_conn = NULL;
6634 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6640 int camera_remove_device_state_changed_cb(int cb_id)
6642 int ret = CAMERA_ERROR_NONE;
6643 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6644 GList *tmp_list = NULL;
6645 camera_cb_info *info = NULL;
6647 /* check camera support */
6648 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6649 if (ret != CAMERA_ERROR_NONE) {
6650 LOGE("get device state failed");
6654 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6656 if (!g_cam_dev_state_changed_cb_list) {
6657 LOGE("there is no callback info");
6658 ret = CAMERA_ERROR_INVALID_OPERATION;
6662 tmp_list = g_cam_dev_state_changed_cb_list;
6665 info = tmp_list->data;
6666 tmp_list = tmp_list->next;
6673 if (info->id == cb_id) {
6674 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6679 if (!g_cam_dev_state_changed_cb_list) {
6680 /* no remained callback */
6681 if (g_cam_dev_state_changed_cb_conn) {
6682 /* unsubscribe signal */
6683 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6684 g_cam_dev_state_changed_cb_subscribe_id = 0;
6686 /* unref connection */
6687 g_object_unref(g_cam_dev_state_changed_cb_conn);
6688 g_cam_dev_state_changed_cb_conn = NULL;
6692 LOGD("id %d callback removed", cb_id);
6693 ret = CAMERA_ERROR_NONE;
6699 LOGE("id %d callback not found", cb_id);
6700 ret = CAMERA_ERROR_INVALID_PARAMETER;
6703 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);