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;
56 static void __global(void *data, struct wl_registry *registry,
57 uint32_t name, const char *interface, uint32_t version)
59 struct tizen_surface **tz_surface = NULL;
66 tz_surface = (struct tizen_surface **)data;
69 LOGW("NULL interface");
73 /*LOGI("interface %s", interface);*/
75 if (strcmp(interface, "tizen_surface") == 0) {
76 LOGD("binding tizen surface for wayland");
78 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
79 if (*tz_surface == NULL)
80 LOGE("failed to bind");
88 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
94 static const struct wl_registry_listener _camera_wl_registry_listener = {
99 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
106 *((unsigned int *)data) = id;
108 LOGD("[CLIENT] got parent_id [%u] from server", id);
113 static const struct tizen_resource_listener _camera_tz_resource_listener = {
117 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
119 int ret = CAMERA_ERROR_NONE;
120 Ecore_Wl_Window *window = NULL;
121 struct wl_display *display = NULL;
122 struct wl_display *display_wrapper = NULL;
123 struct wl_surface *surface = NULL;
124 struct wl_registry *registry = NULL;
125 struct wl_event_queue *queue = NULL;
126 struct tizen_surface *tz_surface = NULL;
127 struct tizen_resource *tz_resource = NULL;
129 if (!obj || !wl_info) {
130 LOGE("NULL parameter %p %p", obj, wl_info);
131 return CAMERA_ERROR_INVALID_OPERATION;
134 window = elm_win_wl_window_get(obj);
136 LOGE("failed to get wayland window");
137 ret = CAMERA_ERROR_INVALID_OPERATION;
141 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
143 LOGE("failed to get wayland surface");
144 ret = CAMERA_ERROR_INVALID_OPERATION;
148 display = (struct wl_display *)ecore_wl_display_get();
150 LOGE("failed to get wayland display");
151 ret = CAMERA_ERROR_INVALID_OPERATION;
155 display_wrapper = wl_proxy_create_wrapper(display);
156 if (!display_wrapper) {
157 LOGE("failed to create wl display wrapper");
158 ret = CAMERA_ERROR_INVALID_OPERATION;
162 queue = wl_display_create_queue(display);
164 LOGE("failed to create wl display queue");
165 ret = CAMERA_ERROR_INVALID_OPERATION;
169 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
171 registry = wl_display_get_registry(display_wrapper);
173 LOGE("failed to get wayland registry");
174 ret = CAMERA_ERROR_INVALID_OPERATION;
178 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
180 wl_display_dispatch_queue(display, queue);
181 wl_display_roundtrip_queue(display, queue);
184 LOGE("failed to get tizen surface");
185 ret = CAMERA_ERROR_INVALID_OPERATION;
189 /* Get parent_id which is unique in a entire systemw. */
190 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
192 LOGE("failed to get tizen resurce");
193 ret = CAMERA_ERROR_INVALID_OPERATION;
197 wl_info->parent_id = 0;
199 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
201 wl_display_roundtrip_queue(display, queue);
203 if (wl_info->parent_id > 0) {
205 Ecore_Evas *ecore_evas = NULL;
206 ret = CAMERA_ERROR_NONE;
208 wl_info->evas_obj = obj;
210 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
211 &wl_info->window_width, &wl_info->window_height);
213 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
215 rotation = ecore_evas_rotation_get(ecore_evas);
216 if (rotation == 90 || rotation == 270) {
217 int temp = wl_info->window_width;
219 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
221 wl_info->window_width = wl_info->window_height;
222 wl_info->window_height = temp;
225 LOGW("failed to get ecore_evas.. skip rotation check");
228 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
229 wl_info->evas_obj, rotation, wl_info->parent_id,
230 wl_info->window_x, wl_info->window_y,
231 wl_info->window_width, wl_info->window_height);
233 ret = CAMERA_ERROR_INVALID_OPERATION;
234 LOGE("failed to get parent id");
239 tizen_surface_destroy(tz_surface);
244 tizen_resource_destroy(tz_resource);
249 wl_registry_destroy(registry);
254 wl_event_queue_destroy(queue);
258 if (display_wrapper) {
259 wl_proxy_wrapper_destroy(display_wrapper);
260 display_wrapper = NULL;
268 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
271 api < 0 || api >= MUSE_CAMERA_API_MAX) {
272 LOGE("invalid param %p %d", cb_info, api);
276 g_mutex_lock(&(cb_info->api_mutex[api]));
277 cb_info->api_waiting[api] += value;
278 g_mutex_unlock(&(cb_info->api_mutex[api]));
280 /*LOGD("api %d, value %d, waiting %d",
281 api, value, cb_info->api_waiting[api]);*/
287 static void __camera_device_state_changed_cb(GDBusConnection *connection,
288 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
289 const gchar *signal_name, GVariant *param, gpointer user_data)
292 camera_device_e device = CAMERA_DEVICE_CAMERA0;
293 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
294 GList *tmp_list = NULL;
295 camera_cb_info *info = NULL;
297 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
299 if (!g_cam_dev_state_changed_cb_list || !param) {
300 LOGW("no callback or NULL param %p", param);
304 /* get device and state */
305 g_variant_get(param, "(i)", &value);
307 device = value >> 16;
308 state = 0x0000ffff & value;
310 LOGD("device %d, state %d", device, state);
312 tmp_list = g_cam_dev_state_changed_cb_list;
315 info = (camera_cb_info *)tmp_list->data;
318 if (info->callback) {
319 LOGD("start id[%d] callback", info->id);
320 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
321 LOGD("returned id[%d] callback", info->id);
323 LOGW("NULL callback for id %d", info->id);
327 tmp_list = tmp_list->next;
331 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
337 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
339 tbm_bo tmp_bo = NULL;
340 tbm_bo_handle tmp_bo_handle = {NULL, };
342 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
343 LOGE("invalid parameter - %p %p %p, key %d",
344 bufmgr, bo, bo_handle, tbm_key);
348 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
349 if (tmp_bo == NULL) {
350 LOGE("import failed - key %d", tbm_key);
354 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
355 if (tmp_bo_handle.ptr == NULL) {
356 LOGE("map failed %p", tmp_bo);
357 tbm_bo_unref(tmp_bo);
362 tbm_bo_unmap(tmp_bo);
364 /* set bo and bo_handle */
366 *bo_handle = tmp_bo_handle;
371 static void _camera_release_imported_bo(tbm_bo *bo)
384 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
386 int ret = CAMERA_ERROR_NONE;
389 /*LOGD("Enter api : %d", api);*/
391 if (!cb_info->is_server_connected) {
392 LOGE("server is disconnected");
393 return CAMERA_ERROR_SERVICE_DISCONNECTED;
396 g_mutex_lock(&(cb_info->api_mutex[api]));
398 if (cb_info->api_activating[api] == 0) {
399 if (time_out == CAMERA_CB_NO_TIMEOUT) {
400 LOGW("wait for api %d", api);
401 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
402 ret = cb_info->api_ret[api];
403 cb_info->api_activating[api] = 0;
404 LOGW("api %d returned 0x%x", api, ret);
406 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
407 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
408 ret = cb_info->api_ret[api];
409 cb_info->api_activating[api] = 0;
410 /*LOGD("return value : 0x%x", ret);*/
412 ret = CAMERA_ERROR_INVALID_OPERATION;
413 LOGE("api %d was TIMED OUT!", api);
417 ret = cb_info->api_ret[api];
418 cb_info->api_activating[api] = 0;
420 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
423 g_mutex_unlock(&(cb_info->api_mutex[api]));
425 if (ret != CAMERA_ERROR_NONE) {
426 LOGE("api %d : error 0x%x", api, ret);
428 if (ret == CAMERA_ERROR_SOUND_POLICY)
429 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
430 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
431 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
432 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
433 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
440 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
441 int *ret, int timeout)
447 LOGE("NULL info - api %d", api);
450 *ret = CAMERA_ERROR_INVALID_PARAMETER;
455 msg = muse_core_msg_json_factory_new(api, NULL);
457 LOGE("msg failed: api %d", api);
460 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
465 /*LOGD("send msg %s", msg);*/
467 if (cb_info->is_server_connected) {
468 __camera_update_api_waiting(cb_info, api, 1);
470 g_mutex_lock(&cb_info->fd_lock);
471 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
472 g_mutex_unlock(&cb_info->fd_lock);
476 LOGE("msg send failed");
478 *ret = CAMERA_ERROR_INVALID_OPERATION;
481 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
484 __camera_update_api_waiting(cb_info, api, -1);
486 muse_core_msg_json_factory_free(msg);
492 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
493 int *ret, camera_msg_param *param, int timeout)
498 if (!cb_info || !param) {
499 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
502 *ret = CAMERA_ERROR_INVALID_PARAMETER;
507 /*LOGD("type %d, name %s", param->type, param->name);*/
509 switch (param->type) {
511 msg = muse_core_msg_json_factory_new(api,
512 param->type, param->name, param->value.value_INT,
515 case MUSE_TYPE_STRING:
516 msg = muse_core_msg_json_factory_new(api,
517 param->type, param->name, param->value.value_STRING,
521 LOGE("unknown type %d", param->type);
526 LOGE("msg failed: api %d", api);
529 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
534 /*LOGD("send msg %s", msg);*/
536 if (cb_info->is_server_connected) {
537 __camera_update_api_waiting(cb_info, api, 1);
539 g_mutex_lock(&cb_info->fd_lock);
540 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
541 g_mutex_unlock(&cb_info->fd_lock);
545 LOGE("msg send failed");
548 *ret = CAMERA_ERROR_INVALID_OPERATION;
551 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
554 __camera_update_api_waiting(cb_info, api, -1);
556 muse_core_msg_json_factory_free(msg);
562 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
564 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
565 in_format >= MM_PIXEL_FORMAT_NUM ||
566 out_format == NULL) {
567 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
568 return CAMERA_ERROR_INVALID_PARAMETER;
572 case MM_PIXEL_FORMAT_NV12:
573 case MM_PIXEL_FORMAT_NV12T:
574 *out_format = TBM_FORMAT_NV12;
577 case MM_PIXEL_FORMAT_NV16:
578 *out_format = TBM_FORMAT_NV16;
580 case MM_PIXEL_FORMAT_NV21:
581 *out_format = TBM_FORMAT_NV21;
583 case MM_PIXEL_FORMAT_YUYV:
584 *out_format = TBM_FORMAT_YUYV;
586 case MM_PIXEL_FORMAT_UYVY:
587 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
588 *out_format = TBM_FORMAT_UYVY;
590 case MM_PIXEL_FORMAT_422P:
591 *out_format = TBM_FORMAT_YUV422;
593 case MM_PIXEL_FORMAT_I420:
594 *out_format = TBM_FORMAT_YUV420;
596 case MM_PIXEL_FORMAT_YV12:
597 *out_format = TBM_FORMAT_YVU420;
599 case MM_PIXEL_FORMAT_RGB565:
600 *out_format = TBM_FORMAT_RGB565;
602 case MM_PIXEL_FORMAT_RGB888:
603 *out_format = TBM_FORMAT_RGB888;
605 case MM_PIXEL_FORMAT_RGBA:
606 *out_format = TBM_FORMAT_RGBA8888;
608 case MM_PIXEL_FORMAT_ARGB:
609 *out_format = TBM_FORMAT_ARGB8888;
612 LOGE("invalid in_format %d", in_format);
613 return CAMERA_ERROR_INVALID_PARAMETER;
617 return CAMERA_ERROR_NONE;
621 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
623 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
624 in_format >= MM_PIXEL_FORMAT_NUM ||
626 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
627 return CAMERA_ERROR_INVALID_PARAMETER;
631 case MM_PIXEL_FORMAT_NV12:
632 case MM_PIXEL_FORMAT_NV12T:
633 *mimetype = MEDIA_FORMAT_NV12;
636 case MM_PIXEL_FORMAT_NV16:
637 *mimetype = MEDIA_FORMAT_NV16;
639 case MM_PIXEL_FORMAT_NV21:
640 *mimetype = MEDIA_FORMAT_NV21;
642 case MM_PIXEL_FORMAT_YUYV:
643 *mimetype = MEDIA_FORMAT_YUYV;
645 case MM_PIXEL_FORMAT_UYVY:
646 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
647 *mimetype = MEDIA_FORMAT_UYVY;
649 case MM_PIXEL_FORMAT_422P:
650 *mimetype = MEDIA_FORMAT_422P;
652 case MM_PIXEL_FORMAT_I420:
653 *mimetype = MEDIA_FORMAT_I420;
655 case MM_PIXEL_FORMAT_YV12:
656 *mimetype = MEDIA_FORMAT_YV12;
658 case MM_PIXEL_FORMAT_RGB565:
659 *mimetype = MEDIA_FORMAT_RGB565;
661 case MM_PIXEL_FORMAT_RGB888:
662 *mimetype = MEDIA_FORMAT_RGB888;
664 case MM_PIXEL_FORMAT_RGBA:
665 *mimetype = MEDIA_FORMAT_RGBA;
667 case MM_PIXEL_FORMAT_ARGB:
668 *mimetype = MEDIA_FORMAT_ARGB;
671 LOGE("invalid in_format %d", in_format);
672 return CAMERA_ERROR_INVALID_PARAMETER;
676 return CAMERA_ERROR_NONE;
679 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
680 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
683 unsigned char *buf_pos = NULL;
685 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
686 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
691 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
692 frame->format = MM_PIXEL_FORMAT_UYVY;
694 frame->format = stream->format;
696 frame->width = stream->width;
697 frame->height = stream->height;
698 frame->timestamp = stream->timestamp;
699 frame->num_of_planes = stream->num_planes;
701 if (num_buffer_key == 0) {
704 if (!data_bo_handle || !data_bo_handle->ptr) {
705 LOGE("NULL pointer");
709 buf_pos = data_bo_handle->ptr;
711 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
712 frame->data.encoded_plane.data = buf_pos;
713 frame->data.encoded_plane.size = stream->data.encoded.length_data;
714 total_size = stream->data.encoded.length_data;
716 switch (stream->num_planes) {
718 frame->data.single_plane.yuv = buf_pos;
719 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
720 total_size = stream->data.yuv420.length_yuv;
723 frame->data.double_plane.y = buf_pos;
724 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
725 buf_pos += stream->data.yuv420sp.length_y;
726 frame->data.double_plane.uv = buf_pos;
727 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
728 total_size = stream->data.yuv420sp.length_y + \
729 stream->data.yuv420sp.length_uv;
732 frame->data.triple_plane.y = buf_pos;
733 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
734 buf_pos += stream->data.yuv420p.length_y;
735 frame->data.triple_plane.u = buf_pos;
736 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
737 buf_pos += stream->data.yuv420p.length_u;
738 frame->data.triple_plane.v = buf_pos;
739 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
740 total_size = stream->data.yuv420p.length_y + \
741 stream->data.yuv420p.length_u + \
742 stream->data.yuv420p.length_v;
751 switch (stream->num_planes) {
754 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
755 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
756 total_size = stream->data.yuv420.length_yuv;
760 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
761 if (stream->num_planes == (unsigned int)num_buffer_key)
762 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
764 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
765 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
766 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
767 total_size = stream->data.yuv420sp.length_y + \
768 stream->data.yuv420sp.length_uv;
772 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
773 if (stream->num_planes == (unsigned int)num_buffer_key) {
774 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
775 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
777 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
778 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
780 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
781 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
782 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
783 total_size = stream->data.yuv420p.length_y + \
784 stream->data.yuv420p.length_u + \
785 stream->data.yuv420p.length_v;
794 LOGD("format %d, %dx%d, size %d plane num %d",
795 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
801 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
802 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
805 int ret = CAMERA_ERROR_NONE;
806 camera_media_packet_data *tmp_mp_data = NULL;
808 if (*mp_data == NULL) {
809 tmp_mp_data = g_new0(camera_media_packet_data, 1);
811 tmp_mp_data->tbm_key = tbm_key;
812 tmp_mp_data->num_buffer_key = num_buffer_key;
813 tmp_mp_data->bo = bo;
814 tmp_mp_data->data_bo = data_bo;
815 tmp_mp_data->ref_cnt++;
817 for (i = 0 ; i < num_buffer_key ; i++)
818 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
820 *mp_data = tmp_mp_data;
821 /*LOGD("mp_data %p", tmp_mp_data);*/
823 ret = CAMERA_ERROR_OUT_OF_MEMORY;
824 LOGE("failed to alloc media packet data");
827 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
833 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
837 camera_msg_param param;
839 if (!mp_data || !cb_info) {
840 LOGE("NULL pointer %p %p", mp_data, cb_info);
844 if (mp_data->ref_cnt > 1) {
846 LOGD("ref count %d", mp_data->ref_cnt);
848 /* release imported bo */
849 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
850 tbm_bo_unref(mp_data->buffer_bo[i]);
851 mp_data->buffer_bo[i] = NULL;
855 _camera_release_imported_bo(&mp_data->bo);
856 _camera_release_imported_bo(&mp_data->data_bo);
859 tbm_key = mp_data->tbm_key;
861 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
863 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
872 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
873 camera_media_packet_data *mp_data, media_packet_h *packet)
875 media_packet_h pkt = NULL;
876 bool make_pkt_fmt = false;
877 tbm_surface_h tsurf = NULL;
878 tbm_surface_info_s tsurf_info;
879 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
880 uint32_t bo_format = 0;
883 int num_buffer_key = 0;
884 tbm_bo *buffer_bo = NULL;
886 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
887 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
888 cb_info, stream, mp_data, packet);
889 return CAMERA_ERROR_INVALID_PARAMETER;
892 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
893 buffer_bo = mp_data->buffer_bo;
894 num_buffer_key = mp_data->num_buffer_key;
896 /* create tbm surface */
897 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
898 tsurf_info.planes[i].stride = stream->stride[i];
900 /* get tbm surface format */
901 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
902 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
904 if (ret == CAMERA_ERROR_NONE) {
905 tsurf_info.width = stream->width;
906 tsurf_info.height = stream->height;
907 tsurf_info.format = bo_format;
908 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
909 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
911 if (num_buffer_key > 0) {
913 case TBM_FORMAT_NV12:
914 case TBM_FORMAT_NV21:
915 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
916 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
917 tsurf_info.planes[0].offset = 0;
918 if (num_buffer_key == 1)
919 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
920 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
923 case TBM_FORMAT_YUV420:
924 case TBM_FORMAT_YVU420:
925 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
926 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
927 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
928 tsurf_info.planes[0].offset = 0;
929 if (num_buffer_key == 1) {
930 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
931 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
933 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
935 case TBM_FORMAT_UYVY:
936 case TBM_FORMAT_YUYV:
937 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
938 tsurf_info.planes[0].offset = 0;
939 tsurf_info.size = tsurf_info.planes[0].size;
946 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
947 } else if (mp_data->data_bo) {
950 case TBM_FORMAT_NV12:
951 case TBM_FORMAT_NV21:
952 tsurf_info.planes[0].size = stream->width * stream->height;
953 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
954 tsurf_info.planes[0].offset = 0;
955 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
956 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
958 case TBM_FORMAT_YUV420:
959 case TBM_FORMAT_YVU420:
960 tsurf_info.planes[0].size = stream->width * stream->height;
961 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
962 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
963 tsurf_info.planes[0].offset = 0;
964 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
965 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
966 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
968 case TBM_FORMAT_UYVY:
969 case TBM_FORMAT_YUYV:
970 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
971 tsurf_info.planes[0].offset = 0;
972 tsurf_info.size = tsurf_info.planes[0].size;
978 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
981 /*LOGD("tbm surface %p", tsurf);*/
985 /* check media packet format */
986 if (cb_info->pkt_fmt) {
987 int pkt_fmt_width = 0;
988 int pkt_fmt_height = 0;
989 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
991 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
992 if (pkt_fmt_mimetype != mimetype ||
993 pkt_fmt_width != stream->width ||
994 pkt_fmt_height != stream->height) {
995 LOGW("change fmt: current 0x%x, %dx%d",
996 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
997 media_format_unref(cb_info->pkt_fmt);
998 cb_info->pkt_fmt = NULL;
1002 make_pkt_fmt = true;
1005 /* create packet format */
1007 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1008 ret = media_format_create(&cb_info->pkt_fmt);
1009 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1010 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1011 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1012 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1013 LOGW("media_format_set : 0x%x", ret);
1015 LOGW("media_format_create failed 0x%x", ret);
1019 /* create media packet */
1020 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1021 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1022 (void *)cb_info, &pkt);
1023 if (ret != MEDIA_PACKET_ERROR_NONE) {
1024 LOGE("media_packet_create failed 0x%x", ret);
1025 tbm_surface_destroy(tsurf);
1029 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1030 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1034 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1035 /* set media packet data */
1036 ret = media_packet_set_extra(pkt, (void *)mp_data);
1037 if (ret != MEDIA_PACKET_ERROR_NONE) {
1038 LOGE("media_packet_set_extra failed");
1040 _camera_media_packet_data_release(mp_data, cb_info);
1043 media_packet_destroy(pkt);
1046 /* set timestamp : msec -> nsec */
1047 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1048 LOGW("media_packet_set_pts failed");
1057 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1060 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1061 camera_media_packet_data *mp_data = NULL;
1062 tbm_surface_h tsurf = NULL;
1064 if (!pkt || !cb_info) {
1065 LOGE("NULL pointer %p %p", pkt, cb_info);
1066 return MEDIA_PACKET_FINALIZE;
1069 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1070 if (ret != MEDIA_PACKET_ERROR_NONE) {
1071 LOGE("media_packet_get_extra failed 0x%x", ret);
1072 return MEDIA_PACKET_FINALIZE;
1075 /*LOGD("mp_data %p", mp_data);*/
1077 g_mutex_lock(&cb_info->mp_data_mutex);
1079 _camera_media_packet_data_release(mp_data, cb_info);
1082 g_mutex_unlock(&cb_info->mp_data_mutex);
1084 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1085 if (ret != MEDIA_PACKET_ERROR_NONE)
1086 LOGE("get tbm_surface failed 0x%x", ret);
1089 tbm_surface_destroy(tsurf);
1093 return MEDIA_PACKET_FINALIZE;
1096 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1102 tbm_bo_handle bo_handle = {NULL, };
1103 camera_msg_param param;
1105 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1106 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1110 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1112 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1113 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1114 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1115 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1116 /* return preview callback */
1117 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1120 muse_camera_msg_get(tbm_key, recv_msg);
1121 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1123 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1124 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1128 } else if (cb_info->user_cb[event] == NULL) {
1129 LOGW("user callback for event %d is not set", event);
1134 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1140 muse_camera_msg_get(previous, recv_msg);
1141 muse_camera_msg_get(current, recv_msg);
1142 muse_camera_msg_get(by_policy, recv_msg);
1144 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1145 previous, current, by_policy);
1147 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1148 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1151 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1155 muse_camera_msg_get(state, recv_msg);
1157 LOGD("FOCUS state - %d", state);
1159 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1162 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1163 LOGD("CAPTURE_COMPLETED");
1164 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1166 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1167 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1171 int num_buffer_key = 0;
1172 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1174 unsigned char *buf_pos = NULL;
1176 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1177 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1178 tbm_bo data_bo = NULL;
1179 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1181 camera_preview_data_s frame;
1182 camera_stream_data_s *stream = NULL;
1183 camera_media_packet_data *mp_data = NULL;
1184 media_packet_h pkt = NULL;
1185 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1186 media_packet_h pkt_evas = NULL;
1187 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1189 muse_camera_msg_get(tbm_key, recv_msg);
1190 muse_camera_msg_get(num_buffer_key, recv_msg);
1191 muse_camera_msg_get_array(buffer_key, recv_msg);
1192 muse_camera_msg_get(data_key, recv_msg);
1194 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1197 LOGE("invalid key %d", tbm_key);
1201 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1203 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1204 LOGE("invalid num buffer key %d", num_buffer_key);
1205 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1210 /* import tbm data_bo and get virtual address */
1211 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1212 LOGE("failed to import data key %d", data_key);
1213 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1218 /* import tbm bo and get virtual address */
1219 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1220 LOGE("failed to import key %d", tbm_key);
1221 _camera_release_imported_bo(&data_bo);
1222 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1226 buf_pos = (unsigned char *)bo_handle.ptr;
1228 /* get stream info */
1229 stream = (camera_stream_data_s *)buf_pos;
1231 for (i = 0 ; i < num_buffer_key ; i++) {
1232 /* import buffer bo and get virtual address */
1233 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1234 LOGE("failed to import buffer key %d", buffer_key[i]);
1236 /* release imported bo */
1237 _camera_release_imported_bo(&data_bo);
1238 _camera_release_imported_bo(&bo);
1240 for (i -= 1 ; i >= 0 ; i--)
1241 _camera_release_imported_bo(&buffer_bo[i]);
1243 /* send return buffer */
1244 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1250 /* call preview callback */
1251 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1252 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1254 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1255 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1258 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1259 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1260 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1262 if (ret == CAMERA_ERROR_NONE) {
1263 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1264 if (ret != CAMERA_ERROR_NONE) {
1265 LOGE("create pkt for evas failed");
1266 _camera_media_packet_data_release(mp_data, cb_info);
1270 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1271 LOGW("evas renderer is not supported");
1272 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1275 /* call media packet callback */
1276 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1277 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1279 if (ret == CAMERA_ERROR_NONE) {
1280 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1282 if (ret == CAMERA_ERROR_NONE) {
1283 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1284 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1286 _camera_media_packet_data_release(mp_data, cb_info);
1292 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1293 /* call evas renderer */
1295 g_mutex_lock(&cb_info->evas_mutex);
1296 if (cb_info->run_evas_render) {
1297 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1299 LOGW("evas renderer is stopped, skip this buffer...");
1300 media_packet_destroy(pkt_evas);
1303 g_mutex_unlock(&cb_info->evas_mutex);
1305 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1307 /* send message for preview callback return */
1308 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1309 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1311 if (mp_data == NULL) {
1312 /* release imported bo */
1313 for (i = 0 ; i < num_buffer_key ; i++)
1314 _camera_release_imported_bo(&buffer_bo[i]);
1316 /* unmap and unref tbm bo */
1317 _camera_release_imported_bo(&data_bo);
1318 _camera_release_imported_bo(&bo);
1321 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1323 /*LOGD("return buffer Done");*/
1328 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1332 muse_camera_msg_get(percent, recv_msg);
1334 LOGD("HDR progress - %d \%", percent);
1336 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1339 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1345 muse_camera_msg_get(policy, recv_msg);
1346 muse_camera_msg_get(previous, recv_msg);
1347 muse_camera_msg_get(current, recv_msg);
1349 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1350 policy, previous, current);
1352 if (policy == CAMERA_POLICY_SOUND)
1353 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1354 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1355 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1356 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1357 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1359 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1360 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1363 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1366 camera_detected_face_s *faces = NULL;
1368 muse_camera_msg_get(count, recv_msg);
1369 muse_camera_msg_get(tbm_key, recv_msg);
1372 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1376 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1378 faces = bo_handle.ptr;
1382 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1385 _camera_release_imported_bo(&bo);
1389 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1390 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1391 /*LOGD("return buffer done");*/
1394 LOGE("invalid message - count %d, key %d", count, tbm_key);
1398 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1401 int current_state = 0;
1403 muse_camera_msg_get(error, recv_msg);
1404 muse_camera_msg_get(current_state, recv_msg);
1406 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1408 if (error == CAMERA_ERROR_SOUND_POLICY)
1409 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1410 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1411 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1412 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1413 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1415 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1416 (camera_state_e)current_state, cb_info->user_data[event]);
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1423 muse_camera_msg_get(param1, recv_msg);
1424 muse_camera_msg_get(param2, recv_msg);
1426 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1428 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1429 cb_info->user_cb[event] = NULL;
1430 cb_info->user_data[event] = NULL;
1431 LOGW("stop foreach callback for event %d", event);
1434 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1436 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1438 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1442 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1448 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1450 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1452 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1454 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1456 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1458 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1461 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1463 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1464 muse_camera_msg_get(param1, recv_msg);
1466 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1468 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1469 cb_info->user_cb[event] = NULL;
1470 cb_info->user_data[event] = NULL;
1471 LOGW("stop foreach callback for event %d", event);
1475 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1477 camera_image_data_s *rImage = NULL;
1478 camera_image_data_s *rPostview = NULL;
1479 camera_image_data_s *rThumbnail = NULL;
1480 unsigned char *buf_pos = NULL;
1481 int tbm_key_main = 0;
1482 int tbm_key_post = 0;
1483 int tbm_key_thumb = 0;
1484 tbm_bo bo_main = NULL;
1485 tbm_bo bo_post = NULL;
1486 tbm_bo bo_thumb = NULL;
1487 tbm_bo_handle bo_main_handle = {NULL, };
1488 tbm_bo_handle bo_post_handle = {NULL, };
1489 tbm_bo_handle bo_thumb_handle = {NULL, };
1491 muse_camera_msg_get(tbm_key_main, recv_msg);
1492 muse_camera_msg_get(tbm_key_post, recv_msg);
1493 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1496 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1497 tbm_key_main, tbm_key_post, tbm_key_thumb);
1500 if (tbm_key_main <= 0) {
1501 LOGE("invalid key %d", tbm_key_main);
1505 /* import tbm bo and get virtual address */
1506 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1509 buf_pos = (unsigned char *)bo_main_handle.ptr;
1510 rImage = (camera_image_data_s *)buf_pos;
1511 rImage->data = buf_pos + sizeof(camera_image_data_s);
1512 if (rImage->exif && rImage->exif_size > 0) {
1513 rImage->exif = rImage->data + rImage->size;
1515 rImage->exif = NULL;
1516 rImage->exif_size = 0;
1519 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1520 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1522 if (tbm_key_post > 0) {
1523 /* import tbm bo and get virtual address */
1524 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1527 buf_pos = (unsigned char *)bo_post_handle.ptr;
1528 rPostview = (camera_image_data_s *)buf_pos;
1529 LOGD("rPostview->size : %d", rPostview->size);
1530 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1533 if (tbm_key_thumb > 0) {
1534 /* import tbm bo and get virtual address */
1535 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1538 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1540 rThumbnail = (camera_image_data_s *)buf_pos;
1541 LOGD("rThumbnail->size : %d", rThumbnail->size);
1542 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1545 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1547 /* unmap and unref tbm bo */
1548 _camera_release_imported_bo(&bo_main);
1551 tbm_key = tbm_key_main;
1553 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1555 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1557 if (tbm_key_post > 0) {
1558 /* unmap and unref tbm bo */
1559 _camera_release_imported_bo(&bo_post);
1562 param.value.value_INT = tbm_key_post;
1563 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1566 if (tbm_key_thumb > 0) {
1567 /* unmap and unref tbm bo */
1568 _camera_release_imported_bo(&bo_thumb);
1571 param.value.value_INT = tbm_key_thumb;
1572 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1575 LOGD("return buffer done");
1578 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1579 LOGE("render error");
1586 static bool _camera_idle_event_callback(void *data)
1588 camera_cb_info_s *cb_info = NULL;
1589 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1591 if (cam_idle_event == NULL) {
1592 LOGE("cam_idle_event is NULL");
1597 g_mutex_lock(&cam_idle_event->event_mutex);
1599 cb_info = cam_idle_event->cb_info;
1600 if (cb_info == NULL) {
1601 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1602 goto IDLE_EVENT_CALLBACK_DONE;
1605 /* remove event from list */
1606 g_mutex_lock(&cb_info->idle_event_mutex);
1608 if (cb_info->idle_event_list)
1609 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1611 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1612 g_mutex_unlock(&cb_info->idle_event_mutex);
1615 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1617 /* send signal for waiting thread */
1618 g_cond_signal(&cb_info->idle_event_cond);
1620 IDLE_EVENT_CALLBACK_DONE:
1621 /* unlock and release event */
1622 g_mutex_unlock(&cam_idle_event->event_mutex);
1623 g_mutex_clear(&cam_idle_event->event_mutex);
1625 g_free(cam_idle_event);
1626 cam_idle_event = NULL;
1631 static void *_camera_msg_handler_func(gpointer data)
1635 camera_message_s *cam_msg = NULL;
1636 camera_idle_event_s *cam_idle_event = NULL;
1637 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1638 camera_cb_info_s *cb_info = NULL;
1640 if (!handler_info || !handler_info->cb_info) {
1641 LOGE("NULL handler %p", handler_info);
1645 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1646 type = handler_info->type;
1648 LOGD("t:%d start", type);
1650 g_mutex_lock(&handler_info->mutex);
1652 while (g_atomic_int_get(&handler_info->running)) {
1653 if (g_queue_is_empty(handler_info->queue)) {
1654 /*LOGD("t:%d signal wait...", type);*/
1655 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1656 /*LOGD("t:%d signal received", type);*/
1658 if (g_atomic_int_get(&handler_info->running) == 0) {
1659 LOGD("t:%d stop event thread", type);
1664 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1666 g_mutex_unlock(&handler_info->mutex);
1668 if (cam_msg == NULL) {
1669 LOGE("t:%d NULL message", type);
1670 g_mutex_lock(&handler_info->mutex);
1676 if (api < MUSE_CAMERA_API_MAX) {
1679 g_mutex_lock(&cb_info->api_mutex[api]);
1681 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1682 if (cb_info->api_waiting[api] > 0) {
1683 cb_info->api_ret[api] = ret;
1684 cb_info->api_activating[api] = 1;
1686 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1688 g_cond_signal(&cb_info->api_cond[api]);
1690 LOGW("no waiting for this api [%d]", api);
1693 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1696 g_mutex_unlock(&cb_info->api_mutex[api]);
1697 } else if (api == MUSE_CAMERA_CB_EVENT) {
1698 switch (cam_msg->event_class) {
1699 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1700 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1702 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1703 cam_idle_event = g_new0(camera_idle_event_s, 1);
1704 if (cam_idle_event == NULL) {
1705 LOGE("t:%d cam_idle_event alloc failed", type);
1709 cam_idle_event->event = cam_msg->event;
1710 cam_idle_event->cb_info = cb_info;
1711 g_mutex_init(&cam_idle_event->event_mutex);
1712 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1714 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1716 g_mutex_lock(&cb_info->idle_event_mutex);
1717 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1718 g_mutex_unlock(&cb_info->idle_event_mutex);
1720 g_idle_add_full(G_PRIORITY_DEFAULT,
1721 (GSourceFunc)_camera_idle_event_callback,
1722 (gpointer)cam_idle_event,
1726 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1730 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1736 g_mutex_lock(&handler_info->mutex);
1739 /* remove remained event */
1740 while (!g_queue_is_empty(handler_info->queue)) {
1741 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1743 LOGD("t:%d remove camera message %p", type, cam_msg);
1747 LOGW("t:%d NULL camera message", type);
1751 g_mutex_unlock(&handler_info->mutex);
1753 LOGD("t:%d return", type);
1759 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1761 camera_idle_event_s *cam_idle_event = NULL;
1763 gint64 end_time = 0;
1765 if (cb_info == NULL) {
1766 LOGE("cb_info is NULL");
1770 g_mutex_lock(&cb_info->idle_event_mutex);
1772 if (cb_info->idle_event_list == NULL) {
1773 LOGD("No remained idle event");
1774 g_mutex_unlock(&cb_info->idle_event_mutex);
1778 list = cb_info->idle_event_list;
1781 cam_idle_event = list->data;
1782 list = g_list_next(list);
1784 if (!cam_idle_event) {
1785 LOGW("Fail to remove idle event. The event is NULL");
1789 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1790 LOGW("lock failed, %p event is calling now", cam_idle_event);
1792 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1794 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1795 LOGW("signal received");
1802 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1803 cam_idle_event, cam_idle_event->event);
1805 cam_idle_event->cb_info = NULL;
1807 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1809 g_mutex_unlock(&cam_idle_event->event_mutex);
1812 g_list_free(cb_info->idle_event_list);
1813 cb_info->idle_event_list = NULL;
1815 g_mutex_unlock(&cb_info->idle_event_mutex);
1821 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1823 camera_message_s *cam_msg = NULL;
1825 if (!cb_info || !msg) {
1826 LOGE("NULL pointer %p %p", cb_info, msg);
1830 cam_msg = g_new0(camera_message_s, 1);
1832 LOGE("failed to alloc cam_msg for [%s]", msg);
1837 cam_msg->event = event;
1838 cam_msg->event_class = event_class;
1840 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1842 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1844 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1845 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1846 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1847 g_cond_signal(&cb_info->preview_cb_info.cond);
1848 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1849 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1850 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1851 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1852 g_cond_signal(&cb_info->capture_cb_info.cond);
1853 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1855 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1856 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1857 g_cond_signal(&cb_info->msg_handler_info.cond);
1858 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1867 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1869 int ret = CAMERA_ERROR_NONE;
1873 int event_class = -1;
1877 if (!cb_info || !msg) {
1878 LOGE("invalid ptr %p %p", cb_info, msg);
1882 /*LOGD("msg [%s]", msg);*/
1884 if (!muse_camera_msg_get(api, msg)) {
1885 LOGE("failed to get camera api");
1889 if (api == MUSE_CAMERA_CB_EVENT) {
1890 if (!muse_camera_msg_get(event, msg) ||
1891 !muse_camera_msg_get(event_class, msg)) {
1892 LOGE("failed to get camera event or event_class [%s]", msg);
1896 if (!muse_camera_msg_get(api_class, msg)) {
1897 LOGE("failed to get camera api_class [%s]", msg);
1902 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1903 if (api >= MUSE_CAMERA_API_MAX) {
1904 LOGE("invalid api %d", api);
1908 if (!muse_camera_msg_get(ret, msg)) {
1909 LOGE("failed to get camera ret");
1913 g_mutex_lock(&cb_info->api_mutex[api]);
1916 case MUSE_CAMERA_API_CREATE:
1917 if (ret != CAMERA_ERROR_NONE) {
1918 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1919 LOGE("camera create error 0x%x. close client cb handler", ret);
1922 case MUSE_CAMERA_API_DESTROY:
1923 if (ret == CAMERA_ERROR_NONE) {
1924 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1925 LOGD("camera destroy done. close client cb handler");
1929 muse_camera_msg_get(get_type, msg);
1930 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1931 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1932 muse_camera_msg_get(get_index, msg);
1935 case MUSE_CAMERA_GET_TYPE_INT:
1936 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1938 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1939 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1940 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1942 case MUSE_CAMERA_GET_TYPE_ARRAY:
1943 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1944 muse_core_msg_json_deserialize("get_value",
1945 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1946 LOGD("get display roi %d,%d,%dx%d",
1947 cb_info->get_display_roi_area[0],
1948 cb_info->get_display_roi_area[1],
1949 cb_info->get_display_roi_area[2],
1950 cb_info->get_display_roi_area[3]);
1952 muse_core_msg_json_deserialize("get_value",
1953 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1954 LOGD("get geotag %lf, %lf, %lf",
1955 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1958 case MUSE_CAMERA_GET_TYPE_STRING:
1959 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1962 LOGW("unknown type %d", get_type);
1969 if (cb_info->api_waiting[api] > 0) {
1970 cb_info->api_ret[api] = ret;
1971 cb_info->api_activating[api] = 1;
1973 g_cond_signal(&cb_info->api_cond[api]);
1975 LOGW("no waiting for this api [%d]", api);
1978 g_mutex_unlock(&cb_info->api_mutex[api]);
1979 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1980 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1982 LOGW("unknown camera api %d, class %d", api, api_class);
1989 static void *_camera_msg_recv_func(gpointer data)
1991 int recv_length = 0;
1992 int single_length = 0;
1993 int remained_length = 0;
1994 char *recv_msg = NULL;
1995 char *single_msg = NULL;
1996 char *remained_msg = NULL;
2000 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2003 LOGE("cb_info NULL");
2009 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2011 LOGE("single_msg malloc failed");
2015 recv_msg = cb_info->recv_msg;
2017 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2018 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
2019 if (recv_length <= 0) {
2020 cb_info->is_server_connected = FALSE;
2021 LOGE("receive msg failed - server disconnected");
2029 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2031 /* Need to split the combined entering msgs */
2032 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2033 if (recv_msg[cur_pos] == '}') {
2034 single_length = cur_pos - prev_pos + 1;
2036 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2037 /* check remained msg */
2038 if (remained_length > 0) {
2040 strncpy(single_msg, remained_msg, remained_length);
2041 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2042 single_msg[remained_length + single_length] = '\0';
2045 remained_msg = NULL;
2047 strncpy(single_msg, recv_msg + prev_pos, single_length);
2048 single_msg[single_length] = '\0';
2049 LOGE("lost msg [%s], skip...", single_msg);
2052 remained_length = 0;
2054 strncpy(single_msg, recv_msg + prev_pos, single_length);
2055 single_msg[single_length] = '\0';
2058 if (single_msg[0] == '{') {
2060 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2061 /* process each message */
2062 __camera_process_msg(cb_info, single_msg);
2064 LOGE("invalid msg [%s]", single_msg);
2067 LOGE("too long message [len %d] skip...", single_length);
2070 prev_pos = cur_pos + 1;
2074 /* check incompleted message */
2075 if (recv_msg[recv_length - 1] != '}') {
2076 remained_length = recv_length - prev_pos;
2078 LOGW("incompleted message [len %d]", remained_length);
2080 remained_msg = (char *)malloc(remained_length + 1);
2082 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2083 remained_msg[remained_length] = '\0';
2085 LOGE("failed to alloc for remained msg");
2088 remained_length = 0;
2092 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2094 if (!cb_info->is_server_connected) {
2095 /* send error msg for server disconnection */
2096 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2097 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2098 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2102 LOGE("error_msg failed");
2103 goto CB_HANDLER_EXIT;
2106 __camera_add_msg_to_queue(cb_info,
2107 MUSE_CAMERA_CB_EVENT,
2108 MUSE_CAMERA_EVENT_TYPE_ERROR,
2109 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2112 muse_core_msg_json_factory_free(error_msg);
2115 LOGE("add error msg for service disconnection done");
2126 remained_msg = NULL;
2133 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2134 int type, const char *thread_name, camera_cb_info_s *cb_info)
2136 if (!handler_info || !thread_name || !cb_info) {
2137 LOGE("t:%d NULL %p %p %p",
2138 type, handler_info, thread_name, cb_info);
2144 handler_info->type = type;
2145 handler_info->queue = g_queue_new();
2146 if (handler_info->queue == NULL) {
2147 LOGE("t:%d queue failed", type);
2151 g_mutex_init(&handler_info->mutex);
2152 g_cond_init(&handler_info->cond);
2154 handler_info->cb_info = (void *)cb_info;
2155 g_atomic_int_set(&handler_info->running, 1);
2157 handler_info->thread = g_thread_try_new(thread_name,
2158 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2159 if (handler_info->thread == NULL) {
2160 LOGE("t:%d thread failed", type);
2162 g_mutex_clear(&handler_info->mutex);
2163 g_cond_clear(&handler_info->cond);
2164 g_queue_free(handler_info->queue);
2165 handler_info->queue = NULL;
2170 LOGD("t:%d done", type);
2176 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2180 if (!handler_info) {
2181 LOGE("NULL handler");
2185 if (!handler_info->thread) {
2186 LOGW("thread is not created");
2190 type = handler_info->type;
2192 LOGD("t:%d thread %p", type, handler_info->thread);
2194 g_mutex_lock(&handler_info->mutex);
2195 g_atomic_int_set(&handler_info->running, 0);
2196 g_cond_signal(&handler_info->cond);
2197 g_mutex_unlock(&handler_info->mutex);
2199 g_thread_join(handler_info->thread);
2200 handler_info->thread = NULL;
2202 g_mutex_clear(&handler_info->mutex);
2203 g_cond_clear(&handler_info->cond);
2204 g_queue_free(handler_info->queue);
2205 handler_info->queue = NULL;
2207 LOGD("t:%d done", type);
2213 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2215 camera_cb_info_s *cb_info = NULL;
2218 g_return_val_if_fail(sockfd > 0, NULL);
2220 cb_info = g_new0(camera_cb_info_s, 1);
2221 if (cb_info == NULL) {
2222 LOGE("cb_info failed");
2226 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2228 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2229 g_mutex_init(&cb_info->api_mutex[i]);
2230 g_cond_init(&cb_info->api_cond[i]);
2233 g_mutex_init(&cb_info->fd_lock);
2234 g_mutex_init(&cb_info->idle_event_mutex);
2235 g_cond_init(&cb_info->idle_event_cond);
2236 g_mutex_init(&cb_info->mp_data_mutex);
2237 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2238 g_mutex_init(&cb_info->evas_mutex);
2239 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2241 /* message handler thread */
2242 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2243 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2244 LOGE("msg_handler_info failed");
2248 /* message handler thread for preview callback */
2249 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2250 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2251 LOGE("preview_cb_info failed");
2255 /* message handler thread for capture callback */
2256 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2257 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2258 LOGE("capture_cb_info failed");
2262 cb_info->fd = sockfd;
2263 cb_info->preview_cb_flag = 0;
2264 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2265 cb_info->evas_info = NULL;
2266 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2268 /* message receive thread */
2269 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2270 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2271 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2272 if (cb_info->msg_recv_thread == NULL) {
2273 LOGE("message receive thread creation failed");
2277 cb_info->is_server_connected = TRUE;
2283 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2284 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2285 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2287 g_mutex_clear(&cb_info->fd_lock);
2288 g_mutex_clear(&cb_info->idle_event_mutex);
2289 g_cond_clear(&cb_info->idle_event_cond);
2290 g_mutex_clear(&cb_info->mp_data_mutex);
2291 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2292 g_mutex_clear(&cb_info->evas_mutex);
2293 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2295 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2296 g_mutex_clear(&cb_info->api_mutex[i]);
2297 g_cond_clear(&cb_info->api_cond[i]);
2308 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2312 g_return_if_fail(cb_info != NULL);
2314 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2316 g_thread_join(cb_info->msg_recv_thread);
2317 cb_info->msg_recv_thread = NULL;
2319 LOGD("msg_recv thread removed");
2321 /* destroy msg handler threads */
2322 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2323 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2324 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2326 g_mutex_clear(&cb_info->fd_lock);
2327 g_mutex_clear(&cb_info->idle_event_mutex);
2328 g_cond_clear(&cb_info->idle_event_cond);
2329 g_mutex_clear(&cb_info->mp_data_mutex);
2330 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2331 g_mutex_clear(&cb_info->evas_mutex);
2332 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2334 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2335 g_mutex_clear(&cb_info->api_mutex[i]);
2336 g_cond_clear(&cb_info->api_cond[i]);
2339 if (cb_info->fd > -1) {
2340 muse_core_connection_close(cb_info->fd);
2344 if (cb_info->bufmgr) {
2345 tbm_bufmgr_deinit(cb_info->bufmgr);
2346 cb_info->bufmgr = NULL;
2348 if (cb_info->pkt_fmt) {
2349 media_format_unref(cb_info->pkt_fmt);
2350 cb_info->pkt_fmt = NULL;
2353 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2354 if (cb_info->evas_info)
2355 mm_evas_renderer_destroy(&cb_info->evas_info);
2356 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2358 cb_info->preview_cb_flag = 0;
2367 int _camera_start_evas_rendering(camera_h camera)
2369 int ret = CAMERA_ERROR_NONE;
2370 camera_cli_s *pc = (camera_cli_s *)camera;
2372 if (!pc || !pc->cb_info) {
2373 LOGE("NULL handle");
2374 return CAMERA_ERROR_INVALID_PARAMETER;
2379 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2380 LOGE("EVAS surface is not set");
2381 return CAMERA_ERROR_NONE;
2384 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2385 g_mutex_lock(&pc->cb_info->evas_mutex);
2387 /* set evas render flag as RUN */
2388 pc->cb_info->run_evas_render = true;
2389 ret = CAMERA_ERROR_NONE;
2391 g_mutex_unlock(&pc->cb_info->evas_mutex);
2392 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2393 LOGW("evas renderer is not supported");
2394 ret = CAMERA_ERROR_NOT_SUPPORTED;
2395 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2401 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2403 int ret = CAMERA_ERROR_NONE;
2404 camera_cli_s *pc = (camera_cli_s *)camera;
2406 if (!pc || !pc->cb_info) {
2407 LOGE("NULL handle");
2408 return CAMERA_ERROR_INVALID_PARAMETER;
2411 LOGD("stop - keep screen %d", keep_screen);
2413 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2414 LOGE("EVAS surface is not set");
2415 return CAMERA_ERROR_NONE;
2418 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2419 g_mutex_lock(&pc->cb_info->evas_mutex);
2421 /* set evas render flag as STOP and release buffers */
2422 pc->cb_info->run_evas_render = false;
2424 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2425 if (ret != MM_ERROR_NONE) {
2426 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2427 ret = CAMERA_ERROR_INVALID_OPERATION;
2430 g_mutex_unlock(&pc->cb_info->evas_mutex);
2431 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2432 LOGW("evas renderer is not supported");
2433 ret = CAMERA_ERROR_NOT_SUPPORTED;
2434 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2440 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2442 int ret = CAMERA_ERROR_NONE;
2445 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2447 /* create muse connection */
2448 if (!key || !value) {
2449 LOGE("NULL pointer");
2450 return CAMERA_ERROR_INVALID_PARAMETER;
2453 sock_fd = muse_core_client_new();
2455 LOGE("muse_core_client_new failed");
2456 return CAMERA_ERROR_INVALID_OPERATION;
2459 msg = muse_core_msg_json_factory_new(api,
2460 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2461 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2465 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2469 ret = muse_core_ipc_send_msg(sock_fd, msg);
2471 muse_core_msg_json_factory_free(msg);
2475 LOGE("send msg failed");
2476 ret = CAMERA_ERROR_INVALID_OPERATION;
2480 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2482 LOGE("recv msg failed %d", errno);
2483 ret = CAMERA_ERROR_INVALID_OPERATION;
2487 if (!muse_camera_msg_get(ret, recv_msg)) {
2488 LOGE("failed to get return value from msg [%s]", recv_msg);
2489 ret = CAMERA_ERROR_INVALID_OPERATION;
2493 if (ret == CAMERA_ERROR_NONE)
2494 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2496 LOGD("api %d - value %d", api, *value);
2500 muse_core_connection_close(sock_fd);
2508 int camera_create(camera_device_e device, camera_h *camera)
2511 char *send_msg = NULL;
2513 int ret = CAMERA_ERROR_NONE;
2515 camera_cli_s *pc = NULL;
2516 tbm_bufmgr bufmgr = NULL;
2518 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2519 muse_core_api_module_e muse_module = MUSE_CAMERA;
2520 int device_type = (int)device;
2523 LOGE("NULL pointer");
2524 return CAMERA_ERROR_INVALID_PARAMETER;
2527 sock_fd = muse_core_client_new();
2529 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2530 ret = CAMERA_ERROR_INVALID_OPERATION;
2536 send_msg = muse_core_msg_json_factory_new(api,
2537 MUSE_TYPE_INT, "module", muse_module,
2538 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2539 MUSE_TYPE_INT, "pid", pid,
2544 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2548 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2550 muse_core_msg_json_factory_free(send_msg);
2554 LOGE("send msg failed %d", errno);
2555 ret = CAMERA_ERROR_INVALID_OPERATION;
2559 pc = g_new0(camera_cli_s, 1);
2561 LOGE("camera_cli_s alloc failed");
2562 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2566 bufmgr = tbm_bufmgr_init(-1);
2567 if (bufmgr == NULL) {
2568 LOGE("get tbm bufmgr failed");
2569 ret = CAMERA_ERROR_INVALID_OPERATION;
2573 pc->cb_info = _camera_client_callback_new(sock_fd);
2574 if (pc->cb_info == NULL) {
2575 LOGE("cb_info alloc failed");
2576 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2582 LOGD("cb info : %d", pc->cb_info->fd);
2584 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_NO_TIMEOUT);
2586 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2588 if (ret == CAMERA_ERROR_NONE) {
2589 intptr_t handle = 0;
2590 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2592 LOGE("Receiving Handle Failed!!");
2593 ret = CAMERA_ERROR_INVALID_OPERATION;
2597 pc->remote_handle = handle;
2598 pc->cb_info->bufmgr = bufmgr;
2600 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2601 if (ret != CAMERA_ERROR_NONE) {
2602 LOGE("init display failed 0x%x", ret);
2606 LOGD("camera create 0x%x", pc->remote_handle);
2607 *camera = (camera_h)pc;
2616 tbm_bufmgr_deinit(bufmgr);
2621 muse_core_connection_close(sock_fd);
2627 _camera_client_callback_destroy(pc->cb_info);
2634 LOGE("camera create error : 0x%x", ret);
2641 int camera_change_device(camera_h camera, camera_device_e device)
2644 int ret = CAMERA_ERROR_NONE;
2645 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2646 camera_cli_s *pc = (camera_cli_s *)camera;
2647 camera_msg_param param;
2649 if (!pc || !pc->cb_info) {
2650 LOGE("NULL handle");
2651 return CAMERA_ERROR_INVALID_PARAMETER;
2654 CAMERA_MSG_PARAM_SET(param, INT, device);
2656 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2658 if (ret == CAMERA_ERROR_NONE) {
2659 /* reset callback and user data */
2660 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2661 pc->cb_info->user_cb[i] = NULL;
2662 pc->cb_info->user_data[i] = NULL;
2664 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2671 int camera_destroy(camera_h camera)
2673 int ret = CAMERA_ERROR_NONE;
2674 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
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 if (pc->cb_info->is_server_connected)
2685 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2687 LOGW("server disconnected. release resource without send message.");
2689 if (ret == CAMERA_ERROR_NONE) {
2690 _camera_deactivate_idle_event_all(pc->cb_info);
2691 _camera_client_callback_destroy(pc->cb_info);
2701 int camera_start_preview(camera_h camera)
2703 int ret = CAMERA_ERROR_NONE;
2704 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2705 camera_cli_s *pc = (camera_cli_s *)camera;
2707 if (!pc || !pc->cb_info) {
2708 LOGE("NULL handle");
2709 return CAMERA_ERROR_INVALID_PARAMETER;
2714 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2715 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2716 ret = _camera_start_evas_rendering(camera);
2717 if (ret != CAMERA_ERROR_NONE) {
2718 LOGE("stop preview because of error");
2719 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2723 LOGD("ret : 0x%x", ret);
2729 int camera_stop_preview(camera_h camera)
2731 int ret = CAMERA_ERROR_NONE;
2732 camera_cli_s *pc = (camera_cli_s *)camera;
2733 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2734 camera_state_e current_state = CAMERA_STATE_NONE;
2736 if (!pc || !pc->cb_info) {
2737 LOGE("NULL handle");
2738 return CAMERA_ERROR_INVALID_PARAMETER;
2744 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2745 ret = camera_get_state(camera, ¤t_state);
2746 if (ret != CAMERA_ERROR_NONE) {
2747 LOGE("failed to get current state 0x%x", ret);
2751 if (current_state == CAMERA_STATE_PREVIEW) {
2752 ret = _camera_stop_evas_rendering(camera, false);
2753 if (ret != CAMERA_ERROR_NONE)
2758 /* send stop preview message */
2759 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2761 if (ret != CAMERA_ERROR_NONE &&
2762 current_state == CAMERA_STATE_PREVIEW) {
2763 LOGW("restart evas rendering");
2764 _camera_start_evas_rendering(camera);
2767 LOGD("ret : 0x%x", ret);
2773 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2775 int ret = CAMERA_ERROR_NONE;
2776 camera_cli_s *pc = (camera_cli_s *)camera;
2777 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2779 if (!pc || !pc->cb_info) {
2780 LOGE("NULL handle");
2781 return CAMERA_ERROR_INVALID_PARAMETER;
2786 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2787 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2789 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2790 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2792 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2794 LOGD("ret : 0x%x", ret);
2800 bool camera_is_supported_continuous_capture(camera_h camera)
2802 int ret = CAMERA_ERROR_NONE;
2803 camera_cli_s *pc = (camera_cli_s *)camera;
2804 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2806 if (!pc || !pc->cb_info) {
2807 LOGE("NULL handle");
2808 return CAMERA_ERROR_INVALID_PARAMETER;
2813 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2816 LOGE("error is occurred 0x%x", ret);
2820 LOGD("ret : %d", ret);
2826 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)
2828 int ret = CAMERA_ERROR_NONE;
2829 camera_cli_s *pc = (camera_cli_s *)camera;
2830 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2831 camera_msg_param param;
2834 if (!pc || !pc->cb_info) {
2835 LOGE("NULL handle");
2836 return CAMERA_ERROR_INVALID_PARAMETER;
2841 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2842 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2844 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2847 value = (count << 16) | interval;
2848 CAMERA_MSG_PARAM_SET(param, INT, value);
2850 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2852 LOGD("ret : 0x%x", ret);
2858 int camera_stop_continuous_capture(camera_h camera)
2860 int ret = CAMERA_ERROR_NONE;
2861 camera_cli_s *pc = (camera_cli_s *)camera;
2862 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2864 if (!pc || !pc->cb_info) {
2865 LOGE("NULL handle");
2866 return CAMERA_ERROR_INVALID_PARAMETER;
2871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2873 LOGD("ret : 0x%x", ret);
2879 bool camera_is_supported_face_detection(camera_h camera)
2881 int ret = CAMERA_ERROR_NONE;
2882 camera_cli_s *pc = (camera_cli_s *)camera;
2883 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2885 if (!pc || !pc->cb_info) {
2886 LOGE("NULL handle");
2887 return CAMERA_ERROR_INVALID_PARAMETER;
2892 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2895 LOGE("error is occurred 0x%x", ret);
2899 LOGD("ret : %d", ret);
2905 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2907 int ret = CAMERA_ERROR_NONE;
2908 camera_cli_s *pc = (camera_cli_s *)camera;
2909 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2911 if (!pc || !pc->cb_info) {
2912 LOGE("NULL handle");
2913 return CAMERA_ERROR_INVALID_PARAMETER;
2918 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2921 LOGE("error is occurred 0x%x", ret);
2925 LOGD("ret : %d", ret);
2931 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2933 int ret = CAMERA_ERROR_NONE;
2934 camera_cli_s *pc = (camera_cli_s *)camera;
2935 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2937 if (!pc || !pc->cb_info) {
2938 LOGE("NULL handle");
2939 return CAMERA_ERROR_INVALID_PARAMETER;
2944 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2947 LOGE("error is occurred 0x%x", ret);
2951 LOGD("ret : %d", ret);
2956 int camera_get_device_count(camera_h camera, int *device_count)
2958 int ret = CAMERA_ERROR_NONE;
2959 camera_cli_s *pc = (camera_cli_s *)camera;
2960 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2962 if (!pc || !pc->cb_info) {
2963 LOGE("NULL handle");
2964 return CAMERA_ERROR_INVALID_PARAMETER;
2969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2971 if (ret == CAMERA_ERROR_NONE)
2972 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2974 LOGD("ret : 0x%x", ret);
2979 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2981 int ret = CAMERA_ERROR_NONE;
2982 camera_cli_s *pc = (camera_cli_s *)camera;
2983 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2985 if (!pc || !pc->cb_info) {
2986 LOGE("NULL handle");
2987 return CAMERA_ERROR_INVALID_PARAMETER;
2992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2995 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2997 LOGD("ret : 0x%x", ret);
3002 int camera_stop_face_detection(camera_h camera)
3004 int ret = CAMERA_ERROR_NONE;
3005 camera_cli_s *pc = (camera_cli_s *)camera;
3006 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3008 if (!pc || !pc->cb_info) {
3009 LOGE("NULL handle");
3010 return CAMERA_ERROR_INVALID_PARAMETER;
3015 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3017 LOGD("ret : 0x%x", ret);
3022 int camera_get_state(camera_h camera, camera_state_e *state)
3024 int ret = CAMERA_ERROR_NONE;
3025 camera_cli_s *pc = (camera_cli_s *)camera;
3026 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3028 if (!pc || !pc->cb_info || !state) {
3029 LOGE("NULL pointer %p %p", pc, state);
3030 return CAMERA_ERROR_INVALID_PARAMETER;
3035 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3037 if (ret == CAMERA_ERROR_NONE)
3038 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3040 LOGD("ret : 0x%x", ret);
3045 int camera_start_focusing(camera_h camera, bool continuous)
3047 int ret = CAMERA_ERROR_NONE;
3048 camera_cli_s *pc = (camera_cli_s *)camera;
3049 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3050 camera_msg_param param;
3051 int is_continuous = (int)continuous;
3053 if (!pc || !pc->cb_info) {
3054 LOGE("NULL handle");
3055 return CAMERA_ERROR_INVALID_PARAMETER;
3060 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3064 LOGD("ret : 0x%x", ret);
3069 int camera_cancel_focusing(camera_h camera)
3071 int ret = CAMERA_ERROR_NONE;
3072 camera_cli_s *pc = (camera_cli_s *)camera;
3073 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3075 if (!pc || !pc->cb_info) {
3076 LOGE("NULL handle");
3077 return CAMERA_ERROR_INVALID_PARAMETER;
3080 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3082 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3084 LOGD("ret : 0x%x", ret);
3089 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3091 int ret = CAMERA_ERROR_NONE;
3092 void *set_display_handle = NULL;
3093 Evas_Object *obj = NULL;
3094 const char *object_type = NULL;
3095 camera_cli_s *pc = (camera_cli_s *)camera;
3096 camera_cb_info_s *cb_info = NULL;
3097 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3098 camera_state_e current_state = CAMERA_STATE_NONE;
3099 camera_msg_param param;
3103 if (!pc || !pc->cb_info) {
3104 LOGE("NULL handle");
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3108 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3109 LOGE("invalid type %d", type);
3110 return CAMERA_ERROR_INVALID_PARAMETER;
3113 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3114 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3115 return CAMERA_ERROR_INVALID_PARAMETER;
3118 cb_info = (camera_cb_info_s *)pc->cb_info;
3120 ret = camera_get_state(camera, ¤t_state);
3121 if (ret != CAMERA_ERROR_NONE) {
3122 LOGE("failed to get current state 0x%x", ret);
3126 if (current_state != CAMERA_STATE_CREATED) {
3127 LOGE("INVALID_STATE : current %d", current_state);
3128 return CAMERA_ERROR_INVALID_STATE;
3131 LOGD("Enter - display : %p", display);
3133 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3134 set_display_handle = 0;
3135 LOGD("display type NONE");
3138 obj = (Evas_Object *)display;
3139 object_type = evas_object_type_get(obj);
3141 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3142 /* get wayland parent id */
3143 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3144 LOGE("failed to get wayland info");
3145 return CAMERA_ERROR_INVALID_OPERATION;
3148 set_display_handle = (void *)&pc->wl_info;
3149 LOGD("display type OVERLAY : handle %p", set_display_handle);
3150 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3151 /* evas object surface */
3152 set_display_handle = (void *)display;
3153 LOGD("display type EVAS : handle %p", set_display_handle);
3155 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3156 g_mutex_lock(&cb_info->evas_mutex);
3158 if (cb_info->evas_info) {
3159 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3160 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3161 if (ret != MM_ERROR_NONE) {
3162 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3163 g_mutex_unlock(&cb_info->evas_mutex);
3164 return CAMERA_ERROR_INVALID_OPERATION;
3168 /* create evas renderer */
3169 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3170 if (ret == MM_ERROR_NONE) {
3171 camera_flip_e flip = CAMERA_FLIP_NONE;
3172 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3173 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3180 camera_get_display_flip(camera, &flip);
3181 camera_get_display_mode(camera, &mode);
3182 camera_get_display_rotation(camera, &rotation);
3183 camera_is_display_visible(camera, &visible);
3184 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3186 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3187 flip, mode, rotation, visible, x, y, width, height);
3189 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3190 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3191 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3192 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3194 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3195 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3198 g_mutex_unlock(&cb_info->evas_mutex);
3200 if (ret != MM_ERROR_NONE) {
3201 LOGE("mm_evas_renderer error 0x%x", ret);
3202 return CAMERA_ERROR_INVALID_OPERATION;
3204 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3205 LOGE("EVAS surface is not supported");
3206 return CAMERA_ERROR_NOT_SUPPORTED;
3207 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3209 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3210 return CAMERA_ERROR_INVALID_PARAMETER;
3213 LOGE("failed to get evas object type from %p", obj);
3214 return CAMERA_ERROR_INVALID_PARAMETER;
3218 pc->display_handle = (intptr_t)set_display_handle;
3220 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3223 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3224 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3226 msg = muse_core_msg_json_factory_new(api,
3227 MUSE_TYPE_INT, "type", type,
3228 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3231 LOGE("msg creation failed: api %d", api);
3232 return CAMERA_ERROR_OUT_OF_MEMORY;
3235 if (pc->cb_info->is_server_connected) {
3236 __camera_update_api_waiting(pc->cb_info, api, 1);
3238 g_mutex_lock(&pc->cb_info->fd_lock);
3239 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3240 g_mutex_unlock(&pc->cb_info->fd_lock);
3244 LOGE("message send failed");
3245 ret = CAMERA_ERROR_INVALID_OPERATION;
3247 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3250 __camera_update_api_waiting(pc->cb_info, api, -1);
3252 muse_core_msg_json_factory_free(msg);
3254 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3255 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3256 pc->wl_info.window_width, pc->wl_info.window_height);
3258 CAMERA_MSG_PARAM_SET(param, INT, type);
3260 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3263 if (ret != CAMERA_ERROR_NONE)
3264 LOGE("set display error 0x%x", ret);
3265 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3266 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3272 int camera_set_preview_resolution(camera_h camera, int width, int height)
3274 int ret = CAMERA_ERROR_NONE;
3275 camera_state_e current_state = CAMERA_STATE_NONE;
3276 camera_cli_s *pc = (camera_cli_s *)camera;
3277 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3278 camera_msg_param param;
3281 if (!pc || !pc->cb_info) {
3282 LOGE("NULL handle");
3283 return CAMERA_ERROR_INVALID_PARAMETER;
3286 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3287 ret = camera_get_state(camera, ¤t_state);
3288 if (ret != CAMERA_ERROR_NONE) {
3289 LOGE("failed to get current state 0x%x", ret);
3293 if (current_state == CAMERA_STATE_PREVIEW) {
3294 ret = _camera_stop_evas_rendering(camera, true);
3295 if (ret != CAMERA_ERROR_NONE)
3300 value = (width << 16) | height;
3301 CAMERA_MSG_PARAM_SET(param, INT, value);
3303 LOGD("%dx%d -> 0x%x", width, height, value);
3305 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3307 LOGD("ret : 0x%x", ret);
3309 if (current_state == CAMERA_STATE_PREVIEW) {
3310 LOGW("restart evas rendering");
3311 _camera_start_evas_rendering(camera);
3318 int camera_set_capture_resolution(camera_h camera, int width, int height)
3320 int ret = CAMERA_ERROR_NONE;
3321 camera_cli_s *pc = (camera_cli_s *)camera;
3322 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3323 camera_msg_param param;
3326 if (!pc || !pc->cb_info) {
3327 LOGE("NULL handle");
3328 return CAMERA_ERROR_INVALID_PARAMETER;
3333 value = (width << 16) | height;
3334 CAMERA_MSG_PARAM_SET(param, INT, value);
3336 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3338 LOGD("ret : 0x%x", ret);
3344 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3346 int ret = CAMERA_ERROR_NONE;
3347 int set_format = (int)format;
3348 camera_cli_s *pc = (camera_cli_s *)camera;
3349 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3350 camera_msg_param param;
3352 if (!pc || !pc->cb_info) {
3353 LOGE("NULL handle");
3354 return CAMERA_ERROR_INVALID_PARAMETER;
3357 LOGD("Enter - format %d", set_format);
3359 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3361 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3363 LOGD("ret : 0x%x", ret);
3369 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3371 int ret = CAMERA_ERROR_NONE;
3372 int set_format = (int)format;
3373 camera_msg_param param;
3374 camera_cli_s *pc = (camera_cli_s *)camera;
3375 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3377 if (!pc || !pc->cb_info) {
3378 LOGE("NULL handle");
3379 return CAMERA_ERROR_INVALID_PARAMETER;
3382 LOGD("Enter - capture_format %d", set_format);
3384 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3386 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3388 LOGD("ret : 0x%x", ret);
3394 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3396 int ret = CAMERA_ERROR_NONE;
3397 camera_cli_s *pc = (camera_cli_s *)camera;
3398 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3400 if (!pc || !pc->cb_info || !width || !height) {
3401 LOGE("NULL pointer %p %p %p", pc, width, height);
3402 return CAMERA_ERROR_INVALID_PARAMETER;
3407 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3409 if (ret == CAMERA_ERROR_NONE) {
3410 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3411 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3414 LOGD("ret : 0x%x", ret);
3420 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3422 int ret = CAMERA_ERROR_NONE;
3423 int set_rotation = (int)rotation;
3424 camera_cli_s *pc = (camera_cli_s *)camera;
3425 camera_msg_param param;
3427 if (!pc || !pc->cb_info) {
3428 LOGE("NULL handle");
3429 return CAMERA_ERROR_INVALID_PARAMETER;
3432 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3433 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3434 g_mutex_lock(&pc->cb_info->evas_mutex);
3436 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3438 g_mutex_unlock(&pc->cb_info->evas_mutex);
3440 if (ret != MM_ERROR_NONE) {
3441 LOGE("failed to set rotation for evas surface 0x%x", ret);
3442 return CAMERA_ERROR_INVALID_OPERATION;
3445 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3447 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3449 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3455 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3457 int ret = CAMERA_ERROR_NONE;
3458 camera_cli_s *pc = (camera_cli_s *)camera;
3460 if (!pc || !pc->cb_info || !rotation) {
3461 LOGE("NULL pointer %p %p", pc, rotation);
3462 return CAMERA_ERROR_INVALID_PARAMETER;
3465 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3467 if (ret == CAMERA_ERROR_NONE)
3468 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3474 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3476 int ret = CAMERA_ERROR_NONE;
3477 int set_flip = (int)flip;
3478 camera_cli_s *pc = (camera_cli_s *)camera;
3479 camera_msg_param param;
3481 if (!pc || !pc->cb_info) {
3482 LOGE("NULL handle");
3483 return CAMERA_ERROR_INVALID_PARAMETER;
3486 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3487 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3488 g_mutex_lock(&pc->cb_info->evas_mutex);
3490 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3492 g_mutex_unlock(&pc->cb_info->evas_mutex);
3494 if (ret != MM_ERROR_NONE) {
3495 LOGE("failed to set flip for evas surface 0x%x", ret);
3496 return CAMERA_ERROR_INVALID_OPERATION;
3499 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3501 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3503 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3509 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3511 int ret = CAMERA_ERROR_NONE;
3512 camera_cli_s *pc = (camera_cli_s *)camera;
3514 if (!pc || !pc->cb_info || !flip) {
3515 LOGE("NULL pointer %p %p", pc, flip);
3516 return CAMERA_ERROR_INVALID_PARAMETER;
3519 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3521 if (ret == CAMERA_ERROR_NONE)
3522 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3528 int camera_set_display_visible(camera_h camera, bool visible)
3530 int ret = CAMERA_ERROR_NONE;
3531 int set_visible = (int)visible;
3532 camera_cli_s *pc = (camera_cli_s *)camera;
3533 camera_msg_param param;
3535 if (!pc || !pc->cb_info) {
3536 LOGE("NULL handle");
3537 return CAMERA_ERROR_INVALID_PARAMETER;
3540 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3541 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3542 g_mutex_lock(&pc->cb_info->evas_mutex);
3544 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3546 g_mutex_unlock(&pc->cb_info->evas_mutex);
3548 if (ret != MM_ERROR_NONE) {
3549 LOGE("failed to set visible for evas surface 0x%x", ret);
3550 return CAMERA_ERROR_INVALID_OPERATION;
3553 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3555 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3557 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3563 int camera_is_display_visible(camera_h camera, bool *visible)
3565 int ret = CAMERA_ERROR_NONE;
3566 camera_cli_s *pc = (camera_cli_s *)camera;
3568 if (!pc || !pc->cb_info || !visible) {
3569 LOGE("NULL pointer %p %p", pc, visible);
3570 return CAMERA_ERROR_INVALID_PARAMETER;
3573 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3575 if (ret == CAMERA_ERROR_NONE)
3576 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3582 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3584 int ret = CAMERA_ERROR_NONE;
3585 int set_mode = (int)mode;
3586 camera_cli_s *pc = (camera_cli_s *)camera;
3587 camera_msg_param param;
3589 if (!pc || !pc->cb_info) {
3590 LOGE("NULL handle");
3591 return CAMERA_ERROR_INVALID_PARAMETER;
3594 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3595 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3596 g_mutex_lock(&pc->cb_info->evas_mutex);
3598 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3600 g_mutex_unlock(&pc->cb_info->evas_mutex);
3602 if (ret != MM_ERROR_NONE) {
3603 LOGE("failed to set geometry for evas surface 0x%x", ret);
3604 return CAMERA_ERROR_INVALID_OPERATION;
3607 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3609 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3611 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3617 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3619 int ret = CAMERA_ERROR_NONE;
3620 camera_cli_s *pc = (camera_cli_s *)camera;
3622 if (!pc || !pc->cb_info || !mode) {
3623 LOGE("NULL pointer %p %p", pc, mode);
3624 return CAMERA_ERROR_INVALID_PARAMETER;
3627 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3629 if (ret == CAMERA_ERROR_NONE)
3630 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3636 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3638 int ret = CAMERA_ERROR_NONE;
3639 int set_hint = (int)hint;
3640 camera_cli_s *pc = (camera_cli_s *)camera;
3641 camera_msg_param param;
3643 if (!pc || !pc->cb_info) {
3644 LOGE("NULL handle");
3645 return CAMERA_ERROR_INVALID_PARAMETER;
3648 LOGD("Enter - hint %d", set_hint);
3650 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3652 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3658 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3660 int ret = CAMERA_ERROR_NONE;
3661 camera_cli_s *pc = (camera_cli_s *)camera;
3662 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3664 if (!pc || !pc->cb_info || !hint) {
3665 LOGE("NULL pointer %p %p", pc, hint);
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3671 if (ret == CAMERA_ERROR_NONE) {
3672 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3673 LOGD("display reuse hint %d", *hint);
3680 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3682 int ret = CAMERA_ERROR_NONE;
3683 camera_cli_s *pc = (camera_cli_s *)camera;
3684 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3686 if (!pc || !pc->cb_info || !width || !height) {
3687 LOGE("NULL pointer %p %p %p", pc, width, height);
3688 return CAMERA_ERROR_INVALID_PARAMETER;
3693 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3695 if (ret == CAMERA_ERROR_NONE) {
3696 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3697 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3700 LOGD("ret : 0x%x", ret);
3706 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3708 int ret = CAMERA_ERROR_NONE;
3709 camera_cli_s *pc = (camera_cli_s *)camera;
3710 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3712 if (!pc || !pc->cb_info || !format) {
3713 LOGE("NULL pointer %p %p", pc, format);
3714 return CAMERA_ERROR_INVALID_PARAMETER;
3719 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3721 if (ret == CAMERA_ERROR_NONE)
3722 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3724 LOGD("ret : 0x%x", ret);
3730 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3732 int ret = CAMERA_ERROR_NONE;
3733 camera_cli_s *pc = (camera_cli_s *)camera;
3734 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3736 if (!pc || !pc->cb_info || !format) {
3737 LOGE("NULL pointer %p %p", pc, format);
3738 return CAMERA_ERROR_INVALID_PARAMETER;
3743 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3745 if (ret == CAMERA_ERROR_NONE)
3746 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3748 LOGD("ret : 0x%x", ret);
3754 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3760 if (!pc || !pc->cb_info || !facing_direction) {
3761 LOGE("NULL pointer %p %p", pc, facing_direction);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3767 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3769 if (ret == CAMERA_ERROR_NONE)
3770 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3772 LOGD("ret : 0x%x", ret);
3778 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3780 int ret = CAMERA_ERROR_NONE;
3781 camera_cli_s *pc = (camera_cli_s *)camera;
3782 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3784 if (!pc || !pc->cb_info || !callback) {
3785 LOGE("NULL pointer %p %p", pc, callback);
3786 return CAMERA_ERROR_INVALID_PARAMETER;
3791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3793 if (ret == CAMERA_ERROR_NONE) {
3794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3796 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3799 LOGD("ret : 0x%x", ret);
3805 int camera_unset_preview_cb(camera_h camera)
3807 int ret = CAMERA_ERROR_NONE;
3808 camera_cli_s *pc = (camera_cli_s *)camera;
3809 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3811 if (!pc || !pc->cb_info) {
3812 LOGE("NULL handle");
3813 return CAMERA_ERROR_INVALID_PARAMETER;
3818 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3820 if (ret == CAMERA_ERROR_NONE) {
3821 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3822 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3823 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3826 LOGD("ret : 0x%x", ret);
3832 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3838 if (!pc || !pc->cb_info) {
3839 LOGE("NULL handle");
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3843 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3844 LOGE("NOT SUPPORTED");
3845 return CAMERA_ERROR_NOT_SUPPORTED;
3848 if (callback == NULL) {
3849 LOGE("NULL callback");
3850 return CAMERA_ERROR_INVALID_PARAMETER;
3855 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3857 if (ret == CAMERA_ERROR_NONE) {
3858 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3859 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3862 LOGD("ret : 0x%x", ret);
3868 int camera_unset_media_packet_preview_cb(camera_h camera)
3870 int ret = CAMERA_ERROR_NONE;
3871 camera_cli_s *pc = (camera_cli_s *)camera;
3872 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3874 if (!pc || !pc->cb_info) {
3875 LOGE("NULL handle");
3876 return CAMERA_ERROR_INVALID_PARAMETER;
3881 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3883 if (ret == CAMERA_ERROR_NONE) {
3884 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3885 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3888 LOGD("ret : 0x%x", ret);
3894 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3896 int ret = CAMERA_ERROR_NONE;
3897 camera_cli_s *pc = (camera_cli_s *)camera;
3898 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3900 if (!pc || !pc->cb_info || !callback) {
3901 LOGE("NULL pointer %p %p", pc, callback);
3902 return CAMERA_ERROR_INVALID_PARAMETER;
3907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3909 if (ret == CAMERA_ERROR_NONE) {
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3914 LOGD("ret : 0x%x", ret);
3920 int camera_unset_state_changed_cb(camera_h camera)
3922 int ret = CAMERA_ERROR_NONE;
3923 camera_cli_s *pc = (camera_cli_s *)camera;
3924 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3926 if (!pc || !pc->cb_info) {
3927 LOGE("NULL handle");
3928 return CAMERA_ERROR_INVALID_PARAMETER;
3933 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3935 if (ret == CAMERA_ERROR_NONE) {
3936 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3937 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3940 LOGD("ret : 0x%x", ret);
3946 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3948 int ret = CAMERA_ERROR_NONE;
3949 camera_cli_s *pc = (camera_cli_s *)camera;
3950 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3952 if (!pc || !pc->cb_info || !callback) {
3953 LOGE("NULL pointer %p %p", pc, callback);
3954 return CAMERA_ERROR_INVALID_PARAMETER;
3959 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3961 if (ret == CAMERA_ERROR_NONE) {
3962 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3963 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3966 LOGD("ret : 0x%x", ret);
3972 int camera_unset_interrupted_cb(camera_h camera)
3974 int ret = CAMERA_ERROR_NONE;
3975 camera_cli_s *pc = (camera_cli_s *)camera;
3976 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3978 if (!pc || !pc->cb_info) {
3979 LOGE("NULL handle");
3980 return CAMERA_ERROR_INVALID_PARAMETER;
3985 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3987 if (ret == CAMERA_ERROR_NONE) {
3988 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3989 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3992 LOGD("ret : 0x%x", ret);
3998 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4000 int ret = CAMERA_ERROR_NONE;
4001 camera_cli_s *pc = (camera_cli_s *)camera;
4002 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4004 if (!pc || !pc->cb_info || !callback) {
4005 LOGE("NULL pointer %p %p", pc, callback);
4006 return CAMERA_ERROR_INVALID_PARAMETER;
4011 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4013 if (ret == CAMERA_ERROR_NONE) {
4014 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4015 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4018 LOGD("ret : 0x%x", ret);
4024 int camera_unset_focus_changed_cb(camera_h camera)
4026 int ret = CAMERA_ERROR_NONE;
4027 camera_cli_s *pc = (camera_cli_s *)camera;
4028 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4030 if (!pc || !pc->cb_info) {
4031 LOGE("NULL handle");
4032 return CAMERA_ERROR_INVALID_PARAMETER;
4037 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4039 if (ret == CAMERA_ERROR_NONE) {
4040 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4041 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4044 LOGD("ret : 0x%x", ret);
4050 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4052 int ret = CAMERA_ERROR_NONE;
4053 camera_cli_s *pc = (camera_cli_s *)camera;
4054 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4056 if (!pc || !pc->cb_info || !callback) {
4057 LOGE("NULL pointer %p %p", pc, callback);
4058 return CAMERA_ERROR_INVALID_PARAMETER;
4063 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4065 if (ret == CAMERA_ERROR_NONE) {
4066 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4067 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4070 LOGD("ret : 0x%x", ret);
4076 int camera_unset_error_cb(camera_h camera)
4078 int ret = CAMERA_ERROR_NONE;
4079 camera_cli_s *pc = (camera_cli_s *)camera;
4080 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4082 if (!pc || !pc->cb_info) {
4083 LOGE("NULL handle");
4084 return CAMERA_ERROR_INVALID_PARAMETER;
4089 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4091 if (ret == CAMERA_ERROR_NONE) {
4092 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4093 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4096 LOGD("ret : 0x%x", ret);
4102 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4104 int ret = CAMERA_ERROR_NONE;
4105 camera_cli_s *pc = (camera_cli_s *)camera;
4106 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4108 if (!pc || !pc->cb_info || !foreach_cb) {
4109 LOGE("NULL pointer %p %p", pc, foreach_cb);
4110 return CAMERA_ERROR_INVALID_PARAMETER;
4115 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4116 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4118 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4120 LOGD("ret : 0x%x", ret);
4126 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4128 int ret = CAMERA_ERROR_NONE;
4129 camera_cli_s *pc = (camera_cli_s *)camera;
4130 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4132 if (!pc || !pc->cb_info || !foreach_cb) {
4133 LOGE("NULL pointer %p %p", pc, foreach_cb);
4134 return CAMERA_ERROR_INVALID_PARAMETER;
4139 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4140 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4142 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4144 LOGD("ret : 0x%x", ret);
4150 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4152 int ret = CAMERA_ERROR_NONE;
4153 camera_cli_s *pc = (camera_cli_s *)camera;
4154 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4156 if (!pc || !pc->cb_info || !foreach_cb) {
4157 LOGE("NULL pointer %p %p", pc, foreach_cb);
4158 return CAMERA_ERROR_INVALID_PARAMETER;
4163 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4164 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4166 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4168 LOGD("ret : 0x%x", ret);
4174 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4176 int ret = CAMERA_ERROR_NONE;
4177 camera_cli_s *pc = (camera_cli_s *)camera;
4178 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4180 if (!pc || !pc->cb_info || !foreach_cb) {
4181 LOGE("NULL pointer %p %p", pc, foreach_cb);
4182 return CAMERA_ERROR_INVALID_PARAMETER;
4187 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4188 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4190 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4192 LOGD("ret : 0x%x", ret);
4198 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4200 int ret = CAMERA_ERROR_NONE;
4201 camera_cli_s *pc = (camera_cli_s *)camera;
4202 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4204 if (!pc || !pc->cb_info || !width || !height) {
4205 LOGE("NULL pointer %p %p %p", pc, width, height);
4206 return CAMERA_ERROR_INVALID_PARAMETER;
4210 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4212 if (ret == CAMERA_ERROR_NONE) {
4213 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4214 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4217 LOGD("ret : 0x%x", ret);
4223 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4225 int ret = CAMERA_ERROR_NONE;
4226 camera_cli_s *pc = (camera_cli_s *)camera;
4227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4229 if (!pc || !pc->cb_info || !angle) {
4230 LOGE("NULL pointer %p %p", pc, angle);
4231 return CAMERA_ERROR_INVALID_PARAMETER;
4236 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4238 if (ret == CAMERA_ERROR_NONE)
4239 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4241 LOGD("ret : 0x%x", ret);
4247 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4249 int ret = CAMERA_ERROR_NONE;
4250 camera_cli_s *pc = (camera_cli_s *)camera;
4251 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4252 camera_msg_param param;
4253 int set_mode = (int)mode;
4255 if (!pc || !pc->cb_info) {
4256 LOGE("NULL handle");
4257 return CAMERA_ERROR_INVALID_PARAMETER;
4262 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4264 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4266 LOGD("ret : 0x%x", ret);
4272 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4274 int ret = CAMERA_ERROR_NONE;
4275 camera_cli_s *pc = (camera_cli_s *)camera;
4276 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4278 if (!pc || !pc->cb_info || !mode) {
4279 LOGE("NULL pointer %p %p", pc, mode);
4280 return CAMERA_ERROR_INVALID_PARAMETER;
4285 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4287 if (ret == CAMERA_ERROR_NONE)
4288 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4290 LOGD("ret : 0x%x", ret);
4296 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4298 int ret = CAMERA_ERROR_NONE;
4299 camera_cli_s *pc = (camera_cli_s *)camera;
4300 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4302 if (!pc || !pc->cb_info || !foreach_cb) {
4303 LOGE("NULL pointer %p %p", pc, foreach_cb);
4304 return CAMERA_ERROR_INVALID_PARAMETER;
4309 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4310 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4312 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4314 LOGD("Finish, return :%x", ret);
4320 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4322 int ret = CAMERA_ERROR_NONE;
4323 camera_cli_s *pc = (camera_cli_s *)camera;
4324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4325 camera_msg_param param;
4326 int set_fps = (int)fps;
4328 if (!pc || !pc->cb_info) {
4329 LOGE("NULL handle");
4330 return CAMERA_ERROR_INVALID_PARAMETER;
4335 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4337 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4339 LOGD("ret : 0x%x", ret);
4345 int camera_attr_set_image_quality(camera_h camera, int quality)
4347 int ret = CAMERA_ERROR_NONE;
4348 camera_cli_s *pc = (camera_cli_s *)camera;
4349 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4350 camera_msg_param param;
4352 if (!pc || !pc->cb_info) {
4353 LOGE("NULL handle");
4354 return CAMERA_ERROR_INVALID_PARAMETER;
4359 CAMERA_MSG_PARAM_SET(param, INT, quality);
4361 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4363 LOGD("ret : 0x%x", ret);
4369 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4371 int ret = CAMERA_ERROR_NONE;
4372 camera_cli_s *pc = (camera_cli_s *)camera;
4373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4375 if (!pc || !pc->cb_info || !fps) {
4376 LOGE("NULL pointer %p %p", pc, fps);
4377 return CAMERA_ERROR_INVALID_PARAMETER;
4382 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4384 if (ret == CAMERA_ERROR_NONE)
4385 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4387 LOGD("ret : 0x%x", ret);
4393 int camera_attr_get_image_quality(camera_h camera, int *quality)
4395 int ret = CAMERA_ERROR_NONE;
4396 camera_cli_s *pc = (camera_cli_s *)camera;
4397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4399 if (!pc || !pc->cb_info || !quality) {
4400 LOGE("NULL pointer %p %p", pc, quality);
4401 return CAMERA_ERROR_INVALID_PARAMETER;
4406 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4408 if (ret == CAMERA_ERROR_NONE)
4409 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4411 LOGD("ret : 0x%x", ret);
4417 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4419 int ret = CAMERA_ERROR_NONE;
4420 camera_cli_s *pc = (camera_cli_s *)camera;
4421 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4423 if (!pc || !pc->cb_info || !bitrate) {
4424 LOGE("NULL pointer %p %p", pc, bitrate);
4425 return CAMERA_ERROR_INVALID_PARAMETER;
4430 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4432 if (ret == CAMERA_ERROR_NONE)
4433 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4435 LOGD("ret : 0x%x", ret);
4441 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4443 int ret = CAMERA_ERROR_NONE;
4444 camera_cli_s *pc = (camera_cli_s *)camera;
4445 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4446 camera_msg_param param;
4447 int set_bitrate = bitrate;
4449 if (!pc || !pc->cb_info) {
4450 LOGE("NULL handle");
4451 return CAMERA_ERROR_INVALID_PARAMETER;
4456 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4458 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4460 LOGD("ret : 0x%x", ret);
4466 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4468 int ret = CAMERA_ERROR_NONE;
4469 camera_cli_s *pc = (camera_cli_s *)camera;
4470 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4472 if (!pc || !pc->cb_info || !interval) {
4473 LOGE("NULL pointer %p %p", pc, interval);
4474 return CAMERA_ERROR_INVALID_PARAMETER;
4479 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4481 if (ret == CAMERA_ERROR_NONE)
4482 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4484 LOGD("ret : 0x%x", ret);
4490 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4492 int ret = CAMERA_ERROR_NONE;
4493 camera_cli_s *pc = (camera_cli_s *)camera;
4494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4495 camera_msg_param param;
4496 int set_gop_interval = interval;
4498 if (!pc || !pc->cb_info) {
4499 LOGE("NULL handle");
4500 return CAMERA_ERROR_INVALID_PARAMETER;
4505 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4507 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4509 LOGD("ret : 0x%x", ret);
4515 int camera_attr_set_zoom(camera_h camera, int zoom)
4517 int ret = CAMERA_ERROR_NONE;
4518 camera_cli_s *pc = (camera_cli_s *)camera;
4519 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4520 camera_msg_param param;
4522 if (!pc || !pc->cb_info) {
4523 LOGE("NULL handle");
4524 return CAMERA_ERROR_INVALID_PARAMETER;
4527 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4529 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4531 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4533 LOGD("ret : 0x%x", ret);
4539 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4541 int ret = CAMERA_ERROR_NONE;
4542 camera_cli_s *pc = (camera_cli_s *)camera;
4543 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4544 camera_msg_param param;
4545 int set_mode = (int)mode;
4547 if (!pc || !pc->cb_info) {
4548 LOGE("NULL handle");
4549 return CAMERA_ERROR_INVALID_PARAMETER;
4552 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4554 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4556 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4562 int camera_attr_set_af_area(camera_h camera, int x, int y)
4564 int ret = CAMERA_ERROR_NONE;
4565 camera_cli_s *pc = (camera_cli_s *)camera;
4566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4567 camera_msg_param param;
4570 if (!pc || !pc->cb_info) {
4571 LOGE("NULL handle");
4572 return CAMERA_ERROR_INVALID_PARAMETER;
4575 LOGD("Enter - %d,%d", x, y);
4577 value = (x << 16) | y;
4578 CAMERA_MSG_PARAM_SET(param, INT, value);
4580 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4582 LOGD("ret : 0x%x", ret);
4588 int camera_attr_clear_af_area(camera_h camera)
4590 int ret = CAMERA_ERROR_NONE;
4591 camera_cli_s *pc = (camera_cli_s *)camera;
4592 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4594 if (!pc || !pc->cb_info) {
4595 LOGE("NULL handle");
4596 return CAMERA_ERROR_INVALID_PARAMETER;
4601 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4603 LOGD("ret : 0x%x", ret);
4609 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4611 int ret = CAMERA_ERROR_NONE;
4612 camera_cli_s *pc = (camera_cli_s *)camera;
4613 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4614 camera_msg_param param;
4615 int set_mode = (int)mode;
4617 if (!pc || !pc->cb_info) {
4618 LOGE("NULL handle");
4619 return CAMERA_ERROR_INVALID_PARAMETER;
4624 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4626 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4628 LOGD("ret : 0x%x", ret);
4634 int camera_attr_set_exposure(camera_h camera, int value)
4636 int ret = CAMERA_ERROR_NONE;
4637 camera_cli_s *pc = (camera_cli_s *)camera;
4638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4639 camera_msg_param param;
4641 if (!pc || !pc->cb_info) {
4642 LOGE("NULL handle");
4643 return CAMERA_ERROR_INVALID_PARAMETER;
4648 CAMERA_MSG_PARAM_SET(param, INT, value);
4650 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4652 LOGD("ret : 0x%x", ret);
4658 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4660 int ret = CAMERA_ERROR_NONE;
4661 camera_cli_s *pc = (camera_cli_s *)camera;
4662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4663 camera_msg_param param;
4664 int set_iso = (int)iso;
4666 if (!pc || !pc->cb_info) {
4667 LOGE("NULL handle");
4668 return CAMERA_ERROR_INVALID_PARAMETER;
4673 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4675 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4677 LOGD("ret : 0x%x", ret);
4683 int camera_attr_set_brightness(camera_h camera, int level)
4685 int ret = CAMERA_ERROR_NONE;
4686 camera_cli_s *pc = (camera_cli_s *)camera;
4687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4688 camera_msg_param param;
4690 if (!pc || !pc->cb_info) {
4691 LOGE("NULL handle");
4692 return CAMERA_ERROR_INVALID_PARAMETER;
4697 CAMERA_MSG_PARAM_SET(param, INT, level);
4699 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4701 LOGD("ret : 0x%x", ret);
4707 int camera_attr_set_contrast(camera_h camera, int level)
4709 int ret = CAMERA_ERROR_NONE;
4710 camera_cli_s *pc = (camera_cli_s *)camera;
4711 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4712 camera_msg_param param;
4714 if (!pc || !pc->cb_info) {
4715 LOGE("NULL handle");
4716 return CAMERA_ERROR_INVALID_PARAMETER;
4721 CAMERA_MSG_PARAM_SET(param, INT, level);
4723 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4725 LOGD("ret : 0x%x", ret);
4731 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4733 int ret = CAMERA_ERROR_NONE;
4734 camera_cli_s *pc = (camera_cli_s *)camera;
4735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4736 camera_msg_param param;
4737 int set_whitebalance = (int)wb;
4739 if (!pc || !pc->cb_info) {
4740 LOGE("NULL handle");
4741 return CAMERA_ERROR_INVALID_PARAMETER;
4746 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4748 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4750 LOGD("ret : 0x%x", ret);
4756 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4758 int ret = CAMERA_ERROR_NONE;
4759 camera_cli_s *pc = (camera_cli_s *)camera;
4760 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4761 camera_msg_param param;
4762 int set_effect = (int)effect;
4764 if (!pc || !pc->cb_info) {
4765 LOGE("NULL handle");
4766 return CAMERA_ERROR_INVALID_PARAMETER;
4771 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4773 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4775 LOGD("ret : 0x%x", ret);
4781 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4783 int ret = CAMERA_ERROR_NONE;
4784 camera_cli_s *pc = (camera_cli_s *)camera;
4785 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4786 camera_msg_param param;
4787 int set_mode = (int)mode;
4789 if (!pc || !pc->cb_info) {
4790 LOGE("NULL handle");
4791 return CAMERA_ERROR_INVALID_PARAMETER;
4796 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4798 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4800 LOGD("ret : 0x%x", ret);
4806 int camera_attr_enable_tag(camera_h camera, bool enable)
4808 int ret = CAMERA_ERROR_NONE;
4809 camera_cli_s *pc = (camera_cli_s *)camera;
4810 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4811 camera_msg_param param;
4812 int set_enable = (int)enable;
4814 if (!pc || !pc->cb_info) {
4815 LOGE("NULL handle");
4816 return CAMERA_ERROR_INVALID_PARAMETER;
4821 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4823 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4825 LOGD("ret : 0x%x", ret);
4831 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4833 int ret = CAMERA_ERROR_NONE;
4834 camera_cli_s *pc = (camera_cli_s *)camera;
4835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4836 camera_msg_param param;
4838 if (!pc || !pc->cb_info || !description) {
4839 LOGE("NULL pointer %p %p", pc, description);
4840 return CAMERA_ERROR_INVALID_PARAMETER;
4845 CAMERA_MSG_PARAM_SET(param, STRING, description);
4847 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4849 LOGD("ret : 0x%x", ret);
4855 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4857 int ret = CAMERA_ERROR_NONE;
4858 camera_cli_s *pc = (camera_cli_s *)camera;
4859 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4860 camera_msg_param param;
4861 int set_orientation = (int)orientation;
4863 if (!pc || !pc->cb_info) {
4864 LOGE("NULL handle");
4865 return CAMERA_ERROR_INVALID_PARAMETER;
4870 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4872 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4874 LOGD("ret : 0x%x", ret);
4880 int camera_attr_set_tag_software(camera_h camera, const char *software)
4882 int ret = CAMERA_ERROR_NONE;
4883 camera_cli_s *pc = (camera_cli_s *)camera;
4884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4885 camera_msg_param param;
4887 if (!pc || !pc->cb_info || !software) {
4888 LOGE("NULL pointer %p %p", pc, software);
4889 return CAMERA_ERROR_INVALID_PARAMETER;
4892 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4894 CAMERA_MSG_PARAM_SET(param, STRING, software);
4896 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4898 LOGD("ret : 0x%x", ret);
4904 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4906 int ret = CAMERA_ERROR_NONE;
4907 camera_cli_s *pc = (camera_cli_s *)camera;
4908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4909 double set_geotag[3] = {latitude, longitude, altitude};
4914 if (!pc || !pc->cb_info) {
4915 LOGE("NULL handle");
4916 return CAMERA_ERROR_INVALID_PARAMETER;
4921 length = sizeof(set_geotag) / sizeof(int) + \
4922 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4924 msg = muse_core_msg_json_factory_new(api,
4925 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4928 LOGE("msg creation failed: api %d", api);
4929 return CAMERA_ERROR_OUT_OF_MEMORY;
4932 if (pc->cb_info->is_server_connected) {
4933 __camera_update_api_waiting(pc->cb_info, api, 1);
4935 g_mutex_lock(&pc->cb_info->fd_lock);
4936 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4937 g_mutex_unlock(&pc->cb_info->fd_lock);
4941 LOGE("message send failed");
4942 ret = CAMERA_ERROR_INVALID_OPERATION;
4944 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4947 __camera_update_api_waiting(pc->cb_info, api, -1);
4949 muse_core_msg_json_factory_free(msg);
4951 LOGD("ret : 0x%x", ret);
4957 int camera_attr_remove_geotag(camera_h camera)
4959 int ret = CAMERA_ERROR_NONE;
4960 camera_cli_s *pc = (camera_cli_s *)camera;
4961 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4963 if (!pc || !pc->cb_info) {
4964 LOGE("NULL handle");
4965 return CAMERA_ERROR_INVALID_PARAMETER;
4970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4972 LOGD("ret : 0x%x", ret);
4978 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4980 int ret = CAMERA_ERROR_NONE;
4981 camera_cli_s *pc = (camera_cli_s *)camera;
4982 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4983 camera_msg_param param;
4984 int set_mode = (int)mode;
4986 if (!pc || !pc->cb_info) {
4987 LOGE("NULL handle");
4988 return CAMERA_ERROR_INVALID_PARAMETER;
4993 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4995 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4997 LOGD("ret : 0x%x", ret);
5003 int camera_attr_get_zoom(camera_h camera, int *zoom)
5005 int ret = CAMERA_ERROR_NONE;
5006 camera_cli_s *pc = (camera_cli_s *)camera;
5007 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5009 if (!pc || !pc->cb_info || !zoom) {
5010 LOGE("NULL pointer %p %p", pc, zoom);
5011 return CAMERA_ERROR_INVALID_PARAMETER;
5016 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5018 if (ret == CAMERA_ERROR_NONE)
5019 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5021 LOGD("ret : 0x%x", ret);
5027 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5029 int ret = CAMERA_ERROR_NONE;
5030 camera_cli_s *pc = (camera_cli_s *)camera;
5031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5033 if (!pc || !pc->cb_info || !min || !max) {
5034 LOGE("NULL pointer %p %p %p", pc, min, max);
5035 return CAMERA_ERROR_INVALID_PARAMETER;
5040 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5042 if (ret == CAMERA_ERROR_NONE) {
5043 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5044 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5047 LOGD("ret : 0x%x", ret);
5053 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5055 int ret = CAMERA_ERROR_NONE;
5056 camera_cli_s *pc = (camera_cli_s *)camera;
5057 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5059 if (!pc || !pc->cb_info || !mode) {
5060 LOGE("NULL pointer %p %p", pc, mode);
5061 return CAMERA_ERROR_INVALID_PARAMETER;
5066 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5068 if (ret == CAMERA_ERROR_NONE)
5069 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5071 LOGD("ret : 0x%x", ret);
5077 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5079 int ret = CAMERA_ERROR_NONE;
5080 camera_cli_s *pc = (camera_cli_s *)camera;
5081 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5083 if (!pc || !pc->cb_info || !mode) {
5084 LOGE("NULL pointer %p %p", pc, mode);
5085 return CAMERA_ERROR_INVALID_PARAMETER;
5090 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5092 if (ret == CAMERA_ERROR_NONE)
5093 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5095 LOGD("ret : 0x%x", ret);
5101 int camera_attr_get_exposure(camera_h camera, int *value)
5103 int ret = CAMERA_ERROR_NONE;
5104 camera_cli_s *pc = (camera_cli_s *)camera;
5105 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5107 if (!pc || !pc->cb_info || !value) {
5108 LOGE("NULL pointer %p %p", pc, value);
5109 return CAMERA_ERROR_INVALID_PARAMETER;
5114 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5116 if (ret == CAMERA_ERROR_NONE)
5117 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5119 LOGD("ret : 0x%x", ret);
5125 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5127 int ret = CAMERA_ERROR_NONE;
5128 camera_cli_s *pc = (camera_cli_s *)camera;
5129 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5131 if (!pc || !pc->cb_info || !min || !max) {
5132 LOGE("NULL pointer %p %p %p", pc, min, max);
5133 return CAMERA_ERROR_INVALID_PARAMETER;
5138 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5140 if (ret == CAMERA_ERROR_NONE) {
5141 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5142 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5145 LOGD("ret : 0x%x", ret);
5151 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5153 int ret = CAMERA_ERROR_NONE;
5154 camera_cli_s *pc = (camera_cli_s *)camera;
5155 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5157 if (!pc || !pc->cb_info || !iso) {
5158 LOGE("NULL pointer %p %p", pc, iso);
5159 return CAMERA_ERROR_INVALID_PARAMETER;
5164 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5166 if (ret == CAMERA_ERROR_NONE)
5167 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5169 LOGD("ret : 0x%x", ret);
5175 int camera_attr_get_brightness(camera_h camera, int *level)
5177 int ret = CAMERA_ERROR_NONE;
5178 camera_cli_s *pc = (camera_cli_s *)camera;
5179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5181 if (!pc || !pc->cb_info || !level) {
5182 LOGE("NULL pointer %p %p", pc, level);
5183 return CAMERA_ERROR_INVALID_PARAMETER;
5188 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5190 if (ret == CAMERA_ERROR_NONE)
5191 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5193 LOGD("ret : 0x%x", ret);
5199 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5201 int ret = CAMERA_ERROR_NONE;
5202 camera_cli_s *pc = (camera_cli_s *)camera;
5203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5205 if (!pc || !pc->cb_info || !min || !max) {
5206 LOGE("NULL pointer %p %p %p", pc, min, max);
5207 return CAMERA_ERROR_INVALID_PARAMETER;
5212 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5214 if (ret == CAMERA_ERROR_NONE) {
5215 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5216 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5219 LOGD("ret : 0x%x", ret);
5225 int camera_attr_get_contrast(camera_h camera, int *level)
5227 int ret = CAMERA_ERROR_NONE;
5228 camera_cli_s *pc = (camera_cli_s *)camera;
5229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5231 if (!pc || !pc->cb_info || !level) {
5232 LOGE("NULL pointer %p %p", pc, level);
5233 return CAMERA_ERROR_INVALID_PARAMETER;
5238 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5240 if (ret == CAMERA_ERROR_NONE)
5241 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5243 LOGD("ret : 0x%x", ret);
5249 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5251 int ret = CAMERA_ERROR_NONE;
5252 camera_cli_s *pc = (camera_cli_s *)camera;
5253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5255 if (!pc || !pc->cb_info || !min || !max) {
5256 LOGE("NULL pointer %p %p %p", pc, min, max);
5257 return CAMERA_ERROR_INVALID_PARAMETER;
5262 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5264 if (ret == CAMERA_ERROR_NONE) {
5265 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5266 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5267 LOGD("min %d, max %d", *min, *max);
5270 LOGD("ret : 0x%x", ret);
5276 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5278 int ret = CAMERA_ERROR_NONE;
5279 camera_cli_s *pc = (camera_cli_s *)camera;
5280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5282 if (!pc || !pc->cb_info || !wb) {
5283 LOGE("NULL pointer %p %p", pc, wb);
5284 return CAMERA_ERROR_INVALID_PARAMETER;
5289 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5291 if (ret == CAMERA_ERROR_NONE)
5292 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5294 LOGD("ret : 0x%x", ret);
5300 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5302 int ret = CAMERA_ERROR_NONE;
5303 camera_cli_s *pc = (camera_cli_s *)camera;
5304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5306 if (!pc || !pc->cb_info || !effect) {
5307 LOGE("NULL pointer %p %p", pc, effect);
5308 return CAMERA_ERROR_INVALID_PARAMETER;
5313 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5315 if (ret == CAMERA_ERROR_NONE)
5316 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5318 LOGD("ret : 0x%x", ret);
5324 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5326 int ret = CAMERA_ERROR_NONE;
5327 camera_cli_s *pc = (camera_cli_s *)camera;
5328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5330 if (!pc || !pc->cb_info || !mode) {
5331 LOGE("NULL pointer %p %p", pc, mode);
5332 return CAMERA_ERROR_INVALID_PARAMETER;
5337 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5339 if (ret == CAMERA_ERROR_NONE)
5340 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5342 LOGD("ret : 0x%x", ret);
5348 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5350 int ret = CAMERA_ERROR_NONE;
5351 camera_cli_s *pc = (camera_cli_s *)camera;
5352 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5354 if (!pc || !pc->cb_info || !enable) {
5355 LOGE("NULL pointer %p %p", pc, enable);
5356 return CAMERA_ERROR_INVALID_PARAMETER;
5361 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5363 if (ret == CAMERA_ERROR_NONE)
5364 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5366 LOGD("ret : 0x%x", ret);
5372 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5374 int ret = CAMERA_ERROR_NONE;
5375 camera_cli_s *pc = (camera_cli_s *)camera;
5376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5378 if (!pc || !pc->cb_info || !description) {
5379 LOGE("NULL pointer %p %p", pc, description);
5380 return CAMERA_ERROR_INVALID_PARAMETER;
5385 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5387 if (ret == CAMERA_ERROR_NONE)
5388 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5390 LOGD("ret : 0x%x", ret);
5396 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5398 int ret = CAMERA_ERROR_NONE;
5399 camera_cli_s *pc = (camera_cli_s *)camera;
5400 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5402 if (!pc || !pc->cb_info || !orientation) {
5403 LOGE("NULL pointer %p %p", pc, orientation);
5404 return CAMERA_ERROR_INVALID_PARAMETER;
5409 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5411 if (ret == CAMERA_ERROR_NONE)
5412 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5414 LOGD("ret : 0x%x", ret);
5420 int camera_attr_get_tag_software(camera_h camera, char **software)
5422 int ret = CAMERA_ERROR_NONE;
5423 camera_cli_s *pc = (camera_cli_s *)camera;
5424 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5426 if (!pc || !pc->cb_info || !software) {
5427 LOGE("NULL pointer %p %p", pc, software);
5428 return CAMERA_ERROR_INVALID_PARAMETER;
5433 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5435 if (ret == CAMERA_ERROR_NONE)
5436 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5438 LOGD("ret : 0x%x", ret);
5444 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5446 int ret = CAMERA_ERROR_NONE;
5447 camera_cli_s *pc = (camera_cli_s *)camera;
5448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5450 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5451 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5452 return CAMERA_ERROR_INVALID_PARAMETER;
5457 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5459 if (ret == CAMERA_ERROR_NONE) {
5460 *latitude = pc->cb_info->get_geotag[0];
5461 *longitude = pc->cb_info->get_geotag[1];
5462 *altitude = pc->cb_info->get_geotag[2];
5465 LOGD("ret : 0x%x", ret);
5471 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5473 int ret = CAMERA_ERROR_NONE;
5474 camera_cli_s *pc = (camera_cli_s *)camera;
5475 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5477 if (!pc || !pc->cb_info || !mode) {
5478 LOGE("NULL pointer %p %p", pc, mode);
5479 return CAMERA_ERROR_INVALID_PARAMETER;
5484 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5486 if (ret == CAMERA_ERROR_NONE)
5487 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5489 LOGD("ret : 0x%x", ret);
5495 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5497 int ret = CAMERA_ERROR_NONE;
5498 int get_flash_state = 0;
5501 LOGE("NULL pointer");
5502 return CAMERA_ERROR_INVALID_PARAMETER;
5505 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5506 (int)device, "get_flash_state", &get_flash_state);
5508 if (ret == CAMERA_ERROR_NONE) {
5509 *state = (camera_flash_state_e)get_flash_state;
5510 LOGD("flash state %d", *state);
5512 LOGE("failed 0x%x", ret);
5519 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5521 int ret = CAMERA_ERROR_NONE;
5522 camera_cli_s *pc = (camera_cli_s *)camera;
5523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5525 if (!pc || !pc->cb_info || !foreach_cb) {
5526 LOGE("NULL pointer %p %p", pc, foreach_cb);
5527 return CAMERA_ERROR_INVALID_PARAMETER;
5532 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5533 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5535 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5537 LOGD("ret : 0x%x", ret);
5543 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5545 int ret = CAMERA_ERROR_NONE;
5546 camera_cli_s *pc = (camera_cli_s *)camera;
5547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5549 if (!pc || !pc->cb_info || !foreach_cb) {
5550 LOGE("NULL pointer %p %p", pc, foreach_cb);
5551 return CAMERA_ERROR_INVALID_PARAMETER;
5556 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5557 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5559 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5561 LOGD("ret : 0x%x", ret);
5567 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5569 int ret = CAMERA_ERROR_NONE;
5570 camera_cli_s *pc = (camera_cli_s *)camera;
5571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5573 if (!pc || !pc->cb_info || !foreach_cb) {
5574 LOGE("NULL pointer %p %p", pc, foreach_cb);
5575 return CAMERA_ERROR_INVALID_PARAMETER;
5580 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5581 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5583 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5585 LOGD("ret : 0x%x", ret);
5591 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5593 int ret = CAMERA_ERROR_NONE;
5594 camera_cli_s *pc = (camera_cli_s *)camera;
5595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5597 if (!pc || !pc->cb_info || !foreach_cb) {
5598 LOGE("NULL pointer %p %p", pc, foreach_cb);
5599 return CAMERA_ERROR_INVALID_PARAMETER;
5604 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5605 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5607 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5609 LOGD("ret : 0x%x", ret);
5615 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5617 int ret = CAMERA_ERROR_NONE;
5618 camera_cli_s *pc = (camera_cli_s *)camera;
5619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5621 if (!pc || !pc->cb_info || !foreach_cb) {
5622 LOGE("NULL pointer %p %p", pc, foreach_cb);
5623 return CAMERA_ERROR_INVALID_PARAMETER;
5628 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5629 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5631 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5633 LOGD("ret : 0x%x", ret);
5639 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5641 int ret = CAMERA_ERROR_NONE;
5642 camera_cli_s *pc = (camera_cli_s *)camera;
5643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5645 if (!pc || !pc->cb_info || !foreach_cb) {
5646 LOGE("NULL pointer %p %p", pc, foreach_cb);
5647 return CAMERA_ERROR_INVALID_PARAMETER;
5652 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5653 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5655 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5657 LOGD("ret : 0x%x", ret);
5663 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5665 int ret = CAMERA_ERROR_NONE;
5666 camera_cli_s *pc = (camera_cli_s *)camera;
5667 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5669 if (!pc || !pc->cb_info || !foreach_cb) {
5670 LOGE("NULL pointer %p %p", pc, foreach_cb);
5671 return CAMERA_ERROR_INVALID_PARAMETER;
5676 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5677 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5679 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5681 LOGD("ret : 0x%x", ret);
5687 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5689 int ret = CAMERA_ERROR_NONE;
5690 camera_cli_s *pc = (camera_cli_s *)camera;
5691 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5693 if (!pc || !pc->cb_info || !foreach_cb) {
5694 LOGE("NULL pointer %p %p", pc, foreach_cb);
5695 return CAMERA_ERROR_INVALID_PARAMETER;
5700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5703 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5705 LOGD("Enter, handle :%x", pc->remote_handle);
5711 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)
5713 int ret = CAMERA_ERROR_NONE;
5714 camera_cli_s *pc = (camera_cli_s *)camera;
5715 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5716 camera_msg_param param;
5719 if (!pc || !pc->cb_info || !foreach_cb) {
5720 LOGE("NULL pointer %p %p", pc, foreach_cb);
5721 return CAMERA_ERROR_INVALID_PARAMETER;
5726 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5727 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5729 value = (width << 16) | height;
5730 CAMERA_MSG_PARAM_SET(param, INT, value);
5732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5734 LOGD("ret : 0x%x", ret);
5740 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5742 int ret = CAMERA_ERROR_NONE;
5743 camera_cli_s *pc = (camera_cli_s *)camera;
5744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5746 if (!pc || !pc->cb_info || !foreach_cb) {
5747 LOGE("NULL pointer %p %p", pc, foreach_cb);
5748 return CAMERA_ERROR_INVALID_PARAMETER;
5753 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5754 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5756 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5758 LOGD("ret : 0x%x", ret);
5764 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5766 int ret = CAMERA_ERROR_NONE;
5767 camera_cli_s *pc = (camera_cli_s *)camera;
5768 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5770 if (!pc || !pc->cb_info || !foreach_cb) {
5771 LOGE("NULL pointer %p %p", pc, foreach_cb);
5772 return CAMERA_ERROR_INVALID_PARAMETER;
5777 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5778 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5780 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5782 LOGD("ret : 0x%x", ret);
5788 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5790 int ret = CAMERA_ERROR_NONE;
5791 camera_cli_s *pc = (camera_cli_s *)camera;
5792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5793 camera_msg_param param;
5794 int set_rotation = (int)rotation;
5796 if (!pc || !pc->cb_info) {
5797 LOGE("NULL handle");
5798 return CAMERA_ERROR_INVALID_PARAMETER;
5803 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5805 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5807 LOGD("ret : 0x%x", ret);
5813 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5815 int ret = CAMERA_ERROR_NONE;
5816 camera_cli_s *pc = (camera_cli_s *)camera;
5817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5819 if (!pc || !pc->cb_info || !rotation) {
5820 LOGE("NULL pointer %p %p", pc, rotation);
5821 return CAMERA_ERROR_INVALID_PARAMETER;
5826 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5828 if (ret == CAMERA_ERROR_NONE)
5829 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5831 LOGD("ret : 0x%x", ret);
5837 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5839 int ret = CAMERA_ERROR_NONE;
5840 camera_cli_s *pc = (camera_cli_s *)camera;
5841 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5842 camera_msg_param param;
5843 int set_flip = (int)flip;
5845 if (!pc || !pc->cb_info) {
5846 LOGE("NULL handle");
5847 return CAMERA_ERROR_INVALID_PARAMETER;
5852 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5854 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5856 LOGD("ret : 0x%x", ret);
5862 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5864 int ret = CAMERA_ERROR_NONE;
5865 camera_cli_s *pc = (camera_cli_s *)camera;
5866 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5868 if (!pc || !pc->cb_info || !flip) {
5869 LOGE("NULL pointer %p %p", pc, flip);
5870 return CAMERA_ERROR_INVALID_PARAMETER;
5875 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5877 if (ret == CAMERA_ERROR_NONE)
5878 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5880 LOGD("ret : 0x%x", ret);
5885 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5887 int ret = CAMERA_ERROR_NONE;
5888 camera_cli_s *pc = (camera_cli_s *)camera;
5889 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5890 camera_msg_param param;
5891 int set_mode = (int)mode;
5893 if (!pc || !pc->cb_info) {
5894 LOGE("NULL handle");
5895 return CAMERA_ERROR_INVALID_PARAMETER;
5900 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5902 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5904 LOGD("ret : 0x%x", ret);
5910 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5912 int ret = CAMERA_ERROR_NONE;
5913 camera_cli_s *pc = (camera_cli_s *)camera;
5914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5916 if (!pc || !pc->cb_info || !mode) {
5917 LOGE("NULL pointer %p %p", pc, mode);
5918 return CAMERA_ERROR_INVALID_PARAMETER;
5923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5925 if (ret == CAMERA_ERROR_NONE)
5926 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5928 LOGD("ret : 0x%x", ret);
5934 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5936 int ret = CAMERA_ERROR_NONE;
5937 camera_cli_s *pc = (camera_cli_s *)camera;
5938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5940 if (!pc || !pc->cb_info) {
5941 LOGE("NULL handle");
5942 return CAMERA_ERROR_INVALID_PARAMETER;
5947 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5950 LOGE("error is occurred 0x%x", ret);
5954 LOGD("ret : %d", ret);
5960 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5962 int ret = CAMERA_ERROR_NONE;
5963 camera_cli_s *pc = (camera_cli_s *)camera;
5964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5966 if (!pc || !pc->cb_info) {
5967 LOGE("NULL handle");
5968 return CAMERA_ERROR_INVALID_PARAMETER;
5973 if (!camera_attr_is_supported_hdr_capture(camera)) {
5974 LOGE("HDR not supported");
5975 return CAMERA_ERROR_NOT_SUPPORTED;
5979 LOGE("NULL callback");
5980 return CAMERA_ERROR_INVALID_PARAMETER;
5983 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5985 if (ret == CAMERA_ERROR_NONE) {
5986 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5987 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5990 LOGD("ret : 0x%x", ret);
5996 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5998 int ret = CAMERA_ERROR_NONE;
5999 camera_cli_s *pc = (camera_cli_s *)camera;
6000 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6002 if (!pc || !pc->cb_info) {
6003 LOGE("NULL handle");
6004 return CAMERA_ERROR_INVALID_PARAMETER;
6009 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6011 if (ret == CAMERA_ERROR_NONE) {
6012 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6013 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6016 LOGD("ret : 0x%x", ret);
6022 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6024 int ret = CAMERA_ERROR_NONE;
6025 camera_cli_s *pc = (camera_cli_s *)camera;
6026 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6027 camera_msg_param param;
6028 int set_enable = (int)enable;
6030 if (!pc || !pc->cb_info) {
6031 LOGE("NULL handle");
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6037 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6039 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6041 LOGD("ret : 0x%x", ret);
6047 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6049 int ret = CAMERA_ERROR_NONE;
6050 camera_cli_s *pc = (camera_cli_s *)camera;
6051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6053 if (!pc || !pc->cb_info || !enabled) {
6054 LOGE("NULL pointer %p %p", pc, enabled);
6055 return CAMERA_ERROR_INVALID_PARAMETER;
6060 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6062 if (ret == CAMERA_ERROR_NONE)
6063 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6065 LOGD("ret : 0x%x", ret);
6071 bool camera_attr_is_supported_anti_shake(camera_h camera)
6073 int ret = CAMERA_ERROR_NONE;
6074 camera_cli_s *pc = (camera_cli_s *)camera;
6075 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6077 if (!pc || !pc->cb_info) {
6078 LOGE("NULL handle");
6079 return CAMERA_ERROR_INVALID_PARAMETER;
6084 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6087 LOGE("error is occurred 0x%x", ret);
6091 LOGD("ret : %d", ret);
6097 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6099 int ret = CAMERA_ERROR_NONE;
6100 camera_cli_s *pc = (camera_cli_s *)camera;
6101 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6102 camera_msg_param param;
6103 int set_enable = (int)enable;
6105 if (!pc || !pc->cb_info) {
6106 LOGE("NULL handle");
6107 return CAMERA_ERROR_INVALID_PARAMETER;
6112 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6114 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6116 LOGD("ret : 0x%x", ret);
6122 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6124 int ret = CAMERA_ERROR_NONE;
6125 camera_cli_s *pc = (camera_cli_s *)camera;
6126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6128 if (!pc || !pc->cb_info || !enabled) {
6129 LOGE("NULL pointer %p %p", pc, enabled);
6130 return CAMERA_ERROR_INVALID_PARAMETER;
6135 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6137 if (ret == CAMERA_ERROR_NONE)
6138 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6140 LOGD("ret : 0x%x", ret);
6146 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6148 int ret = CAMERA_ERROR_NONE;
6149 camera_cli_s *pc = (camera_cli_s *)camera;
6150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6152 if (!pc || !pc->cb_info) {
6153 LOGE("NULL handle");
6154 return CAMERA_ERROR_INVALID_PARAMETER;
6159 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6162 LOGE("error is occurred 0x%x", ret);
6166 LOGD("ret : %d", ret);
6172 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6174 int ret = CAMERA_ERROR_NONE;
6175 camera_cli_s *pc = (camera_cli_s *)camera;
6176 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6177 camera_msg_param param;
6178 int set_enable = (int)enable;
6180 if (!pc || !pc->cb_info) {
6181 LOGE("NULL handle");
6182 return CAMERA_ERROR_INVALID_PARAMETER;
6187 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6189 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6191 LOGD("ret : 0x%x", ret);
6197 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6199 int ret = CAMERA_ERROR_NONE;
6200 camera_cli_s *pc = (camera_cli_s *)camera;
6201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6203 if (!pc || !pc->cb_info || !enabled) {
6204 LOGE("NULL pointer %p %p", pc, enabled);
6205 return CAMERA_ERROR_INVALID_PARAMETER;
6210 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6212 if (ret == CAMERA_ERROR_NONE)
6213 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6215 LOGD("ret : 0x%x", ret);
6221 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6223 int ret = CAMERA_ERROR_NONE;
6224 camera_cli_s *pc = (camera_cli_s *)camera;
6225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6227 if (!pc || !pc->cb_info) {
6228 LOGE("NULL handle");
6229 return CAMERA_ERROR_INVALID_PARAMETER;
6234 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6237 LOGE("error is occurred 0x%x", ret);
6241 LOGD("ret : %d", ret);
6247 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6249 int ret = CAMERA_ERROR_NONE;
6250 camera_cli_s *pc = (camera_cli_s *)camera;
6251 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6252 camera_msg_param param;
6253 int set_disable = (int)disable;
6255 if (!pc || !pc->cb_info) {
6256 LOGE("NULL handle");
6257 return CAMERA_ERROR_INVALID_PARAMETER;
6262 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6264 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6266 LOGD("ret : 0x%x", ret);
6272 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6274 int ret = CAMERA_ERROR_NONE;
6275 camera_cli_s *pc = (camera_cli_s *)camera;
6276 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6277 camera_msg_param param;
6278 int set_move_type = (int)move_type;
6281 if (!pc || !pc->cb_info) {
6282 LOGE("NULL handle");
6283 return CAMERA_ERROR_INVALID_PARAMETER;
6288 value = (set_move_type << 16) | pan_step;
6289 CAMERA_MSG_PARAM_SET(param, INT, value);
6291 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6293 LOGD("ret : 0x%x", ret);
6299 int camera_attr_get_pan(camera_h camera, int *pan_step)
6301 int ret = CAMERA_ERROR_NONE;
6302 camera_cli_s *pc = (camera_cli_s *)camera;
6303 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6305 if (!pc || !pc->cb_info || !pan_step) {
6306 LOGE("NULL pointer %p %p", pc, pan_step);
6307 return CAMERA_ERROR_INVALID_PARAMETER;
6312 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6314 if (ret == CAMERA_ERROR_NONE)
6315 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6317 LOGD("ret : 0x%x", ret);
6323 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6325 int ret = CAMERA_ERROR_NONE;
6326 camera_cli_s *pc = (camera_cli_s *)camera;
6327 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6329 if (!pc || !pc->cb_info || !min || !max) {
6330 LOGE("NULL pointer %p %p", pc, min, max);
6331 return CAMERA_ERROR_INVALID_PARAMETER;
6336 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6338 if (ret == CAMERA_ERROR_NONE) {
6339 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6340 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6343 LOGD("ret : 0x%x", ret);
6349 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6351 int ret = CAMERA_ERROR_NONE;
6352 camera_cli_s *pc = (camera_cli_s *)camera;
6353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6354 camera_msg_param param;
6355 int set_move_type = (int)move_type;
6358 if (!pc || !pc->cb_info) {
6359 LOGE("NULL handle");
6360 return CAMERA_ERROR_INVALID_PARAMETER;
6365 value = (set_move_type << 16) | tilt_step;
6366 CAMERA_MSG_PARAM_SET(param, INT, value);
6368 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6370 LOGD("ret : 0x%x", ret);
6376 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6378 int ret = CAMERA_ERROR_NONE;
6379 camera_cli_s *pc = (camera_cli_s *)camera;
6380 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6382 if (!pc || !pc->cb_info || !tilt_step) {
6383 LOGE("NULL pointer %p %p", pc, tilt_step);
6384 return CAMERA_ERROR_INVALID_PARAMETER;
6389 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6391 if (ret == CAMERA_ERROR_NONE)
6392 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6394 LOGD("ret : 0x%x", ret);
6400 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6402 int ret = CAMERA_ERROR_NONE;
6403 camera_cli_s *pc = (camera_cli_s *)camera;
6404 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6406 if (!pc || !pc->cb_info || !min || !max) {
6407 LOGE("NULL pointer %p %p %p", pc, min, max);
6408 return CAMERA_ERROR_INVALID_PARAMETER;
6413 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6415 if (ret == CAMERA_ERROR_NONE) {
6416 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6417 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6420 LOGD("ret : 0x%x", ret);
6426 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6428 int ret = CAMERA_ERROR_NONE;
6429 camera_cli_s *pc = (camera_cli_s *)camera;
6430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6431 camera_msg_param param;
6432 int set_ptz_type = (int)ptz_type;
6434 if (!pc || !pc->cb_info) {
6435 LOGE("NULL handle");
6436 return CAMERA_ERROR_INVALID_PARAMETER;
6441 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6443 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6445 LOGD("ret : 0x%x", ret);
6451 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6453 int ret = CAMERA_ERROR_NONE;
6454 camera_cli_s *pc = (camera_cli_s *)camera;
6455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6457 if (!pc || !pc->cb_info || !foreach_cb) {
6458 LOGE("NULL pointer %p %p", pc, foreach_cb);
6459 return CAMERA_ERROR_INVALID_PARAMETER;
6464 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6465 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6469 LOGD("ret : 0x%x", ret);
6475 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6477 int ret = CAMERA_ERROR_NONE;
6478 camera_cli_s *pc = (camera_cli_s *)camera;
6479 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6480 int set_display_roi_area[4] = {x, y, width, height};
6485 if (!pc || !pc->cb_info) {
6486 LOGE("NULL handle");
6487 return CAMERA_ERROR_INVALID_PARAMETER;
6492 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6493 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6494 g_mutex_lock(&pc->cb_info->evas_mutex);
6496 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6498 g_mutex_unlock(&pc->cb_info->evas_mutex);
6500 if (ret != MM_ERROR_NONE) {
6501 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6502 return CAMERA_ERROR_INVALID_OPERATION;
6505 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6507 length = sizeof(set_display_roi_area) / sizeof(int) + \
6508 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6510 msg = muse_core_msg_json_factory_new(api,
6511 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6514 LOGE("msg creation failed: api %d", api);
6515 return CAMERA_ERROR_OUT_OF_MEMORY;
6518 if (pc->cb_info->is_server_connected) {
6519 __camera_update_api_waiting(pc->cb_info, api, 1);
6521 g_mutex_lock(&pc->cb_info->fd_lock);
6522 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6523 g_mutex_unlock(&pc->cb_info->fd_lock);
6527 LOGE("message send failed");
6528 ret = CAMERA_ERROR_INVALID_OPERATION;
6530 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6533 __camera_update_api_waiting(pc->cb_info, api, -1);
6535 muse_core_msg_json_factory_free(msg);
6537 LOGD("ret : 0x%x", ret);
6543 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6545 camera_cli_s *pc = (camera_cli_s *)camera;
6546 int ret = CAMERA_ERROR_NONE;
6547 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6549 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6550 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6551 return CAMERA_ERROR_INVALID_PARAMETER;
6556 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6558 if (ret == CAMERA_ERROR_NONE) {
6559 *x = pc->cb_info->get_display_roi_area[0];
6560 *y = pc->cb_info->get_display_roi_area[1];
6561 *width = pc->cb_info->get_display_roi_area[2];
6562 *height = pc->cb_info->get_display_roi_area[3];
6565 LOGD("ret : 0x%x", ret);
6571 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6573 int ret = CAMERA_ERROR_NONE;
6574 int get_device_state = 0;
6577 LOGE("NULL pointer");
6578 return CAMERA_ERROR_INVALID_PARAMETER;
6581 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6582 (int)device, "get_device_state", &get_device_state);
6584 if (ret == CAMERA_ERROR_NONE) {
6585 *state = (camera_device_state_e)get_device_state;
6586 LOGD("device state %d", *state);
6588 LOGE("failed 0x%x", ret);
6595 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6597 int ret = CAMERA_ERROR_NONE;
6598 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6599 camera_cb_info *info = NULL;
6601 if (!callback || !cb_id) {
6602 LOGE("invalid pointer %p %p", callback, cb_id);
6603 return CAMERA_ERROR_INVALID_PARAMETER;
6606 /* check camera support */
6607 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6608 if (ret != CAMERA_ERROR_NONE) {
6609 LOGE("get device state failed");
6613 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6615 info = g_new0(camera_cb_info, 1);
6617 LOGE("info failed");
6618 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6622 info->id = ++g_cam_dev_state_changed_cb_id;
6623 info->callback = (void *)callback;
6624 info->user_data = user_data;
6628 /* subscribe dbus signal for camera state change */
6629 if (!g_cam_dev_state_changed_cb_conn) {
6630 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6631 if (!g_cam_dev_state_changed_cb_conn) {
6632 LOGE("failed to get gdbus connection");
6633 ret = CAMERA_ERROR_INVALID_OPERATION;
6637 LOGD("subscribe signal %s - %s - %s",
6638 MM_CAMCORDER_DBUS_OBJECT,
6639 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6640 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6642 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6643 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6644 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6645 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6646 LOGE("failed to get gdbus connection");
6647 ret = CAMERA_ERROR_INVALID_OPERATION;
6651 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6654 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6656 LOGD("callback id %d", info->id);
6659 if (ret != CAMERA_ERROR_NONE) {
6665 if (g_cam_dev_state_changed_cb_conn) {
6666 g_object_unref(g_cam_dev_state_changed_cb_conn);
6667 g_cam_dev_state_changed_cb_conn = NULL;
6671 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6677 int camera_remove_device_state_changed_cb(int cb_id)
6679 int ret = CAMERA_ERROR_NONE;
6680 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6681 GList *tmp_list = NULL;
6682 camera_cb_info *info = NULL;
6684 /* check camera support */
6685 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6686 if (ret != CAMERA_ERROR_NONE) {
6687 LOGE("get device state failed");
6691 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6693 if (!g_cam_dev_state_changed_cb_list) {
6694 LOGE("there is no callback info");
6695 ret = CAMERA_ERROR_INVALID_OPERATION;
6699 tmp_list = g_cam_dev_state_changed_cb_list;
6702 info = tmp_list->data;
6703 tmp_list = tmp_list->next;
6710 if (info->id == cb_id) {
6711 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6716 if (!g_cam_dev_state_changed_cb_list) {
6717 /* no remained callback */
6718 if (g_cam_dev_state_changed_cb_conn) {
6719 /* unsubscribe signal */
6720 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6721 g_cam_dev_state_changed_cb_subscribe_id = 0;
6723 /* unref connection */
6724 g_object_unref(g_cam_dev_state_changed_cb_conn);
6725 g_cam_dev_state_changed_cb_conn = NULL;
6729 LOGD("id %d callback removed", cb_id);
6730 ret = CAMERA_ERROR_NONE;
6736 LOGE("id %d callback not found", cb_id);
6737 ret = CAMERA_ERROR_INVALID_PARAMETER;
6740 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);