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);
1333 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1337 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1339 faces = bo_handle.ptr;
1343 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1346 _camera_release_imported_bo(&bo);
1350 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1351 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1352 /*LOGD("return buffer done");*/
1355 LOGE("invalid message - count %d, key %d", count, tbm_key);
1359 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1362 int current_state = 0;
1364 muse_camera_msg_get(error, recv_msg);
1365 muse_camera_msg_get(current_state, recv_msg);
1367 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1369 if (error == CAMERA_ERROR_SOUND_POLICY)
1370 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1371 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1372 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1373 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1374 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1376 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1377 (camera_state_e)current_state, cb_info->user_data[event]);
1380 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1382 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1383 muse_camera_msg_get(param1, recv_msg);
1384 muse_camera_msg_get(param2, recv_msg);
1386 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1388 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1389 cb_info->user_cb[event] = NULL;
1390 cb_info->user_data[event] = NULL;
1391 LOGW("stop foreach callback for event %d", event);
1394 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1396 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1398 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1400 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1406 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1408 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1410 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1412 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1414 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1423 muse_camera_msg_get(param1, recv_msg);
1425 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1427 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1428 cb_info->user_cb[event] = NULL;
1429 cb_info->user_data[event] = NULL;
1430 LOGW("stop foreach callback for event %d", event);
1433 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1435 camera_image_data_s *rImage = NULL;
1436 camera_image_data_s *rPostview = NULL;
1437 camera_image_data_s *rThumbnail = NULL;
1438 unsigned char *buf_pos = NULL;
1439 int tbm_key_main = 0;
1440 int tbm_key_post = 0;
1441 int tbm_key_thumb = 0;
1442 tbm_bo bo_main = NULL;
1443 tbm_bo bo_post = NULL;
1444 tbm_bo bo_thumb = NULL;
1445 tbm_bo_handle bo_main_handle = {NULL, };
1446 tbm_bo_handle bo_post_handle = {NULL, };
1447 tbm_bo_handle bo_thumb_handle = {NULL, };
1449 muse_camera_msg_get(tbm_key_main, recv_msg);
1450 muse_camera_msg_get(tbm_key_post, recv_msg);
1451 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1454 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1455 tbm_key_main, tbm_key_post, tbm_key_thumb);
1458 if (tbm_key_main <= 0) {
1459 LOGE("invalid key %d", tbm_key_main);
1463 /* import tbm bo and get virtual address */
1464 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1467 buf_pos = (unsigned char *)bo_main_handle.ptr;
1468 rImage = (camera_image_data_s *)buf_pos;
1469 rImage->data = buf_pos + sizeof(camera_image_data_s);
1470 if (rImage->exif && rImage->exif_size > 0) {
1471 rImage->exif = rImage->data + rImage->size;
1473 rImage->exif = NULL;
1474 rImage->exif_size = 0;
1477 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1478 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1480 if (tbm_key_post > 0) {
1481 /* import tbm bo and get virtual address */
1482 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1485 buf_pos = (unsigned char *)bo_post_handle.ptr;
1486 rPostview = (camera_image_data_s *)buf_pos;
1487 LOGD("rPostview->size : %d", rPostview->size);
1488 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1491 if (tbm_key_thumb > 0) {
1492 /* import tbm bo and get virtual address */
1493 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1496 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1498 rThumbnail = (camera_image_data_s *)buf_pos;
1499 LOGD("rThumbnail->size : %d", rThumbnail->size);
1500 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1503 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1505 /* unmap and unref tbm bo */
1506 _camera_release_imported_bo(&bo_main);
1509 tbm_key = tbm_key_main;
1511 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1513 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1515 if (tbm_key_post > 0) {
1516 /* unmap and unref tbm bo */
1517 _camera_release_imported_bo(&bo_post);
1520 param.value.value_INT = tbm_key_post;
1521 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1524 if (tbm_key_thumb > 0) {
1525 /* unmap and unref tbm bo */
1526 _camera_release_imported_bo(&bo_thumb);
1529 param.value.value_INT = tbm_key_thumb;
1530 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1533 LOGD("return buffer done");
1536 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1537 LOGE("render error");
1544 static bool _camera_idle_event_callback(void *data)
1546 camera_cb_info_s *cb_info = NULL;
1547 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1549 if (cam_idle_event == NULL) {
1550 LOGE("cam_idle_event is NULL");
1555 g_mutex_lock(&cam_idle_event->event_mutex);
1557 cb_info = cam_idle_event->cb_info;
1558 if (cb_info == NULL) {
1559 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1560 goto IDLE_EVENT_CALLBACK_DONE;
1563 /* remove event from list */
1564 g_mutex_lock(&cb_info->idle_event_mutex);
1566 if (cb_info->idle_event_list)
1567 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1569 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1570 g_mutex_unlock(&cb_info->idle_event_mutex);
1573 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1575 /* send signal for waiting thread */
1576 g_cond_signal(&cb_info->idle_event_cond);
1578 IDLE_EVENT_CALLBACK_DONE:
1579 /* unlock and release event */
1580 g_mutex_unlock(&cam_idle_event->event_mutex);
1581 g_mutex_clear(&cam_idle_event->event_mutex);
1583 g_free(cam_idle_event);
1584 cam_idle_event = NULL;
1589 static void *_camera_msg_handler_func(gpointer data)
1593 camera_message_s *cam_msg = NULL;
1594 camera_idle_event_s *cam_idle_event = NULL;
1595 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1596 camera_cb_info_s *cb_info = NULL;
1598 if (!handler_info || !handler_info->cb_info) {
1599 LOGE("NULL handler %p", handler_info);
1603 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1604 type = handler_info->type;
1606 LOGD("t:%d start", type);
1608 g_mutex_lock(&handler_info->mutex);
1610 while (g_atomic_int_get(&handler_info->running)) {
1611 if (g_queue_is_empty(handler_info->queue)) {
1612 /*LOGD("t:%d signal wait...", type);*/
1613 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1614 /*LOGD("t:%d signal received", type);*/
1616 if (g_atomic_int_get(&handler_info->running) == 0) {
1617 LOGD("t:%d stop event thread", type);
1622 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1624 g_mutex_unlock(&handler_info->mutex);
1626 if (cam_msg == NULL) {
1627 LOGE("t:%d NULL message", type);
1628 g_mutex_lock(&handler_info->mutex);
1634 if (api < MUSE_CAMERA_API_MAX) {
1637 g_mutex_lock(&cb_info->api_mutex[api]);
1639 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1640 if (cb_info->api_waiting[api] > 0) {
1641 cb_info->api_ret[api] = ret;
1642 cb_info->api_activating[api] = 1;
1644 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1646 g_cond_signal(&cb_info->api_cond[api]);
1648 LOGW("no waiting for this api [%d]", api);
1651 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1654 g_mutex_unlock(&cb_info->api_mutex[api]);
1655 } else if (api == MUSE_CAMERA_CB_EVENT) {
1656 switch (cam_msg->event_class) {
1657 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1658 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1660 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1661 cam_idle_event = g_new0(camera_idle_event_s, 1);
1662 if (cam_idle_event == NULL) {
1663 LOGE("t:%d cam_idle_event alloc failed", type);
1667 cam_idle_event->event = cam_msg->event;
1668 cam_idle_event->cb_info = cb_info;
1669 g_mutex_init(&cam_idle_event->event_mutex);
1670 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1672 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1674 g_mutex_lock(&cb_info->idle_event_mutex);
1675 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1676 g_mutex_unlock(&cb_info->idle_event_mutex);
1678 g_idle_add_full(G_PRIORITY_DEFAULT,
1679 (GSourceFunc)_camera_idle_event_callback,
1680 (gpointer)cam_idle_event,
1684 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1688 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1694 g_mutex_lock(&handler_info->mutex);
1697 /* remove remained event */
1698 while (!g_queue_is_empty(handler_info->queue)) {
1699 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1701 LOGD("t:%d remove camera message %p", type, cam_msg);
1705 LOGW("t:%d NULL camera message", type);
1709 g_mutex_unlock(&handler_info->mutex);
1711 LOGD("t:%d return", type);
1717 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1719 camera_idle_event_s *cam_idle_event = NULL;
1720 gboolean ret = TRUE;
1722 gint64 end_time = 0;
1724 if (cb_info == NULL) {
1725 LOGE("cb_info is NULL");
1729 g_mutex_lock(&cb_info->idle_event_mutex);
1731 if (cb_info->idle_event_list == NULL) {
1732 LOGD("No remained idle event");
1733 g_mutex_unlock(&cb_info->idle_event_mutex);
1737 list = cb_info->idle_event_list;
1740 cam_idle_event = list->data;
1741 list = g_list_next(list);
1743 if (!cam_idle_event) {
1744 LOGW("Fail to remove idle event. The event is NULL");
1748 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1749 ret = g_idle_remove_by_data(cam_idle_event);
1751 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1754 cam_idle_event->cb_info = NULL;
1755 LOGW("idle event %p will be called later", cam_idle_event);
1758 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1760 g_mutex_unlock(&cam_idle_event->event_mutex);
1763 g_mutex_clear(&cam_idle_event->event_mutex);
1765 g_free(cam_idle_event);
1766 cam_idle_event = NULL;
1768 LOGD("remove idle event done");
1774 LOGW("event lock failed. it's being called...");
1776 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1778 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1779 LOGW("signal received");
1784 g_list_free(cb_info->idle_event_list);
1785 cb_info->idle_event_list = NULL;
1787 g_mutex_unlock(&cb_info->idle_event_mutex);
1793 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1795 camera_message_s *cam_msg = NULL;
1797 if (!cb_info || !msg) {
1798 LOGE("NULL pointer %p %p", cb_info, msg);
1802 cam_msg = g_new0(camera_message_s, 1);
1804 LOGE("failed to alloc cam_msg for [%s]", msg);
1809 cam_msg->event = event;
1810 cam_msg->event_class = event_class;
1812 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1814 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1816 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1817 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1818 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1819 g_cond_signal(&cb_info->preview_cb_info.cond);
1820 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1821 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1822 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1823 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1824 g_cond_signal(&cb_info->capture_cb_info.cond);
1825 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1827 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1828 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1829 g_cond_signal(&cb_info->msg_handler_info.cond);
1830 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1839 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1841 int ret = CAMERA_ERROR_NONE;
1845 int event_class = -1;
1849 if (!cb_info || !msg) {
1850 LOGE("invalid ptr %p %p", cb_info, msg);
1854 /*LOGD("msg [%s]", msg);*/
1856 if (!muse_camera_msg_get(api, msg)) {
1857 LOGE("failed to get camera api");
1861 if (api == MUSE_CAMERA_CB_EVENT) {
1862 if (!muse_camera_msg_get(event, msg) ||
1863 !muse_camera_msg_get(event_class, msg)) {
1864 LOGE("failed to get camera event or event_class [%s]", msg);
1868 if (!muse_camera_msg_get(api_class, msg)) {
1869 LOGE("failed to get camera api_class [%s]", msg);
1874 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1875 if (api >= MUSE_CAMERA_API_MAX) {
1876 LOGE("invalid api %d", api);
1880 if (!muse_camera_msg_get(ret, msg)) {
1881 LOGE("failed to get camera ret");
1885 g_mutex_lock(&cb_info->api_mutex[api]);
1888 case MUSE_CAMERA_API_CREATE:
1889 if (ret != CAMERA_ERROR_NONE) {
1890 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1891 LOGE("camera create error 0x%x. close client cb handler", ret);
1894 case MUSE_CAMERA_API_DESTROY:
1895 if (ret == CAMERA_ERROR_NONE) {
1896 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1897 LOGD("camera destroy done. close client cb handler");
1901 muse_camera_msg_get(get_type, msg);
1902 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1903 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1904 muse_camera_msg_get(get_index, msg);
1907 case MUSE_CAMERA_GET_TYPE_INT:
1908 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1910 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1911 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1912 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1914 case MUSE_CAMERA_GET_TYPE_ARRAY:
1915 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1916 muse_core_msg_json_deserialize("get_value",
1917 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1918 LOGD("get display roi %d,%d,%dx%d",
1919 cb_info->get_display_roi_area[0],
1920 cb_info->get_display_roi_area[1],
1921 cb_info->get_display_roi_area[2],
1922 cb_info->get_display_roi_area[3]);
1924 muse_core_msg_json_deserialize("get_value",
1925 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1926 LOGD("get geotag %lf, %lf, %lf",
1927 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1930 case MUSE_CAMERA_GET_TYPE_STRING:
1931 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1934 LOGW("unknown type %d", get_type);
1941 if (cb_info->api_waiting[api] > 0) {
1942 cb_info->api_ret[api] = ret;
1943 cb_info->api_activating[api] = 1;
1945 g_cond_signal(&cb_info->api_cond[api]);
1947 LOGW("no waiting for this api [%d]", api);
1950 g_mutex_unlock(&cb_info->api_mutex[api]);
1951 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1952 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1954 LOGW("unknown camera api %d, class %d", api, api_class);
1961 static void *_camera_msg_recv_func(gpointer data)
1963 int recv_length = 0;
1964 int single_length = 0;
1965 int remained_length = 0;
1966 char *recv_msg = NULL;
1967 char *single_msg = NULL;
1968 char *remained_msg = NULL;
1972 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1975 LOGE("cb_info NULL");
1981 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1983 LOGE("single_msg malloc failed");
1987 recv_msg = cb_info->recv_msg;
1989 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1990 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1991 if (recv_length <= 0) {
1992 cb_info->is_server_connected = FALSE;
1993 LOGE("receive msg failed - server disconnected");
2001 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2003 /* Need to split the combined entering msgs */
2004 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2005 if (recv_msg[cur_pos] == '}') {
2006 single_length = cur_pos - prev_pos + 1;
2008 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2009 /* check remained msg */
2010 if (remained_length > 0) {
2012 strncpy(single_msg, remained_msg, remained_length);
2013 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2014 single_msg[remained_length + single_length] = '\0';
2017 remained_msg = NULL;
2019 strncpy(single_msg, recv_msg + prev_pos, single_length);
2020 single_msg[single_length] = '\0';
2021 LOGE("lost msg [%s], skip...", single_msg);
2024 remained_length = 0;
2026 strncpy(single_msg, recv_msg + prev_pos, single_length);
2027 single_msg[single_length] = '\0';
2030 if (single_msg[0] == '{') {
2032 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2033 /* process each message */
2034 __camera_process_msg(cb_info, single_msg);
2036 LOGE("invalid msg [%s]", single_msg);
2039 LOGE("too long message [len %d] skip...", single_length);
2042 prev_pos = cur_pos + 1;
2046 /* check incompleted message */
2047 if (recv_msg[recv_length - 1] != '}') {
2048 remained_length = recv_length - prev_pos;
2050 LOGW("incompleted message [len %d]", remained_length);
2052 remained_msg = (char *)malloc(remained_length + 1);
2054 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2055 remained_msg[remained_length] = '\0';
2057 LOGE("failed to alloc for remained msg");
2060 remained_length = 0;
2064 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2066 if (!cb_info->is_server_connected) {
2067 /* send error msg for server disconnection */
2068 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2069 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2070 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2074 LOGE("error_msg failed");
2075 goto CB_HANDLER_EXIT;
2078 __camera_add_msg_to_queue(cb_info,
2079 MUSE_CAMERA_CB_EVENT,
2080 MUSE_CAMERA_EVENT_TYPE_ERROR,
2081 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2084 muse_core_msg_json_factory_free(error_msg);
2087 LOGE("add error msg for service disconnection done");
2098 remained_msg = NULL;
2105 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2106 int type, const char *thread_name, camera_cb_info_s *cb_info)
2108 if (!handler_info || !thread_name || !cb_info) {
2109 LOGE("t:%d NULL %p %p %p",
2110 type, handler_info, thread_name, cb_info);
2116 handler_info->type = type;
2117 handler_info->queue = g_queue_new();
2118 if (handler_info->queue == NULL) {
2119 LOGE("t:%d queue failed", type);
2123 g_mutex_init(&handler_info->mutex);
2124 g_cond_init(&handler_info->cond);
2126 handler_info->cb_info = (void *)cb_info;
2127 g_atomic_int_set(&handler_info->running, 1);
2129 handler_info->thread = g_thread_try_new(thread_name,
2130 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2131 if (handler_info->thread == NULL) {
2132 LOGE("t:%d thread failed", type);
2134 g_mutex_clear(&handler_info->mutex);
2135 g_cond_clear(&handler_info->cond);
2136 g_queue_free(handler_info->queue);
2137 handler_info->queue = NULL;
2142 LOGD("t:%d done", type);
2148 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2152 if (!handler_info) {
2153 LOGE("NULL handler");
2157 if (!handler_info->thread) {
2158 LOGW("thread is not created");
2162 type = handler_info->type;
2164 LOGD("t:%d thread %p", type, handler_info->thread);
2166 g_mutex_lock(&handler_info->mutex);
2167 g_atomic_int_set(&handler_info->running, 0);
2168 g_cond_signal(&handler_info->cond);
2169 g_mutex_unlock(&handler_info->mutex);
2171 g_thread_join(handler_info->thread);
2172 handler_info->thread = NULL;
2174 g_mutex_clear(&handler_info->mutex);
2175 g_cond_clear(&handler_info->cond);
2176 g_queue_free(handler_info->queue);
2177 handler_info->queue = NULL;
2179 LOGD("t:%d done", type);
2185 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2187 camera_cb_info_s *cb_info = NULL;
2190 g_return_val_if_fail(sockfd > 0, NULL);
2192 cb_info = g_new0(camera_cb_info_s, 1);
2193 if (cb_info == NULL) {
2194 LOGE("cb_info failed");
2198 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2200 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2201 g_mutex_init(&cb_info->api_mutex[i]);
2202 g_cond_init(&cb_info->api_cond[i]);
2205 g_mutex_init(&cb_info->fd_lock);
2206 g_mutex_init(&cb_info->idle_event_mutex);
2207 g_cond_init(&cb_info->idle_event_cond);
2208 g_mutex_init(&cb_info->mp_data_mutex);
2209 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2210 g_mutex_init(&cb_info->evas_mutex);
2211 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2213 /* message handler thread */
2214 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2215 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2216 LOGE("msg_handler_info failed");
2220 /* message handler thread for preview callback */
2221 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2222 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2223 LOGE("preview_cb_info failed");
2227 /* message handler thread for capture callback */
2228 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2229 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2230 LOGE("capture_cb_info failed");
2234 cb_info->fd = sockfd;
2235 cb_info->preview_cb_flag = 0;
2236 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2237 cb_info->evas_info = NULL;
2238 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2240 /* message receive thread */
2241 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2242 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2243 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2244 if (cb_info->msg_recv_thread == NULL) {
2245 LOGE("message receive thread creation failed");
2249 cb_info->is_server_connected = TRUE;
2255 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2256 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2257 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2259 g_mutex_clear(&cb_info->fd_lock);
2260 g_mutex_clear(&cb_info->idle_event_mutex);
2261 g_cond_clear(&cb_info->idle_event_cond);
2262 g_mutex_clear(&cb_info->mp_data_mutex);
2263 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2264 g_mutex_clear(&cb_info->evas_mutex);
2265 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2267 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2268 g_mutex_clear(&cb_info->api_mutex[i]);
2269 g_cond_clear(&cb_info->api_cond[i]);
2279 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2283 g_return_if_fail(cb_info != NULL);
2285 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2287 g_thread_join(cb_info->msg_recv_thread);
2288 cb_info->msg_recv_thread = NULL;
2290 LOGD("msg_recv thread removed");
2292 /* destroy msg handler threads */
2293 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2294 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2295 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2297 g_mutex_clear(&cb_info->fd_lock);
2298 g_mutex_clear(&cb_info->idle_event_mutex);
2299 g_cond_clear(&cb_info->idle_event_cond);
2300 g_mutex_clear(&cb_info->mp_data_mutex);
2301 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2302 g_mutex_clear(&cb_info->evas_mutex);
2303 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2305 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2306 g_mutex_clear(&cb_info->api_mutex[i]);
2307 g_cond_clear(&cb_info->api_cond[i]);
2310 if (cb_info->fd > -1) {
2311 muse_core_connection_close(cb_info->fd);
2315 if (cb_info->bufmgr) {
2316 tbm_bufmgr_deinit(cb_info->bufmgr);
2317 cb_info->bufmgr = NULL;
2319 if (cb_info->pkt_fmt) {
2320 media_format_unref(cb_info->pkt_fmt);
2321 cb_info->pkt_fmt = NULL;
2324 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2325 if (cb_info->evas_info)
2326 mm_evas_renderer_destroy(&cb_info->evas_info);
2327 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2329 cb_info->preview_cb_flag = 0;
2338 int _camera_start_evas_rendering(camera_h camera)
2340 int ret = CAMERA_ERROR_NONE;
2341 camera_cli_s *pc = (camera_cli_s *)camera;
2343 if (!pc || !pc->cb_info) {
2344 LOGE("NULL handle");
2345 return CAMERA_ERROR_INVALID_PARAMETER;
2350 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2351 LOGE("EVAS surface is not set");
2352 return CAMERA_ERROR_NONE;
2355 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2356 g_mutex_lock(&pc->cb_info->evas_mutex);
2358 /* set evas render flag as RUN */
2359 pc->cb_info->run_evas_render = true;
2360 ret = CAMERA_ERROR_NONE;
2362 g_mutex_unlock(&pc->cb_info->evas_mutex);
2363 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2364 LOGW("evas renderer is not supported");
2365 ret = CAMERA_ERROR_NOT_SUPPORTED;
2366 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2372 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2374 int ret = CAMERA_ERROR_NONE;
2375 camera_cli_s *pc = (camera_cli_s *)camera;
2377 if (!pc || !pc->cb_info) {
2378 LOGE("NULL handle");
2379 return CAMERA_ERROR_INVALID_PARAMETER;
2382 LOGD("stop - keep screen %d", keep_screen);
2384 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2385 LOGE("EVAS surface is not set");
2386 return CAMERA_ERROR_NONE;
2389 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2390 g_mutex_lock(&pc->cb_info->evas_mutex);
2392 /* set evas render flag as STOP and release buffers */
2393 pc->cb_info->run_evas_render = false;
2395 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2396 if (ret != MM_ERROR_NONE) {
2397 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2398 ret = CAMERA_ERROR_INVALID_OPERATION;
2401 g_mutex_unlock(&pc->cb_info->evas_mutex);
2402 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2403 LOGW("evas renderer is not supported");
2404 ret = CAMERA_ERROR_NOT_SUPPORTED;
2405 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2411 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2413 int ret = CAMERA_ERROR_NONE;
2416 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2418 /* create muse connection */
2419 if (!key || !value) {
2420 LOGE("NULL pointer");
2421 return CAMERA_ERROR_INVALID_PARAMETER;
2424 sock_fd = muse_core_client_new();
2426 LOGE("muse_core_client_new failed");
2427 return CAMERA_ERROR_INVALID_OPERATION;
2430 msg = muse_core_msg_json_factory_new(api,
2431 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2432 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2436 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2440 ret = muse_core_ipc_send_msg(sock_fd, msg);
2442 muse_core_msg_json_factory_free(msg);
2446 LOGE("send msg failed");
2447 ret = CAMERA_ERROR_INVALID_OPERATION;
2451 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2453 LOGE("recv msg failed %d", errno);
2454 ret = CAMERA_ERROR_INVALID_OPERATION;
2458 if (!muse_camera_msg_get(ret, recv_msg)) {
2459 LOGE("failed to get return value from msg [%s]", recv_msg);
2460 ret = CAMERA_ERROR_INVALID_OPERATION;
2464 if (ret == CAMERA_ERROR_NONE)
2465 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2467 LOGD("api %d - value %d", api, *value);
2471 muse_core_connection_close(sock_fd);
2479 int camera_create(camera_device_e device, camera_h *camera)
2482 char *send_msg = NULL;
2484 int ret = CAMERA_ERROR_NONE;
2486 camera_cli_s *pc = NULL;
2487 tbm_bufmgr bufmgr = NULL;
2489 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2490 muse_core_api_module_e muse_module = MUSE_CAMERA;
2491 int device_type = (int)device;
2494 LOGE("NULL pointer");
2495 return CAMERA_ERROR_INVALID_PARAMETER;
2498 sock_fd = muse_core_client_new();
2500 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2501 ret = CAMERA_ERROR_INVALID_OPERATION;
2507 send_msg = muse_core_msg_json_factory_new(api,
2508 MUSE_TYPE_INT, "module", muse_module,
2509 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2510 MUSE_TYPE_INT, "pid", pid,
2515 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2519 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2521 muse_core_msg_json_factory_free(send_msg);
2525 LOGE("send msg failed %d", errno);
2526 ret = CAMERA_ERROR_INVALID_OPERATION;
2530 pc = g_new0(camera_cli_s, 1);
2532 LOGE("camera_cli_s alloc failed");
2533 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2537 bufmgr = tbm_bufmgr_init(-1);
2538 if (bufmgr == NULL) {
2539 LOGE("get tbm bufmgr failed");
2540 ret = CAMERA_ERROR_INVALID_OPERATION;
2544 pc->cb_info = _camera_client_callback_new(sock_fd);
2545 if (pc->cb_info == NULL) {
2546 LOGE("cb_info alloc failed");
2547 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2553 LOGD("cb info : %d", pc->cb_info->fd);
2555 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2557 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2559 if (ret == CAMERA_ERROR_NONE) {
2560 intptr_t handle = 0;
2561 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2563 LOGE("Receiving Handle Failed!!");
2564 ret = CAMERA_ERROR_INVALID_OPERATION;
2568 pc->remote_handle = handle;
2569 pc->cb_info->bufmgr = bufmgr;
2571 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2572 if (ret != CAMERA_ERROR_NONE) {
2573 LOGE("init display failed 0x%x", ret);
2577 LOGD("camera create 0x%x", pc->remote_handle);
2578 *camera = (camera_h)pc;
2587 tbm_bufmgr_deinit(bufmgr);
2592 muse_core_connection_close(sock_fd);
2598 _camera_client_callback_destroy(pc->cb_info);
2605 LOGE("camera create error : 0x%x", ret);
2611 int camera_change_device(camera_h camera, camera_device_e device)
2614 int ret = CAMERA_ERROR_NONE;
2615 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2616 camera_cli_s *pc = (camera_cli_s *)camera;
2617 camera_msg_param param;
2619 if (!pc || !pc->cb_info) {
2620 LOGE("NULL handle");
2621 return CAMERA_ERROR_INVALID_PARAMETER;
2624 CAMERA_MSG_PARAM_SET(param, INT, device);
2626 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2628 if (ret == CAMERA_ERROR_NONE) {
2629 /* reset callback and user data */
2630 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2631 pc->cb_info->user_cb[i] = NULL;
2632 pc->cb_info->user_data[i] = NULL;
2634 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2641 int camera_destroy(camera_h camera)
2643 int ret = CAMERA_ERROR_NONE;
2644 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2645 camera_cli_s *pc = (camera_cli_s *)camera;
2647 if (!pc || !pc->cb_info) {
2648 LOGE("NULL handle");
2649 return CAMERA_ERROR_INVALID_PARAMETER;
2654 if (pc->cb_info->is_server_connected)
2655 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2657 LOGW("server disconnected. release resource without send message.");
2659 if (ret == CAMERA_ERROR_NONE) {
2660 _camera_remove_idle_event_all(pc->cb_info);
2661 _camera_client_callback_destroy(pc->cb_info);
2671 int camera_start_preview(camera_h camera)
2673 int ret = CAMERA_ERROR_NONE;
2674 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2675 camera_cli_s *pc = (camera_cli_s *)camera;
2677 if (!pc || !pc->cb_info) {
2678 LOGE("NULL handle");
2679 return CAMERA_ERROR_INVALID_PARAMETER;
2684 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2685 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2686 ret = _camera_start_evas_rendering(camera);
2687 if (ret != CAMERA_ERROR_NONE) {
2688 LOGE("stop preview because of error");
2689 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2693 LOGD("ret : 0x%x", ret);
2699 int camera_stop_preview(camera_h camera)
2701 int ret = CAMERA_ERROR_NONE;
2702 camera_cli_s *pc = (camera_cli_s *)camera;
2703 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2704 camera_state_e current_state = CAMERA_STATE_NONE;
2706 if (!pc || !pc->cb_info) {
2707 LOGE("NULL handle");
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2713 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2714 ret = camera_get_state(camera, ¤t_state);
2715 if (ret != CAMERA_ERROR_NONE) {
2716 LOGE("failed to get current state 0x%x", ret);
2720 if (current_state == CAMERA_STATE_PREVIEW) {
2721 ret = _camera_stop_evas_rendering(camera, false);
2722 if (ret != CAMERA_ERROR_NONE)
2727 /* send stop preview message */
2728 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2730 if (ret != CAMERA_ERROR_NONE &&
2731 current_state == CAMERA_STATE_PREVIEW) {
2732 LOGW("restart evas rendering");
2733 _camera_start_evas_rendering(camera);
2736 LOGD("ret : 0x%x", ret);
2742 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2744 int ret = CAMERA_ERROR_NONE;
2745 camera_cli_s *pc = (camera_cli_s *)camera;
2746 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2748 if (!pc || !pc->cb_info) {
2749 LOGE("NULL handle");
2750 return CAMERA_ERROR_INVALID_PARAMETER;
2755 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2756 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2758 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2759 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2761 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2763 LOGD("ret : 0x%x", ret);
2769 bool camera_is_supported_continuous_capture(camera_h camera)
2771 int ret = CAMERA_ERROR_NONE;
2772 camera_cli_s *pc = (camera_cli_s *)camera;
2773 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2775 if (!pc || !pc->cb_info) {
2776 LOGE("NULL handle");
2777 return CAMERA_ERROR_INVALID_PARAMETER;
2782 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2785 LOGE("error is occurred 0x%x", ret);
2789 LOGD("ret : %d", ret);
2795 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)
2797 int ret = CAMERA_ERROR_NONE;
2798 camera_cli_s *pc = (camera_cli_s *)camera;
2799 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2800 camera_msg_param param;
2803 if (!pc || !pc->cb_info) {
2804 LOGE("NULL handle");
2805 return CAMERA_ERROR_INVALID_PARAMETER;
2810 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2811 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2813 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2814 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2816 value = (count << 16) | interval;
2817 CAMERA_MSG_PARAM_SET(param, INT, value);
2819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2821 LOGD("ret : 0x%x", ret);
2827 int camera_stop_continuous_capture(camera_h camera)
2829 int ret = CAMERA_ERROR_NONE;
2830 camera_cli_s *pc = (camera_cli_s *)camera;
2831 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2833 if (!pc || !pc->cb_info) {
2834 LOGE("NULL handle");
2835 return CAMERA_ERROR_INVALID_PARAMETER;
2840 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2842 LOGD("ret : 0x%x", ret);
2848 bool camera_is_supported_face_detection(camera_h camera)
2850 int ret = CAMERA_ERROR_NONE;
2851 camera_cli_s *pc = (camera_cli_s *)camera;
2852 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2854 if (!pc || !pc->cb_info) {
2855 LOGE("NULL handle");
2856 return CAMERA_ERROR_INVALID_PARAMETER;
2861 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2864 LOGE("error is occurred 0x%x", ret);
2868 LOGD("ret : %d", ret);
2874 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2876 int ret = CAMERA_ERROR_NONE;
2877 camera_cli_s *pc = (camera_cli_s *)camera;
2878 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2880 if (!pc || !pc->cb_info) {
2881 LOGE("NULL handle");
2882 return CAMERA_ERROR_INVALID_PARAMETER;
2887 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2890 LOGE("error is occurred 0x%x", ret);
2894 LOGD("ret : %d", ret);
2900 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2902 int ret = CAMERA_ERROR_NONE;
2903 camera_cli_s *pc = (camera_cli_s *)camera;
2904 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2906 if (!pc || !pc->cb_info) {
2907 LOGE("NULL handle");
2908 return CAMERA_ERROR_INVALID_PARAMETER;
2913 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2916 LOGE("error is occurred 0x%x", ret);
2920 LOGD("ret : %d", ret);
2925 int camera_get_device_count(camera_h camera, int *device_count)
2927 int ret = CAMERA_ERROR_NONE;
2928 camera_cli_s *pc = (camera_cli_s *)camera;
2929 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2931 if (!pc || !pc->cb_info) {
2932 LOGE("NULL handle");
2933 return CAMERA_ERROR_INVALID_PARAMETER;
2938 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2940 if (ret == CAMERA_ERROR_NONE)
2941 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2943 LOGD("ret : 0x%x", ret);
2948 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2950 int ret = CAMERA_ERROR_NONE;
2951 camera_cli_s *pc = (camera_cli_s *)camera;
2952 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2954 if (!pc || !pc->cb_info) {
2955 LOGE("NULL handle");
2956 return CAMERA_ERROR_INVALID_PARAMETER;
2961 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2962 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2964 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2966 LOGD("ret : 0x%x", ret);
2971 int camera_stop_face_detection(camera_h camera)
2973 int ret = CAMERA_ERROR_NONE;
2974 camera_cli_s *pc = (camera_cli_s *)camera;
2975 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2977 if (!pc || !pc->cb_info) {
2978 LOGE("NULL handle");
2979 return CAMERA_ERROR_INVALID_PARAMETER;
2984 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2986 LOGD("ret : 0x%x", ret);
2991 int camera_get_state(camera_h camera, camera_state_e *state)
2993 int ret = CAMERA_ERROR_NONE;
2994 camera_cli_s *pc = (camera_cli_s *)camera;
2995 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2997 if (!pc || !pc->cb_info || !state) {
2998 LOGE("NULL pointer %p %p", pc, state);
2999 return CAMERA_ERROR_INVALID_PARAMETER;
3004 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3006 if (ret == CAMERA_ERROR_NONE)
3007 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3009 LOGD("ret : 0x%x", ret);
3014 int camera_start_focusing(camera_h camera, bool continuous)
3016 int ret = CAMERA_ERROR_NONE;
3017 camera_cli_s *pc = (camera_cli_s *)camera;
3018 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3019 camera_msg_param param;
3020 int is_continuous = (int)continuous;
3022 if (!pc || !pc->cb_info) {
3023 LOGE("NULL handle");
3024 return CAMERA_ERROR_INVALID_PARAMETER;
3029 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3031 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3033 LOGD("ret : 0x%x", ret);
3038 int camera_cancel_focusing(camera_h camera)
3040 int ret = CAMERA_ERROR_NONE;
3041 camera_cli_s *pc = (camera_cli_s *)camera;
3042 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3044 if (!pc || !pc->cb_info) {
3045 LOGE("NULL handle");
3046 return CAMERA_ERROR_INVALID_PARAMETER;
3049 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3053 LOGD("ret : 0x%x", ret);
3058 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3060 int ret = CAMERA_ERROR_NONE;
3061 void *set_display_handle = NULL;
3062 Evas_Object *obj = NULL;
3063 const char *object_type = NULL;
3064 camera_cli_s *pc = (camera_cli_s *)camera;
3065 camera_cb_info_s *cb_info = NULL;
3066 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3067 camera_state_e current_state = CAMERA_STATE_NONE;
3068 camera_msg_param param;
3072 if (!pc || !pc->cb_info) {
3073 LOGE("NULL handle");
3074 return CAMERA_ERROR_INVALID_PARAMETER;
3077 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3078 LOGE("invalid type %d", type);
3079 return CAMERA_ERROR_INVALID_PARAMETER;
3082 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3083 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3084 return CAMERA_ERROR_INVALID_PARAMETER;
3087 cb_info = (camera_cb_info_s *)pc->cb_info;
3089 ret = camera_get_state(camera, ¤t_state);
3090 if (ret != CAMERA_ERROR_NONE) {
3091 LOGE("failed to get current state 0x%x", ret);
3095 if (current_state != CAMERA_STATE_CREATED) {
3096 LOGE("INVALID_STATE : current %d", current_state);
3097 return CAMERA_ERROR_INVALID_STATE;
3100 LOGD("Enter - display : %p", display);
3102 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3103 set_display_handle = 0;
3104 LOGD("display type NONE");
3106 obj = (Evas_Object *)display;
3107 object_type = evas_object_type_get(obj);
3109 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3110 /* get wayland parent id */
3111 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3112 LOGE("failed to get wayland info");
3113 return CAMERA_ERROR_INVALID_OPERATION;
3116 set_display_handle = (void *)&pc->wl_info;
3117 LOGD("display type OVERLAY : handle %p", set_display_handle);
3118 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3119 /* evas object surface */
3120 set_display_handle = (void *)display;
3121 LOGD("display type EVAS : handle %p", set_display_handle);
3123 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3124 g_mutex_lock(&cb_info->evas_mutex);
3126 if (cb_info->evas_info) {
3127 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3128 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3129 if (ret != MM_ERROR_NONE) {
3130 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3131 g_mutex_unlock(&cb_info->evas_mutex);
3132 return CAMERA_ERROR_INVALID_OPERATION;
3136 /* create evas renderer */
3137 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3138 if (ret == MM_ERROR_NONE) {
3139 camera_flip_e flip = CAMERA_FLIP_NONE;
3140 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3141 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3148 camera_get_display_flip(camera, &flip);
3149 camera_get_display_mode(camera, &mode);
3150 camera_get_display_rotation(camera, &rotation);
3151 camera_is_display_visible(camera, &visible);
3152 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3154 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3155 flip, mode, rotation, visible, x, y, width, height);
3157 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3158 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3159 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3160 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3162 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3163 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3166 g_mutex_unlock(&cb_info->evas_mutex);
3168 if (ret != MM_ERROR_NONE) {
3169 LOGE("mm_evas_renderer error 0x%x", ret);
3170 return CAMERA_ERROR_INVALID_OPERATION;
3172 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3173 LOGE("EVAS surface is not supported");
3174 return CAMERA_ERROR_NOT_SUPPORTED;
3175 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3177 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3178 return CAMERA_ERROR_INVALID_PARAMETER;
3181 LOGE("failed to get evas object type from %p", obj);
3182 return CAMERA_ERROR_INVALID_PARAMETER;
3186 pc->display_handle = (intptr_t)set_display_handle;
3188 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3191 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3192 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3194 msg = muse_core_msg_json_factory_new(api,
3195 MUSE_TYPE_INT, "type", type,
3196 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3199 LOGE("msg creation failed: api %d", api);
3200 return CAMERA_ERROR_OUT_OF_MEMORY;
3203 if (pc->cb_info->is_server_connected) {
3204 __camera_update_api_waiting(pc->cb_info, api, 1);
3206 g_mutex_lock(&pc->cb_info->fd_lock);
3207 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3208 g_mutex_unlock(&pc->cb_info->fd_lock);
3212 LOGE("message send failed");
3213 ret = CAMERA_ERROR_INVALID_OPERATION;
3215 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3218 __camera_update_api_waiting(pc->cb_info, api, -1);
3220 muse_core_msg_json_factory_free(msg);
3222 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3223 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3224 pc->wl_info.window_width, pc->wl_info.window_height);
3226 CAMERA_MSG_PARAM_SET(param, INT, type);
3228 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3231 if (ret != CAMERA_ERROR_NONE)
3232 LOGE("set display error 0x%x", ret);
3233 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3234 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3240 int camera_set_preview_resolution(camera_h camera, int width, int height)
3242 int ret = CAMERA_ERROR_NONE;
3243 camera_state_e current_state = CAMERA_STATE_NONE;
3244 camera_cli_s *pc = (camera_cli_s *)camera;
3245 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3246 camera_msg_param param;
3249 if (!pc || !pc->cb_info) {
3250 LOGE("NULL handle");
3251 return CAMERA_ERROR_INVALID_PARAMETER;
3254 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3255 ret = camera_get_state(camera, ¤t_state);
3256 if (ret != CAMERA_ERROR_NONE) {
3257 LOGE("failed to get current state 0x%x", ret);
3261 if (current_state == CAMERA_STATE_PREVIEW) {
3262 ret = _camera_stop_evas_rendering(camera, true);
3263 if (ret != CAMERA_ERROR_NONE)
3268 value = (width << 16) | height;
3269 CAMERA_MSG_PARAM_SET(param, INT, value);
3271 LOGD("%dx%d -> 0x%x", width, height, value);
3273 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3275 LOGD("ret : 0x%x", ret);
3277 if (current_state == CAMERA_STATE_PREVIEW) {
3278 LOGW("restart evas rendering");
3279 _camera_start_evas_rendering(camera);
3286 int camera_set_capture_resolution(camera_h camera, int width, int height)
3288 int ret = CAMERA_ERROR_NONE;
3289 camera_cli_s *pc = (camera_cli_s *)camera;
3290 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3291 camera_msg_param param;
3294 if (!pc || !pc->cb_info) {
3295 LOGE("NULL handle");
3296 return CAMERA_ERROR_INVALID_PARAMETER;
3301 value = (width << 16) | height;
3302 CAMERA_MSG_PARAM_SET(param, INT, value);
3304 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3306 LOGD("ret : 0x%x", ret);
3312 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3314 int ret = CAMERA_ERROR_NONE;
3315 int set_format = (int)format;
3316 camera_cli_s *pc = (camera_cli_s *)camera;
3317 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3318 camera_msg_param param;
3320 if (!pc || !pc->cb_info) {
3321 LOGE("NULL handle");
3322 return CAMERA_ERROR_INVALID_PARAMETER;
3325 LOGD("Enter - format %d", set_format);
3327 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3331 LOGD("ret : 0x%x", ret);
3337 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3339 int ret = CAMERA_ERROR_NONE;
3340 int set_format = (int)format;
3341 camera_msg_param param;
3342 camera_cli_s *pc = (camera_cli_s *)camera;
3343 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3345 if (!pc || !pc->cb_info) {
3346 LOGE("NULL handle");
3347 return CAMERA_ERROR_INVALID_PARAMETER;
3350 LOGD("Enter - capture_format %d", set_format);
3352 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3354 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3356 LOGD("ret : 0x%x", ret);
3362 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3364 int ret = CAMERA_ERROR_NONE;
3365 camera_cli_s *pc = (camera_cli_s *)camera;
3366 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3368 if (!pc || !pc->cb_info || !width || !height) {
3369 LOGE("NULL pointer %p %p %p", pc, width, height);
3370 return CAMERA_ERROR_INVALID_PARAMETER;
3375 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3377 if (ret == CAMERA_ERROR_NONE) {
3378 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3379 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3382 LOGD("ret : 0x%x", ret);
3388 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3390 int ret = CAMERA_ERROR_NONE;
3391 int set_rotation = (int)rotation;
3392 camera_cli_s *pc = (camera_cli_s *)camera;
3393 camera_msg_param param;
3395 if (!pc || !pc->cb_info) {
3396 LOGE("NULL handle");
3397 return CAMERA_ERROR_INVALID_PARAMETER;
3400 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3401 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3402 g_mutex_lock(&pc->cb_info->evas_mutex);
3404 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3406 g_mutex_unlock(&pc->cb_info->evas_mutex);
3408 if (ret != MM_ERROR_NONE) {
3409 LOGE("failed to set rotation for evas surface 0x%x", ret);
3410 return CAMERA_ERROR_INVALID_OPERATION;
3413 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3415 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3417 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3423 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3425 int ret = CAMERA_ERROR_NONE;
3426 camera_cli_s *pc = (camera_cli_s *)camera;
3428 if (!pc || !pc->cb_info || !rotation) {
3429 LOGE("NULL pointer %p %p", pc, rotation);
3430 return CAMERA_ERROR_INVALID_PARAMETER;
3433 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3435 if (ret == CAMERA_ERROR_NONE)
3436 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3442 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3444 int ret = CAMERA_ERROR_NONE;
3445 int set_flip = (int)flip;
3446 camera_cli_s *pc = (camera_cli_s *)camera;
3447 camera_msg_param param;
3449 if (!pc || !pc->cb_info) {
3450 LOGE("NULL handle");
3451 return CAMERA_ERROR_INVALID_PARAMETER;
3454 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3455 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3456 g_mutex_lock(&pc->cb_info->evas_mutex);
3458 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3460 g_mutex_unlock(&pc->cb_info->evas_mutex);
3462 if (ret != MM_ERROR_NONE) {
3463 LOGE("failed to set flip for evas surface 0x%x", ret);
3464 return CAMERA_ERROR_INVALID_OPERATION;
3467 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3469 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3471 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3477 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3479 int ret = CAMERA_ERROR_NONE;
3480 camera_cli_s *pc = (camera_cli_s *)camera;
3482 if (!pc || !pc->cb_info || !flip) {
3483 LOGE("NULL pointer %p %p", pc, flip);
3484 return CAMERA_ERROR_INVALID_PARAMETER;
3487 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3489 if (ret == CAMERA_ERROR_NONE)
3490 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3496 int camera_set_display_visible(camera_h camera, bool visible)
3498 int ret = CAMERA_ERROR_NONE;
3499 int set_visible = (int)visible;
3500 camera_cli_s *pc = (camera_cli_s *)camera;
3501 camera_msg_param param;
3503 if (!pc || !pc->cb_info) {
3504 LOGE("NULL handle");
3505 return CAMERA_ERROR_INVALID_PARAMETER;
3508 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3509 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3510 g_mutex_lock(&pc->cb_info->evas_mutex);
3512 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3514 g_mutex_unlock(&pc->cb_info->evas_mutex);
3516 if (ret != MM_ERROR_NONE) {
3517 LOGE("failed to set visible for evas surface 0x%x", ret);
3518 return CAMERA_ERROR_INVALID_OPERATION;
3521 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3523 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3525 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3531 int camera_is_display_visible(camera_h camera, bool *visible)
3533 int ret = CAMERA_ERROR_NONE;
3534 camera_cli_s *pc = (camera_cli_s *)camera;
3536 if (!pc || !pc->cb_info || !visible) {
3537 LOGE("NULL pointer %p %p", pc, visible);
3538 return CAMERA_ERROR_INVALID_PARAMETER;
3541 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3543 if (ret == CAMERA_ERROR_NONE)
3544 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3550 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3552 int ret = CAMERA_ERROR_NONE;
3553 int set_mode = (int)mode;
3554 camera_cli_s *pc = (camera_cli_s *)camera;
3555 camera_msg_param param;
3557 if (!pc || !pc->cb_info) {
3558 LOGE("NULL handle");
3559 return CAMERA_ERROR_INVALID_PARAMETER;
3562 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3563 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3564 g_mutex_lock(&pc->cb_info->evas_mutex);
3566 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3568 g_mutex_unlock(&pc->cb_info->evas_mutex);
3570 if (ret != MM_ERROR_NONE) {
3571 LOGE("failed to set geometry for evas surface 0x%x", ret);
3572 return CAMERA_ERROR_INVALID_OPERATION;
3575 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3577 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3579 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3585 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3587 int ret = CAMERA_ERROR_NONE;
3588 camera_cli_s *pc = (camera_cli_s *)camera;
3590 if (!pc || !pc->cb_info || !mode) {
3591 LOGE("NULL pointer %p %p", pc, mode);
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3595 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3597 if (ret == CAMERA_ERROR_NONE)
3598 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3604 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3606 int ret = CAMERA_ERROR_NONE;
3607 int set_hint = (int)hint;
3608 camera_cli_s *pc = (camera_cli_s *)camera;
3609 camera_msg_param param;
3611 if (!pc || !pc->cb_info) {
3612 LOGE("NULL handle");
3613 return CAMERA_ERROR_INVALID_PARAMETER;
3616 LOGD("Enter - hint %d", set_hint);
3618 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3620 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3626 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3628 int ret = CAMERA_ERROR_NONE;
3629 camera_cli_s *pc = (camera_cli_s *)camera;
3630 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3632 if (!pc || !pc->cb_info || !hint) {
3633 LOGE("NULL pointer %p %p", pc, hint);
3634 return CAMERA_ERROR_INVALID_PARAMETER;
3637 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3639 if (ret == CAMERA_ERROR_NONE) {
3640 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3641 LOGD("display reuse hint %d", *hint);
3648 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3650 int ret = CAMERA_ERROR_NONE;
3651 camera_cli_s *pc = (camera_cli_s *)camera;
3652 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3654 if (!pc || !pc->cb_info || !width || !height) {
3655 LOGE("NULL pointer %p %p %p", pc, width, height);
3656 return CAMERA_ERROR_INVALID_PARAMETER;
3661 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3663 if (ret == CAMERA_ERROR_NONE) {
3664 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3665 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3668 LOGD("ret : 0x%x", ret);
3674 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3676 int ret = CAMERA_ERROR_NONE;
3677 camera_cli_s *pc = (camera_cli_s *)camera;
3678 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3680 if (!pc || !pc->cb_info || !format) {
3681 LOGE("NULL pointer %p %p", pc, format);
3682 return CAMERA_ERROR_INVALID_PARAMETER;
3687 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3689 if (ret == CAMERA_ERROR_NONE)
3690 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3692 LOGD("ret : 0x%x", ret);
3698 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3700 int ret = CAMERA_ERROR_NONE;
3701 camera_cli_s *pc = (camera_cli_s *)camera;
3702 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3704 if (!pc || !pc->cb_info || !format) {
3705 LOGE("NULL pointer %p %p", pc, format);
3706 return CAMERA_ERROR_INVALID_PARAMETER;
3711 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3713 if (ret == CAMERA_ERROR_NONE)
3714 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3716 LOGD("ret : 0x%x", ret);
3722 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3724 int ret = CAMERA_ERROR_NONE;
3725 camera_cli_s *pc = (camera_cli_s *)camera;
3726 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3728 if (!pc || !pc->cb_info || !facing_direction) {
3729 LOGE("NULL pointer %p %p", pc, facing_direction);
3730 return CAMERA_ERROR_INVALID_PARAMETER;
3735 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3737 if (ret == CAMERA_ERROR_NONE)
3738 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3740 LOGD("ret : 0x%x", ret);
3746 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3748 int ret = CAMERA_ERROR_NONE;
3749 camera_cli_s *pc = (camera_cli_s *)camera;
3750 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3752 if (!pc || !pc->cb_info || !callback) {
3753 LOGE("NULL pointer %p %p", pc, callback);
3754 return CAMERA_ERROR_INVALID_PARAMETER;
3759 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3761 if (ret == CAMERA_ERROR_NONE) {
3762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3764 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3767 LOGD("ret : 0x%x", ret);
3773 int camera_unset_preview_cb(camera_h camera)
3775 int ret = CAMERA_ERROR_NONE;
3776 camera_cli_s *pc = (camera_cli_s *)camera;
3777 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3779 if (!pc || !pc->cb_info) {
3780 LOGE("NULL handle");
3781 return CAMERA_ERROR_INVALID_PARAMETER;
3786 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3787 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3789 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3793 LOGD("ret : 0x%x", ret);
3799 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3801 int ret = CAMERA_ERROR_NONE;
3802 camera_cli_s *pc = (camera_cli_s *)camera;
3803 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3805 if (!pc || !pc->cb_info) {
3806 LOGE("NULL handle");
3807 return CAMERA_ERROR_INVALID_PARAMETER;
3810 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3811 LOGE("NOT SUPPORTED");
3812 return CAMERA_ERROR_NOT_SUPPORTED;
3815 if (callback == NULL) {
3816 LOGE("NULL callback");
3817 return CAMERA_ERROR_INVALID_PARAMETER;
3822 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3824 if (ret == CAMERA_ERROR_NONE) {
3825 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3826 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3829 LOGD("ret : 0x%x", ret);
3835 int camera_unset_media_packet_preview_cb(camera_h camera)
3837 int ret = CAMERA_ERROR_NONE;
3838 camera_cli_s *pc = (camera_cli_s *)camera;
3839 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3841 if (!pc || !pc->cb_info) {
3842 LOGE("NULL handle");
3843 return CAMERA_ERROR_INVALID_PARAMETER;
3848 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3849 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3851 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3853 LOGD("ret : 0x%x", ret);
3859 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3861 int ret = CAMERA_ERROR_NONE;
3862 camera_cli_s *pc = (camera_cli_s *)camera;
3863 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3865 if (!pc || !pc->cb_info || !callback) {
3866 LOGE("NULL pointer %p %p", pc, callback);
3867 return CAMERA_ERROR_INVALID_PARAMETER;
3872 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3874 if (ret == CAMERA_ERROR_NONE) {
3875 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3876 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3879 LOGD("ret : 0x%x", ret);
3885 int camera_unset_state_changed_cb(camera_h camera)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3891 if (!pc || !pc->cb_info) {
3892 LOGE("NULL handle");
3893 return CAMERA_ERROR_INVALID_PARAMETER;
3898 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3899 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3901 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3903 LOGD("ret : 0x%x", ret);
3909 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3911 int ret = CAMERA_ERROR_NONE;
3912 camera_cli_s *pc = (camera_cli_s *)camera;
3913 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3915 if (!pc || !pc->cb_info || !callback) {
3916 LOGE("NULL pointer %p %p", pc, callback);
3917 return CAMERA_ERROR_INVALID_PARAMETER;
3922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3924 if (ret == CAMERA_ERROR_NONE) {
3925 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3926 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3929 LOGD("ret : 0x%x", ret);
3935 int camera_unset_interrupted_cb(camera_h camera)
3937 int ret = CAMERA_ERROR_NONE;
3938 camera_cli_s *pc = (camera_cli_s *)camera;
3939 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3941 if (!pc || !pc->cb_info) {
3942 LOGE("NULL handle");
3943 return CAMERA_ERROR_INVALID_PARAMETER;
3948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3951 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3953 LOGD("ret : 0x%x", ret);
3959 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3961 int ret = CAMERA_ERROR_NONE;
3962 camera_cli_s *pc = (camera_cli_s *)camera;
3963 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3965 if (!pc || !pc->cb_info || !callback) {
3966 LOGE("NULL pointer %p %p", pc, callback);
3967 return CAMERA_ERROR_INVALID_PARAMETER;
3972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3974 if (ret == CAMERA_ERROR_NONE) {
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3979 LOGD("ret : 0x%x", ret);
3985 int camera_unset_focus_changed_cb(camera_h camera)
3987 int ret = CAMERA_ERROR_NONE;
3988 camera_cli_s *pc = (camera_cli_s *)camera;
3989 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3991 if (!pc || !pc->cb_info) {
3992 LOGE("NULL handle");
3993 return CAMERA_ERROR_INVALID_PARAMETER;
3998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4001 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4003 LOGD("ret : 0x%x", ret);
4009 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4011 int ret = CAMERA_ERROR_NONE;
4012 camera_cli_s *pc = (camera_cli_s *)camera;
4013 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4015 if (!pc || !pc->cb_info || !callback) {
4016 LOGE("NULL pointer %p %p", pc, callback);
4017 return CAMERA_ERROR_INVALID_PARAMETER;
4022 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4024 if (ret == CAMERA_ERROR_NONE) {
4025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4029 LOGD("ret : 0x%x", ret);
4035 int camera_unset_error_cb(camera_h camera)
4037 int ret = CAMERA_ERROR_NONE;
4038 camera_cli_s *pc = (camera_cli_s *)camera;
4039 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4041 if (!pc || !pc->cb_info) {
4042 LOGE("NULL handle");
4043 return CAMERA_ERROR_INVALID_PARAMETER;
4048 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4049 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 LOGD("ret : 0x%x", ret);
4059 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4061 int ret = CAMERA_ERROR_NONE;
4062 camera_cli_s *pc = (camera_cli_s *)camera;
4063 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4065 if (!pc || !pc->cb_info || !foreach_cb) {
4066 LOGE("NULL pointer %p %p", pc, foreach_cb);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4072 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4073 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4077 LOGD("ret : 0x%x", ret);
4083 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4085 int ret = CAMERA_ERROR_NONE;
4086 camera_cli_s *pc = (camera_cli_s *)camera;
4087 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4089 if (!pc || !pc->cb_info || !foreach_cb) {
4090 LOGE("NULL pointer %p %p", pc, foreach_cb);
4091 return CAMERA_ERROR_INVALID_PARAMETER;
4096 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4097 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4099 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4101 LOGD("ret : 0x%x", ret);
4107 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4109 int ret = CAMERA_ERROR_NONE;
4110 camera_cli_s *pc = (camera_cli_s *)camera;
4111 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4113 if (!pc || !pc->cb_info || !foreach_cb) {
4114 LOGE("NULL pointer %p %p", pc, foreach_cb);
4115 return CAMERA_ERROR_INVALID_PARAMETER;
4120 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4121 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4123 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4125 LOGD("ret : 0x%x", ret);
4131 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4133 int ret = CAMERA_ERROR_NONE;
4134 camera_cli_s *pc = (camera_cli_s *)camera;
4135 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4137 if (!pc || !pc->cb_info || !foreach_cb) {
4138 LOGE("NULL pointer %p %p", pc, foreach_cb);
4139 return CAMERA_ERROR_INVALID_PARAMETER;
4144 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4145 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4147 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4149 LOGD("ret : 0x%x", ret);
4155 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4161 if (!pc || !pc->cb_info || !width || !height) {
4162 LOGE("NULL pointer %p %p %p", pc, width, height);
4163 return CAMERA_ERROR_INVALID_PARAMETER;
4167 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4169 if (ret == CAMERA_ERROR_NONE) {
4170 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4171 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4174 LOGD("ret : 0x%x", ret);
4180 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4182 int ret = CAMERA_ERROR_NONE;
4183 camera_cli_s *pc = (camera_cli_s *)camera;
4184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4186 if (!pc || !pc->cb_info || !angle) {
4187 LOGE("NULL pointer %p %p", pc, angle);
4188 return CAMERA_ERROR_INVALID_PARAMETER;
4193 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4195 if (ret == CAMERA_ERROR_NONE)
4196 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4198 LOGD("ret : 0x%x", ret);
4204 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4206 int ret = CAMERA_ERROR_NONE;
4207 camera_cli_s *pc = (camera_cli_s *)camera;
4208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4209 camera_msg_param param;
4210 int set_mode = (int)mode;
4212 if (!pc || !pc->cb_info) {
4213 LOGE("NULL handle");
4214 return CAMERA_ERROR_INVALID_PARAMETER;
4219 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4221 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4223 LOGD("ret : 0x%x", ret);
4229 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4231 int ret = CAMERA_ERROR_NONE;
4232 camera_cli_s *pc = (camera_cli_s *)camera;
4233 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4235 if (!pc || !pc->cb_info || !mode) {
4236 LOGE("NULL pointer %p %p", pc, mode);
4237 return CAMERA_ERROR_INVALID_PARAMETER;
4242 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4244 if (ret == CAMERA_ERROR_NONE)
4245 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4247 LOGD("ret : 0x%x", ret);
4253 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4259 if (!pc || !pc->cb_info || !foreach_cb) {
4260 LOGE("NULL pointer %p %p", pc, foreach_cb);
4261 return CAMERA_ERROR_INVALID_PARAMETER;
4266 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4267 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4269 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4271 LOGD("Finish, return :%x", ret);
4277 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4279 int ret = CAMERA_ERROR_NONE;
4280 camera_cli_s *pc = (camera_cli_s *)camera;
4281 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4282 camera_msg_param param;
4283 int set_fps = (int)fps;
4285 if (!pc || !pc->cb_info) {
4286 LOGE("NULL handle");
4287 return CAMERA_ERROR_INVALID_PARAMETER;
4292 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4294 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4296 LOGD("ret : 0x%x", ret);
4302 int camera_attr_set_image_quality(camera_h camera, int quality)
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4307 camera_msg_param param;
4309 if (!pc || !pc->cb_info) {
4310 LOGE("NULL handle");
4311 return CAMERA_ERROR_INVALID_PARAMETER;
4316 CAMERA_MSG_PARAM_SET(param, INT, quality);
4318 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4320 LOGD("ret : 0x%x", ret);
4326 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4328 int ret = CAMERA_ERROR_NONE;
4329 camera_cli_s *pc = (camera_cli_s *)camera;
4330 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4332 if (!pc || !pc->cb_info || !fps) {
4333 LOGE("NULL pointer %p %p", pc, fps);
4334 return CAMERA_ERROR_INVALID_PARAMETER;
4339 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4341 if (ret == CAMERA_ERROR_NONE)
4342 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4344 LOGD("ret : 0x%x", ret);
4350 int camera_attr_get_image_quality(camera_h camera, int *quality)
4352 int ret = CAMERA_ERROR_NONE;
4353 camera_cli_s *pc = (camera_cli_s *)camera;
4354 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4356 if (!pc || !pc->cb_info || !quality) {
4357 LOGE("NULL pointer %p %p", pc, quality);
4358 return CAMERA_ERROR_INVALID_PARAMETER;
4363 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4365 if (ret == CAMERA_ERROR_NONE)
4366 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4368 LOGD("ret : 0x%x", ret);
4374 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4376 int ret = CAMERA_ERROR_NONE;
4377 camera_cli_s *pc = (camera_cli_s *)camera;
4378 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4380 if (!pc || !pc->cb_info || !bitrate) {
4381 LOGE("NULL pointer %p %p", pc, bitrate);
4382 return CAMERA_ERROR_INVALID_PARAMETER;
4387 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4389 if (ret == CAMERA_ERROR_NONE)
4390 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4392 LOGD("ret : 0x%x", ret);
4398 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4400 int ret = CAMERA_ERROR_NONE;
4401 camera_cli_s *pc = (camera_cli_s *)camera;
4402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4403 camera_msg_param param;
4404 int set_bitrate = bitrate;
4406 if (!pc || !pc->cb_info) {
4407 LOGE("NULL handle");
4408 return CAMERA_ERROR_INVALID_PARAMETER;
4413 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4417 LOGD("ret : 0x%x", ret);
4423 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4425 int ret = CAMERA_ERROR_NONE;
4426 camera_cli_s *pc = (camera_cli_s *)camera;
4427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4429 if (!pc || !pc->cb_info || !interval) {
4430 LOGE("NULL pointer %p %p", pc, interval);
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4436 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4438 if (ret == CAMERA_ERROR_NONE)
4439 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4441 LOGD("ret : 0x%x", ret);
4447 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4449 int ret = CAMERA_ERROR_NONE;
4450 camera_cli_s *pc = (camera_cli_s *)camera;
4451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4452 camera_msg_param param;
4453 int set_gop_interval = interval;
4455 if (!pc || !pc->cb_info) {
4456 LOGE("NULL handle");
4457 return CAMERA_ERROR_INVALID_PARAMETER;
4462 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4464 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4466 LOGD("ret : 0x%x", ret);
4472 int camera_attr_set_zoom(camera_h camera, int zoom)
4474 int ret = CAMERA_ERROR_NONE;
4475 camera_cli_s *pc = (camera_cli_s *)camera;
4476 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4477 camera_msg_param param;
4479 if (!pc || !pc->cb_info) {
4480 LOGE("NULL handle");
4481 return CAMERA_ERROR_INVALID_PARAMETER;
4484 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4486 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4488 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4490 LOGD("ret : 0x%x", ret);
4496 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4498 int ret = CAMERA_ERROR_NONE;
4499 camera_cli_s *pc = (camera_cli_s *)camera;
4500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4501 camera_msg_param param;
4502 int set_mode = (int)mode;
4504 if (!pc || !pc->cb_info) {
4505 LOGE("NULL handle");
4506 return CAMERA_ERROR_INVALID_PARAMETER;
4509 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4511 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4513 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4519 int camera_attr_set_af_area(camera_h camera, int x, int y)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4524 camera_msg_param param;
4527 if (!pc || !pc->cb_info) {
4528 LOGE("NULL handle");
4529 return CAMERA_ERROR_INVALID_PARAMETER;
4532 LOGD("Enter - %d,%d", x, y);
4534 value = (x << 16) | y;
4535 CAMERA_MSG_PARAM_SET(param, INT, value);
4537 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4539 LOGD("ret : 0x%x", ret);
4545 int camera_attr_clear_af_area(camera_h camera)
4547 int ret = CAMERA_ERROR_NONE;
4548 camera_cli_s *pc = (camera_cli_s *)camera;
4549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4551 if (!pc || !pc->cb_info) {
4552 LOGE("NULL handle");
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4558 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4560 LOGD("ret : 0x%x", ret);
4566 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4568 int ret = CAMERA_ERROR_NONE;
4569 camera_cli_s *pc = (camera_cli_s *)camera;
4570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4571 camera_msg_param param;
4572 int set_mode = (int)mode;
4574 if (!pc || !pc->cb_info) {
4575 LOGE("NULL handle");
4576 return CAMERA_ERROR_INVALID_PARAMETER;
4581 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4583 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4585 LOGD("ret : 0x%x", ret);
4591 int camera_attr_set_exposure(camera_h camera, int value)
4593 int ret = CAMERA_ERROR_NONE;
4594 camera_cli_s *pc = (camera_cli_s *)camera;
4595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4596 camera_msg_param param;
4598 if (!pc || !pc->cb_info) {
4599 LOGE("NULL handle");
4600 return CAMERA_ERROR_INVALID_PARAMETER;
4605 CAMERA_MSG_PARAM_SET(param, INT, value);
4607 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4609 LOGD("ret : 0x%x", ret);
4615 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4620 camera_msg_param param;
4621 int set_iso = (int)iso;
4623 if (!pc || !pc->cb_info) {
4624 LOGE("NULL handle");
4625 return CAMERA_ERROR_INVALID_PARAMETER;
4630 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4632 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4634 LOGD("ret : 0x%x", ret);
4640 int camera_attr_set_brightness(camera_h camera, int level)
4642 int ret = CAMERA_ERROR_NONE;
4643 camera_cli_s *pc = (camera_cli_s *)camera;
4644 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4645 camera_msg_param param;
4647 if (!pc || !pc->cb_info) {
4648 LOGE("NULL handle");
4649 return CAMERA_ERROR_INVALID_PARAMETER;
4654 CAMERA_MSG_PARAM_SET(param, INT, level);
4656 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4658 LOGD("ret : 0x%x", ret);
4664 int camera_attr_set_contrast(camera_h camera, int level)
4666 int ret = CAMERA_ERROR_NONE;
4667 camera_cli_s *pc = (camera_cli_s *)camera;
4668 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4669 camera_msg_param param;
4671 if (!pc || !pc->cb_info) {
4672 LOGE("NULL handle");
4673 return CAMERA_ERROR_INVALID_PARAMETER;
4678 CAMERA_MSG_PARAM_SET(param, INT, level);
4680 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4682 LOGD("ret : 0x%x", ret);
4688 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4690 int ret = CAMERA_ERROR_NONE;
4691 camera_cli_s *pc = (camera_cli_s *)camera;
4692 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4693 camera_msg_param param;
4694 int set_whitebalance = (int)wb;
4696 if (!pc || !pc->cb_info) {
4697 LOGE("NULL handle");
4698 return CAMERA_ERROR_INVALID_PARAMETER;
4703 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4705 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4707 LOGD("ret : 0x%x", ret);
4713 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4715 int ret = CAMERA_ERROR_NONE;
4716 camera_cli_s *pc = (camera_cli_s *)camera;
4717 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4718 camera_msg_param param;
4719 int set_effect = (int)effect;
4721 if (!pc || !pc->cb_info) {
4722 LOGE("NULL handle");
4723 return CAMERA_ERROR_INVALID_PARAMETER;
4728 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 LOGD("ret : 0x%x", ret);
4738 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4743 camera_msg_param param;
4744 int set_mode = (int)mode;
4746 if (!pc || !pc->cb_info) {
4747 LOGE("NULL handle");
4748 return CAMERA_ERROR_INVALID_PARAMETER;
4753 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4755 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4757 LOGD("ret : 0x%x", ret);
4763 int camera_attr_enable_tag(camera_h camera, bool enable)
4765 int ret = CAMERA_ERROR_NONE;
4766 camera_cli_s *pc = (camera_cli_s *)camera;
4767 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4768 camera_msg_param param;
4769 int set_enable = (int)enable;
4771 if (!pc || !pc->cb_info) {
4772 LOGE("NULL handle");
4773 return CAMERA_ERROR_INVALID_PARAMETER;
4778 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4780 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4782 LOGD("ret : 0x%x", ret);
4788 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4790 int ret = CAMERA_ERROR_NONE;
4791 camera_cli_s *pc = (camera_cli_s *)camera;
4792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4793 camera_msg_param param;
4795 if (!pc || !pc->cb_info || !description) {
4796 LOGE("NULL pointer %p %p", pc, description);
4797 return CAMERA_ERROR_INVALID_PARAMETER;
4802 CAMERA_MSG_PARAM_SET(param, STRING, description);
4804 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4806 LOGD("ret : 0x%x", ret);
4812 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4817 camera_msg_param param;
4818 int set_orientation = (int)orientation;
4820 if (!pc || !pc->cb_info) {
4821 LOGE("NULL handle");
4822 return CAMERA_ERROR_INVALID_PARAMETER;
4827 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4829 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4831 LOGD("ret : 0x%x", ret);
4837 int camera_attr_set_tag_software(camera_h camera, const char *software)
4839 int ret = CAMERA_ERROR_NONE;
4840 camera_cli_s *pc = (camera_cli_s *)camera;
4841 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4842 camera_msg_param param;
4844 if (!pc || !pc->cb_info || !software) {
4845 LOGE("NULL pointer %p %p", pc, software);
4846 return CAMERA_ERROR_INVALID_PARAMETER;
4849 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4851 CAMERA_MSG_PARAM_SET(param, STRING, software);
4853 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4855 LOGD("ret : 0x%x", ret);
4861 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4863 int ret = CAMERA_ERROR_NONE;
4864 camera_cli_s *pc = (camera_cli_s *)camera;
4865 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4866 double set_geotag[3] = {latitude, longitude, altitude};
4871 if (!pc || !pc->cb_info) {
4872 LOGE("NULL handle");
4873 return CAMERA_ERROR_INVALID_PARAMETER;
4878 length = sizeof(set_geotag) / sizeof(int) + \
4879 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4881 msg = muse_core_msg_json_factory_new(api,
4882 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4885 LOGE("msg creation failed: api %d", api);
4886 return CAMERA_ERROR_OUT_OF_MEMORY;
4889 if (pc->cb_info->is_server_connected) {
4890 __camera_update_api_waiting(pc->cb_info, api, 1);
4892 g_mutex_lock(&pc->cb_info->fd_lock);
4893 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4894 g_mutex_unlock(&pc->cb_info->fd_lock);
4898 LOGE("message send failed");
4899 ret = CAMERA_ERROR_INVALID_OPERATION;
4901 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4904 __camera_update_api_waiting(pc->cb_info, api, -1);
4906 muse_core_msg_json_factory_free(msg);
4908 LOGD("ret : 0x%x", ret);
4914 int camera_attr_remove_geotag(camera_h camera)
4916 int ret = CAMERA_ERROR_NONE;
4917 camera_cli_s *pc = (camera_cli_s *)camera;
4918 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4920 if (!pc || !pc->cb_info) {
4921 LOGE("NULL handle");
4922 return CAMERA_ERROR_INVALID_PARAMETER;
4927 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4929 LOGD("ret : 0x%x", ret);
4935 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4937 int ret = CAMERA_ERROR_NONE;
4938 camera_cli_s *pc = (camera_cli_s *)camera;
4939 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4940 camera_msg_param param;
4941 int set_mode = (int)mode;
4943 if (!pc || !pc->cb_info) {
4944 LOGE("NULL handle");
4945 return CAMERA_ERROR_INVALID_PARAMETER;
4950 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4952 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4954 LOGD("ret : 0x%x", ret);
4960 int camera_attr_get_zoom(camera_h camera, int *zoom)
4962 int ret = CAMERA_ERROR_NONE;
4963 camera_cli_s *pc = (camera_cli_s *)camera;
4964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4966 if (!pc || !pc->cb_info || !zoom) {
4967 LOGE("NULL pointer %p %p", pc, zoom);
4968 return CAMERA_ERROR_INVALID_PARAMETER;
4973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4975 if (ret == CAMERA_ERROR_NONE)
4976 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4978 LOGD("ret : 0x%x", ret);
4984 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4986 int ret = CAMERA_ERROR_NONE;
4987 camera_cli_s *pc = (camera_cli_s *)camera;
4988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4990 if (!pc || !pc->cb_info || !min || !max) {
4991 LOGE("NULL pointer %p %p %p", pc, min, max);
4992 return CAMERA_ERROR_INVALID_PARAMETER;
4997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4999 if (ret == CAMERA_ERROR_NONE) {
5000 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5001 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5004 LOGD("ret : 0x%x", ret);
5010 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5012 int ret = CAMERA_ERROR_NONE;
5013 camera_cli_s *pc = (camera_cli_s *)camera;
5014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5016 if (!pc || !pc->cb_info || !mode) {
5017 LOGE("NULL pointer %p %p", pc, mode);
5018 return CAMERA_ERROR_INVALID_PARAMETER;
5023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5025 if (ret == CAMERA_ERROR_NONE)
5026 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5028 LOGD("ret : 0x%x", ret);
5034 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5040 if (!pc || !pc->cb_info || !mode) {
5041 LOGE("NULL pointer %p %p", pc, mode);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE)
5050 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5052 LOGD("ret : 0x%x", ret);
5058 int camera_attr_get_exposure(camera_h camera, int *value)
5060 int ret = CAMERA_ERROR_NONE;
5061 camera_cli_s *pc = (camera_cli_s *)camera;
5062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5064 if (!pc || !pc->cb_info || !value) {
5065 LOGE("NULL pointer %p %p", pc, value);
5066 return CAMERA_ERROR_INVALID_PARAMETER;
5071 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5073 if (ret == CAMERA_ERROR_NONE)
5074 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5076 LOGD("ret : 0x%x", ret);
5082 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5084 int ret = CAMERA_ERROR_NONE;
5085 camera_cli_s *pc = (camera_cli_s *)camera;
5086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5088 if (!pc || !pc->cb_info || !min || !max) {
5089 LOGE("NULL pointer %p %p %p", pc, min, max);
5090 return CAMERA_ERROR_INVALID_PARAMETER;
5095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5097 if (ret == CAMERA_ERROR_NONE) {
5098 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5099 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5102 LOGD("ret : 0x%x", ret);
5108 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5110 int ret = CAMERA_ERROR_NONE;
5111 camera_cli_s *pc = (camera_cli_s *)camera;
5112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5114 if (!pc || !pc->cb_info || !iso) {
5115 LOGE("NULL pointer %p %p", pc, iso);
5116 return CAMERA_ERROR_INVALID_PARAMETER;
5121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5123 if (ret == CAMERA_ERROR_NONE)
5124 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5126 LOGD("ret : 0x%x", ret);
5132 int camera_attr_get_brightness(camera_h camera, int *level)
5134 int ret = CAMERA_ERROR_NONE;
5135 camera_cli_s *pc = (camera_cli_s *)camera;
5136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5138 if (!pc || !pc->cb_info || !level) {
5139 LOGE("NULL pointer %p %p", pc, level);
5140 return CAMERA_ERROR_INVALID_PARAMETER;
5145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5147 if (ret == CAMERA_ERROR_NONE)
5148 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5150 LOGD("ret : 0x%x", ret);
5156 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5158 int ret = CAMERA_ERROR_NONE;
5159 camera_cli_s *pc = (camera_cli_s *)camera;
5160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5162 if (!pc || !pc->cb_info || !min || !max) {
5163 LOGE("NULL pointer %p %p %p", pc, min, max);
5164 return CAMERA_ERROR_INVALID_PARAMETER;
5169 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5171 if (ret == CAMERA_ERROR_NONE) {
5172 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5173 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5176 LOGD("ret : 0x%x", ret);
5182 int camera_attr_get_contrast(camera_h camera, int *level)
5184 int ret = CAMERA_ERROR_NONE;
5185 camera_cli_s *pc = (camera_cli_s *)camera;
5186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5188 if (!pc || !pc->cb_info || !level) {
5189 LOGE("NULL pointer %p %p", pc, level);
5190 return CAMERA_ERROR_INVALID_PARAMETER;
5195 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5197 if (ret == CAMERA_ERROR_NONE)
5198 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5200 LOGD("ret : 0x%x", ret);
5206 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5208 int ret = CAMERA_ERROR_NONE;
5209 camera_cli_s *pc = (camera_cli_s *)camera;
5210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5212 if (!pc || !pc->cb_info || !min || !max) {
5213 LOGE("NULL pointer %p %p %p", pc, min, max);
5214 return CAMERA_ERROR_INVALID_PARAMETER;
5219 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5221 if (ret == CAMERA_ERROR_NONE) {
5222 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5223 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5224 LOGD("min %d, max %d", *min, *max);
5227 LOGD("ret : 0x%x", ret);
5233 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5239 if (!pc || !pc->cb_info || !wb) {
5240 LOGE("NULL pointer %p %p", pc, wb);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5246 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE)
5249 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5251 LOGD("ret : 0x%x", ret);
5257 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5259 int ret = CAMERA_ERROR_NONE;
5260 camera_cli_s *pc = (camera_cli_s *)camera;
5261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5263 if (!pc || !pc->cb_info || !effect) {
5264 LOGE("NULL pointer %p %p", pc, effect);
5265 return CAMERA_ERROR_INVALID_PARAMETER;
5270 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5272 if (ret == CAMERA_ERROR_NONE)
5273 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5275 LOGD("ret : 0x%x", ret);
5281 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5283 int ret = CAMERA_ERROR_NONE;
5284 camera_cli_s *pc = (camera_cli_s *)camera;
5285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5287 if (!pc || !pc->cb_info || !mode) {
5288 LOGE("NULL pointer %p %p", pc, mode);
5289 return CAMERA_ERROR_INVALID_PARAMETER;
5294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5296 if (ret == CAMERA_ERROR_NONE)
5297 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5299 LOGD("ret : 0x%x", ret);
5305 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5307 int ret = CAMERA_ERROR_NONE;
5308 camera_cli_s *pc = (camera_cli_s *)camera;
5309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5311 if (!pc || !pc->cb_info || !enable) {
5312 LOGE("NULL pointer %p %p", pc, enable);
5313 return CAMERA_ERROR_INVALID_PARAMETER;
5318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5320 if (ret == CAMERA_ERROR_NONE)
5321 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5323 LOGD("ret : 0x%x", ret);
5329 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5331 int ret = CAMERA_ERROR_NONE;
5332 camera_cli_s *pc = (camera_cli_s *)camera;
5333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5335 if (!pc || !pc->cb_info || !description) {
5336 LOGE("NULL pointer %p %p", pc, description);
5337 return CAMERA_ERROR_INVALID_PARAMETER;
5342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5344 if (ret == CAMERA_ERROR_NONE)
5345 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5347 LOGD("ret : 0x%x", ret);
5353 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5355 int ret = CAMERA_ERROR_NONE;
5356 camera_cli_s *pc = (camera_cli_s *)camera;
5357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5359 if (!pc || !pc->cb_info || !orientation) {
5360 LOGE("NULL pointer %p %p", pc, orientation);
5361 return CAMERA_ERROR_INVALID_PARAMETER;
5366 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5368 if (ret == CAMERA_ERROR_NONE)
5369 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5371 LOGD("ret : 0x%x", ret);
5377 int camera_attr_get_tag_software(camera_h camera, char **software)
5379 int ret = CAMERA_ERROR_NONE;
5380 camera_cli_s *pc = (camera_cli_s *)camera;
5381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5383 if (!pc || !pc->cb_info || !software) {
5384 LOGE("NULL pointer %p %p", pc, software);
5385 return CAMERA_ERROR_INVALID_PARAMETER;
5390 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5392 if (ret == CAMERA_ERROR_NONE)
5393 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5395 LOGD("ret : 0x%x", ret);
5401 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5403 int ret = CAMERA_ERROR_NONE;
5404 camera_cli_s *pc = (camera_cli_s *)camera;
5405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5407 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5408 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5409 return CAMERA_ERROR_INVALID_PARAMETER;
5414 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5416 if (ret == CAMERA_ERROR_NONE) {
5417 *latitude = pc->cb_info->get_geotag[0];
5418 *longitude = pc->cb_info->get_geotag[1];
5419 *altitude = pc->cb_info->get_geotag[2];
5422 LOGD("ret : 0x%x", ret);
5428 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5430 int ret = CAMERA_ERROR_NONE;
5431 camera_cli_s *pc = (camera_cli_s *)camera;
5432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5434 if (!pc || !pc->cb_info || !mode) {
5435 LOGE("NULL pointer %p %p", pc, mode);
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5441 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5443 if (ret == CAMERA_ERROR_NONE)
5444 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5446 LOGD("ret : 0x%x", ret);
5452 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5454 int ret = CAMERA_ERROR_NONE;
5455 int get_flash_state = 0;
5458 LOGE("NULL pointer");
5459 return CAMERA_ERROR_INVALID_PARAMETER;
5462 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5463 (int)device, "get_flash_state", &get_flash_state);
5465 if (ret == CAMERA_ERROR_NONE) {
5466 *state = (camera_flash_state_e)get_flash_state;
5467 LOGD("flash state %d", *state);
5469 LOGE("failed 0x%x", ret);
5476 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5478 int ret = CAMERA_ERROR_NONE;
5479 camera_cli_s *pc = (camera_cli_s *)camera;
5480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5482 if (!pc || !pc->cb_info || !foreach_cb) {
5483 LOGE("NULL pointer %p %p", pc, foreach_cb);
5484 return CAMERA_ERROR_INVALID_PARAMETER;
5489 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5490 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5492 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5494 LOGD("ret : 0x%x", ret);
5500 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5506 if (!pc || !pc->cb_info || !foreach_cb) {
5507 LOGE("NULL pointer %p %p", pc, foreach_cb);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5513 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5514 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5516 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5518 LOGD("ret : 0x%x", ret);
5524 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5530 if (!pc || !pc->cb_info || !foreach_cb) {
5531 LOGE("NULL pointer %p %p", pc, foreach_cb);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5537 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5538 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5540 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5542 LOGD("ret : 0x%x", ret);
5548 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5550 int ret = CAMERA_ERROR_NONE;
5551 camera_cli_s *pc = (camera_cli_s *)camera;
5552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5554 if (!pc || !pc->cb_info || !foreach_cb) {
5555 LOGE("NULL pointer %p %p", pc, foreach_cb);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5561 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5562 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5564 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5566 LOGD("ret : 0x%x", ret);
5572 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5574 int ret = CAMERA_ERROR_NONE;
5575 camera_cli_s *pc = (camera_cli_s *)camera;
5576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5578 if (!pc || !pc->cb_info || !foreach_cb) {
5579 LOGE("NULL pointer %p %p", pc, foreach_cb);
5580 return CAMERA_ERROR_INVALID_PARAMETER;
5585 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5586 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5590 LOGD("ret : 0x%x", ret);
5596 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5598 int ret = CAMERA_ERROR_NONE;
5599 camera_cli_s *pc = (camera_cli_s *)camera;
5600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5602 if (!pc || !pc->cb_info || !foreach_cb) {
5603 LOGE("NULL pointer %p %p", pc, foreach_cb);
5604 return CAMERA_ERROR_INVALID_PARAMETER;
5609 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5610 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5612 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5614 LOGD("ret : 0x%x", ret);
5620 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5622 int ret = CAMERA_ERROR_NONE;
5623 camera_cli_s *pc = (camera_cli_s *)camera;
5624 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5626 if (!pc || !pc->cb_info || !foreach_cb) {
5627 LOGE("NULL pointer %p %p", pc, foreach_cb);
5628 return CAMERA_ERROR_INVALID_PARAMETER;
5633 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5634 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5636 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5638 LOGD("ret : 0x%x", ret);
5644 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5646 int ret = CAMERA_ERROR_NONE;
5647 camera_cli_s *pc = (camera_cli_s *)camera;
5648 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5650 if (!pc || !pc->cb_info || !foreach_cb) {
5651 LOGE("NULL pointer %p %p", pc, foreach_cb);
5652 return CAMERA_ERROR_INVALID_PARAMETER;
5657 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5658 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5660 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5662 LOGD("Enter, handle :%x", pc->remote_handle);
5668 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)
5670 int ret = CAMERA_ERROR_NONE;
5671 camera_cli_s *pc = (camera_cli_s *)camera;
5672 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5673 camera_msg_param param;
5676 if (!pc || !pc->cb_info || !foreach_cb) {
5677 LOGE("NULL pointer %p %p", pc, foreach_cb);
5678 return CAMERA_ERROR_INVALID_PARAMETER;
5683 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5684 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5686 value = (width << 16) | height;
5687 CAMERA_MSG_PARAM_SET(param, INT, value);
5689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5691 LOGD("ret : 0x%x", ret);
5697 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5703 if (!pc || !pc->cb_info || !foreach_cb) {
5704 LOGE("NULL pointer %p %p", pc, foreach_cb);
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5710 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5711 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5715 LOGD("ret : 0x%x", ret);
5721 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5723 int ret = CAMERA_ERROR_NONE;
5724 camera_cli_s *pc = (camera_cli_s *)camera;
5725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5727 if (!pc || !pc->cb_info || !foreach_cb) {
5728 LOGE("NULL pointer %p %p", pc, foreach_cb);
5729 return CAMERA_ERROR_INVALID_PARAMETER;
5734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5737 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5739 LOGD("ret : 0x%x", ret);
5745 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5747 int ret = CAMERA_ERROR_NONE;
5748 camera_cli_s *pc = (camera_cli_s *)camera;
5749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5750 camera_msg_param param;
5751 int set_rotation = (int)rotation;
5753 if (!pc || !pc->cb_info) {
5754 LOGE("NULL handle");
5755 return CAMERA_ERROR_INVALID_PARAMETER;
5760 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5764 LOGD("ret : 0x%x", ret);
5770 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5772 int ret = CAMERA_ERROR_NONE;
5773 camera_cli_s *pc = (camera_cli_s *)camera;
5774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5776 if (!pc || !pc->cb_info || !rotation) {
5777 LOGE("NULL pointer %p %p", pc, rotation);
5778 return CAMERA_ERROR_INVALID_PARAMETER;
5783 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5785 if (ret == CAMERA_ERROR_NONE)
5786 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5788 LOGD("ret : 0x%x", ret);
5794 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5796 int ret = CAMERA_ERROR_NONE;
5797 camera_cli_s *pc = (camera_cli_s *)camera;
5798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5799 camera_msg_param param;
5800 int set_flip = (int)flip;
5802 if (!pc || !pc->cb_info) {
5803 LOGE("NULL handle");
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5813 LOGD("ret : 0x%x", ret);
5819 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5825 if (!pc || !pc->cb_info || !flip) {
5826 LOGE("NULL pointer %p %p", pc, flip);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5832 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5834 if (ret == CAMERA_ERROR_NONE)
5835 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5837 LOGD("ret : 0x%x", ret);
5842 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5844 int ret = CAMERA_ERROR_NONE;
5845 camera_cli_s *pc = (camera_cli_s *)camera;
5846 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5847 camera_msg_param param;
5848 int set_mode = (int)mode;
5850 if (!pc || !pc->cb_info) {
5851 LOGE("NULL handle");
5852 return CAMERA_ERROR_INVALID_PARAMETER;
5857 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5859 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5861 LOGD("ret : 0x%x", ret);
5867 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5869 int ret = CAMERA_ERROR_NONE;
5870 camera_cli_s *pc = (camera_cli_s *)camera;
5871 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5873 if (!pc || !pc->cb_info || !mode) {
5874 LOGE("NULL pointer %p %p", pc, mode);
5875 return CAMERA_ERROR_INVALID_PARAMETER;
5880 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5882 if (ret == CAMERA_ERROR_NONE)
5883 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5885 LOGD("ret : 0x%x", ret);
5891 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5893 int ret = CAMERA_ERROR_NONE;
5894 camera_cli_s *pc = (camera_cli_s *)camera;
5895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5897 if (!pc || !pc->cb_info) {
5898 LOGE("NULL handle");
5899 return CAMERA_ERROR_INVALID_PARAMETER;
5904 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5907 LOGE("error is occurred 0x%x", ret);
5911 LOGD("ret : %d", ret);
5917 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5919 int ret = CAMERA_ERROR_NONE;
5920 camera_cli_s *pc = (camera_cli_s *)camera;
5921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5923 if (!pc || !pc->cb_info) {
5924 LOGE("NULL handle");
5925 return CAMERA_ERROR_INVALID_PARAMETER;
5930 if (!camera_attr_is_supported_hdr_capture(camera)) {
5931 LOGE("HDR not supported");
5932 return CAMERA_ERROR_NOT_SUPPORTED;
5936 LOGE("NULL callback");
5937 return CAMERA_ERROR_INVALID_PARAMETER;
5940 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5941 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5943 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5945 LOGD("ret : 0x%x", ret);
5951 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5953 int ret = CAMERA_ERROR_NONE;
5954 camera_cli_s *pc = (camera_cli_s *)camera;
5955 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5957 if (!pc || !pc->cb_info) {
5958 LOGE("NULL handle");
5959 return CAMERA_ERROR_INVALID_PARAMETER;
5964 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5965 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5967 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5969 LOGD("ret : 0x%x", ret);
5975 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5977 int ret = CAMERA_ERROR_NONE;
5978 camera_cli_s *pc = (camera_cli_s *)camera;
5979 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5980 camera_msg_param param;
5981 int set_enable = (int)enable;
5983 if (!pc || !pc->cb_info) {
5984 LOGE("NULL handle");
5985 return CAMERA_ERROR_INVALID_PARAMETER;
5990 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5992 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5994 LOGD("ret : 0x%x", ret);
6000 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6002 int ret = CAMERA_ERROR_NONE;
6003 camera_cli_s *pc = (camera_cli_s *)camera;
6004 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6006 if (!pc || !pc->cb_info || !enabled) {
6007 LOGE("NULL pointer %p %p", pc, enabled);
6008 return CAMERA_ERROR_INVALID_PARAMETER;
6013 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6015 if (ret == CAMERA_ERROR_NONE)
6016 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6018 LOGD("ret : 0x%x", ret);
6024 bool camera_attr_is_supported_anti_shake(camera_h camera)
6026 int ret = CAMERA_ERROR_NONE;
6027 camera_cli_s *pc = (camera_cli_s *)camera;
6028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6030 if (!pc || !pc->cb_info) {
6031 LOGE("NULL handle");
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6037 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6040 LOGE("error is occurred 0x%x", ret);
6044 LOGD("ret : %d", ret);
6050 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6052 int ret = CAMERA_ERROR_NONE;
6053 camera_cli_s *pc = (camera_cli_s *)camera;
6054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6055 camera_msg_param param;
6056 int set_enable = (int)enable;
6058 if (!pc || !pc->cb_info) {
6059 LOGE("NULL handle");
6060 return CAMERA_ERROR_INVALID_PARAMETER;
6065 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6067 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6069 LOGD("ret : 0x%x", ret);
6075 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6077 int ret = CAMERA_ERROR_NONE;
6078 camera_cli_s *pc = (camera_cli_s *)camera;
6079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6081 if (!pc || !pc->cb_info || !enabled) {
6082 LOGE("NULL pointer %p %p", pc, enabled);
6083 return CAMERA_ERROR_INVALID_PARAMETER;
6088 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6090 if (ret == CAMERA_ERROR_NONE)
6091 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6093 LOGD("ret : 0x%x", ret);
6099 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6101 int ret = CAMERA_ERROR_NONE;
6102 camera_cli_s *pc = (camera_cli_s *)camera;
6103 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6105 if (!pc || !pc->cb_info) {
6106 LOGE("NULL handle");
6107 return CAMERA_ERROR_INVALID_PARAMETER;
6112 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 LOGE("error is occurred 0x%x", ret);
6119 LOGD("ret : %d", ret);
6125 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6127 int ret = CAMERA_ERROR_NONE;
6128 camera_cli_s *pc = (camera_cli_s *)camera;
6129 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6130 camera_msg_param param;
6131 int set_enable = (int)enable;
6133 if (!pc || !pc->cb_info) {
6134 LOGE("NULL handle");
6135 return CAMERA_ERROR_INVALID_PARAMETER;
6140 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6142 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6144 LOGD("ret : 0x%x", ret);
6150 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6152 int ret = CAMERA_ERROR_NONE;
6153 camera_cli_s *pc = (camera_cli_s *)camera;
6154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6156 if (!pc || !pc->cb_info || !enabled) {
6157 LOGE("NULL pointer %p %p", pc, enabled);
6158 return CAMERA_ERROR_INVALID_PARAMETER;
6163 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6165 if (ret == CAMERA_ERROR_NONE)
6166 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6168 LOGD("ret : 0x%x", ret);
6174 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6176 int ret = CAMERA_ERROR_NONE;
6177 camera_cli_s *pc = (camera_cli_s *)camera;
6178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6180 if (!pc || !pc->cb_info) {
6181 LOGE("NULL handle");
6182 return CAMERA_ERROR_INVALID_PARAMETER;
6187 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6190 LOGE("error is occurred 0x%x", ret);
6194 LOGD("ret : %d", ret);
6200 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6202 int ret = CAMERA_ERROR_NONE;
6203 camera_cli_s *pc = (camera_cli_s *)camera;
6204 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6205 camera_msg_param param;
6206 int set_disable = (int)disable;
6208 if (!pc || !pc->cb_info) {
6209 LOGE("NULL handle");
6210 return CAMERA_ERROR_INVALID_PARAMETER;
6215 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6217 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6219 LOGD("ret : 0x%x", ret);
6225 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6227 int ret = CAMERA_ERROR_NONE;
6228 camera_cli_s *pc = (camera_cli_s *)camera;
6229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6230 camera_msg_param param;
6231 int set_move_type = (int)move_type;
6234 if (!pc || !pc->cb_info) {
6235 LOGE("NULL handle");
6236 return CAMERA_ERROR_INVALID_PARAMETER;
6241 value = (set_move_type << 16) | pan_step;
6242 CAMERA_MSG_PARAM_SET(param, INT, value);
6244 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6246 LOGD("ret : 0x%x", ret);
6252 int camera_attr_get_pan(camera_h camera, int *pan_step)
6254 int ret = CAMERA_ERROR_NONE;
6255 camera_cli_s *pc = (camera_cli_s *)camera;
6256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6258 if (!pc || !pc->cb_info || !pan_step) {
6259 LOGE("NULL pointer %p %p", pc, pan_step);
6260 return CAMERA_ERROR_INVALID_PARAMETER;
6265 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6267 if (ret == CAMERA_ERROR_NONE)
6268 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6270 LOGD("ret : 0x%x", ret);
6276 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6278 int ret = CAMERA_ERROR_NONE;
6279 camera_cli_s *pc = (camera_cli_s *)camera;
6280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6282 if (!pc || !pc->cb_info || !min || !max) {
6283 LOGE("NULL pointer %p %p", pc, min, max);
6284 return CAMERA_ERROR_INVALID_PARAMETER;
6289 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6291 if (ret == CAMERA_ERROR_NONE) {
6292 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6293 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6296 LOGD("ret : 0x%x", ret);
6302 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6304 int ret = CAMERA_ERROR_NONE;
6305 camera_cli_s *pc = (camera_cli_s *)camera;
6306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6307 camera_msg_param param;
6308 int set_move_type = (int)move_type;
6311 if (!pc || !pc->cb_info) {
6312 LOGE("NULL handle");
6313 return CAMERA_ERROR_INVALID_PARAMETER;
6318 value = (set_move_type << 16) | tilt_step;
6319 CAMERA_MSG_PARAM_SET(param, INT, value);
6321 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6323 LOGD("ret : 0x%x", ret);
6329 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6331 int ret = CAMERA_ERROR_NONE;
6332 camera_cli_s *pc = (camera_cli_s *)camera;
6333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6335 if (!pc || !pc->cb_info || !tilt_step) {
6336 LOGE("NULL pointer %p %p", pc, tilt_step);
6337 return CAMERA_ERROR_INVALID_PARAMETER;
6342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6344 if (ret == CAMERA_ERROR_NONE)
6345 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6347 LOGD("ret : 0x%x", ret);
6353 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6355 int ret = CAMERA_ERROR_NONE;
6356 camera_cli_s *pc = (camera_cli_s *)camera;
6357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6359 if (!pc || !pc->cb_info || !min || !max) {
6360 LOGE("NULL pointer %p %p %p", pc, min, max);
6361 return CAMERA_ERROR_INVALID_PARAMETER;
6366 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6368 if (ret == CAMERA_ERROR_NONE) {
6369 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6370 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6373 LOGD("ret : 0x%x", ret);
6379 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6381 int ret = CAMERA_ERROR_NONE;
6382 camera_cli_s *pc = (camera_cli_s *)camera;
6383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6384 camera_msg_param param;
6385 int set_ptz_type = (int)ptz_type;
6387 if (!pc || !pc->cb_info) {
6388 LOGE("NULL handle");
6389 return CAMERA_ERROR_INVALID_PARAMETER;
6394 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6396 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6398 LOGD("ret : 0x%x", ret);
6404 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6406 int ret = CAMERA_ERROR_NONE;
6407 camera_cli_s *pc = (camera_cli_s *)camera;
6408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6410 if (!pc || !pc->cb_info || !foreach_cb) {
6411 LOGE("NULL pointer %p %p", pc, foreach_cb);
6412 return CAMERA_ERROR_INVALID_PARAMETER;
6417 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6418 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6420 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6422 LOGD("ret : 0x%x", ret);
6428 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6430 int ret = CAMERA_ERROR_NONE;
6431 camera_cli_s *pc = (camera_cli_s *)camera;
6432 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6433 int set_display_roi_area[4] = {x, y, width, height};
6438 if (!pc || !pc->cb_info) {
6439 LOGE("NULL handle");
6440 return CAMERA_ERROR_INVALID_PARAMETER;
6445 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6446 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6447 g_mutex_lock(&pc->cb_info->evas_mutex);
6449 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6451 g_mutex_unlock(&pc->cb_info->evas_mutex);
6453 if (ret != MM_ERROR_NONE) {
6454 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6455 return CAMERA_ERROR_INVALID_OPERATION;
6458 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6460 length = sizeof(set_display_roi_area) / sizeof(int) + \
6461 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6463 msg = muse_core_msg_json_factory_new(api,
6464 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6467 LOGE("msg creation failed: api %d", api);
6468 return CAMERA_ERROR_OUT_OF_MEMORY;
6471 if (pc->cb_info->is_server_connected) {
6472 __camera_update_api_waiting(pc->cb_info, api, 1);
6474 g_mutex_lock(&pc->cb_info->fd_lock);
6475 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6476 g_mutex_unlock(&pc->cb_info->fd_lock);
6480 LOGE("message send failed");
6481 ret = CAMERA_ERROR_INVALID_OPERATION;
6483 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6486 __camera_update_api_waiting(pc->cb_info, api, -1);
6488 muse_core_msg_json_factory_free(msg);
6490 LOGD("ret : 0x%x", ret);
6496 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6498 camera_cli_s *pc = (camera_cli_s *)camera;
6499 int ret = CAMERA_ERROR_NONE;
6500 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6502 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6503 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6504 return CAMERA_ERROR_INVALID_PARAMETER;
6509 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6511 if (ret == CAMERA_ERROR_NONE) {
6512 *x = pc->cb_info->get_display_roi_area[0];
6513 *y = pc->cb_info->get_display_roi_area[1];
6514 *width = pc->cb_info->get_display_roi_area[2];
6515 *height = pc->cb_info->get_display_roi_area[3];
6518 LOGD("ret : 0x%x", ret);
6524 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6526 int ret = CAMERA_ERROR_NONE;
6527 int get_device_state = 0;
6530 LOGE("NULL pointer");
6531 return CAMERA_ERROR_INVALID_PARAMETER;
6534 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6535 (int)device, "get_device_state", &get_device_state);
6537 if (ret == CAMERA_ERROR_NONE) {
6538 *state = (camera_device_state_e)get_device_state;
6539 LOGD("device state %d", *state);
6541 LOGE("failed 0x%x", ret);
6548 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6550 int ret = CAMERA_ERROR_NONE;
6551 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6552 camera_cb_info *info = NULL;
6554 if (!callback || !cb_id) {
6555 LOGE("invalid pointer %p %p", callback, cb_id);
6556 return CAMERA_ERROR_INVALID_PARAMETER;
6559 /* check camera support */
6560 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6561 if (ret != CAMERA_ERROR_NONE) {
6562 LOGE("get device state failed");
6566 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6568 info = g_new0(camera_cb_info, 1);
6570 LOGE("info failed");
6571 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6575 info->id = ++g_cam_dev_state_changed_cb_id;
6576 info->callback = (void *)callback;
6577 info->user_data = user_data;
6581 /* subscribe dbus signal for camera state change */
6582 if (!g_cam_dev_state_changed_cb_conn) {
6583 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6584 if (!g_cam_dev_state_changed_cb_conn) {
6585 LOGE("failed to get gdbus connection");
6586 ret = CAMERA_ERROR_INVALID_OPERATION;
6590 LOGD("subscribe signal %s - %s - %s",
6591 MM_CAMCORDER_DBUS_OBJECT,
6592 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6593 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6595 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6596 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6597 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6598 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6599 LOGE("failed to get gdbus connection");
6600 ret = CAMERA_ERROR_INVALID_OPERATION;
6604 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6607 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6609 LOGD("callback id %d", info->id);
6612 if (ret != CAMERA_ERROR_NONE) {
6618 if (g_cam_dev_state_changed_cb_conn) {
6619 g_object_unref(g_cam_dev_state_changed_cb_conn);
6620 g_cam_dev_state_changed_cb_conn = NULL;
6624 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6630 int camera_remove_device_state_changed_cb(int cb_id)
6632 int ret = CAMERA_ERROR_NONE;
6633 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6634 GList *tmp_list = NULL;
6635 camera_cb_info *info = NULL;
6637 /* check camera support */
6638 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6639 if (ret != CAMERA_ERROR_NONE) {
6640 LOGE("get device state failed");
6644 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6646 if (!g_cam_dev_state_changed_cb_list) {
6647 LOGE("there is no callback info");
6648 ret = CAMERA_ERROR_INVALID_OPERATION;
6652 tmp_list = g_cam_dev_state_changed_cb_list;
6655 info = tmp_list->data;
6656 tmp_list = tmp_list->next;
6663 if (info->id == cb_id) {
6664 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6669 if (!g_cam_dev_state_changed_cb_list) {
6670 /* no remained callback */
6671 if (g_cam_dev_state_changed_cb_conn) {
6672 /* unsubscribe signal */
6673 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6674 g_cam_dev_state_changed_cb_subscribe_id = 0;
6676 /* unref connection */
6677 g_object_unref(g_cam_dev_state_changed_cb_conn);
6678 g_cam_dev_state_changed_cb_conn = NULL;
6682 LOGD("id %d callback removed", cb_id);
6683 ret = CAMERA_ERROR_NONE;
6689 LOGE("id %d callback not found", cb_id);
6690 ret = CAMERA_ERROR_INVALID_PARAMETER;
6693 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);